placementt-core 1.300.154 → 1.300.155

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,24 @@
1
- import { CohortData, InstituteData, OrganisationAddress, ProviderData, SchoolData, UserData } from "./typeDefinitions";
1
+ import { CohortData, InstituteData, OrganisationAddress, ProviderData, SchoolData, StudentPlacementData, UserData } from "./typeDefinitions";
2
2
  type InstituteTipNames = "createCohort" | "addSchools" | "uploadStaff" | "assignStaffRoles" | "uploadPlacements" | "allowExternalPlacementUpload" | "uploadStaffGuidance" | "uploadStudentGuidance";
3
3
  type ProviderTipNames = string;
4
4
  type StudentTipNames = string;
5
5
  export type InstituteTaskNames = "missingParentEmail" | "expiredInsurance" | "approveAlumniConversation" | "outstandingReminders" | "invalidStaffEmails" | "invalidStudentEmails" | "invalidParentEmails" | "invalidProviderEmails" | "verifyInsurance" | "verifyRiskAssessment" | "verifyDbsCheck" | "inactiveStudents" | "uploadStudents" | "inactiveStaff" | "requiredStage" | "approveExternalPlacement" | "overdueStage";
6
6
  export type StudentTaskNames = "completeOnboarding";
7
7
  export type ProviderTaskNames = "applicationRequireReview" | "activateStaff" | "requestedVisiblePlacementListings" | "requestedVisibleAddresses" | "completeStudentDocs" | "uploadOnboarding" | "reviewOnboarding" | "completeListing" | "completeAddress" | "registrationRequests" | "placementStarting" | "completeFeedback" | "setUpFeedback";
8
+ type TaskItem = {
9
+ title?: string;
10
+ message?: string;
11
+ link?: string;
12
+ buttonTitle?: string;
13
+ dismissible?: boolean;
14
+ severity?: "error" | "warning" | "success" | "primary" | "info";
15
+ } | {
16
+ [key: string]: StudentPlacementData;
17
+ };
8
18
  export type TaskQueryReturnObject = {
19
+ [itemName in InstituteTaskNames | InstituteTipNames | StudentTipNames | ProviderTipNames]: TaskItem | TaskItem[];
20
+ } | undefined;
21
+ export type TipQueryReturnObject = {
9
22
  itemName?: InstituteTaskNames | InstituteTipNames | StudentTipNames | ProviderTipNames;
10
23
  title?: string;
11
24
  message?: string;
@@ -21,22 +34,22 @@ export type InstituteTaskObject = {
21
34
  organisation: InstituteData & ProviderData;
22
35
  cohorts: CohortData | [string, CohortData][];
23
36
  schools?: SchoolData | [string, SchoolData][];
24
- }) => Promise<TaskQueryReturnObject | TaskQueryReturnObject[]>;
37
+ }) => Promise<TaskQueryReturnObject>;
25
38
  };
26
39
  };
27
40
  export type StudentTaskObject = {
28
41
  [key in StudentTaskNames]: {
29
- callback: (user: UserData) => Promise<TaskQueryReturnObject | TaskQueryReturnObject[]>;
42
+ callback: (user: UserData) => Promise<TaskQueryReturnObject>;
30
43
  };
31
44
  };
32
45
  export type ProviderTaskObject = {
33
46
  [key in ProviderTaskNames]: {
34
- callback: (user: UserData) => Promise<TaskQueryReturnObject | TaskQueryReturnObject[]>;
47
+ callback: (user: UserData) => Promise<TaskQueryReturnObject>;
35
48
  };
36
49
  };
37
50
  export declare const getTips: (user: UserData, organisation: InstituteData | ProviderData, addresses?: {
38
51
  [key: string]: OrganisationAddress;
39
- }) => Promise<(TaskQueryReturnObject)[]>;
52
+ }) => Promise<(TipQueryReturnObject)[]>;
40
53
  export declare const getTasks: ({ user, organisation, cohort, school }: {
41
54
  user: UserData;
42
55
  organisation?: InstituteData & ProviderData;
@@ -151,13 +151,13 @@ const instituteTasks = {
151
151
  return;
152
152
  const staffCount = (await firebaseQuery.getCount(["users"], [(0, firestore_1.where)("oId", "==", user.oId), (0, firestore_1.where)("userType", "==", "Staff"), (0, firestore_1.where)("flags", "array-contains", "userEmailFailed")]));
153
153
  if (staffCount > 0) {
154
- return {
155
- dismissible: false,
156
- severity: "error",
157
- title: `${staffCount} staff have invalid emails.`,
158
- message: `${staffCount} staff accounts have invalid email addresses. Delete and reupload these users.`,
159
- link: "/institutes/organisation/staff/all",
160
- };
154
+ return { invalidStaffEmails: {
155
+ dismissible: false,
156
+ severity: "error",
157
+ title: `${staffCount} staff have invalid emails.`,
158
+ message: `${staffCount} staff accounts have invalid email addresses. Delete and reupload these users.`,
159
+ link: "/institutes/organisation/staff/all",
160
+ } };
161
161
  }
162
162
  return;
163
163
  },
@@ -169,13 +169,13 @@ const instituteTasks = {
169
169
  return;
170
170
  const convos = (await firebaseQuery.getCount(["alumniConversations"], [(0, firestore_1.where)("oId", "==", user.oId), (0, firestore_1.where)("open", "==", true), (0, firestore_1.where)("delivered", "==", "pending")]));
171
171
  if (convos > 0) {
172
- return {
173
- dismissible: false,
174
- severity: "info",
175
- title: `${convos} alumni conversation message${convos > 1 ? "s" : ""} needs approval.`,
176
- message: `There are ${convos} message${convos > 1 ? "s" : ""} to alumni for you to review and release.`,
177
- link: "/institutes/network/alumni/conversations",
178
- };
172
+ return { approveAlumniConversation: {
173
+ dismissible: false,
174
+ severity: "info",
175
+ title: `${convos} alumni conversation message${convos > 1 ? "s" : ""} needs approval.`,
176
+ message: `There are ${convos} message${convos > 1 ? "s" : ""} to alumni for you to review and release.`,
177
+ link: "/institutes/network/alumni/conversations",
178
+ } };
179
179
  }
180
180
  return;
181
181
  }
@@ -183,13 +183,13 @@ const instituteTasks = {
183
183
  // One school
184
184
  const convos = (await firebaseQuery.getCount(["alumniConversations"], [(0, firestore_1.where)("oId", "==", user.oId), (0, firestore_1.where)("schoolId", "==", schools.id), (0, firestore_1.where)("open", "==", true), (0, firestore_1.where)("delivered", "==", "pending")]));
185
185
  if (convos > 0) {
186
- return {
187
- dismissible: false,
188
- severity: "info",
189
- title: `${convos} alumni conversation message${convos > 1 ? "s" : ""} needs approval.`,
190
- message: `There are ${convos} message${convos > 1 ? "s" : ""} to alumni for you to review and release.`,
191
- link: `/institutes/network/alumni/conversations/${schools.id}`,
192
- };
186
+ return { approveAlumniConversation: {
187
+ dismissible: false,
188
+ severity: "info",
189
+ title: `${convos} alumni conversation message${convos > 1 ? "s" : ""} needs approval.`,
190
+ message: `There are ${convos} message${convos > 1 ? "s" : ""} to alumni for you to review and release.`,
191
+ link: `/institutes/network/alumni/conversations/${schools.id}`,
192
+ } };
193
193
  }
194
194
  return;
195
195
  }
@@ -208,7 +208,7 @@ const instituteTasks = {
208
208
  }
209
209
  return;
210
210
  }));
211
- return items.filter((v) => v);
211
+ return ({ approveAlumniConversation: items.filter((v) => v) });
212
212
  },
213
213
  },
214
214
  invalidStudentEmails: {
@@ -218,13 +218,13 @@ const instituteTasks = {
218
218
  if (!Array.isArray(cohorts)) {
219
219
  const studentCount = (await firebaseQuery.getCount(["users"], [(0, firestore_1.where)("oId", "==", user.oId), (0, firestore_1.where)("userType", "==", "Students"), (0, firestore_1.where)("cohort", "==", cohorts.id), (0, firestore_1.where)("flags", "array-contains", "userEmailFailed")]));
220
220
  if (studentCount > 0) {
221
- return {
222
- dismissible: false,
223
- severity: "error",
224
- title: `${studentCount} students have invalid emails.`,
225
- message: `${studentCount} student accounts have invalid email addresses. Delete and reupload these users.`,
226
- link: `/institutes/cohorts/${cohorts.id}/students`,
227
- };
221
+ return { invalidStudentEmails: {
222
+ dismissible: false,
223
+ severity: "error",
224
+ title: `${studentCount} students have invalid emails.`,
225
+ message: `${studentCount} student accounts have invalid email addresses. Delete and reupload these users.`,
226
+ link: `/institutes/cohorts/${cohorts.id}/students`,
227
+ } };
228
228
  }
229
229
  return;
230
230
  }
@@ -241,7 +241,7 @@ const instituteTasks = {
241
241
  }
242
242
  return;
243
243
  }));
244
- return items.filter((v) => v);
244
+ return { invalidStudentEmails: items.filter((v) => v) };
245
245
  },
246
246
  },
247
247
  outstandingReminders: {
@@ -249,13 +249,13 @@ const instituteTasks = {
249
249
  if (!Array.isArray(cohorts)) {
250
250
  const reminderCount = (await firebaseQuery.getCount(["reminders"], [(0, firestore_1.where)("oId", "==", user.oId), (0, firestore_1.where)("uid", "==", user.id), (0, firestore_1.where)("dueDate", "<=", (0, util_2.convertDate)(new Date(), "dbstring")), (0, firestore_1.where)("cohort", "==", cohorts.id), (0, firestore_1.where)("status", "==", "upcoming")]));
251
251
  if (reminderCount > 0) {
252
- return {
253
- dismissible: false,
254
- severity: "primary",
255
- title: `You have ${reminderCount} reminder${reminderCount > 1 ? "s" : ""}.`,
256
- message: `You have ${reminderCount} outstanding placement reminder${reminderCount > 1 ? "s" : ""}. Click to view.`,
257
- link: `/institutes/cohorts/${cohorts.id}/placements`,
258
- };
252
+ return { outstandingReminders: {
253
+ dismissible: false,
254
+ severity: "primary",
255
+ title: `You have ${reminderCount} reminder${reminderCount > 1 ? "s" : ""}.`,
256
+ message: `You have ${reminderCount} outstanding placement reminder${reminderCount > 1 ? "s" : ""}. Click to view.`,
257
+ link: `/institutes/cohorts/${cohorts.id}/placements`,
258
+ } };
259
259
  }
260
260
  return;
261
261
  }
@@ -272,7 +272,7 @@ const instituteTasks = {
272
272
  }
273
273
  return;
274
274
  }));
275
- return items.filter((v) => v);
275
+ return { outstandingReminders: items.filter((v) => v) };
276
276
  },
277
277
  },
278
278
  invalidParentEmails: {
@@ -282,13 +282,13 @@ const instituteTasks = {
282
282
  if (!Array.isArray(cohorts)) {
283
283
  const placementCount = (await firebaseQuery.getCount(["placements"], [(0, firestore_1.where)("oId", "==", user.oId), (0, firestore_1.where)("cohort", "==", cohorts.id), (0, firestore_1.where)("flags", "array-contains", "parentEmailFailed")]));
284
284
  if (placementCount > 0) {
285
- return {
286
- dismissible: false,
287
- severity: "error",
288
- title: `${placementCount} placements have invalid parent emails.`,
289
- message: `Your cohort '${cohorts.name}' has placements with invalid parent emails. Click to view these placements.`,
290
- link: `/institutes/cohorts/${cohorts.schoolId ? `${cohorts.schoolId}/${cohorts.id}` : cohorts.id}/placements?selectedView=allData&id=inProgress`,
291
- };
285
+ return { invalidParentEmails: {
286
+ dismissible: false,
287
+ severity: "error",
288
+ title: `${placementCount} placements have invalid parent emails.`,
289
+ message: `Your cohort '${cohorts.name}' has placements with invalid parent emails. Click to view these placements.`,
290
+ link: `/institutes/cohorts/${cohorts.schoolId ? `${cohorts.schoolId}/${cohorts.id}` : cohorts.id}/placements?selectedView=allData&id=inProgress`,
291
+ } };
292
292
  }
293
293
  return;
294
294
  }
@@ -306,7 +306,7 @@ const instituteTasks = {
306
306
  }
307
307
  return;
308
308
  }));
309
- return items.filter((v) => v);
309
+ return { invalidParentEmails: items.filter((v) => v) };
310
310
  },
311
311
  },
312
312
  expiredInsurance: {
@@ -316,13 +316,13 @@ const instituteTasks = {
316
316
  if (!Array.isArray(cohorts)) {
317
317
  const placementCount = (await firebaseQuery.getCount(["placements"], [(0, firestore_1.where)("oId", "==", user.oId), (0, firestore_1.where)("cohort", "==", cohorts.id), (0, firestore_1.where)("endDate", ">", (0, util_2.convertDate)(new Date(), "dbstring")), (0, firestore_1.where)("flags", "array-contains", "insuranceExpired")]));
318
318
  if (placementCount > 0) {
319
- return {
320
- dismissible: false,
321
- severity: "error",
322
- title: `${placementCount} placements have expired insurance.`,
323
- message: `Your cohort '${cohorts.name}' has placements with expired insurance Click to view these placements.`,
324
- link: `/institutes/cohorts/${cohorts.schoolId ? `${cohorts.schoolId}/${cohorts.id}` : cohorts.id}/placements?selectedView=allData&id=inProgress`,
325
- };
319
+ return { expiredInsurance: {
320
+ dismissible: false,
321
+ severity: "error",
322
+ title: `${placementCount} placements have expired insurance.`,
323
+ message: `Your cohort '${cohorts.name}' has placements with expired insurance Click to view these placements.`,
324
+ link: `/institutes/cohorts/${cohorts.schoolId ? `${cohorts.schoolId}/${cohorts.id}` : cohorts.id}/placements?selectedView=allData&id=inProgress`,
325
+ } };
326
326
  }
327
327
  return;
328
328
  }
@@ -340,7 +340,7 @@ const instituteTasks = {
340
340
  }
341
341
  return;
342
342
  }));
343
- return items.filter((v) => v);
343
+ return { expiredInsurance: items.filter((v) => v) };
344
344
  },
345
345
  },
346
346
  invalidProviderEmails: {
@@ -350,13 +350,13 @@ const instituteTasks = {
350
350
  if (!Array.isArray(cohorts)) {
351
351
  const placementCount = (await firebaseQuery.getCount(["placements"], [(0, firestore_1.where)("oId", "==", user.oId), (0, firestore_1.where)("cohort", "==", cohorts.id), (0, firestore_1.where)("flags", "array-contains", "providerEmailFailed")]));
352
352
  if (placementCount > 0) {
353
- return {
354
- dismissible: false,
355
- severity: "error",
356
- title: `${placementCount} placements have invalid provider emails.`,
357
- message: `Your cohort '${cohorts.name}' has placements with invalid provider emails. Click to view these placements.`,
358
- link: `/institutes/cohorts/${cohorts.schoolId ? `${cohorts.schoolId}/${cohorts.id}` : cohorts.id}/placements?selectedView=allData&id=inProgress`,
359
- };
353
+ return { invalidProviderEmails: {
354
+ dismissible: false,
355
+ severity: "error",
356
+ title: `${placementCount} placements have invalid provider emails.`,
357
+ message: `Your cohort '${cohorts.name}' has placements with invalid provider emails. Click to view these placements.`,
358
+ link: `/institutes/cohorts/${cohorts.schoolId ? `${cohorts.schoolId}/${cohorts.id}` : cohorts.id}/placements?selectedView=allData&id=inProgress`,
359
+ } };
360
360
  }
361
361
  return;
362
362
  }
@@ -374,7 +374,7 @@ const instituteTasks = {
374
374
  }
375
375
  return;
376
376
  }));
377
- return items.filter((v) => v);
377
+ return { invalidProviderEmails: items.filter((v) => v) };
378
378
  },
379
379
  },
380
380
  requiredStage: {
@@ -382,33 +382,20 @@ const instituteTasks = {
382
382
  if (!(0, util_1.getAccess)(user, "signOffPlacements") || user.viewStudents === "none")
383
383
  return;
384
384
  if (!Array.isArray(cohorts)) {
385
- const placementCount = (await firebaseQuery.getCount(["placements"], [(0, firestore_1.where)("oId", "==", user.oId), (0, firestore_1.where)("cohort", "==", cohorts.id), (0, firestore_1.where)("reqUserType", "==", user.userType)]));
386
- if (placementCount > 0) {
387
- return {
388
- dismissible: false,
389
- severity: "primary",
390
- title: `${placementCount} placements require your attention.`,
391
- message: `Your cohort '${cohorts.name}' has placements for you to review. Click to view these placements.`,
392
- link: `/institutes/cohorts/${cohorts.schoolId ? `${cohorts.schoolId}/${cohorts.id}` : cohorts.id}/placements?selectedView=allData&id=inProgress&reqUserType=${user.userType}`,
393
- };
385
+ const placements = (await firebaseQuery.getDocsWhere(["placements"], [(0, firestore_1.where)("oId", "==", user.oId), (0, firestore_1.where)("cohort", "==", cohorts.id), (0, firestore_1.where)("reqUserType", "==", user.userType)]));
386
+ if (Object.keys(placements).length > 0) {
387
+ return { requiredStage: placements };
394
388
  }
395
389
  return;
396
390
  }
397
391
  const items = await Promise.all(cohorts.map(async ([id, cohort]) => {
398
- const placementCount = (await firebaseQuery.getCount(["placements"], [(0, firestore_1.where)("oId", "==", user.oId), (0, firestore_1.where)("cohort", "==", id), (0, firestore_1.where)("reqUserType", "==", user.userType)]));
399
- if (placementCount > 0) {
400
- return {
401
- dismissible: false,
402
- severity: "primary",
403
- title: `${placementCount} placements in '${cohort.name}' require your attention.`,
404
- message: `Your cohort '${cohort.name}' has placements for you to review. Click to view these placements.`,
405
- link: `/institutes/cohorts/${cohort.schoolId ? `${cohort.schoolId}/${id}` : id}/placements?selectedView=allData&id=inProgress&reqUserType=${user.userType}`,
406
- buttonTitle: "Review placements",
407
- };
392
+ const placements = (await firebaseQuery.getDocsWhere(["placements"], [(0, firestore_1.where)("oId", "==", user.oId), (0, firestore_1.where)("cohort", "==", id), (0, firestore_1.where)("reqUserType", "==", user.userType)]));
393
+ if (Object.keys(placements).length > 0) {
394
+ return placements;
408
395
  }
409
396
  return;
410
397
  }));
411
- return items.filter((v) => v);
398
+ return { requiredStage: items.filter((v) => v) };
412
399
  },
413
400
  },
414
401
  verifyInsurance: {
@@ -416,33 +403,20 @@ const instituteTasks = {
416
403
  if (!(0, util_1.getAccess)(user, "verifyInsurance") || user.viewStudents === "none")
417
404
  return;
418
405
  if (!Array.isArray(cohorts)) {
419
- const placementCount = (await firebaseQuery.getCount(["placements"], [(0, firestore_1.where)("oId", "==", user.oId), (0, firestore_1.where)("cohort", "==", cohorts.id), (0, firestore_1.where)("insurance", "==", "awaitingReview")]));
420
- if (placementCount > 0) {
421
- return {
422
- dismissible: false,
423
- severity: "primary",
424
- title: `${placementCount} placements have insurance that require review.`,
425
- message: `Your cohort '${cohorts.name}' has employer's liability insurance documents that require review`,
426
- link: `/institutes/cohorts/${cohorts.schoolId ? `${cohorts.schoolId}/${cohorts.id}` : cohorts.id}/placements?selectedView=allData&id=inProgress&insurance=awaitingReview`,
427
- };
406
+ const placements = (await firebaseQuery.getDocsWhere(["placements"], [(0, firestore_1.where)("oId", "==", user.oId), (0, firestore_1.where)("cohort", "==", cohorts.id), (0, firestore_1.where)("insurance", "==", "awaitingReview")]));
407
+ if (Object.keys(placements).length > 0) {
408
+ return { verifyInsurance: placements };
428
409
  }
429
410
  return;
430
411
  }
431
412
  const items = await Promise.all(cohorts.map(async ([id, cohort]) => {
432
- const placementCount = (await firebaseQuery.getCount(["placements"], [(0, firestore_1.where)("oId", "==", user.oId), (0, firestore_1.where)("cohort", "==", id), (0, firestore_1.where)("insurance", "==", "awaitingReview")]));
433
- if (placementCount > 0) {
434
- return {
435
- dismissible: false,
436
- severity: "primary",
437
- title: `${placementCount} placements in '${cohort.name}' have insurance that require review.`,
438
- message: `Your cohort '${cohort.name}' has employer's liability insurance documents that require review`,
439
- link: `/institutes/cohorts/${cohort.schoolId ? `${cohort.schoolId}/${id}` : id}/placements?selectedView=allData&id=inProgress&insurance=awaitingReview`,
440
- buttonTitle: "Review placements",
441
- };
413
+ const placements = (await firebaseQuery.getDocsWhere(["placements"], [(0, firestore_1.where)("oId", "==", user.oId), (0, firestore_1.where)("cohort", "==", id), (0, firestore_1.where)("insurance", "==", "awaitingReview")]));
414
+ if (Object.keys(placements).length > 0) {
415
+ return placements;
442
416
  }
443
417
  return;
444
418
  }));
445
- return items.filter((v) => v);
419
+ return { verifyInsurance: items.filter((v) => v) };
446
420
  },
447
421
  },
448
422
  verifyDbsCheck: {
@@ -450,33 +424,20 @@ const instituteTasks = {
450
424
  if (!(0, util_1.getAccess)(user, "verifyDbsChecks") || user.viewStudents === "none")
451
425
  return;
452
426
  if (!Array.isArray(cohorts)) {
453
- const placementCount = (await firebaseQuery.getCount(["placements"], [(0, firestore_1.where)("oId", "==", user.oId), (0, firestore_1.where)("cohort", "==", cohorts.id), (0, firestore_1.where)("dbsCheck", "==", "awaitingReview")]));
454
- if (placementCount > 0) {
455
- return {
456
- dismissible: false,
457
- severity: "primary",
458
- title: `${placementCount} placements have DBS checks that require review.`,
459
- message: `Your cohort '${cohorts.name}' has DBS checks that require review`,
460
- link: `/institutes/cohorts/${cohorts.schoolId ? `${cohorts.schoolId}/${cohorts.id}` : cohorts.id}/placements?selectedView=allData&id=inProgress&dbsCheck=awaitingReview`,
461
- };
427
+ const placements = (await firebaseQuery.getDocsWhere(["placements"], [(0, firestore_1.where)("oId", "==", user.oId), (0, firestore_1.where)("cohort", "==", cohorts.id), (0, firestore_1.where)("dbsCheck", "==", "awaitingReview")]));
428
+ if (Object.keys(placements).length > 0) {
429
+ return { verifyDbsCheck: placements };
462
430
  }
463
431
  return;
464
432
  }
465
433
  const items = await Promise.all(cohorts.map(async ([id, cohort]) => {
466
- const placementCount = (await firebaseQuery.getCount(["placements"], [(0, firestore_1.where)("oId", "==", user.oId), (0, firestore_1.where)("cohort", "==", id), (0, firestore_1.where)("dbsCheck", "==", "awaitingReview")]));
467
- if (placementCount > 0) {
468
- return {
469
- dismissible: false,
470
- severity: "primary",
471
- title: `${placementCount} placements in '${cohort.name}' have DBS checks that require review.`,
472
- message: `Your cohort '${cohort.name}' has DBS checks that require review`,
473
- link: `/institutes/cohorts/${cohort.schoolId ? `${cohort.schoolId}/${id}` : id}/placements?selectedView=allData&id=inProgress&dbsCheck=awaitingReview`,
474
- buttonTitle: "Review placements",
475
- };
434
+ const placements = (await firebaseQuery.getDocsWhere(["placements"], [(0, firestore_1.where)("oId", "==", user.oId), (0, firestore_1.where)("cohort", "==", id), (0, firestore_1.where)("dbsCheck", "==", "awaitingReview")]));
435
+ if (Object.keys(placements).length > 0) {
436
+ return placements;
476
437
  }
477
438
  return;
478
439
  }));
479
- return items.filter((v) => v);
440
+ return { verifyDbsCheck: items.filter((v) => v) };
480
441
  },
481
442
  },
482
443
  verifyRiskAssessment: {
@@ -484,33 +445,20 @@ const instituteTasks = {
484
445
  if (!(0, util_1.getAccess)(user, "verifyRiskAssessments") || user.viewStudents === "none")
485
446
  return;
486
447
  if (!Array.isArray(cohorts)) {
487
- const placementCount = (await firebaseQuery.getCount(["placements"], [(0, firestore_1.where)("oId", "==", user.oId), (0, firestore_1.where)("cohort", "==", cohorts.id), (0, firestore_1.where)("riskAssessment", "==", "awaitingReview")]));
488
- if (placementCount > 0) {
489
- return {
490
- dismissible: false,
491
- severity: "primary",
492
- title: `${placementCount} placements have risk assessments that require review.`,
493
- message: `Your cohort '${cohorts.name}' has risk assessents that require review`,
494
- link: `/institutes/cohorts/${cohorts.schoolId ? `${cohorts.schoolId}/${cohorts.id}` : cohorts.id}/placements?selectedView=allData&id=inProgress&riskAssessment=awaitingReview`,
495
- };
448
+ const placements = (await firebaseQuery.getDocsWhere(["placements"], [(0, firestore_1.where)("oId", "==", user.oId), (0, firestore_1.where)("cohort", "==", cohorts.id), (0, firestore_1.where)("riskAssessment", "==", "awaitingReview")]));
449
+ if (Object.keys(placements).length > 0) {
450
+ return { verifyRiskAssessment: placements };
496
451
  }
497
452
  return;
498
453
  }
499
454
  const items = await Promise.all(cohorts.map(async ([id, cohort]) => {
500
- const placementCount = (await firebaseQuery.getCount(["placements"], [(0, firestore_1.where)("oId", "==", user.oId), (0, firestore_1.where)("cohort", "==", id), (0, firestore_1.where)("riskAssessment", "==", "awaitingReview")]));
501
- if (placementCount > 0) {
502
- return {
503
- dismissible: false,
504
- severity: "primary",
505
- title: `${placementCount} placements in '${cohort.name}' have risk assessments that require review.`,
506
- message: `Your cohort '${cohort.name}' has risk assessments that require review`,
507
- link: `/institutes/cohorts/${cohort.schoolId ? `${cohort.schoolId}/${id}` : id}/placements?selectedView=allData&id=inProgress&riskAssessment=awaitingReview`,
508
- buttonTitle: "Review placements",
509
- };
455
+ const placements = (await firebaseQuery.getDocsWhere(["placements"], [(0, firestore_1.where)("oId", "==", user.oId), (0, firestore_1.where)("cohort", "==", id), (0, firestore_1.where)("riskAssessment", "==", "awaitingReview")]));
456
+ if (Object.keys(placements).length > 0) {
457
+ return placements;
510
458
  }
511
459
  return;
512
460
  }));
513
- return items.filter((v) => v);
461
+ return { verifyRiskAssessment: items.filter((v) => v) };
514
462
  },
515
463
  },
516
464
  missingParentEmail: {
@@ -528,13 +476,13 @@ const instituteTasks = {
528
476
  }
529
477
  const studentCount = (await firebaseQuery.getCount(["users"], constraints));
530
478
  if (studentCount > 0) {
531
- return {
532
- dismissible: false,
533
- severity: "info",
534
- title: `${studentCount} students do not have a parent email.`,
535
- message: `Your cohort '${cohorts.name}' has students without a parent email. To allow proper processing of their placements, add these emails.`,
536
- link: `/institutes/cohorts/${cohorts.id}/students?parentEmail=false`,
537
- };
479
+ return { missingParentEmail: {
480
+ dismissible: false,
481
+ severity: "info",
482
+ title: `${studentCount} students do not have a parent email.`,
483
+ message: `Your cohort '${cohorts.name}' has students without a parent email. To allow proper processing of their placements, add these emails.`,
484
+ link: `/institutes/cohorts/${cohorts.id}/students?parentEmail=false`,
485
+ } };
538
486
  }
539
487
  return;
540
488
  }
@@ -560,7 +508,7 @@ const instituteTasks = {
560
508
  }
561
509
  return;
562
510
  }));
563
- return items.filter((v) => v);
511
+ return { missingParentEmail: items.filter((v) => v) };
564
512
  },
565
513
  },
566
514
  inactiveStudents: {
@@ -575,13 +523,13 @@ const instituteTasks = {
575
523
  }
576
524
  const studentCount = (await firebaseQuery.getCount(["users"], constraints));
577
525
  if (studentCount > 0) {
578
- return {
579
- dismissible: false,
580
- severity: "info",
581
- title: `${studentCount} students in are inactive.`,
582
- message: `Your cohort '${cohorts.name}' has inactive students. Activate them to enable them to use the platform.`,
583
- link: `/institutes/cohorts/${cohorts.id}/students?status=inactive`,
584
- };
526
+ return { inactiveStudents: {
527
+ dismissible: false,
528
+ severity: "info",
529
+ title: `${studentCount} students in are inactive.`,
530
+ message: `Your cohort '${cohorts.name}' has inactive students. Activate them to enable them to use the platform.`,
531
+ link: `/institutes/cohorts/${cohorts.id}/students?status=inactive`,
532
+ } };
585
533
  }
586
534
  return;
587
535
  }
@@ -604,7 +552,7 @@ const instituteTasks = {
604
552
  }
605
553
  return;
606
554
  }));
607
- return items.filter((v) => v);
555
+ return { inactiveStudents: items.filter((v) => v) };
608
556
  },
609
557
  },
610
558
  uploadStudents: {
@@ -633,7 +581,7 @@ const instituteTasks = {
633
581
  }
634
582
  return;
635
583
  }));
636
- return items.filter((v) => v);
584
+ return { uploadStudents: items.filter((v) => v) };
637
585
  },
638
586
  },
639
587
  inactiveStaff: {
@@ -649,11 +597,11 @@ const instituteTasks = {
649
597
  };
650
598
  const inactiveStaff = await firebaseQuery.getCount(["users"], [(0, firestore_1.where)("oId", "==", user.oId), (0, firestore_1.where)("userType", "==", "Staff"), (0, firestore_1.where)("status", "==", "inactive")]);
651
599
  if (inactiveStaff > 0) {
652
- return {
653
- ...returnObj,
654
- title: "Inactive staff",
655
- message: `You have ${inactiveStaff} inactive staff members. You can activate them in the 'Staff' cohorts tab.`,
656
- };
600
+ return { inactiveStaff: {
601
+ ...returnObj,
602
+ title: "Inactive staff",
603
+ message: `You have ${inactiveStaff} inactive staff members. You can activate them in the 'Staff' cohorts tab.`,
604
+ } };
657
605
  }
658
606
  return;
659
607
  },
@@ -670,17 +618,10 @@ const instituteTasks = {
670
618
  return;
671
619
  if (!Array.isArray(cohorts))
672
620
  return;
673
- const externalCount = await firebaseQuery.getCount(["placementListings"], [(0, firestore_1.where)(`savedBy.${user.oId}.exists`, "==", true), (0, firestore_1.where)(`savedBy.${user.oId}.status`, "==", "uploaded"), (0, firestore_1.where)("mapConsent", "==", "institute")]);
674
- console.log("EXT", externalCount);
675
- if (externalCount > 0) {
676
- return {
677
- dismissible: false,
678
- severity: "warning",
679
- title: `${externalCount} external placements require approval`,
680
- message: "Review and approve these placements to add them to your institute placement map",
681
- link: "/institutes/placements",
682
- buttonTitle: "View placements",
683
- };
621
+ const requests = await firebaseQuery.getDocsWhere(["providerContacts"], [(0, firestore_1.where)(`savedBy.${user.oId}.exists`, "==", true), (0, firestore_1.where)(`savedBy.${user.oId}.status`, "==", "uploaded"), (0, firestore_1.where)("mapConsent", "==", "institute")]);
622
+ console.log("EXT", requests);
623
+ if (Object.keys(requests).length > 0) {
624
+ return { approveExternalPlacement: requests };
684
625
  }
685
626
  return;
686
627
  },
@@ -700,7 +641,7 @@ const studentTasks = {
700
641
  link: `/${user.product}/placements/${k}`,
701
642
  buttonTitle: "View onboarding",
702
643
  }));
703
- return items;
644
+ return { completeOnboarding: items };
704
645
  },
705
646
  }
706
647
  };
@@ -1099,14 +1040,13 @@ const getTasks = async ({ user, organisation, cohort, school }) => {
1099
1040
  };
1100
1041
  exports.getTasks = getTasks;
1101
1042
  const getStudentTasks = async (user, organisation, cohort) => {
1102
- const processedTasks = await Object.entries(studentTasks).reduce(async (acc, [itemName, item]) => {
1043
+ const processedTasks = await Object.entries(studentTasks).reduce(async (accPromise, [itemName, item]) => {
1044
+ const acc = await accPromise; // Wait for the previous accumulator value
1103
1045
  const queryResult = await item.callback(user);
1104
1046
  if (!queryResult)
1105
- return await acc;
1106
- const queryResultArray = Array.isArray(queryResult) ? queryResult : [queryResult];
1107
- const results = queryResultArray.map((r) => ({ itemName: itemName, ...r }));
1108
- (await acc).push(...results);
1109
- return await acc;
1047
+ return acc; // If no result, return the accumulator as is
1048
+ // Merge the query result with the current accumulator
1049
+ return { ...acc, ...queryResult };
1110
1050
  }, Promise.resolve([]));
1111
1051
  return processedTasks;
1112
1052
  };
@@ -1173,18 +1113,16 @@ const getInstituteTasks = async ({ user, organisation, cohort, school }) => {
1173
1113
  fCohort = await getCohortsOrSchoolsIfNotProvided("cohorts", fSchool);
1174
1114
  }
1175
1115
  console.log("FCOHORTS FOR TASKS", fCohort);
1176
- const processedTasks = await Object.entries(instituteTasks).reduce(async (acc, [itemName, item]) => {
1116
+ const processedTasks = await Object.entries(instituteTasks).reduce(async (accPromise, [itemName, item]) => {
1177
1117
  if (!fCohort) {
1178
1118
  console.log("No cohorts to retrieve tasks for");
1179
1119
  return ([]);
1180
1120
  }
1121
+ const acc = await accPromise;
1181
1122
  const queryResult = await item.callback({ user, organisation, cohorts: fCohort, schools: fSchool });
1182
1123
  if (!queryResult)
1183
- return await acc;
1184
- const queryResultArray = Array.isArray(queryResult) ? queryResult : [queryResult];
1185
- const results = queryResultArray.map((r) => ({ itemName: itemName, ...r }));
1186
- (await acc).push(...results);
1187
- return await acc;
1124
+ return acc;
1125
+ return { ...acc, ...queryResult }; // Merge the query result into the accumulator object
1188
1126
  }, Promise.resolve([]));
1189
1127
  return processedTasks;
1190
1128
  };