1
|
|
|
import { IntlShape } from "react-intl"; |
2
|
|
|
import { ApplicationNormalized } from "../../../models/types"; |
3
|
|
|
import { |
4
|
|
|
ProgressBarProps, |
5
|
|
|
stepNames, |
6
|
|
|
ProgressBarStepStatus, |
7
|
|
|
} from "./ProgressBar"; |
8
|
|
|
import { |
9
|
|
|
applicationBasic, |
10
|
|
|
applicationExperienceIntro, |
11
|
|
|
applicationSkills, |
12
|
|
|
applicationFit, |
13
|
|
|
applicationReview, |
14
|
|
|
applicationSubmission, |
15
|
|
|
} from "../../../helpers/routes"; |
16
|
|
|
import { getLocale } from "../../../helpers/localize"; |
17
|
|
|
|
18
|
|
|
function basicInfoStatus( |
19
|
|
|
application: ApplicationNormalized | null, |
20
|
|
|
): ProgressBarStepStatus { |
21
|
|
|
if (application === null) { |
22
|
|
|
return "default"; |
23
|
|
|
} |
24
|
|
|
// TODO: implement. |
25
|
|
|
return "complete"; |
26
|
|
|
} |
27
|
|
|
function experienceStatus( |
28
|
|
|
application: ApplicationNormalized | null, |
29
|
|
|
): ProgressBarStepStatus { |
30
|
|
|
if (application === null) { |
31
|
|
|
return "default"; |
32
|
|
|
} |
33
|
|
|
// TODO: implement. |
34
|
|
|
return "complete"; |
35
|
|
|
} |
36
|
|
|
function skillsStatus( |
37
|
|
|
application: ApplicationNormalized | null, |
38
|
|
|
): ProgressBarStepStatus { |
39
|
|
|
if (application === null) { |
40
|
|
|
return "default"; |
41
|
|
|
} |
42
|
|
|
// TODO: implement. |
43
|
|
|
return "complete"; |
44
|
|
|
} |
45
|
|
|
function myFitStatus( |
46
|
|
|
application: ApplicationNormalized | null, |
47
|
|
|
): ProgressBarStepStatus { |
48
|
|
|
if (application === null) { |
49
|
|
|
return "default"; |
50
|
|
|
} |
51
|
|
|
// TODO: implement. |
52
|
|
|
return "complete"; |
53
|
|
|
} |
54
|
|
|
function reviewStatus( |
55
|
|
|
application: ApplicationNormalized | null, |
56
|
|
|
): ProgressBarStepStatus { |
57
|
|
|
if (application === null) { |
58
|
|
|
return "default"; |
59
|
|
|
} |
60
|
|
|
// TODO: implement. |
61
|
|
|
return "complete"; |
62
|
|
|
} |
63
|
|
|
function submissionStatus( |
64
|
|
|
application: ApplicationNormalized | null, |
65
|
|
|
): ProgressBarStepStatus { |
66
|
|
|
if (application === null) { |
67
|
|
|
return "default"; |
68
|
|
|
} |
69
|
|
|
// TODO: implement. |
70
|
|
|
return "complete"; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
export function makeProgressBarSteps( |
74
|
|
|
applicationId: number, |
75
|
|
|
application: ApplicationNormalized | null, |
76
|
|
|
intl: IntlShape, |
77
|
|
|
currentStep: |
78
|
|
|
| "welcome" |
79
|
|
|
| "basic" |
80
|
|
|
| "experience" |
81
|
|
|
| "skills" |
82
|
|
|
| "fit" |
83
|
|
|
| "review" |
84
|
|
|
| "submission" |
85
|
|
|
| "other", |
86
|
|
|
): ProgressBarProps["steps"] { |
87
|
|
|
const locale = getLocale(intl.locale); |
88
|
|
|
return [ |
89
|
|
|
{ |
90
|
|
|
link: { |
91
|
|
|
url: applicationBasic(locale, applicationId), |
92
|
|
|
text: intl.formatMessage(stepNames.step01), |
93
|
|
|
title: intl.formatMessage(stepNames.step01), |
94
|
|
|
}, |
95
|
|
|
status: |
96
|
|
|
currentStep === "basic" ? "current" : basicInfoStatus(application), |
97
|
|
|
}, |
98
|
|
|
{ |
99
|
|
|
link: { |
100
|
|
|
url: applicationExperienceIntro(locale, applicationId), |
101
|
|
|
text: intl.formatMessage(stepNames.step02), |
102
|
|
|
title: intl.formatMessage(stepNames.step02), |
103
|
|
|
}, |
104
|
|
|
status: |
105
|
|
|
currentStep === "experience" |
106
|
|
|
? "current" |
107
|
|
|
: experienceStatus(application), |
108
|
|
|
}, |
109
|
|
|
{ |
110
|
|
|
link: { |
111
|
|
|
url: applicationSkills(locale, applicationId), |
112
|
|
|
text: intl.formatMessage(stepNames.step03), |
113
|
|
|
title: intl.formatMessage(stepNames.step03), |
114
|
|
|
}, |
115
|
|
|
status: currentStep === "skills" ? "current" : skillsStatus(application), |
116
|
|
|
}, |
117
|
|
|
{ |
118
|
|
|
link: { |
119
|
|
|
url: applicationFit(locale, applicationId), |
120
|
|
|
text: intl.formatMessage(stepNames.step04), |
121
|
|
|
title: intl.formatMessage(stepNames.step04), |
122
|
|
|
}, |
123
|
|
|
status: currentStep === "fit" ? "current" : myFitStatus(application), |
124
|
|
|
}, |
125
|
|
|
{ |
126
|
|
|
link: { |
127
|
|
|
url: applicationReview(locale, applicationId), |
128
|
|
|
text: intl.formatMessage(stepNames.step05), |
129
|
|
|
title: intl.formatMessage(stepNames.step05), |
130
|
|
|
}, |
131
|
|
|
status: currentStep === "review" ? "current" : reviewStatus(application), |
132
|
|
|
}, |
133
|
|
|
{ |
134
|
|
|
link: { |
135
|
|
|
url: applicationSubmission(locale, applicationId), |
136
|
|
|
text: intl.formatMessage(stepNames.step06), |
137
|
|
|
title: intl.formatMessage(stepNames.step06), |
138
|
|
|
}, |
139
|
|
|
status: |
140
|
|
|
currentStep === "submission" |
141
|
|
|
? "current" |
142
|
|
|
: submissionStatus(application), |
143
|
|
|
}, |
144
|
|
|
]; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
export default makeProgressBarSteps; |
148
|
|
|
|