Passed
Push — task/ci-test-actions ( 9a656a...06edf0 )
by Tristan
04:26
created

resources/assets/js/components/Application/Skills/SkillsIntroPage.tsx   A

Complexity

Total Complexity 4
Complexity/F 0

Size

Lines of Code 140
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 114
mnd 4
bc 4
fnc 0
dl 0
loc 140
rs 10
bpm 0
cpm 0
noi 0
c 0
b 0
f 0
1
/* eslint-disable camelcase */
2
import React from "react";
3
import { useIntl, FormattedMessage } from "react-intl";
4
import { useDispatch } from "react-redux";
5
import makeProgressBarSteps from "../ProgressBar/progressHelpers";
6
import ProgressBar, { stepNames } from "../ProgressBar/ProgressBar";
7
import { navigate } from "../../../helpers/router";
8
import { applicationSkills } from "../../../helpers/routes";
9
import { getLocale } from "../../../helpers/localize";
10
import { DispatchType } from "../../../configureStore";
11
import { loadingMessages } from "../applicationMessages";
12
import {
13
  useApplication,
14
  useFetchAllApplicationData,
15
  useJob,
16
  useJobApplicationSteps,
17
  useTouchApplicationStep,
18
} from "../../../hooks/applicationHooks";
19
20
interface SkillsIntroPageProps {
21
  applicationId: number;
22
}
23
24
/**
25
 * This page displays some instructions for the Skills step, and prefetches the data that will be used there.
26
 * @param applicationId
27
 */
28
export const SkillsIntroPage: React.FunctionComponent<SkillsIntroPageProps> = ({
29
  applicationId,
30
}) => {
31
  const intl = useIntl();
32
  const locale = getLocale(intl.locale);
33
  const dispatch = useDispatch<DispatchType>();
34
35
  useFetchAllApplicationData(applicationId, dispatch);
36
  const application = useApplication(applicationId);
37
  const job = useJob(application?.job_poster_id);
38
  const steps = useJobApplicationSteps();
39
  const closeDate = job?.close_date_time ?? null;
40
41
  const stepsAreUpdating = useTouchApplicationStep(
42
    applicationId,
43
    "skills",
44
    dispatch,
45
  );
46
47
  const handleContinue = (): void => {
48
    navigate(applicationSkills(locale, applicationId));
49
  };
50
51
  return (
52
    <>
53
      {application && (
54
        <ProgressBar
55
          closeDateTime={closeDate}
56
          currentTitle={intl.formatMessage(stepNames.step03)}
57
          steps={makeProgressBarSteps(
58
            applicationId,
59
            steps,
60
            intl,
61
            "skills",
62
            stepsAreUpdating,
63
          )}
64
        />
65
      )}
66
      {!application && (
67
        <h2
68
          data-c-heading="h2"
69
          data-c-align="center"
70
          data-c-padding="top(2) bottom(2)"
71
        >
72
          {intl.formatMessage(loadingMessages.loading)}
73
        </h2>
74
      )}
75
      {application && (
76
        <div data-c-border="bottom(thin, solid, gray)">
77
          <div data-c-container="medium">
78
            <h2 data-c-heading="h2" data-c-margin="top(3) bottom(1)">
79
              <FormattedMessage
80
                id="application.skills.intro.header"
81
                defaultMessage="How You Used Each Skill"
82
                description="Header for the Skills Intro step."
83
              />
84
            </h2>
85
            <p data-c-margin="bottom(1)">
86
              <FormattedMessage
87
                id="application.skills.intro.opening"
88
                defaultMessage="Now that you've shared your experiences, tell us how they connect to the skills required for the job."
89
                description="Opening sentence describing the Skills step."
90
              />
91
            </p>
92
            <p data-c-margin="bottom(1)">
93
              <FormattedMessage
94
                id="application.skills.intro.explanation"
95
                defaultMessage="For each experience <b>add a short explanation that demonstrates how you used the skill</b>. These explanations are what the manager will use to decide how strong your application is, so <b>it's important that you share your best examples</b>."
96
                description="Paragraphs explaining what to expect on the Skills step."
97
                values={{
98
                  b: (...chunks) => (
99
                    <span data-c-font-weight="bold">{chunks}</span>
100
                  ),
101
                }}
102
              />
103
            </p>
104
            <p data-c-margin="bottom(1)">
105
              <FormattedMessage
106
                id="application.skills.intro.savedToProfile"
107
                defaultMessage="Just like experience, this information is saved to your profile so that you can reuse it on other applications!"
108
                description="Paragraph explaining that changes to Skills will be saved to profile."
109
              />
110
            </p>
111
          </div>
112
          <div data-c-container="medium" data-c-padding="tb(2)">
113
            <hr data-c-hr="thin(c1)" data-c-margin="bottom(2)" />
114
            <div data-c-grid="gutter(all, 1)">
115
              <div data-c-grid-item="tl(1of1)" data-c-align="base(center)">
116
                <button
117
                  data-c-button="solid(c1)"
118
                  data-c-radius="rounded"
119
                  type="button"
120
                  onClick={handleContinue}
121
                >
122
                  <span>
123
                    <FormattedMessage
124
                      id="application.skills.intro.letsGo"
125
                      defaultMessage="Let's Go"
126
                      description="Button text for continuing to next step in Application Form."
127
                    />
128
                  </span>
129
                </button>
130
              </div>
131
            </div>
132
          </div>
133
        </div>
134
      )}
135
    </>
136
  );
137
};
138
139
export default SkillsIntroPage;
140