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

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

Complexity

Total Complexity 6
Complexity/F 0

Size

Lines of Code 95
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 6
eloc 88
mnd 6
bc 6
fnc 0
dl 0
loc 95
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 } from "../../../helpers/localize";
5
import { readableDate } from "../../../helpers/dates";
6
import { ExperienceCommunity } from "../../../models/types";
7
8
const ExperienceCommunityDetails: React.FC<{
9
  experience: ExperienceCommunity;
10
}> = ({ experience }) => {
11
  const intl = useIntl();
12
  const locale = getLocale(intl.locale);
13
14
  const { title, group, project } = experience;
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-people-carry"
39
              data-h2-font-color="b(theme-1)"
40
              data-h2-margin="b(right, .25)"
41
            />
42
            {intl.formatMessage(detailsMessages.communityType)}
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.communityRoleLabel)}
50
          </p>
51
          {title ? <p>{title}</p> : notApplicable}
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.communityOrganizationLabel)}
58
          </p>
59
          {group ? <p>{group}</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.communityProjectLabel)}
66
          </p>
67
          {project ? <p>{project}</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.startDateLabel)}
74
          </p>
75
          {startDate ? <p>{readableDate(locale, startDate)}</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.endDateLabel)}
82
          </p>
83
          {isActive ? (
84
            <p>{intl.formatMessage(detailsMessages.ongoing)}</p>
85
          ) : (
86
            endDateOrNa
87
          )}
88
        </div>
89
      </div>
90
    </div>
91
  );
92
};
93
94
export default ExperienceCommunityDetails;
95