|
1
|
|
|
import { IntlShape } from "react-intl"; |
|
2
|
|
|
import { ProgressBarProps, stepNames } from "./ProgressBar"; |
|
3
|
|
|
import { |
|
4
|
|
|
applicationBasic, |
|
5
|
|
|
applicationFit, |
|
6
|
|
|
applicationReview, |
|
7
|
|
|
applicationSubmission, |
|
8
|
|
|
applicationExperience, |
|
9
|
|
|
applicationSkills, |
|
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
|
|
|
return step === currentStep ? "current" : steps[step]; |
|
35
|
|
|
}; |
|
36
|
|
|
const isLoading = (step: ApplicationStep): boolean => { |
|
37
|
|
|
return steps[step] !== "default" && stepsUpdateInProgress; |
|
38
|
|
|
}; |
|
39
|
|
|
|
|
40
|
|
|
return [ |
|
41
|
|
|
{ |
|
42
|
|
|
link: { |
|
43
|
|
|
url: applicationBasic(locale, applicationId), |
|
44
|
|
|
text: intl.formatMessage(stepNames.step01), |
|
45
|
|
|
title: intl.formatMessage(stepNames.step01), |
|
46
|
|
|
}, |
|
47
|
|
|
status: makeStatus("basic"), |
|
48
|
|
|
loading: isLoading("basic"), |
|
49
|
|
|
}, |
|
50
|
|
|
{ |
|
51
|
|
|
link: { |
|
52
|
|
|
url: applicationExperience(locale, applicationId), |
|
53
|
|
|
text: intl.formatMessage(stepNames.step02), |
|
54
|
|
|
title: intl.formatMessage(stepNames.step02), |
|
55
|
|
|
}, |
|
56
|
|
|
status: makeStatus("experience"), |
|
57
|
|
|
loading: isLoading("experience"), |
|
58
|
|
|
}, |
|
59
|
|
|
{ |
|
60
|
|
|
link: { |
|
61
|
|
|
url: applicationSkills(locale, applicationId), |
|
62
|
|
|
text: intl.formatMessage(stepNames.step03), |
|
63
|
|
|
title: intl.formatMessage(stepNames.step03), |
|
64
|
|
|
}, |
|
65
|
|
|
status: makeStatus("skills"), |
|
66
|
|
|
loading: isLoading("skills"), |
|
67
|
|
|
}, |
|
68
|
|
|
{ |
|
69
|
|
|
link: { |
|
70
|
|
|
url: applicationFit(locale, applicationId), |
|
71
|
|
|
text: intl.formatMessage(stepNames.step04), |
|
72
|
|
|
title: intl.formatMessage(stepNames.step04), |
|
73
|
|
|
}, |
|
74
|
|
|
status: makeStatus("fit"), |
|
75
|
|
|
loading: isLoading("fit"), |
|
76
|
|
|
}, |
|
77
|
|
|
{ |
|
78
|
|
|
link: { |
|
79
|
|
|
url: applicationReview(locale, applicationId), |
|
80
|
|
|
text: intl.formatMessage(stepNames.step05), |
|
81
|
|
|
title: intl.formatMessage(stepNames.step05), |
|
82
|
|
|
}, |
|
83
|
|
|
status: makeStatus("review"), |
|
84
|
|
|
loading: isLoading("review"), |
|
85
|
|
|
}, |
|
86
|
|
|
{ |
|
87
|
|
|
link: { |
|
88
|
|
|
url: applicationSubmission(locale, applicationId), |
|
89
|
|
|
text: intl.formatMessage(stepNames.step06), |
|
90
|
|
|
title: intl.formatMessage(stepNames.step06), |
|
91
|
|
|
}, |
|
92
|
|
|
status: makeStatus("submission"), |
|
93
|
|
|
loading: isLoading("submission"), |
|
94
|
|
|
}, |
|
95
|
|
|
]; |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
export default makeProgressBarSteps; |
|
99
|
|
|
|