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

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

Complexity

Total Complexity 5
Complexity/F 0

Size

Lines of Code 100
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 92
mnd 5
bc 5
fnc 0
dl 0
loc 100
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 { ExperienceAward } from "../../../models/types";
7
8
const ExperienceAwardDetails: React.FC<{
9
  experience: ExperienceAward;
10
}> = ({ experience }): React.ReactElement => {
11
  const intl = useIntl();
12
  const locale = getLocale(intl.locale);
13
14
  const { title } = experience;
15
  const recipient = localizeFieldNonNull(
16
    locale,
17
    experience,
18
    "award_recipient_type",
19
  );
20
  const issuer = experience.issued_by;
21
  const scope = localizeFieldNonNull(
22
    locale,
23
    experience,
24
    "award_recognition_type",
25
  );
26
  const awardedDate = experience.awarded_date;
27
28
  const notApplicable = (
29
    <p data-h2-font-color="b(gray-1)">
30
      {intl.formatMessage(detailsMessages.notApplicable)}
31
    </p>
32
  );
33
34
  return (
35
    <div data-h2-grid="b(middle, expanded, flush, 1)">
36
      <div data-h2-grid-item="b(1of2) m(1of3)">
37
        <div data-h2-grid-content>
38
          <p data-h2-font-weight="b(600)">
39
            {intl.formatMessage(detailsMessages.experienceTypeLabel)}
40
          </p>
41
          <p>
42
            <i
43
              className="fas fa-trophy"
44
              data-h2-font-color="b(theme-1)"
45
              data-h2-margin="b(right, .25)"
46
            />
47
            {intl.formatMessage(detailsMessages.awardType)}
48
          </p>
49
        </div>
50
      </div>
51
      <div data-h2-grid-item="b(1of2) m(1of3)">
52
        <div data-h2-grid-content>
53
          <p data-h2-font-weight="b(600)">
54
            {intl.formatMessage(detailsMessages.awardTitleLabel)}
55
          </p>
56
          {title ? <p>{title}</p> : notApplicable}
57
        </div>
58
      </div>
59
      <div data-h2-grid-item="b(1of2) m(1of3)">
60
        <div data-h2-grid-content>
61
          <p data-h2-font-weight="b(600)">
62
            {intl.formatMessage(detailsMessages.awardRecipientLabel)}
63
          </p>
64
          {recipient ? <p>{recipient}</p> : notApplicable}
65
        </div>
66
      </div>
67
      <div data-h2-grid-item="b(1of2) m(1of3)">
68
        <div data-h2-grid-content>
69
          <p data-h2-font-weight="b(600)">
70
            {intl.formatMessage(detailsMessages.awardIssuerLabel)}
71
          </p>
72
          {issuer ? <p>{issuer}</p> : notApplicable}
73
        </div>
74
      </div>
75
      <div data-h2-grid-item="b(1of2) m(1of3)">
76
        <div data-h2-grid-content>
77
          <p data-h2-font-weight="b(600)">
78
            {intl.formatMessage(detailsMessages.awardScopeLabel)}
79
          </p>
80
          {scope ? <p>{scope}</p> : notApplicable}
81
        </div>
82
      </div>
83
      <div data-h2-grid-item="b(1of2) m(1of3)">
84
        <div data-h2-grid-content>
85
          <p data-h2-font-weight="b(600)">
86
            {intl.formatMessage(detailsMessages.awardDateLabel)}
87
          </p>
88
          {awardedDate ? (
89
            <p>{readableDate(locale, awardedDate)}</p>
90
          ) : (
91
            notApplicable
92
          )}
93
        </div>
94
      </div>
95
    </div>
96
  );
97
};
98
99
export default ExperienceAwardDetails;
100