Passed
Push — task/job-index-page ( 89239c...ac7676 )
by Tristan
09:32
created

resources/assets/js/components/HRPortal/JobIndexHrPage.tsx   A

Complexity

Total Complexity 1
Complexity/F 0

Size

Lines of Code 115
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 93
dl 0
loc 115
rs 10
c 0
b 0
f 0
wmc 1
mnd 1
bc 1
fnc 0
bpm 0
cpm 0
noi 6
1
import React from "react";
2
import JobIndexHr from "./JobIndexHr";
3
import { JobCardProps } from "../JobCard";
4
import { Job, HrAdvisor } from "../../models/types";
0 ignored issues
show
Unused Code introduced by
'HrAdvisor' is defined but never used.
Loading history...
5
import { classificationString, jobStatus } from "../../models/jobUtil";
6
import { localizeField, Locales } from "../../helpers/localize";
7
import {
8
  hrJobSummary,
9
  hrJobReview,
10
  hrJobPreview,
11
  hrScreeningPlan,
12
} from "../../helpers/routes";
13
import { defineMessages, IntlShape, useIntl } from "react-intl";
0 ignored issues
show
introduced by
react-intl import should occur before import of ./JobIndexHr
Loading history...
14
15
interface JobIndexHrPageProps {
16
  claimedJobIds: number[],
0 ignored issues
show
introduced by
Replace , with ;
Loading history...
17
}
18
19
const messages = defineMessages({
20
  reviewDraft: {
21
    id: "hrJobIndex.reviewDraft",
22
    defaultMessage: "Review Draft",
23
    description: "Text for the link to review job draft.",
24
  },
25
  preview: {
26
    id: "hrJobIndex.preview",
27
    defaultMessage: "Preview Poster",
28
    description: "Text for the link to preview the job poster.",
29
  },
30
  screeningPlan: {
31
    id: "hrJobIndex.viewScreeningPlan",
32
    defaultMessage: "View Assessment Plan",
33
    description: "Text for the link to view the Screening Plan.",
34
  },
35
  viewActivity: {
36
    id: "hrJobIndex.viewActivity",
37
    defaultMessage: "View Activity",
38
    description: "Text for the link to view new entries in the activity feed.",
39
  },
40
  viewSummary: {
41
    id: "hrJobIndex.viewSummary",
42
    defaultMessage: "View Summary",
43
    description: "Text for the link to the Job Summary page.",
44
  },
45
});
46
47
const makeJobAction = (
48
  intl: IntlShape,
49
  locale: Locales,
50
  claimedJobIds: number[],
51
  job: Job,
52
): JobCardProps => {
53
  return {
54
    applicants: 0, // TODO: find real number of applicants.
55
    // TODO: is this intended to be a link as well, like activity?
56
    classification: classificationString(job),
57
    managerTime: 0, // TODO: This isn't recorded yet.
58
    userTime: 0, // TODO: This isn't recorded yet.
59
    owned: claimedJobIds.includes(job.id),
60
    title: localizeField(locale, job, "title") || "TITLE MISSING", // TODO: How did we deal with missing titles elsewhere?
61
    status: jobStatus(job),
62
    activity: {
63
      count: 0, // TODO: requires tracking which comments are "new"
64
      new: {
65
        url: hrJobSummary(locale, job.id), // TODO: this should include a #link
66
        text: intl.formatMessage(messages.viewActivity),
67
        title: "",
68
      },
69
    },
70
    draft: {
71
      url: hrJobReview(locale, job.id),
72
      text: intl.formatMessage(messages.reviewDraft),
73
      title: "",
74
    },
75
    preview: {
76
      url: hrJobPreview(locale, job.id),
77
      text: intl.formatMessage(messages.preview),
78
      title: "",
79
    },
80
    screeningPlan: {
81
      url: hrScreeningPlan(locale, job.id),
82
      text: intl.formatMessage(messages.screeningPlan),
83
      title: "",
84
    },
85
    summary: {
86
      url: hrJobSummary(locale, job.id),
87
      text: intl.formatMessage(messages.viewSummary),
88
      title: "",
89
    },
90
  };
91
};
92
93
const JobIndexHrPage: React.FC<JobIndexHrPageProps> = ({ claimedJobIds }) => {
0 ignored issues
show
Unused Code introduced by
'JobIndexHrPage' is assigned a value but never used.
Loading history...
94
  const intl = useIntl();
95
  const { locale } = intl;
96
  if (locale !== "en" && locale !== "fr") {
97
    throw new Error("Unknown intl.locale");
98
  }
99
100
  const jobActions = [];
101
  const unclaimedJobs = [];
102
  const departmentName = "dept";
103
104
  const jobToAction = (job: Job) =>
0 ignored issues
show
Unused Code introduced by
'jobToAction' is assigned a value but never used.
Loading history...
introduced by
Missing return type on function.
Loading history...
105
    makeJobAction(intl, locale, claimedJobIds, job);
106
107
  return (
108
    <JobIndexHr
109
      jobActions={jobActions}
110
      unclaimedJobs={unclaimedJobs}
111
      departmentName={departmentName}
112
    />
113
  );
114
};
115