Skip to content

Commit 5305285

Browse files
committed
WUP
1 parent 67af18f commit 5305285

File tree

14 files changed

+365
-167
lines changed

14 files changed

+365
-167
lines changed

src/api/routes/reference-router.ts

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import express, { Request, Response } from "express";
22
import knex from "knex";
3+
import { parse } from "papaparse";
34

45
import { DB_CONFIG } from "../config";
6+
import { isArray } from "lodash";
57

68
const db = knex(DB_CONFIG);
79

@@ -27,38 +29,41 @@ referenceRouter.get("/institution_level", async (req: Request, res: Response) =>
2729
res.json({ data: levels });
2830
});
2931

30-
referenceRouter.get("/noc_code", async (req: Request, res: Response) => {
31-
let codes = await db("sfa.noc_code");
32+
referenceRouter.get("/noc_codes", async (req: Request, res: Response) => {
33+
let codes = await db("sfa.noc_codes").select("noc_2021_code", "noc_2021_title");
3234
res.json({ data: codes });
3335
});
3436

35-
referenceRouter.post("/noc_code", async (req: Request, res: Response) => {
36-
const file = req.body.file; // Expecting an array of NOC code objects
37+
referenceRouter.post("/noc_codes", async (req: Request, res: Response) => {
38+
if (!req.files || !req.files.file) return res.status(400).json({ message: "No file provided" });
3739

38-
if (!file) return res.status(400).json({ message: "No file provided" });
40+
const file = isArray(req.files.file) ? req.files.file[0] : req.files.file; // Expecting an array of NOC code objects
41+
const contents = file.data.toString("utf-8");
42+
const csv = parse<{
43+
noc2016v13code: string;
44+
noc2016v13title: string;
45+
gsimtypeofchange: string;
46+
noc2021v10code: string;
47+
noc2021v10title: string;
48+
notes: string;
49+
}>(contents, {
50+
header: true,
51+
skipEmptyLines: true,
52+
transformHeader: (header) => header.toLowerCase().replace(/\s/g, "").replace(".", "").trim(), // remove spaces and dots
53+
});
3954

40-
const lines = file.split("\n");
41-
const header = lines[0].split(",");
42-
if (header[0] !== "NOC 2016 V1.3 Code" || header[3] !== "NOC 2021 V1.0 Code") {
43-
return res.status(400).json({ message: "Invalid file format" });
44-
}
45-
46-
await db("sfa.noc_code").delete();
47-
const records = lines.slice(1);
48-
49-
for (const line of records) {
50-
const cols = line.split(",");
55+
await db("sfa.noc_codes").delete();
5156

52-
if (cols.length != 6) return res.status(400).json({ message: "Invalid file format" });
53-
54-
db("sfa.noc_code").insert({
55-
noc_2016_code: cols[0],
56-
noc_2016_title: cols[1],
57-
gsim_type_of_change: cols[2],
58-
noc_2021_code: cols[3],
59-
noc_2021_title: cols[4],
60-
notes: cols[5],
57+
for (const line of csv.data) {
58+
await db("sfa.noc_codes").insert({
59+
noc_2016_code: line.noc2016v13code,
60+
noc_2016_title: line.noc2016v13title,
61+
gsim_type_of_change: line.gsimtypeofchange,
62+
noc_2021_code: line.noc2021v10code,
63+
noc_2021_title: line.noc2021v10title,
64+
notes: line.notes,
6165
});
62-
res.json({ message: "NOC codes updated successfully" });
6366
}
67+
68+
res.json({ message: "NOC codes updated successfully" });
6469
});

src/web/src/components/adminHome/SubRoutesSideBar.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export default {
4747
{title:"Funding Group", path: "/administration/funding-group"},
4848
{title:"Status", path: "/administration/status"},
4949
{title:"Status Reason", path: "/administration/status-reason"},
50+
{title:"NOC Codes", path: "/administration/noc-code"},
5051
],
5152
ecerts_reports:[
5253
{title:"CSL MSFAA Receive", path: "/administration/csl-msfaa-receive"},

src/web/src/components/application/wup-funding-requests/apprenticeship-training-support/ApprenticeshipTrainingForm.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<template>
22
<div>
3-
<div class="mt-2 ml-1 d-flex">
3+
<div v-if="hasOtherFundingRequest">This application already has the Apprenticeship Training funding request.</div>
4+
<div v-else class="mt-2 ml-1 d-flex">
45
<v-switch class="my-0 mr-2" v-model="hasFundingRequest" @change="toggle($event)"> </v-switch>
56
<h3 class="text-h6 font-weight-regular">Client applied for Training Support</h3>
67
</div>
@@ -271,7 +272,6 @@
271272
/>
272273
</v-col>
273274

274-
275275
<v-col cols="12" md="6">
276276
<v-switch
277277
v-model="fundingRequest.json_data.dependent_care_subsidy_eligible"
@@ -404,6 +404,10 @@ export default {
404404
this.hasFundingRequest = !!myRequest;
405405
return myRequest;
406406
},
407+
hasOtherFundingRequest() {
408+
const otherRequestTypes = [50]; // Example request types
409+
return this.application?.funding_requests?.some((fr) => otherRequestTypes.includes(fr.request_type_id));
410+
},
407411
},
408412
watch: {
409413
/* "fundingRequest.json_data": {

src/web/src/components/application/wup-funding-requests/ei-eligibility/EiEligibilityForm.vue

Lines changed: 128 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -1,124 +1,125 @@
11
<template>
22
<div>
3-
<div class="mt-2 ml-1 d-flex">
4-
<v-switch v-model="isLMDA" class="my-0 mr-2" @change="toggleEligibility('LMDA')"> </v-switch>
5-
<h3 class="text-h6 font-weight-regular">LMDA Eligible</h3>
6-
<v-switch v-model="isWDA" class="my-0 ml-10 mr-2" @change="toggleEligibility('WDA')"> </v-switch>
7-
<h3 class="text-h6 font-weight-regular">WDA Eligible</h3>
8-
</div>
9-
<div>
10-
<div v-if="fundingRequest && fundingRequest.json_data">
11-
<v-card class="default mb-8">
12-
<v-card-text>
13-
<div>
14-
<v-menu
15-
v-model="dateMenu1"
16-
:close-on-content-click="false"
17-
transition="scale-transition"
18-
left
19-
nudge-top="26"
20-
offset-y
21-
min-width="auto"
22-
>
23-
<template v-slot:activator="{ on, attrs }">
24-
<v-text-field
25-
:value="fundingRequest.json_data.expected_last_day_of_working?.slice(0, 10)"
26-
label="Expected last day of work"
27-
append-icon="mdi-calendar"
28-
readonly
29-
outlined
30-
dense
31-
background-color="white"
32-
v-bind="attrs"
33-
v-on="on"
34-
></v-text-field>
35-
</template>
36-
<v-date-picker
3+
<div v-if="fundingRequest && fundingRequest.json_data">
4+
<div class="mt-2 ml-1 d-flex">
5+
<v-switch v-model="isLMDA" class="my-0 mr-2" @change="toggleEligibility('LMDA')"> </v-switch>
6+
<h3 class="text-h6 font-weight-regular">LMDA Eligible</h3>
7+
<v-switch v-model="isWDA" class="my-0 ml-10 mr-2" @change="toggleEligibility('WDA')"> </v-switch>
8+
<h3 class="text-h6 font-weight-regular">WDA Eligible</h3>
9+
</div>
10+
<v-card class="default mb-8">
11+
<v-card-text>
12+
<div>
13+
<v-menu
14+
v-model="dateMenu1"
15+
:close-on-content-click="false"
16+
transition="scale-transition"
17+
left
18+
nudge-top="26"
19+
offset-y
20+
min-width="auto"
21+
>
22+
<template v-slot:activator="{ on, attrs }">
23+
<v-text-field
3724
:value="fundingRequest.json_data.expected_last_day_of_working?.slice(0, 10)"
38-
@input="
39-
(e) => {
40-
fundingRequest.json_data.expected_last_day_of_working = e;
41-
dateMenu1 = false;
42-
saveItem();
43-
}
44-
"
45-
></v-date-picker>
46-
</v-menu>
47-
48-
<v-divider class="mb-8 mt-1" />
49-
50-
<v-row v-for="line of fundingRequest.json_data.ei_eligibility_list">
51-
<v-col cols="12" md="5">
52-
<v-select
53-
:items="['Yes', 'No']"
54-
label="EI Eligibility"
55-
v-model="line.eligible_for_ei"
56-
dense
57-
outlined
58-
hide-details
59-
background-color="white"
60-
@change="saveItem"
61-
/>
62-
</v-col>
63-
<v-col cols="12" md="5">
64-
<v-menu
65-
v-model="line.dateMenu"
66-
:close-on-content-click="false"
67-
transition="scale-transition"
68-
left
69-
nudge-top="26"
70-
offset-y
71-
min-width="auto"
72-
>
73-
<template v-slot:activator="{ on, attrs }">
74-
<v-text-field
75-
:value="line.date_checked?.slice(0, 10)"
76-
label="Date checked"
77-
append-icon="mdi-calendar"
78-
readonly
79-
hide-details
80-
outlined
81-
dense
82-
background-color="white"
83-
v-bind="attrs"
84-
v-on="on"
85-
></v-text-field>
86-
</template>
87-
<v-date-picker
25+
label="Expected last day of work"
26+
append-icon="mdi-calendar"
27+
readonly
28+
outlined
29+
dense
30+
background-color="white"
31+
v-bind="attrs"
32+
v-on="on"
33+
></v-text-field>
34+
</template>
35+
<v-date-picker
36+
:value="fundingRequest.json_data.expected_last_day_of_working?.slice(0, 10)"
37+
@input="
38+
(e) => {
39+
fundingRequest.json_data.expected_last_day_of_working = e;
40+
dateMenu1 = false;
41+
saveItem();
42+
}
43+
"
44+
></v-date-picker>
45+
</v-menu>
46+
47+
<v-divider class="mb-8 mt-1" />
48+
49+
<v-row v-for="line of fundingRequest.json_data.ei_eligibility_list">
50+
<v-col cols="12" md="5">
51+
<v-select
52+
:items="['Yes', 'No']"
53+
label="EI Eligibility"
54+
v-model="line.eligible_for_ei"
55+
dense
56+
outlined
57+
hide-details
58+
background-color="white"
59+
@change="saveItem"
60+
/>
61+
</v-col>
62+
<v-col cols="12" md="5">
63+
<v-menu
64+
v-model="line.dateMenu"
65+
:close-on-content-click="false"
66+
transition="scale-transition"
67+
left
68+
nudge-top="26"
69+
offset-y
70+
min-width="auto"
71+
>
72+
<template v-slot:activator="{ on, attrs }">
73+
<v-text-field
8874
:value="line.date_checked?.slice(0, 10)"
89-
@input="
90-
(e) => {
91-
line.date_checked = e;
92-
line.dateMenu = false;
93-
saveItem();
94-
}
95-
"
96-
></v-date-picker>
97-
</v-menu>
98-
</v-col>
99-
<v-col cols="12" md="2" class="text-right">
100-
<v-btn @click="removeEIEligibility(line)" icon color="warning"><v-icon>mdi-delete</v-icon></v-btn>
101-
</v-col>
102-
</v-row>
103-
104-
<v-btn class="my-5" color="info" @click="addEIEligibility">Add</v-btn>
105-
</div>
106-
107-
<p>If apprentice is not applying for EI, document the reason below</p>
108-
<v-textarea
109-
label="Comments"
110-
rows="3"
111-
auto-grow
112-
v-model="fundingRequest.json_data.notes"
113-
dense
114-
outlined
115-
hide-details
116-
background-color="white"
117-
@blur="saveItem"
118-
/>
119-
</v-card-text>
120-
</v-card>
121-
</div>
75+
label="Date checked"
76+
append-icon="mdi-calendar"
77+
readonly
78+
hide-details
79+
outlined
80+
dense
81+
background-color="white"
82+
v-bind="attrs"
83+
v-on="on"
84+
></v-text-field>
85+
</template>
86+
<v-date-picker
87+
:value="line.date_checked?.slice(0, 10)"
88+
@input="
89+
(e) => {
90+
line.date_checked = e;
91+
line.dateMenu = false;
92+
saveItem();
93+
}
94+
"
95+
></v-date-picker>
96+
</v-menu>
97+
</v-col>
98+
<v-col cols="12" md="2" class="text-right">
99+
<v-btn @click="removeEIEligibility(line)" icon color="warning"><v-icon>mdi-delete</v-icon></v-btn>
100+
</v-col>
101+
</v-row>
102+
103+
<v-btn class="my-5" color="info" @click="addEIEligibility">Add</v-btn>
104+
</div>
105+
106+
<p>If apprentice is not applying for EI, document the reason below</p>
107+
<v-textarea
108+
label="Comments"
109+
rows="3"
110+
auto-grow
111+
v-model="fundingRequest.json_data.notes"
112+
dense
113+
outlined
114+
hide-details
115+
background-color="white"
116+
@blur="saveItem"
117+
/>
118+
</v-card-text>
119+
</v-card>
120+
</div>
121+
<div v-else class="mx-5">
122+
Either the Skills for Success or Apprenticeship Training funding request must be created first
122123
</div>
123124

124125
<confirm-dialog ref="confirm"></confirm-dialog>
@@ -154,16 +155,18 @@ export default {
154155
const myRequest = this.application?.funding_requests?.find((fr) => wupRequestTypes.includes(fr.request_type_id));
155156
this.hasFundingRequest = !!myRequest;
156157
157-
if (myRequest && !myRequest.json_data.funding_source) {
158-
this.isLMDA = false;
159-
this.isWDA = false;
160-
} else {
161-
if (myRequest.json_data.funding_source === "WDA") {
162-
this.isWDA = true;
158+
if (myRequest) {
159+
if (myRequest && !myRequest.json_data.funding_source) {
163160
this.isLMDA = false;
164-
} else {
165-
this.isLMDA = true;
166161
this.isWDA = false;
162+
} else {
163+
if (myRequest.json_data.funding_source === "WDA") {
164+
this.isWDA = true;
165+
this.isLMDA = false;
166+
} else {
167+
this.isLMDA = true;
168+
this.isWDA = false;
169+
}
167170
}
168171
}
169172

0 commit comments

Comments
 (0)