placementt-core 11.0.533 → 11.0.892

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.
Files changed (76) hide show
  1. package/lib/constants.d.ts +13 -1
  2. package/lib/constants.js +86 -1
  3. package/lib/constants.js.map +1 -1
  4. package/lib/features/analytics/useAnalytics.d.ts +2 -0
  5. package/lib/features/analytics/useAnalytics.js +22 -19
  6. package/lib/features/analytics/useAnalytics.js.map +1 -1
  7. package/lib/features/global/downtime/useDowntime.d.ts +1 -0
  8. package/lib/features/global/downtime/useDowntime.js +9 -7
  9. package/lib/features/global/downtime/useDowntime.js.map +1 -1
  10. package/lib/features/global/users/useUserFunctions.js +1 -1
  11. package/lib/features/global/users/useUserFunctions.js.map +1 -1
  12. package/lib/features/jobs/jobsSlice.d.ts +10 -2
  13. package/lib/features/jobs/jobsSlice.js +5 -2
  14. package/lib/features/jobs/jobsSlice.js.map +1 -1
  15. package/lib/features/placements/studentPlacements/activePlacement.d.ts +5 -1
  16. package/lib/features/placements/studentPlacements/activePlacement.js +7 -3
  17. package/lib/features/placements/studentPlacements/activePlacement.js.map +1 -1
  18. package/lib/features/placements/studentPlacements/completedStudentPlacementsSlice.d.ts +3 -2
  19. package/lib/features/placements/studentPlacements/completedStudentPlacementsSlice.js +4 -1
  20. package/lib/features/placements/studentPlacements/completedStudentPlacementsSlice.js.map +1 -1
  21. package/lib/features/placements/studentPlacements/upcomingStudentPlacementsSlice.d.ts +2 -2
  22. package/lib/features/placements/studentPlacements/upcomingStudentPlacementsSlice.js +1 -1
  23. package/lib/features/placements/studentPlacements/upcomingStudentPlacementsSlice.js.map +1 -1
  24. package/lib/features/placements/studentPlacements/useStudentPlacements.d.ts +2 -12
  25. package/lib/features/placements/studentPlacements/useStudentPlacements.js +1 -26
  26. package/lib/features/placements/studentPlacements/useStudentPlacements.js.map +1 -1
  27. package/lib/features/updates/useUpdates.d.ts +1 -0
  28. package/lib/features/updates/useUpdates.js +13 -12
  29. package/lib/features/updates/useUpdates.js.map +1 -1
  30. package/lib/firebase/firebase.d.ts +5 -3
  31. package/lib/firebase/firebase.js +23 -12
  32. package/lib/firebase/firebase.js.map +1 -1
  33. package/lib/firebase/firebaseConfig.js.map +1 -1
  34. package/lib/firebase/firebaseQuery.d.ts +6 -2
  35. package/lib/firebase/firebaseQuery.js +11 -3
  36. package/lib/firebase/firebaseQuery.js.map +1 -1
  37. package/lib/firebase/readDatabase.d.ts +2 -4
  38. package/lib/firebase/readDatabase.js +30 -5
  39. package/lib/firebase/readDatabase.js.map +1 -1
  40. package/lib/firebase/writeDatabase.d.ts +6 -2
  41. package/lib/firebase/writeDatabase.js +2 -1
  42. package/lib/firebase/writeDatabase.js.map +1 -1
  43. package/lib/hooks.d.ts +277 -192
  44. package/lib/hooks.js +1437 -704
  45. package/lib/hooks.js.map +1 -1
  46. package/lib/reduxHooks.d.ts +122 -5
  47. package/lib/reduxHooks.js +132 -29
  48. package/lib/reduxHooks.js.map +1 -1
  49. package/lib/tasksAndTips.d.ts +19 -7
  50. package/lib/tasksAndTips.js +637 -164
  51. package/lib/tasksAndTips.js.map +1 -1
  52. package/lib/typeDefinitions.d.ts +321 -110
  53. package/lib/util.d.ts +15 -3
  54. package/lib/util.js +47 -10
  55. package/lib/util.js.map +1 -1
  56. package/package.json +7 -4
  57. package/src/constants.ts +91 -3
  58. package/src/features/analytics/useAnalytics.tsx +25 -17
  59. package/src/features/global/downtime/useDowntime.tsx +11 -7
  60. package/src/features/global/users/useUserFunctions.tsx +1 -1
  61. package/src/features/jobs/jobsSlice.ts +9 -3
  62. package/src/features/placements/studentPlacements/activePlacement.ts +8 -3
  63. package/src/features/placements/studentPlacements/completedStudentPlacementsSlice.ts +5 -2
  64. package/src/features/placements/studentPlacements/upcomingStudentPlacementsSlice.ts +2 -2
  65. package/src/features/placements/studentPlacements/useStudentPlacements.tsx +4 -28
  66. package/src/features/updates/useUpdates.tsx +14 -12
  67. package/src/firebase/firebase.tsx +26 -15
  68. package/src/firebase/firebaseConfig.tsx +1 -1
  69. package/src/firebase/firebaseQuery.tsx +11 -3
  70. package/src/firebase/readDatabase.tsx +34 -6
  71. package/src/firebase/writeDatabase.tsx +3 -1
  72. package/src/hooks.tsx +1804 -935
  73. package/src/reduxHooks.ts +144 -32
  74. package/src/tasksAndTips.ts +689 -166
  75. package/src/typeDefinitions.ts +373 -109
  76. package/src/util.ts +63 -18
@@ -12,6 +12,22 @@ const firebaseQuery = new firebaseQuery_1.default;
12
12
  const providerTips = {};
13
13
  const studentTips = {};
14
14
  const instituteTips = {
15
+ addSchools: {
16
+ callback: async (user, institute, schools) => {
17
+ if (!(0, util_1.getAccess)(user, "addSchools") || (institute === null || institute === void 0 ? void 0 : institute.package) !== "institutes-two")
18
+ return;
19
+ if (Object.keys(schools).length < 2) {
20
+ return {
21
+ title: "Add your schools",
22
+ message: "Add your schools. These will show up in the 'Cohorts' tab where you can assign cohorts of students to them.",
23
+ link: "/institutes/organisation/overview",
24
+ buttonTitle: "Add schools",
25
+ dismissible: true
26
+ };
27
+ }
28
+ return;
29
+ },
30
+ },
15
31
  createCohort: {
16
32
  callback: async (user) => {
17
33
  if (!(0, util_1.getAccess)(user, "createCohorts"))
@@ -129,9 +145,207 @@ const instituteTips = {
129
145
  };
130
146
  // Accept a cohort to any task
131
147
  const instituteTasks = {
148
+ invalidStaffEmails: {
149
+ callback: async ({ user, cohorts }) => {
150
+ if (!(0, util_1.getAccess)(user, "viewStaff") || !Array.isArray(cohorts))
151
+ return;
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
+ 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
+ };
161
+ }
162
+ return;
163
+ },
164
+ },
165
+ approveAlumniConversation: {
166
+ callback: async ({ user, organisation, schools }) => {
167
+ if (!schools) {
168
+ if (!organisation.alumniConversations)
169
+ return;
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
+ 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
+ };
179
+ }
180
+ return;
181
+ }
182
+ if (!Array.isArray(schools)) {
183
+ // One school
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
+ 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
+ };
193
+ }
194
+ return;
195
+ }
196
+ const items = await Promise.all(schools.map(async ([id, school]) => {
197
+ if (!school.alumniConversations)
198
+ return;
199
+ const convos = (await firebaseQuery.getCount(["alumniConversations"], [(0, firestore_1.where)("oId", "==", user.oId), (0, firestore_1.where)("schoolId", "==", id), (0, firestore_1.where)("open", "==", true), (0, firestore_1.where)("delivered", "==", "pending")]));
200
+ if (convos > 0) {
201
+ return {
202
+ dismissible: false,
203
+ severity: "info",
204
+ title: `${convos} alumni conversation message${convos > 1 ? "s" : ""} needs approval.`,
205
+ message: `${school.name}, has ${convos} outstanding alumni message${convos > 1 ? "s" : ""} to approve. Click to view.`,
206
+ link: `/institutes/network/alumni/conversations/${school.id}`,
207
+ };
208
+ }
209
+ return;
210
+ }));
211
+ return items.filter((v) => v);
212
+ },
213
+ },
214
+ invalidStudentEmails: {
215
+ callback: async ({ user, cohorts }) => {
216
+ if (!(0, util_1.getAccess)(user, "viewStudents") || user.viewStudents === "none")
217
+ return;
218
+ if (!Array.isArray(cohorts)) {
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
+ 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
+ };
228
+ }
229
+ return;
230
+ }
231
+ const items = await Promise.all(cohorts.map(async ([id, cohort]) => {
232
+ const studentCount = (await firebaseQuery.getCount(["users"], [(0, firestore_1.where)("oId", "==", user.oId), (0, firestore_1.where)("userType", "==", "Students"), (0, firestore_1.where)("cohort", "==", id), (0, firestore_1.where)("flags", "array-contains", "userEmailFailed")]));
233
+ if (studentCount > 0) {
234
+ return {
235
+ dismissible: false,
236
+ severity: "error",
237
+ title: `${studentCount} students have invalid emails.`,
238
+ message: `Your cohort, ${cohort.name}, has ${studentCount} student accounts with invalid email addresses. Delete and reupload these users.`,
239
+ link: `/institutes/cohorts/${id}/students`,
240
+ };
241
+ }
242
+ return;
243
+ }));
244
+ return items.filter((v) => v);
245
+ },
246
+ },
247
+ outstandingReminders: {
248
+ callback: async ({ user, cohorts }) => {
249
+ if (!Array.isArray(cohorts)) {
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
+ 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
+ };
259
+ }
260
+ return;
261
+ }
262
+ const items = await Promise.all(cohorts.map(async ([id, cohort]) => {
263
+ 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", "==", id), (0, firestore_1.where)("status", "==", "upcoming")]));
264
+ if (reminderCount > 0) {
265
+ return {
266
+ dismissible: false,
267
+ severity: "primary",
268
+ title: `You have ${reminderCount} reminder${reminderCount > 1 ? "s" : ""}.`,
269
+ message: `Your cohort, ${cohort.name}, has ${reminderCount} outstanding placement reminder${reminderCount > 1 ? "s" : ""}. Click to view.`,
270
+ link: `/institutes/cohorts/${id}/placements`,
271
+ };
272
+ }
273
+ return;
274
+ }));
275
+ return items.filter((v) => v);
276
+ },
277
+ },
278
+ invalidParentEmails: {
279
+ callback: async ({ user, cohorts }) => {
280
+ if (!(0, util_1.getAccess)(user, "signOffPlacements") || user.viewStudents === "none")
281
+ return;
282
+ if (!Array.isArray(cohorts)) {
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
+ 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.id}/placements?id=upcoming`,
291
+ };
292
+ }
293
+ return;
294
+ }
295
+ const items = await Promise.all(cohorts.map(async ([id, cohort]) => {
296
+ const placementCount = (await firebaseQuery.getCount(["placements"], [(0, firestore_1.where)("oId", "==", user.oId), (0, firestore_1.where)("cohort", "==", id), (0, firestore_1.where)("flags", "array-contains", "parentEmailFailed")]));
297
+ if (placementCount > 0) {
298
+ return {
299
+ dismissible: false,
300
+ severity: "error",
301
+ title: `${placementCount} placements in '${cohort.name}' have invalid parent emails.`,
302
+ message: `Your cohort '${cohort.name}' has placements with invalid parent emails. Click to view these placements.`,
303
+ link: `/institutes/cohorts/${id}/placements?id=upcoming`,
304
+ buttonTitle: "Review placements",
305
+ };
306
+ }
307
+ return;
308
+ }));
309
+ return items.filter((v) => v);
310
+ },
311
+ },
312
+ invalidProviderEmails: {
313
+ callback: async ({ user, cohorts }) => {
314
+ if (!(0, util_1.getAccess)(user, "signOffPlacements") || user.viewStudents === "none")
315
+ return;
316
+ if (!Array.isArray(cohorts)) {
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)("flags", "array-contains", "providerEmailFailed")]));
318
+ if (placementCount > 0) {
319
+ return {
320
+ dismissible: false,
321
+ severity: "error",
322
+ title: `${placementCount} placements have invalid provider emails.`,
323
+ message: `Your cohort '${cohorts.name}' has placements with invalid provider emails. Click to view these placements.`,
324
+ link: `/institutes/cohorts/${cohorts.id}/placements?id=upcoming`,
325
+ };
326
+ }
327
+ return;
328
+ }
329
+ const items = await Promise.all(cohorts.map(async ([id, cohort]) => {
330
+ const placementCount = (await firebaseQuery.getCount(["placements"], [(0, firestore_1.where)("oId", "==", user.oId), (0, firestore_1.where)("cohort", "==", id), (0, firestore_1.where)("flags", "array-contains", "providerEmailFailed")]));
331
+ if (placementCount > 0) {
332
+ return {
333
+ dismissible: false,
334
+ severity: "error",
335
+ title: `${placementCount} placements in '${cohort.name}' have invalid provider emails.`,
336
+ message: `Your cohort '${cohort.name}' has placements with invalid provider emails. Click to view these placements.`,
337
+ link: `/institutes/cohorts/${id}/placements?id=upcoming`,
338
+ buttonTitle: "Review placements",
339
+ };
340
+ }
341
+ return;
342
+ }));
343
+ return items.filter((v) => v);
344
+ },
345
+ },
132
346
  requiredStage: {
133
- callback: async (user, _, cohorts) => {
134
- if (!(0, util_1.getAccess)(user, "signOffPlacements"))
347
+ callback: async ({ user, cohorts }) => {
348
+ if (!(0, util_1.getAccess)(user, "signOffPlacements") || user.viewStudents === "none")
135
349
  return;
136
350
  if (!Array.isArray(cohorts)) {
137
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)("reqUserType", "==", user.userType)]));
@@ -164,8 +378,8 @@ const instituteTasks = {
164
378
  },
165
379
  },
166
380
  verifyInsurance: {
167
- callback: async (user, _, cohorts) => {
168
- if (!(0, util_1.getAccess)(user, "verifyInsurance"))
381
+ callback: async ({ user, cohorts }) => {
382
+ if (!(0, util_1.getAccess)(user, "verifyInsurance") || user.viewStudents === "none")
169
383
  return;
170
384
  if (!Array.isArray(cohorts)) {
171
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)("insurance", "==", "awaitingReview")]));
@@ -198,8 +412,8 @@ const instituteTasks = {
198
412
  },
199
413
  },
200
414
  verifyDbsCheck: {
201
- callback: async (user, _, cohorts) => {
202
- if (!(0, util_1.getAccess)(user, "verifyDbsChecks"))
415
+ callback: async ({ user, cohorts }) => {
416
+ if (!(0, util_1.getAccess)(user, "verifyDbsChecks") || user.viewStudents === "none")
203
417
  return;
204
418
  if (!Array.isArray(cohorts)) {
205
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)("dbsCheck", "==", "awaitingReview")]));
@@ -232,8 +446,8 @@ const instituteTasks = {
232
446
  },
233
447
  },
234
448
  verifyRiskAssessment: {
235
- callback: async (user, _, cohorts) => {
236
- if (!(0, util_1.getAccess)(user, "verifyRiskAssessments"))
449
+ callback: async ({ user, cohorts }) => {
450
+ if (!(0, util_1.getAccess)(user, "verifyRiskAssessments") || user.viewStudents === "none")
237
451
  return;
238
452
  if (!Array.isArray(cohorts)) {
239
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)("riskAssessment", "==", "awaitingReview")]));
@@ -266,9 +480,9 @@ const instituteTasks = {
266
480
  },
267
481
  },
268
482
  missingParentEmail: {
269
- callback: async (user, _, cohorts) => {
483
+ callback: async ({ user, cohorts }) => {
270
484
  var _a, _b, _c;
271
- if (!(0, util_1.getAccess)(user, "editStudents"))
485
+ if (!(0, util_1.getAccess)(user, "editStudents") || user.viewStudents === "none")
272
486
  return;
273
487
  if (!Array.isArray(cohorts)) {
274
488
  const requiresParents = Boolean(cohorts.workflow.find((node) => node.userType === "Parent"));
@@ -316,9 +530,9 @@ const instituteTasks = {
316
530
  },
317
531
  },
318
532
  inactiveStudents: {
319
- callback: async (user, _, cohorts) => {
533
+ callback: async ({ user, cohorts }) => {
320
534
  var _a, _b, _c;
321
- if (!(0, util_1.getAccess)(user, "activateStudents"))
535
+ if (!(0, util_1.getAccess)(user, "activateStudents") || user.viewStudents === "none")
322
536
  return;
323
537
  if (!Array.isArray(cohorts)) {
324
538
  const constraints = [(0, firestore_1.where)("oId", "==", user.oId), (0, firestore_1.where)("cohort", "==", cohorts.id), (0, firestore_1.where)("status", "==", "inactive")];
@@ -351,7 +565,7 @@ const instituteTasks = {
351
565
  title: `${studentCount} students in '${cohort.name}' are inactive.`,
352
566
  message: `Your cohort '${cohort.name}' has inactive students. Activate them to enable them to use the platform.`,
353
567
  link: `/institutes/cohorts/${cohort.id}/students?status=inactive`,
354
- buttonTitle: "Review placements",
568
+ buttonTitle: "Review students",
355
569
  };
356
570
  }
357
571
  return;
@@ -360,10 +574,10 @@ const instituteTasks = {
360
574
  },
361
575
  },
362
576
  uploadStudents: {
363
- callback: async (user, _, cohorts) => {
577
+ callback: async ({ user, cohorts }) => {
364
578
  if (!Array.isArray(cohorts))
365
579
  return;
366
- if (!(0, util_1.getAccess)(user, "addStudents"))
580
+ if (!(0, util_1.getAccess)(user, "addStudents") || user.viewStudents === "none")
367
581
  return;
368
582
  if (user.product !== "institutes")
369
583
  return;
@@ -389,7 +603,7 @@ const instituteTasks = {
389
603
  },
390
604
  },
391
605
  inactiveStaff: {
392
- callback: async (user, _, cohorts) => {
606
+ callback: async ({ user, cohorts }) => {
393
607
  if (!(0, util_1.getAccess)(user, "addStaff"))
394
608
  return;
395
609
  if (!Array.isArray(cohorts) || user.product === "students")
@@ -411,16 +625,16 @@ const instituteTasks = {
411
625
  },
412
626
  },
413
627
  overdueStage: {
414
- callback: async (user, _, cohort) => {
415
- console.log(user, cohort);
628
+ callback: async ({ user, cohorts }) => {
629
+ console.log(user, cohorts);
416
630
  return undefined;
417
631
  },
418
632
  },
419
633
  approveExternalPlacement: {
420
- callback: async (user, _, cohort) => {
634
+ callback: async ({ user, cohorts }) => {
421
635
  if (!(0, util_1.getAccess)(user, "verifyListings"))
422
636
  return;
423
- if (!Array.isArray(cohort))
637
+ if (!Array.isArray(cohorts))
424
638
  return;
425
639
  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")]);
426
640
  console.log("EXT", externalCount);
@@ -442,14 +656,13 @@ const studentTasks = {
442
656
  completeOnboarding: {
443
657
  callback: async (user) => {
444
658
  const placementsWithoutOnboarding = await firebaseQuery.getDocsWhere("placements", [(0, firestore_1.where)("uid", "==", user.id), (0, firestore_1.where)("onboarding.deadline", "<=", (0, util_2.convertDate)(new Date(), "dbstring")), (0, firestore_1.where)("onboarding.completed.submitted", "==", false)]);
445
- console.log("placementsWithoutONboarding", placementsWithoutOnboarding);
446
659
  if (Object.keys(placementsWithoutOnboarding).length === 0)
447
660
  return;
448
661
  const items = Object.entries(placementsWithoutOnboarding).map(([k, placement]) => ({
449
662
  dismissible: false,
450
663
  severity: "primary",
451
- title: `Complete required onboarding documents for ${placement.name}`,
452
- message: `${placement.name} has requested you to complete some onboarding documents.`,
664
+ title: `Complete onboarding for ${placement.name}`,
665
+ message: `Review onboarding for your placement starting on ${(0, util_2.convertDate)(placement.startDate, "visual")}`,
453
666
  link: `/${user.product}/placements/${k}`,
454
667
  buttonTitle: "View onboarding",
455
668
  }));
@@ -457,116 +670,364 @@ const studentTasks = {
457
670
  },
458
671
  }
459
672
  };
460
- const providerTasks = {
461
- requestedVisibleAddresses: {
462
- callback: async (user) => {
463
- const accessRequests = await firebaseQuery.getCount("users", [(0, firestore_1.where)("oId", "==", user.oId), (0, firestore_1.where)("product", "==", "providers"), (0, firestore_1.orderBy)("requestedVisibleAddresses")]);
464
- if (accessRequests === 0)
465
- return;
466
- if (accessRequests === 1) {
467
- const userRequestingAccess = Object.entries(await firebaseQuery.getDocsWhere("users", [(0, firestore_1.where)("oId", "==", user.oId), (0, firestore_1.where)("product", "==", "providers"), (0, firestore_1.orderBy)("requestedVisibleAddresses")]) || {})[0];
468
- return {
469
- dismissible: false,
470
- severity: "primary",
471
- title: `${userRequestingAccess[1].details.forename} ${userRequestingAccess[1].details.surname} has requested access to view addresses.`,
472
- message: `Click to review the addresses and grant access to the user.`,
473
- link: `/${user.product}/users/${userRequestingAccess[0]}`,
474
- buttonTitle: "View request",
475
- };
476
- }
477
- return {
478
- dismissible: false,
479
- severity: "warning",
480
- title: `Multiple users have requested access to view addresses.`,
481
- message: `Click to review the addresses and grant access to the user.`,
482
- link: `/${user.product}/organisation/staff/all`,
483
- buttonTitle: "View request",
484
- };
485
- },
486
- },
487
- requestedVisiblePlacementListings: {
488
- callback: async (user) => {
489
- const accessRequests = await firebaseQuery.getCount("users", [(0, firestore_1.where)("oId", "==", user.oId), (0, firestore_1.where)("product", "==", "providers"), (0, firestore_1.orderBy)("requestedVisibleListings")]);
490
- if (accessRequests === 0)
491
- return;
492
- if (accessRequests === 1) {
493
- const userRequestingAccess = Object.entries(await firebaseQuery.getDocsWhere("users", [(0, firestore_1.where)("oId", "==", user.oId), (0, firestore_1.where)("product", "==", "providers"), (0, firestore_1.orderBy)("requestedVisibleListings")]) || {})[0];
494
- return {
495
- dismissible: false,
496
- severity: "primary",
497
- title: `${userRequestingAccess[1].details.forename} ${userRequestingAccess[1].details.surname} has requested access to view placement listings.`,
498
- message: `Click to review the placement listings and grant access to the user.`,
499
- link: `/${user.product}/users/${userRequestingAccess[0]}`,
500
- buttonTitle: "View request",
501
- };
502
- }
503
- return {
504
- dismissible: false,
505
- severity: "warning",
506
- title: `Multiple users have requested access to view placement listings.`,
507
- message: `Click to review the placement listings and grant access to the user.`,
508
- link: `/${user.product}/organisation/staff/all`,
509
- buttonTitle: "View request",
510
- };
511
- },
512
- },
513
- applicationRequireReview: {
514
- callback: async (user) => {
515
- const applicationCount = await firebaseQuery.getCount("applications", [(0, firestore_1.where)("providerId", "==", user.oId), (0, firestore_1.where)("reqUserType", "==", "Staff"), (0, firestore_1.where)("status", "==", "submitted")]);
516
- if (applicationCount === 0)
517
- return;
518
- return {
519
- dismissible: false,
520
- severity: "primary",
521
- title: `${applicationCount} applications require your review.`,
522
- message: `Click to view ${applicationCount} that require your attention.`,
523
- link: `/${user.product}/placementListings/applicants`,
524
- buttonTitle: "View applications",
525
- };
526
- },
527
- },
528
- completeStudentDocs: {
529
- callback: async (user) => {
530
- return {};
531
- },
532
- },
533
- reviewOnboarding: {
534
- callback: async (user) => {
535
- return {};
536
- },
537
- },
538
- completeListing: {
539
- callback: async (user) => {
540
- return {};
541
- },
542
- },
543
- completeAddress: {
544
- callback: async (user) => {
545
- return {};
546
- },
547
- },
548
- registrationRequests: {
549
- callback: async (user) => {
550
- return {};
551
- },
552
- },
553
- placementStarting: {
554
- callback: async (user) => {
555
- return {};
556
- },
557
- },
558
- completeFeedback: {
559
- callback: async (user) => {
560
- return {};
561
- },
562
- },
563
- setUpFeedback: {
564
- callback: async (user) => {
565
- return {};
566
- },
567
- },
568
- };
569
- const getTips = async (user, organisation) => {
673
+ // const providerTasks:ProviderTaskObject = {
674
+ // requestedVisibleAddresses: {
675
+ // callback: async (user) => {
676
+ // if (!getAccess(user, "addStaff")) return;
677
+ // const accessRequests = await firebaseQuery.getCount("users", [where("oId", "==", user.oId), where("product", "==", "providers"), orderBy("requestedVisibleAddresses")]) - ((Array.isArray(user?.requestedVisibleAddresses) && user?.requestedVisibleAddresses.length > 0) ? 1 : 0);
678
+ // if (accessRequests === 0) return;
679
+ // if (accessRequests === 1) {
680
+ // const userRequestingAccess = Object.entries(await firebaseQuery.getDocsWhere("users", [where("product", "==", "providers"), where("oId", "==", user.oId), orderBy("requestedVisibleAddresses")]) || {})[0] as [string, UserData];
681
+ // return {
682
+ // dismissible: false,
683
+ // severity: "primary",
684
+ // title: `${userRequestingAccess[1].details.forename} ${userRequestingAccess[1].details.surname} has requested access to view addresses.`,
685
+ // message: `Click to review the addresses and grant access to the user.`,
686
+ // link: `/${user.product}/users/${userRequestingAccess[0]}`,
687
+ // buttonTitle: "View request",
688
+ // } as TaskQueryReturnObject;
689
+ // }
690
+ // return {
691
+ // dismissible: false,
692
+ // severity: "warning",
693
+ // title: `Multiple users have requested access to view addresses.`,
694
+ // message: `Click to review the addresses and grant access to the user.`,
695
+ // link: `/${user.product}/organisation/staff/all`,
696
+ // buttonTitle: "View request",
697
+ // } as TaskQueryReturnObject;
698
+ // },
699
+ // },
700
+ // requestedVisiblePlacementListings: {
701
+ // callback: async (user) => {
702
+ // if (!getAccess(user, "addStaff")) return;
703
+ // const accessRequests = await firebaseQuery.getCount("users", [where("oId", "==", user.oId), where("product", "==", "providers"), orderBy("requestedVisibleListings")])- ((Array.isArray(user?.requestedVisibleListings) && user?.requestedVisibleListings.length > 0) ? 1 : 0);;
704
+ // if (accessRequests === 0) return;
705
+ // if (accessRequests === 1) {
706
+ // const userRequestingAccess = Object.entries(await firebaseQuery.getDocsWhere("users", [where("oId", "==", user.oId), where("product", "==", "providers"), orderBy("requestedVisibleListings")]) || {})[0] as [string, UserData];
707
+ // return {
708
+ // dismissible: false,
709
+ // severity: "primary",
710
+ // title: `${userRequestingAccess[1].details.forename} ${userRequestingAccess[1].details.surname} has requested access to view placement listings.`,
711
+ // message: `Click to review the placement listings and grant access to the user.`,
712
+ // link: `/${user.product}/users/${userRequestingAccess[0]}`,
713
+ // buttonTitle: "View request",
714
+ // } as TaskQueryReturnObject;
715
+ // }
716
+ // return {
717
+ // dismissible: false,
718
+ // severity: "warning",
719
+ // title: `Multiple users have requested access to view placement listings.`,
720
+ // message: `Click to review the placement listings and grant access to the user.`,
721
+ // link: `/${user.product}/organisation/staff/all`,
722
+ // buttonTitle: "View request",
723
+ // } as TaskQueryReturnObject;
724
+ // },
725
+ // },
726
+ // applicationRequireReview: {
727
+ // callback: async (user) => {
728
+ // const constraints = [where("providerId", "==", user.oId), where("reqUserType", "==", "Staff"), where("status", "==", "submitted")];
729
+ // if (user.userGroup !== "admin") {
730
+ // if (!user.viewPlacementListings || user.viewPlacementListings === "none") return;
731
+ // if (!user.viewAddresses || user.viewAddresses === "none") return;
732
+ // if (user.viewPlacementListings === "request") {
733
+ // if (!user.visibleListings || user.visibleListings?.length === 0) return;
734
+ // constraints.push(where("listingId", 'in', user.visibleListings));
735
+ // } else {
736
+ // // viewPlacementListings must be 'all'
737
+ // if (user.viewAddresses === "request") {
738
+ // if (!user.visibleAddresses || user.visibleAddresses?.length === 0) return;
739
+ // constraints.push(where("addressId", 'in', user.visibleAddresses));
740
+ // }
741
+ // }
742
+ // }
743
+ // const applicationCount = await firebaseQuery.getCount("applications", constraints);
744
+ // if (applicationCount === 0) return;
745
+ // return {
746
+ // dismissible: false,
747
+ // severity: "primary",
748
+ // title: `${applicationCount} applications require your review.`,
749
+ // message: `Click to view ${applicationCount} that require your attention.`,
750
+ // link: `/${user.product}/placementListings/applicants`,
751
+ // buttonTitle: "View applications",
752
+ // } as TaskQueryReturnObject;
753
+ // },
754
+ // },
755
+ // completeStudentDocs: {
756
+ // callback: async (user) => {
757
+ // return;
758
+ // return {} as TaskQueryReturnObject;
759
+ // },
760
+ // },
761
+ // reviewOnboarding: {
762
+ // callback: async (user) => {
763
+ // const constraints = [where("providerId", "==", user.oId), where("onboarding.completed.accepted", "==", false), where("onboarding.completed.submitted", "==", true), where("endDate", ">=", dateToString(new Date()))]
764
+ // if (user.userGroup !== "admin") {
765
+ // if (!user.viewPlacementListings || user.viewPlacementListings === "none") return;
766
+ // if (!user.viewAddresses || user.viewAddresses === "none") return;
767
+ // if (user.viewPlacementListings === "request") {
768
+ // if (!user.visibleListings || user.visibleListings?.length === 0) return;
769
+ // constraints.push(where("placementId", 'in', user.visibleListings));
770
+ // } else {
771
+ // // viewPlacementListings must be 'all'
772
+ // if (user.viewAddresses === "request") {
773
+ // if (!user.visibleAddresses || user.visibleAddresses?.length === 0) return;
774
+ // constraints.push(where("addressId", 'in', user.visibleAddresses));
775
+ // }
776
+ // }
777
+ // }
778
+ // const toReview = await firebaseQuery.getCount("placements", constraints);
779
+ // if (toReview === 0) return;
780
+ // if (toReview === 1) {
781
+ // const placement = Object.entries(await firebaseQuery.getDocsWhere("placements", constraints) || {})[0] as [string, StudentPlacementData];
782
+ // const student = await firebaseQuery.getDocData(["users", placement[1].uid]) as UserData;
783
+ // return {
784
+ // dismissible: false,
785
+ // severity: "primary",
786
+ // title: `${student.details.forename} ${student.details.surname} has completed their onboarding for their placement from ${convertDate(placement[1].startDate, "visual")} to ${convertDate(placement[1].endDate, "visual")}`,
787
+ // message: `Click to view the placement and review the onboarding.`,
788
+ // link: `/${user.product}/placements/${placement[0]}`,
789
+ // buttonTitle: "View",
790
+ // } as TaskQueryReturnObject;
791
+ // }
792
+ // return {
793
+ // dismissible: false,
794
+ // severity: "primary",
795
+ // title: `${toReview} student have completed their onboarding.`,
796
+ // message: `Click to view your placements and approve completed onboarding`,
797
+ // link: `/${user.product}/placementListings/placements`,
798
+ // buttonTitle: "View placements",
799
+ // } as TaskQueryReturnObject;
800
+ // },
801
+ // },
802
+ // uploadOnboarding: {
803
+ // callback: async (user) => {
804
+ // const constraints = [where("providerId", "==", user.oId), where("onboarding", "==", null), where("endDate", ">=", dateToString(new Date()))];
805
+ // if (user.userGroup !== "admin") {
806
+ // if (!user.viewPlacementListings || user.viewPlacementListings === "none") return;
807
+ // if (!user.viewAddresses || user.viewAddresses === "none") return;
808
+ // if (user.viewPlacementListings === "request") {
809
+ // if (!user.visibleListings || user.visibleListings?.length === 0) return;
810
+ // constraints.push(where("placementId", 'in', user.visibleListings));
811
+ // } else {
812
+ // // viewPlacementListings must be 'all'
813
+ // if (user.viewAddresses === "request") {
814
+ // if (!user.visibleAddresses || user.visibleAddresses?.length === 0) return;
815
+ // constraints.push(where("addressId", 'in', user.visibleAddresses));
816
+ // }
817
+ // }
818
+ // }
819
+ // const withoutOnboarding = await firebaseQuery.getCount("placements", constraints);
820
+ // if (withoutOnboarding === 0) return;
821
+ // if (withoutOnboarding === 1) {
822
+ // const placement = Object.entries(await firebaseQuery.getDocsWhere("placements", constraints) || {})[0] as [string, StudentPlacementData];
823
+ // const student = await firebaseQuery.getDocData(["users", placement[1].uid]) as UserData;
824
+ // return {
825
+ // dismissible: false,
826
+ // severity: "primary",
827
+ // title: `Send onboarding documents to ${student.details.forename} ${student.details.surname}'s placement from ${convertDate(placement[1].startDate, "visual")} to ${convertDate(placement[1].endDate, "visual")}`,
828
+ // message: `Click to view the placement and add or dismiss onboarding reminders.`,
829
+ // link: `/${user.product}/placements/${placement[0]}`,
830
+ // buttonTitle: "View",
831
+ // } as TaskQueryReturnObject;
832
+ // }
833
+ // return {
834
+ // dismissible: false,
835
+ // severity: "primary",
836
+ // title: `Set up onboarding for ${withoutOnboarding} placements to prepare yourself and your students.`,
837
+ // message: `Click to view your placements and add or dismiss onboarding reminders.`,
838
+ // link: `/${user.product}/placementListings/placements`,
839
+ // buttonTitle: "View placements",
840
+ // } as TaskQueryReturnObject;
841
+ // },
842
+ // },
843
+ // completeListing: {
844
+ // callback: async (user) => {
845
+ // const constraints = [where("providerId", "==", user.oId), where("status", "==", "draft")];
846
+ // if (user.userGroup !== "admin") {
847
+ // if (!user.viewPlacementListings || user.viewPlacementListings === "none") return;
848
+ // if (!user.viewAddresses || user.viewAddresses === "none") return;
849
+ // if (user.viewPlacementListings === "request") {
850
+ // if (!user.visibleListings || user.visibleListings?.length === 0) return;
851
+ // constraints.push(where(documentId(), 'in', user.visibleListings));
852
+ // } else {
853
+ // // viewPlacementListings must be 'all'
854
+ // if (user.viewAddresses === "request") {
855
+ // if (!user.visibleAddresses || user.visibleAddresses?.length === 0) return;
856
+ // constraints.push(where("addressId", 'in', user.visibleAddresses));
857
+ // }
858
+ // }
859
+ // }
860
+ // const incompleteListings = await firebaseQuery.getCount("placementListings", constraints);
861
+ // if (incompleteListings === 0) return;
862
+ // if (incompleteListings === 1) {
863
+ // const incompleteListing = Object.entries(await firebaseQuery.getDocsWhere("placementListings", constraints) || {})[0] as [string, PlacementListing];
864
+ // const address = incompleteListing[1].addressId ? await firebaseQuery.getDocData(["addresses", incompleteListing[1].addressId]) as OrganisationAddress : undefined;
865
+ // return {
866
+ // dismissible: false,
867
+ // severity: "info",
868
+ // title: `Your listing '${incompleteListing[1].title || "unnamed"}' at ${address ? `${address["address-line1"]}, ${address.postal_code.toUpperCase()}, ${capitaliseWords(camelCaseToNormal(address.country))}` : "unknown address"} requires more information before publishing.`,
869
+ // message: `Click to complete and publish the placement listing.`,
870
+ // link: `/${user.product}/addListing/${incompleteListing[0]}`,
871
+ // buttonTitle: "View listing",
872
+ // } as TaskQueryReturnObject;
873
+ // }
874
+ // return {
875
+ // dismissible: false,
876
+ // severity: "info",
877
+ // title: `You have ${incompleteListings} draft listings waiting to be published.`,
878
+ // message: `Click to review and publish the placement listings.`,
879
+ // link: `/${user.product}/placementListings/listings`,
880
+ // buttonTitle: "View listings",
881
+ // } as TaskQueryReturnObject;
882
+ // },
883
+ // },
884
+ // completeAddress: {
885
+ // callback: async (user) => {
886
+ // const constraints = [where("product", "==", "providers"), where("oId", "==", user.oId), where("stage", "!=", "complete")];
887
+ // if (user.userGroup !== "admin") {
888
+ // if (!user.viewAddresses || user.viewAddresses === "none") return;
889
+ // if (user.viewAddresses === "request") {
890
+ // if (!user.visibleAddresses || user.visibleAddresses?.length === 0) return;
891
+ // constraints.push(where("addressId", 'in', user.visibleAddresses));
892
+ // }
893
+ // }
894
+ // const incompleteAddresses = await firebaseQuery.getCount("addresses", constraints);
895
+ // if (incompleteAddresses === 0) return;
896
+ // if (incompleteAddresses === 1) {
897
+ // const address = Object.entries(await firebaseQuery.getDocsWhere("addresses", constraints) || {})[0] as [string, OrganisationAddress];
898
+ // return {
899
+ // dismissible: false,
900
+ // severity: "info",
901
+ // title: `Your address: ${address[1]["address-line1"]}, ${address[1].postal_code.toUpperCase()}, ${capitaliseWords(camelCaseToNormal(address[1].country))} is currently incomplete.`,
902
+ // message: `Click to complete the addresses.`,
903
+ // link: `/${user.product}/addAddress/${address[0]}`,
904
+ // buttonTitle: "View address",
905
+ // } as TaskQueryReturnObject;
906
+ // }
907
+ // return {
908
+ // dismissible: false,
909
+ // severity: "info",
910
+ // title: `You have ${incompleteAddresses} draft addresses waiting to be published.`,
911
+ // message: `Click to review the addresses.`,
912
+ // link: `/${user.product}/organisation/addresses`,
913
+ // buttonTitle: "View addresses",
914
+ // } as TaskQueryReturnObject;
915
+ // },
916
+ // },
917
+ // registrationRequests: {
918
+ // callback: async (user) => {
919
+ // if (!getAccess(user, "addStaff")) return;
920
+ // const regRequests = await firebaseQuery.getCount("requests", [where("product", "==", user.product), where("oId", "==", user.oId)]);
921
+ // if (regRequests === 0) return;
922
+ // if (regRequests === 1) {
923
+ // const request = Object.entries(await firebaseQuery.getDocsWhere("requests", [where("product", "==", user.product), where("oId", "==", user.oId)]) || {})[0] as [string, RegistrationRequest];
924
+ // return {
925
+ // dismissible: false,
926
+ // severity: "primary",
927
+ // title: `${request[1].forename} ${request[1].surname} has requested to access your organisation.`,
928
+ // message: `Click to review these request.`,
929
+ // link: `/${user.product}/organisation/staff/requests`,
930
+ // buttonTitle: "View requests",
931
+ // } as TaskQueryReturnObject;
932
+ // }
933
+ // return {
934
+ // dismissible: false,
935
+ // severity: "primary",
936
+ // title: `${regRequests} people have requested to register with your organisation.`,
937
+ // message: `Click to review these requests.`,
938
+ // link: `/${user.product}/organisation/staff/requests`,
939
+ // buttonTitle: "View requests",
940
+ // } as TaskQueryReturnObject;
941
+ // },
942
+ // },
943
+ // activateStaff: {
944
+ // callback: async (user) => {
945
+ // if (!getAccess(user, "addStaff")) return;
946
+ // const inactiveAccounts = await firebaseQuery.getCount("users", [where("product", "==", user.product), where("oId", "==", user.oId), where("status", "==", "inactive")]);
947
+ // if (inactiveAccounts === 0) return;
948
+ // if (inactiveAccounts === 1) {
949
+ // const account = Object.entries(await firebaseQuery.getDocsWhere("users", [where("product", "==", user.product), where("oId", "==", user.oId), where("status", "==", "inactive")]) || {})[0] as [string, UserData];
950
+ // return {
951
+ // dismissible: false,
952
+ // severity: "info",
953
+ // title: `Activate ${account[1].details.forename} ${account[1].details.surname}'s staff account.`,
954
+ // message: "Activate this account to give the user access to Placementt.",
955
+ // link: `/${user.product}/organisation/staff/all`,
956
+ // buttonTitle: "View accounts",
957
+ // } as TaskQueryReturnObject;
958
+ // }
959
+ // return {
960
+ // dismissible: false,
961
+ // severity: "info",
962
+ // title: `${inactiveAccounts} staff have inactive active accounts.`,
963
+ // message: "Activate these accounts to give the user access to Placementt.",
964
+ // link: `/${user.product}/organisation/staff/all`,
965
+ // buttonTitle: "View accounts",
966
+ // } as TaskQueryReturnObject;
967
+ // },
968
+ // },
969
+ // placementStarting: {
970
+ // callback: async (user) => {
971
+ // const sevenDaysInFuture = new Date();
972
+ // sevenDaysInFuture.setDate(sevenDaysInFuture.getDate() + 7)
973
+ // const constraints = [where("providerId", "==", user.oId), where("startDate", "<=", convertDate(sevenDaysInFuture, "dbstring")), where("startDate", ">", dateToString(new Date()))];
974
+ // if (user.userGroup !== "admin") {
975
+ // if (!user.viewPlacementListings || user.viewPlacementListings === "none") return;
976
+ // if (!user.viewAddresses || user.viewAddresses === "none") return;
977
+ // if (user.viewPlacementListings === "request") {
978
+ // if (!user.visibleListings || user.visibleListings?.length === 0) return;
979
+ // constraints.push(where(documentId(), 'in', user.visibleListings));
980
+ // } else {
981
+ // // viewPlacementListings must be 'all'
982
+ // if (user.viewAddresses === "request") {
983
+ // if (!user.visibleAddresses || user.visibleAddresses?.length === 0) return;
984
+ // constraints.push(where("addressId", 'in', user.visibleAddresses));
985
+ // }
986
+ // }
987
+ // }
988
+ // const placementsStartingSoon = await firebaseQuery.getCount("placements", constraints);
989
+ // if (placementsStartingSoon === 0) return;
990
+ // if (placementsStartingSoon === 1) {
991
+ // const placement = Object.entries(await firebaseQuery.getDocsWhere("placements", constraints) || {})[0] as [string, StudentPlacementData];
992
+ // const student = placement[1].uid ? await firebaseQuery.getDocData(["users", placement[1].uid]) as UserData : {
993
+ // details: {
994
+ // forename: placement[1].studentForename,
995
+ // surname: placement[1].studentSurname,
996
+ // }
997
+ // };
998
+ // return {
999
+ // dismissible: false,
1000
+ // severity: "success",
1001
+ // title: `${student.details.forename} ${student.details.surname}'s placement from ${convertDate(placement[1].startDate, "visual")} to ${convertDate(placement[1].endDate, "visual")} is starting in less than a week.`,
1002
+ // message: `Click to view the placement and acquaint yourself with the student.`,
1003
+ // link: `/${user.product}/placements/${placement[0]}`,
1004
+ // buttonTitle: "View",
1005
+ // } as TaskQueryReturnObject;
1006
+ // }
1007
+ // return {
1008
+ // dismissible: false,
1009
+ // severity: "success",
1010
+ // title: `${placementsStartingSoon} placements starting soon.`,
1011
+ // message: `Click to view scheduled placements.`,
1012
+ // link: `/${user.product}/placementListings/placements`,
1013
+ // buttonTitle: "View placements",
1014
+ // } as TaskQueryReturnObject;
1015
+ // },
1016
+ // },
1017
+ // completeFeedback: {
1018
+ // callback: async (user) => {
1019
+ // return;
1020
+ // return {} as TaskQueryReturnObject;
1021
+ // },
1022
+ // },
1023
+ // setUpFeedback: {
1024
+ // callback: async (user) => {
1025
+ // return;
1026
+ // return {} as TaskQueryReturnObject;
1027
+ // },
1028
+ // },
1029
+ // }
1030
+ const getTips = async (user, organisation, addresses) => {
570
1031
  const tipsObject = {
571
1032
  providers: providerTips,
572
1033
  institutes: instituteTips,
@@ -574,7 +1035,11 @@ const getTips = async (user, organisation) => {
574
1035
  };
575
1036
  const includedItems = Object.entries(tipsObject[user.product]).filter(([k]) => { var _a; return !((_a = user.dismissedTips) === null || _a === void 0 ? void 0 : _a.includes(k)); });
576
1037
  const processedTips = await includedItems.reduce(async (acc, [itemName, item]) => {
577
- const queryResult = await item.callback(user, organisation);
1038
+ const callbackParams = [user, organisation];
1039
+ if ((itemName === "addAddresses" || itemName === "addSchools") && addresses) {
1040
+ callbackParams.push(addresses);
1041
+ }
1042
+ const queryResult = await item.callback(...callbackParams);
578
1043
  if (!queryResult)
579
1044
  return await acc;
580
1045
  const queryResultArray = Array.isArray(queryResult) ? queryResult : [queryResult];
@@ -585,16 +1050,16 @@ const getTips = async (user, organisation) => {
585
1050
  return processedTips;
586
1051
  };
587
1052
  exports.getTips = getTips;
588
- const getTasks = async (user, organisation, cohort) => {
1053
+ const getTasks = async ({ user, organisation, cohort, school }) => {
589
1054
  // Cohort is either a specific one or all.
590
1055
  if (user.product === "institutes" && user.userType === "Staff" && organisation) {
591
- return await getInstituteTasks(user, organisation, cohort);
1056
+ return await getInstituteTasks({ user, organisation, cohort, school });
592
1057
  }
593
1058
  if (user.product === "students" || user.userType === "Students") {
594
1059
  return await getStudentTasks(user, organisation, cohort);
595
1060
  }
596
1061
  if (user.product === "providers" && organisation) {
597
- return await getProviderTasks(user, organisation);
1062
+ // return await getProviderTasks(user, organisation);
598
1063
  }
599
1064
  return [];
600
1065
  };
@@ -611,47 +1076,55 @@ const getStudentTasks = async (user, organisation, cohort) => {
611
1076
  }, Promise.resolve([]));
612
1077
  return processedTasks;
613
1078
  };
614
- const getProviderTasks = async (user, organisation, cohort) => {
615
- const processedTasks = await Object.entries(providerTasks).reduce(async (acc, [itemName, item]) => {
616
- const queryResult = await item.callback(user);
617
- if (!queryResult)
618
- return await acc;
619
- const queryResultArray = Array.isArray(queryResult) ? queryResult : [queryResult];
620
- const results = queryResultArray.map((r) => ({ itemName: itemName, ...r }));
621
- (await acc).push(...results);
622
- return await acc;
623
- }, Promise.resolve([]));
624
- return processedTasks;
625
- };
626
- const getInstituteTasks = async (user, organisation, cohort) => {
627
- var _a;
1079
+ // const getProviderTasks = async (user: UserData, organisation: InstituteData|ProviderData, cohort?: CohortData):Promise<(TaskQueryReturnObject)[]> => {
1080
+ // const processedTasks = await Object.entries(providerTasks).reduce(async (acc, [itemName, item]) => {
1081
+ // const queryResult = await item.callback(user);
1082
+ // if (!queryResult) return await acc;
1083
+ // const queryResultArray = Array.isArray(queryResult) ? queryResult : [queryResult];
1084
+ // const results = queryResultArray.map((r) => ({itemName: itemName as ProviderTaskNames, ...r}));
1085
+ // (await acc).push(...results);
1086
+ // return await acc;
1087
+ // }, Promise.resolve<TaskQueryReturnObject[]>([]));
1088
+ // return processedTasks;};
1089
+ const getInstituteTasks = async ({ user, organisation, cohort, school }) => {
628
1090
  let fCohort = cohort;
629
- if (!fCohort) {
630
- // get all associated cohorts.
631
- if (user.viewCohorts === "none")
1091
+ let fSchool = school;
1092
+ const getCohortsOrSchoolsIfNotProvided = async (type) => {
1093
+ var _a;
1094
+ if (user[`view${type}`] === "none")
632
1095
  return ([]);
633
- if (user.userGroup === "admin" || user.viewCohorts === "all") {
634
- const cohorts = await firebaseQuery.getDocsWhere("cohorts", [(0, firestore_1.where)("product", "==", user.product), (0, firestore_1.where)("oId", "==", user.oId), (0, firestore_1.where)("stage", "==", "created")]);
635
- fCohort = Object.entries(cohorts);
1096
+ if (user.userGroup === "admin" || user[`view${type}`] === "all") {
1097
+ const constraints = [(0, firestore_1.where)("oId", "==", user.oId)];
1098
+ if (type === "cohorts") {
1099
+ constraints.push((0, firestore_1.where)("product", "==", user.product), (0, firestore_1.where)("stage", "==", "created"));
1100
+ }
1101
+ const cohorts = await firebaseQuery.getDocsWhere(type, constraints);
1102
+ return Object.entries(cohorts);
636
1103
  }
637
- if (user.viewCohorts === "some") {
638
- const cohorts = await ((_a = user.visibleCohorts) === null || _a === void 0 ? void 0 : _a.split(",").reduce(async (acc, cohortId) => {
639
- const cohort = await firebaseQuery.getDocData(["cohorts", cohortId]);
640
- if (cohort.stage !== "created") {
1104
+ if (user[`view${type}`] === "some") {
1105
+ const items = await ((_a = user[`visible${type}s`]) === null || _a === void 0 ? void 0 : _a.reduce(async (acc, itemId) => {
1106
+ const item = await firebaseQuery.getDocData([type, itemId]);
1107
+ if (type === "cohorts" && item.stage !== "created") {
641
1108
  return acc;
642
1109
  }
643
- acc[cohortId] = cohort;
1110
+ acc[itemId] = item;
644
1111
  return acc;
645
1112
  }, Promise.resolve([])));
646
- fCohort = cohorts;
1113
+ return items;
647
1114
  }
1115
+ };
1116
+ if (!fCohort) {
1117
+ fCohort = await getCohortsOrSchoolsIfNotProvided("cohorts");
1118
+ }
1119
+ if (!fSchool) {
1120
+ fSchool = await getCohortsOrSchoolsIfNotProvided("schools");
648
1121
  }
649
1122
  const processedTasks = await Object.entries(instituteTasks).reduce(async (acc, [itemName, item]) => {
650
1123
  if (!fCohort) {
651
1124
  console.log("No cohorts to retrieve tasks for");
652
1125
  return ([]);
653
1126
  }
654
- const queryResult = await item.callback(user, organisation, fCohort);
1127
+ const queryResult = await item.callback({ user, organisation, cohorts: fCohort, schools: fSchool });
655
1128
  if (!queryResult)
656
1129
  return await acc;
657
1130
  const queryResultArray = Array.isArray(queryResult) ? queryResult : [queryResult];