Passed
Push — feature/job-summary-hr ( 67ecfb )
by Grant
13:42
created

resources/assets/js/components/UnclaimedJobCard.tsx   A

Complexity

Total Complexity 3
Complexity/F 0

Size

Lines of Code 141
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 116
dl 0
loc 141
rs 10
c 0
b 0
f 0
mnd 3
bc 3
fnc 0
bpm 0
cpm 0
noi 0
1
import React from "react";
2
import { FormattedMessage } from "react-intl";
3
import { JobStatus } from "../models/lookupConstants";
4
import { Link } from "../models/app";
5
6
export interface UnclaimedJobCardProps {
7
  jobLink: Link;
8
  createdAt: string;
9
  status: JobStatus;
10
  hiringManagers: string[];
11
  hrAdvisors: string[];
12
  claimJob: () => void;
13
}
14
15
const UnclaimedJobCard: React.FunctionComponent<UnclaimedJobCardProps> = ({
16
  jobLink,
17
  createdAt,
18
  status,
19
  hiringManagers,
20
  hrAdvisors,
21
  claimJob,
22
}) => {
23
  return (
24
    <div
25
      data-c-grid-item="tp(1of2) tl(1of3) equal-col"
26
      className="tc-hr-job-card"
27
    >
28
      <div data-c-card data-c-radius="rounded" data-c-background="white(100)">
29
        <a
30
          href={jobLink.url}
31
          title={jobLink.title}
32
          style={{ textDecoration: "none" }}
33
        >
34
          <div data-c-background="black(100)" data-c-padding="all(normal)">
35
            <div data-c-grid="gutter middle">
36
              <div data-c-grid-item="base(1of1)">
37
                <p
38
                  data-c-font-size="h4"
39
                  data-c-colour="white"
40
                  data-c-font-style="underline"
41
                >
42
                  {jobLink.text}
43
                </p>
44
              </div>
45
              <div data-c-grid-item="base(1of2)">
46
                <p data-c-colour="white" data-c-font-size="small">
47
                  <FormattedMessage
48
                    id="openJobCard.createdAt"
49
                    description="Header for when Job Poster was created."
50
                    defaultMessage="Created: "
51
                  />
52
                  {createdAt}
53
                </p>
54
              </div>
55
              <div data-c-grid-item="base(1of2)" data-c-align="base(right)">
56
                <span
57
                  data-c-color="white"
58
                  data-c-border="all(thin, solid, white)"
59
                  data-c-padding="tb(quarter) rl(half)"
60
                  data-c-font-size="small"
61
                  data-c-radius="pill"
62
                >
63
                  {status}
64
                </span>
65
              </div>
66
            </div>
67
          </div>
68
          <div data-c-padding="all(normal)">
69
            <p data-c-color="black" data-c-margin="bottom(normal)">
70
              <FormattedMessage
71
                id="openJobCard.hiringManager"
72
                description="Header before list of hiring managers."
73
                defaultMessage="Hiring Managers: "
74
              />
75
76
              {hiringManagers.map((manager, index): string => {
77
                const comma =
78
                  hiringManagers.length !== 1 &&
79
                  index + 1 !== hiringManagers.length
80
                    ? ","
81
                    : " ";
82
                return `${manager}${comma} `;
83
              })}
84
            </p>
85
86
            {hrAdvisors.length > 0 ? (
87
              <p data-c-color="black" data-c-margin="bottom(normal)">
88
                <FormattedMessage
89
                  id="openJobCard.hrAdvisors"
90
                  description="Header before list of HR advisors."
91
                  defaultMessage="HR Advisors: "
92
                />
93
                {hrAdvisors.map((advisor, index): string => {
94
                  const comma =
95
                    hrAdvisors.length !== 1 && index + 1 !== hrAdvisors.length
96
                      ? ","
97
                      : " ";
98
                  return `${advisor}${comma} `;
99
                })}
100
              </p>
101
            ) : (
102
              <p data-c-color="stop" data-c-margin="bottom(normal)">
103
                <FormattedMessage
104
                  id="openJobCard.unclaimed"
105
                  description="Message displayed if not HR managers have claimed a job."
106
                  defaultMessage="Unclaimed"
107
                />
108
              </p>
109
            )}
110
          </div>
111
        </a>
112
        <div
113
          data-c-padding="all(normal)"
114
          data-c-border="top(thin, solid, black)"
115
          data-c-align="base(right)"
116
        >
117
          <button
118
            data-c-button="solid(c2)"
119
            data-c-radius="rounded"
120
            type="button"
121
            onClick={claimJob}
122
          >
123
            <span data-c-color="black">
124
              +{" "}
125
              <span data-c-font-style="underline">
126
                <FormattedMessage
127
                  id="openJobCard.claimJob"
128
                  description="Message indicating the event of clicking on the job card."
129
                  defaultMessage="Claim This Job"
130
                />
131
              </span>
132
            </span>
133
          </button>
134
        </div>
135
      </div>
136
    </div>
137
  );
138
};
139
140
export default UnclaimedJobCard;
141