1
|
|
|
import { IntlShape } from "react-intl"; |
2
|
|
|
import { ProgressBarProps, stepNames } from "./ProgressBar"; |
3
|
|
|
import { |
4
|
|
|
applicationBasic, |
5
|
|
|
applicationExperienceIntro, |
6
|
|
|
applicationFit, |
7
|
|
|
applicationReview, |
8
|
|
|
applicationSubmission, |
9
|
|
|
applicationSkillsIntro, |
10
|
|
|
} from "../../../helpers/routes"; |
11
|
|
|
import { getLocale } from "../../../helpers/localize"; |
12
|
|
|
import { |
13
|
|
|
ApplicationStep, |
14
|
|
|
ProgressBarStatus, |
15
|
|
|
} from "../../../models/lookupConstants"; |
16
|
|
|
|
17
|
|
|
export function makeProgressBarSteps( |
18
|
|
|
applicationId: number, |
19
|
|
|
steps: { [step in ApplicationStep]: ProgressBarStatus }, |
20
|
|
|
intl: IntlShape, |
21
|
|
|
currentStep: |
22
|
|
|
| "welcome" |
23
|
|
|
| "basic" |
24
|
|
|
| "experience" |
25
|
|
|
| "skills" |
26
|
|
|
| "fit" |
27
|
|
|
| "review" |
28
|
|
|
| "submission" |
29
|
|
|
| "other", |
30
|
|
|
stepsUpdateInProgress: boolean, |
31
|
|
|
): ProgressBarProps["steps"] { |
32
|
|
|
const locale = getLocale(intl.locale); |
33
|
|
|
const makeStatus = (step: ApplicationStep): ProgressBarStatus => { |
34
|
|
|
// eslint-disable-next-line no-nested-ternary |
35
|
|
|
return step === currentStep |
36
|
|
|
? "current" |
37
|
|
|
: steps[step] !== "default" && stepsUpdateInProgress |
38
|
|
|
? "loading" |
39
|
|
|
: steps[step]; |
40
|
|
|
}; |
41
|
|
|
return [ |
42
|
|
|
{ |
43
|
|
|
link: { |
44
|
|
|
url: applicationBasic(locale, applicationId), |
45
|
|
|
text: intl.formatMessage(stepNames.step01), |
46
|
|
|
title: intl.formatMessage(stepNames.step01), |
47
|
|
|
}, |
48
|
|
|
status: makeStatus("basic"), |
49
|
|
|
}, |
50
|
|
|
{ |
51
|
|
|
link: { |
52
|
|
|
url: applicationExperienceIntro(locale, applicationId), |
53
|
|
|
text: intl.formatMessage(stepNames.step02), |
54
|
|
|
title: intl.formatMessage(stepNames.step02), |
55
|
|
|
}, |
56
|
|
|
status: makeStatus("experience"), |
57
|
|
|
}, |
58
|
|
|
{ |
59
|
|
|
link: { |
60
|
|
|
url: applicationSkillsIntro(locale, applicationId), |
61
|
|
|
text: intl.formatMessage(stepNames.step03), |
62
|
|
|
title: intl.formatMessage(stepNames.step03), |
63
|
|
|
}, |
64
|
|
|
status: makeStatus("skills"), |
65
|
|
|
}, |
66
|
|
|
{ |
67
|
|
|
link: { |
68
|
|
|
url: applicationFit(locale, applicationId), |
69
|
|
|
text: intl.formatMessage(stepNames.step04), |
70
|
|
|
title: intl.formatMessage(stepNames.step04), |
71
|
|
|
}, |
72
|
|
|
status: makeStatus("fit"), |
73
|
|
|
}, |
74
|
|
|
{ |
75
|
|
|
link: { |
76
|
|
|
url: applicationReview(locale, applicationId), |
77
|
|
|
text: intl.formatMessage(stepNames.step05), |
78
|
|
|
title: intl.formatMessage(stepNames.step05), |
79
|
|
|
}, |
80
|
|
|
status: makeStatus("review"), |
81
|
|
|
}, |
82
|
|
|
{ |
83
|
|
|
link: { |
84
|
|
|
url: applicationSubmission(locale, applicationId), |
85
|
|
|
text: intl.formatMessage(stepNames.step06), |
86
|
|
|
title: intl.formatMessage(stepNames.step06), |
87
|
|
|
}, |
88
|
|
|
status: makeStatus("submission"), |
89
|
|
|
}, |
90
|
|
|
]; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
export default makeProgressBarSteps; |
94
|
|
|
|