|
1
|
|
|
/* eslint-disable camelcase */ |
|
2
|
|
|
import React from "react"; |
|
3
|
|
|
import { useIntl } from "react-intl"; |
|
4
|
|
|
import { useDispatch } from "react-redux"; |
|
5
|
|
|
import { getLocale } from "../../../helpers/localize"; |
|
6
|
|
|
import { applicationExperience } from "../../../helpers/routes"; |
|
7
|
|
|
import ProgressBar, { stepNames } from "../ProgressBar/ProgressBar"; |
|
8
|
|
|
import { navigate } from "../../../helpers/router"; |
|
9
|
|
|
import makeProgressBarSteps from "../ProgressBar/progressHelpers"; |
|
10
|
|
|
import ExperienceIntro from "./ExperienceIntro"; |
|
11
|
|
|
import { DispatchType } from "../../../configureStore"; |
|
12
|
|
|
import { loadingMessages } from "../applicationMessages"; |
|
13
|
|
|
import { |
|
14
|
|
|
useApplication, |
|
15
|
|
|
useFetchAllApplicationData, |
|
16
|
|
|
useJob, |
|
17
|
|
|
useJobApplicationSteps, |
|
18
|
|
|
useTouchApplicationStep, |
|
19
|
|
|
} from "../../../hooks/applicationHooks"; |
|
20
|
|
|
|
|
21
|
|
|
interface ExperienceIntroPageProps { |
|
22
|
|
|
applicationId: number; |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
export const ExperienceIntroPage: React.FunctionComponent<ExperienceIntroPageProps> = ({ |
|
26
|
|
|
applicationId, |
|
27
|
|
|
}) => { |
|
28
|
|
|
const intl = useIntl(); |
|
29
|
|
|
const locale = getLocale(intl.locale); |
|
30
|
|
|
const dispatch = useDispatch<DispatchType>(); |
|
31
|
|
|
|
|
32
|
|
|
// Fetch all un-loaded data that may be required for the Application. |
|
33
|
|
|
useFetchAllApplicationData(applicationId, dispatch); |
|
34
|
|
|
|
|
35
|
|
|
const application = useApplication(applicationId); |
|
36
|
|
|
const jobId = application?.job_poster_id; |
|
37
|
|
|
const job = useJob(jobId); |
|
38
|
|
|
const steps = useJobApplicationSteps(); |
|
39
|
|
|
|
|
40
|
|
|
const stepsAreUpdating = useTouchApplicationStep( |
|
41
|
|
|
applicationId, |
|
42
|
|
|
"experience", |
|
43
|
|
|
dispatch, |
|
44
|
|
|
); |
|
45
|
|
|
|
|
46
|
|
|
const handleStart = (): void => |
|
47
|
|
|
navigate(applicationExperience(locale, applicationId)); |
|
48
|
|
|
const closeDate = job?.close_date_time ?? null; |
|
49
|
|
|
return application === null ? ( |
|
50
|
|
|
<h2 |
|
51
|
|
|
data-c-heading="h2" |
|
52
|
|
|
data-c-align="center" |
|
53
|
|
|
data-c-padding="top(2) bottom(2)" |
|
54
|
|
|
> |
|
55
|
|
|
{intl.formatMessage(loadingMessages.loading)} |
|
56
|
|
|
</h2> |
|
57
|
|
|
) : ( |
|
58
|
|
|
<> |
|
59
|
|
|
<ProgressBar |
|
60
|
|
|
closeDateTime={closeDate} |
|
61
|
|
|
currentTitle={intl.formatMessage(stepNames.step02)} |
|
62
|
|
|
steps={makeProgressBarSteps( |
|
63
|
|
|
applicationId, |
|
64
|
|
|
steps, |
|
65
|
|
|
intl, |
|
66
|
|
|
"experience", |
|
67
|
|
|
stepsAreUpdating, |
|
68
|
|
|
)} |
|
69
|
|
|
/> |
|
70
|
|
|
<ExperienceIntro handleStart={handleStart} /> |
|
71
|
|
|
</> |
|
72
|
|
|
); |
|
73
|
|
|
}; |
|
74
|
|
|
|
|
75
|
|
|
export default ExperienceIntroPage; |
|
76
|
|
|
|