Passed
Push — feature/profile-skills-finaliz... ( 961836...9d523b )
by Tristan
06:45
created

resources/assets/js/components/ApplicantProfile/ExperienceDetails/ExperiencePersonalDetails.tsx   A

Complexity

Total Complexity 6
Complexity/F 0

Size

Lines of Code 113
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 6
eloc 103
mnd 6
bc 6
fnc 0
dl 0
loc 113
rs 10
bpm 0
cpm 0
noi 0
c 0
b 0
f 0
1
import React, { FunctionComponent } from "react";
2
import { useIntl } from "react-intl";
3
import detailsMessages from "./detailsMessages";
4
import { getLocale } from "../../../helpers/localize";
5
import { readableDate } from "../../../helpers/dates";
6
import { ExperiencePersonal } from "../../../models/types";
7
8
const ExperiencePersonalDetails: FunctionComponent<{
9
  experience: ExperiencePersonal;
10
}> = ({ experience }) => {
11
  const intl = useIntl();
12
  const locale = getLocale(intl.locale);
13
  const { title, description } = experience;
14
  const isShareable = experience.is_shareable;
15
  const startDate = experience.start_date;
16
  const endDate = experience.end_date;
17
  const isActive = experience.is_active;
18
19
  const notApplicable = (
20
    <p data-h2-font-color="b(gray-1)">
21
      {intl.formatMessage(detailsMessages.notApplicable)}
22
    </p>
23
  );
24
  const endDateOrNa = endDate ? (
25
    <p>{readableDate(locale, endDate)}</p>
26
  ) : (
27
    notApplicable
28
  );
29
  return (
30
    <div data-h2-grid="b(middle, expanded, flush, 1)">
31
      <div data-h2-grid-item="b(1of2) m(1of3)">
32
        <div data-h2-grid-content>
33
          <p data-h2-font-weight="b(600)">
34
            {intl.formatMessage(detailsMessages.experienceTypeLabel)}
35
          </p>
36
          <p>
37
            <i
38
              className="fas fa-mountain"
39
              data-h2-font-color="b(theme-1)"
40
              data-h2-margin="b(right, .25)"
41
            />
42
            {intl.formatMessage(detailsMessages.personalType)}
43
          </p>
44
        </div>
45
      </div>
46
      <div data-h2-grid-item="b(1of2) m(1of3)">
47
        <div data-h2-grid-content>
48
          <p data-h2-font-weight="b(600)">
49
            {intl.formatMessage(detailsMessages.personalTitleLabel)}
50
          </p>
51
          {title ? <p>{title}</p> : notApplicable}
52
        </div>
53
      </div>
54
      <div data-h2-grid-item="b(1of1)">
55
        <div data-h2-grid-content>
56
          <p data-h2-font-weight="b(600)">
57
            {intl.formatMessage(detailsMessages.personalDescriptionLabel)}
58
          </p>
59
          {description ? <p>{description}</p> : notApplicable}
60
        </div>
61
      </div>
62
      <div data-h2-grid-item="b(1of2) m(1of3)">
63
        <div data-h2-grid-content>
64
          <p data-h2-font-weight="b(600)">
65
            {intl.formatMessage(detailsMessages.personalShareLabel)}
66
          </p>
67
          {isShareable ? (
68
            <p>
69
              <i
70
                className="fas fa-check-circle"
71
                data-h2-font-color="b(go)"
72
                data-h2-margin="b(right, .25)"
73
              />
74
              {intl.formatMessage(detailsMessages.personalShareAllowed)}
75
            </p>
76
          ) : (
77
            <p>
78
              <i
79
                className="fas fa-check-circle"
80
                data-h2-font-color="b(stop)"
81
                data-h2-margin="b(right, .25)"
82
              />
83
              {intl.formatMessage(detailsMessages.personalShareDenied)}
84
            </p>
85
          )}
86
        </div>
87
      </div>
88
      <div data-h2-grid-item="b(1of2) m(1of3)">
89
        <div data-h2-grid-content>
90
          <p data-h2-font-weight="b(600)">
91
            {intl.formatMessage(detailsMessages.startDateLabel)}
92
          </p>
93
          {startDate ? <p>{readableDate(locale, startDate)}</p> : notApplicable}
94
        </div>
95
      </div>
96
      <div data-h2-grid-item="b(1of2) m(1of3)">
97
        <div data-h2-grid-content>
98
          <p data-h2-font-weight="b(600)">
99
            {intl.formatMessage(detailsMessages.endDateLabel)}
100
          </p>
101
          {isActive ? (
102
            <p>{intl.formatMessage(detailsMessages.ongoing)}</p>
103
          ) : (
104
            endDateOrNa
105
          )}
106
        </div>
107
      </div>
108
    </div>
109
  );
110
};
111
112
export default ExperiencePersonalDetails;
113