1
|
|
|
/* eslint-disable camelcase */ |
2
|
|
|
import React from "react"; |
3
|
|
|
import { useIntl } from "react-intl"; |
4
|
|
|
import { useDispatch } from "react-redux"; |
5
|
|
|
import Intro from "./Intro"; |
6
|
|
|
import ProgressBar, { stepNames } from "../ProgressBar/ProgressBar"; |
7
|
|
|
import makeProgressBarSteps from "../ProgressBar/progressHelpers"; |
8
|
|
|
import { navigate } from "../../../helpers/router"; |
9
|
|
|
import { getLocale } from "../../../helpers/localize"; |
10
|
|
|
import { applicationBasic } from "../../../helpers/routes"; |
11
|
|
|
import { DispatchType } from "../../../configureStore"; |
12
|
|
|
import { |
13
|
|
|
useApplication, |
14
|
|
|
useFetchAllApplicationData, |
15
|
|
|
useJob, |
16
|
|
|
useJobApplicationSteps, |
17
|
|
|
} from "../../../hooks/applicationHooks"; |
18
|
|
|
import { loadingMessages } from "../applicationMessages"; |
19
|
|
|
|
20
|
|
|
interface IntroPageProps { |
21
|
|
|
applicationId: number; |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
export const IntroPage: React.FunctionComponent<IntroPageProps> = ({ |
25
|
|
|
applicationId, |
26
|
|
|
}) => { |
27
|
|
|
const intl = useIntl(); |
28
|
|
|
const locale = getLocale(intl.locale); |
29
|
|
|
const dispatch = useDispatch<DispatchType>(); |
30
|
|
|
|
31
|
|
|
// Fetch all un-loaded data that may be required for the Application. |
32
|
|
|
useFetchAllApplicationData(applicationId, dispatch); |
33
|
|
|
|
34
|
|
|
const application = useApplication(applicationId); |
35
|
|
|
const job = useJob(application?.job_poster_id); |
36
|
|
|
const steps = useJobApplicationSteps(); |
37
|
|
|
|
38
|
|
|
const handleContinue = async (): Promise<void> => { |
39
|
|
|
return navigate(applicationBasic(locale, applicationId)); |
40
|
|
|
}; |
41
|
|
|
const closeDate = job?.close_date_time ?? null; |
42
|
|
|
return ( |
43
|
|
|
<> |
44
|
|
|
{application !== null && ( |
45
|
|
|
<ProgressBar |
46
|
|
|
closeDateTime={closeDate} |
47
|
|
|
currentTitle={intl.formatMessage(stepNames.welcome)} |
48
|
|
|
steps={makeProgressBarSteps( |
49
|
|
|
applicationId, |
50
|
|
|
steps, |
51
|
|
|
intl, |
52
|
|
|
"other", |
53
|
|
|
false, |
54
|
|
|
)} |
55
|
|
|
/> |
56
|
|
|
)} |
57
|
|
|
<Intro handleStart={handleContinue} /> |
58
|
|
|
</> |
59
|
|
|
); |
60
|
|
|
}; |
61
|
|
|
|
62
|
|
|
export default IntroPage; |
63
|
|
|
|