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

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

Complexity

Total Complexity 8
Complexity/F 0

Size

Lines of Code 123
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 8
eloc 114
mnd 8
bc 8
fnc 0
dl 0
loc 123
rs 10
bpm 0
cpm 0
noi 0
c 0
b 0
f 0
1
import React from "react";
2
import { useIntl } from "react-intl";
3
import detailsMessages from "./detailsMessages";
4
import { getLocale, localizeFieldNonNull } from "../../../helpers/localize";
5
import { readableDate } from "../../../helpers/dates";
6
import { ExperienceEducation } from "../../../models/types";
7
8
const ExperienceEducationDetails: React.FC<{
9
  experience: ExperienceEducation;
10
}> = ({ experience }) => {
11
  const intl = useIntl();
12
  const locale = getLocale(intl.locale);
13
14
  const educationType = localizeFieldNonNull(
15
    locale,
16
    experience,
17
    "education_type",
18
  );
19
  const { institution } = experience;
20
  const status = localizeFieldNonNull(locale, experience, "education_status");
21
  const areaOfStudy = experience.area_of_study;
22
  const startDate = experience.start_date;
23
  const endDate = experience.end_date;
24
  const isActive = experience.is_active;
25
  const thesisTitle = experience.thesis_title;
26
27
  const notApplicable = (
28
    <p data-h2-font-color="b(gray-1)">
29
      {intl.formatMessage(detailsMessages.notApplicable)}
30
    </p>
31
  );
32
  const endDateOrNa = endDate ? (
33
    <p>{readableDate(locale, endDate)}</p>
34
  ) : (
35
    notApplicable
36
  );
37
  return (
38
    <div data-h2-grid="b(middle, expanded, flush, 1)">
39
      <div data-h2-grid-item="b(1of2) m(1of3)">
40
        <div data-h2-grid-content>
41
          <p data-h2-font-weight="b(600)">
42
            {intl.formatMessage(detailsMessages.experienceTypeLabel)}
43
          </p>
44
          <p>
45
            <i
46
              className="fas fa-book"
47
              data-h2-font-color="b(theme-1)"
48
              data-h2-margin="b(right, .25)"
49
            />
50
            {intl.formatMessage(detailsMessages.educationType)}
51
          </p>
52
        </div>
53
      </div>
54
      <div data-h2-grid-item="b(1of2) m(1of3)">
55
        <div data-h2-grid-content>
56
          <p data-h2-font-weight="b(600)">
57
            {intl.formatMessage(detailsMessages.educationTypeLabel)}
58
          </p>
59
          {educationType ? <p>{educationType}</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.educationAreaOfStudyLabel)}
66
          </p>
67
          {areaOfStudy ? <p>{areaOfStudy}</p> : notApplicable}
68
        </div>
69
      </div>
70
      <div data-h2-grid-item="b(1of2) m(1of3)">
71
        <div data-h2-grid-content>
72
          <p data-h2-font-weight="b(600)">
73
            {intl.formatMessage(detailsMessages.educationInstitutionLabel)}
74
          </p>
75
          {institution ? <p>{institution}</p> : notApplicable}
76
        </div>
77
      </div>
78
      <div data-h2-grid-item="b(1of2) m(1of3)">
79
        <div data-h2-grid-content>
80
          <p data-h2-font-weight="b(600)">
81
            {intl.formatMessage(detailsMessages.educationStatusLabel)}
82
          </p>
83
          {status ? <p>{status}</p> : notApplicable}
84
        </div>
85
      </div>
86
      <div data-h2-grid-item="b(1of2) m(1of3)">
87
        <div data-h2-grid-content>
88
          <p data-h2-font-weight="b(600)">
89
            {intl.formatMessage(detailsMessages.startDateLabel)}
90
          </p>
91
          {startDate ? (
92
            <p>{readableDate(locale, startDate)}</p>
93
          ) : (
94
            { notApplicable }
95
          )}
96
        </div>
97
      </div>
98
      <div data-h2-grid-item="b(1of2) m(1of3)">
99
        <div data-h2-grid-content>
100
          <p data-h2-font-weight="b(600)">
101
            {intl.formatMessage(detailsMessages.endDateLabel)}
102
          </p>
103
          {isActive ? (
104
            <p>{intl.formatMessage(detailsMessages.ongoing)}</p>
105
          ) : (
106
            endDateOrNa
107
          )}
108
        </div>
109
      </div>
110
      <div data-h2-grid-item="b(1of2) m(1of3)">
111
        <div data-h2-grid-content>
112
          <p data-h2-font-weight="b(600)">
113
            {intl.formatMessage(detailsMessages.educationThesisLabel)}
114
          </p>
115
          {thesisTitle ? <p>{thesisTitle}</p> : notApplicable}
116
        </div>
117
      </div>
118
    </div>
119
  );
120
};
121
122
export default ExperienceEducationDetails;
123