placementt-core 11.0.803 → 11.0.914
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.
- package/lib/constants.d.ts +1 -0
- package/lib/constants.js +2 -1
- package/lib/constants.js.map +1 -1
- package/lib/firebase/firebase.d.ts +1 -1
- package/lib/firebase/firebase.js +8 -3
- package/lib/firebase/firebase.js.map +1 -1
- package/lib/firebase/readDatabase.js +7 -7
- package/lib/firebase/readDatabase.js.map +1 -1
- package/lib/hooks.d.ts +90 -180
- package/lib/hooks.js +739 -639
- package/lib/hooks.js.map +1 -1
- package/lib/reduxHooks.d.ts +66 -1
- package/lib/reduxHooks.js +70 -11
- package/lib/reduxHooks.js.map +1 -1
- package/lib/tasksAndTips.d.ts +14 -4
- package/lib/tasksAndTips.js +463 -454
- package/lib/tasksAndTips.js.map +1 -1
- package/lib/typeDefinitions.d.ts +198 -81
- package/lib/util.d.ts +8 -1
- package/lib/util.js +17 -3
- package/lib/util.js.map +1 -1
- package/package.json +7 -4
- package/src/constants.ts +2 -0
- package/src/firebase/firebase.tsx +8 -4
- package/src/firebase/readDatabase.tsx +7 -7
- package/src/hooks.tsx +834 -742
- package/src/reduxHooks.ts +76 -13
- package/src/tasksAndTips.ts +504 -446
- package/src/typeDefinitions.ts +247 -76
- package/src/util.ts +20 -3
package/lib/tasksAndTips.js
CHANGED
|
@@ -146,8 +146,8 @@ const instituteTips = {
|
|
|
146
146
|
// Accept a cohort to any task
|
|
147
147
|
const instituteTasks = {
|
|
148
148
|
invalidStaffEmails: {
|
|
149
|
-
callback: async (user,
|
|
150
|
-
if (!(0, util_1.getAccess)(user, "viewStaff") || !Array.isArray(
|
|
149
|
+
callback: async ({ user, cohorts }) => {
|
|
150
|
+
if (!(0, util_1.getAccess)(user, "viewStaff") || !Array.isArray(cohorts))
|
|
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) {
|
|
@@ -156,14 +156,63 @@ const instituteTasks = {
|
|
|
156
156
|
severity: "error",
|
|
157
157
|
title: `${staffCount} staff have invalid emails.`,
|
|
158
158
|
message: `${staffCount} staff accounts have invalid email addresses. Delete and reupload these users.`,
|
|
159
|
-
link: "/institutes/
|
|
159
|
+
link: "/institutes/organisation/staff/all",
|
|
160
160
|
};
|
|
161
161
|
}
|
|
162
162
|
return;
|
|
163
163
|
},
|
|
164
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
|
+
},
|
|
165
214
|
invalidStudentEmails: {
|
|
166
|
-
callback: async (user,
|
|
215
|
+
callback: async ({ user, cohorts }) => {
|
|
167
216
|
if (!(0, util_1.getAccess)(user, "viewStudents") || user.viewStudents === "none")
|
|
168
217
|
return;
|
|
169
218
|
if (!Array.isArray(cohorts)) {
|
|
@@ -196,7 +245,7 @@ const instituteTasks = {
|
|
|
196
245
|
},
|
|
197
246
|
},
|
|
198
247
|
outstandingReminders: {
|
|
199
|
-
callback: async (user,
|
|
248
|
+
callback: async ({ user, cohorts }) => {
|
|
200
249
|
if (!Array.isArray(cohorts)) {
|
|
201
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")]));
|
|
202
251
|
if (reminderCount > 0) {
|
|
@@ -227,7 +276,7 @@ const instituteTasks = {
|
|
|
227
276
|
},
|
|
228
277
|
},
|
|
229
278
|
invalidParentEmails: {
|
|
230
|
-
callback: async (user,
|
|
279
|
+
callback: async ({ user, cohorts }) => {
|
|
231
280
|
if (!(0, util_1.getAccess)(user, "signOffPlacements") || user.viewStudents === "none")
|
|
232
281
|
return;
|
|
233
282
|
if (!Array.isArray(cohorts)) {
|
|
@@ -261,7 +310,7 @@ const instituteTasks = {
|
|
|
261
310
|
},
|
|
262
311
|
},
|
|
263
312
|
invalidProviderEmails: {
|
|
264
|
-
callback: async (user,
|
|
313
|
+
callback: async ({ user, cohorts }) => {
|
|
265
314
|
if (!(0, util_1.getAccess)(user, "signOffPlacements") || user.viewStudents === "none")
|
|
266
315
|
return;
|
|
267
316
|
if (!Array.isArray(cohorts)) {
|
|
@@ -295,7 +344,7 @@ const instituteTasks = {
|
|
|
295
344
|
},
|
|
296
345
|
},
|
|
297
346
|
requiredStage: {
|
|
298
|
-
callback: async (user,
|
|
347
|
+
callback: async ({ user, cohorts }) => {
|
|
299
348
|
if (!(0, util_1.getAccess)(user, "signOffPlacements") || user.viewStudents === "none")
|
|
300
349
|
return;
|
|
301
350
|
if (!Array.isArray(cohorts)) {
|
|
@@ -329,7 +378,7 @@ const instituteTasks = {
|
|
|
329
378
|
},
|
|
330
379
|
},
|
|
331
380
|
verifyInsurance: {
|
|
332
|
-
callback: async (user,
|
|
381
|
+
callback: async ({ user, cohorts }) => {
|
|
333
382
|
if (!(0, util_1.getAccess)(user, "verifyInsurance") || user.viewStudents === "none")
|
|
334
383
|
return;
|
|
335
384
|
if (!Array.isArray(cohorts)) {
|
|
@@ -363,7 +412,7 @@ const instituteTasks = {
|
|
|
363
412
|
},
|
|
364
413
|
},
|
|
365
414
|
verifyDbsCheck: {
|
|
366
|
-
callback: async (user,
|
|
415
|
+
callback: async ({ user, cohorts }) => {
|
|
367
416
|
if (!(0, util_1.getAccess)(user, "verifyDbsChecks") || user.viewStudents === "none")
|
|
368
417
|
return;
|
|
369
418
|
if (!Array.isArray(cohorts)) {
|
|
@@ -397,7 +446,7 @@ const instituteTasks = {
|
|
|
397
446
|
},
|
|
398
447
|
},
|
|
399
448
|
verifyRiskAssessment: {
|
|
400
|
-
callback: async (user,
|
|
449
|
+
callback: async ({ user, cohorts }) => {
|
|
401
450
|
if (!(0, util_1.getAccess)(user, "verifyRiskAssessments") || user.viewStudents === "none")
|
|
402
451
|
return;
|
|
403
452
|
if (!Array.isArray(cohorts)) {
|
|
@@ -431,7 +480,7 @@ const instituteTasks = {
|
|
|
431
480
|
},
|
|
432
481
|
},
|
|
433
482
|
missingParentEmail: {
|
|
434
|
-
callback: async (user,
|
|
483
|
+
callback: async ({ user, cohorts }) => {
|
|
435
484
|
var _a, _b, _c;
|
|
436
485
|
if (!(0, util_1.getAccess)(user, "editStudents") || user.viewStudents === "none")
|
|
437
486
|
return;
|
|
@@ -481,7 +530,7 @@ const instituteTasks = {
|
|
|
481
530
|
},
|
|
482
531
|
},
|
|
483
532
|
inactiveStudents: {
|
|
484
|
-
callback: async (user,
|
|
533
|
+
callback: async ({ user, cohorts }) => {
|
|
485
534
|
var _a, _b, _c;
|
|
486
535
|
if (!(0, util_1.getAccess)(user, "activateStudents") || user.viewStudents === "none")
|
|
487
536
|
return;
|
|
@@ -525,7 +574,7 @@ const instituteTasks = {
|
|
|
525
574
|
},
|
|
526
575
|
},
|
|
527
576
|
uploadStudents: {
|
|
528
|
-
callback: async (user,
|
|
577
|
+
callback: async ({ user, cohorts }) => {
|
|
529
578
|
if (!Array.isArray(cohorts))
|
|
530
579
|
return;
|
|
531
580
|
if (!(0, util_1.getAccess)(user, "addStudents") || user.viewStudents === "none")
|
|
@@ -554,7 +603,7 @@ const instituteTasks = {
|
|
|
554
603
|
},
|
|
555
604
|
},
|
|
556
605
|
inactiveStaff: {
|
|
557
|
-
callback: async (user,
|
|
606
|
+
callback: async ({ user, cohorts }) => {
|
|
558
607
|
if (!(0, util_1.getAccess)(user, "addStaff"))
|
|
559
608
|
return;
|
|
560
609
|
if (!Array.isArray(cohorts) || user.product === "students")
|
|
@@ -576,16 +625,16 @@ const instituteTasks = {
|
|
|
576
625
|
},
|
|
577
626
|
},
|
|
578
627
|
overdueStage: {
|
|
579
|
-
callback: async (user,
|
|
580
|
-
console.log(user,
|
|
628
|
+
callback: async ({ user, cohorts }) => {
|
|
629
|
+
console.log(user, cohorts);
|
|
581
630
|
return undefined;
|
|
582
631
|
},
|
|
583
632
|
},
|
|
584
633
|
approveExternalPlacement: {
|
|
585
|
-
callback: async (user,
|
|
634
|
+
callback: async ({ user, cohorts }) => {
|
|
586
635
|
if (!(0, util_1.getAccess)(user, "verifyListings"))
|
|
587
636
|
return;
|
|
588
|
-
if (!Array.isArray(
|
|
637
|
+
if (!Array.isArray(cohorts))
|
|
589
638
|
return;
|
|
590
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")]);
|
|
591
640
|
console.log("EXT", externalCount);
|
|
@@ -621,411 +670,363 @@ const studentTasks = {
|
|
|
621
670
|
},
|
|
622
671
|
}
|
|
623
672
|
};
|
|
624
|
-
const providerTasks = {
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
return;
|
|
982
|
-
constraints.push((0, firestore_1.where)("addressId", 'in', user.visibleAddresses));
|
|
983
|
-
}
|
|
984
|
-
}
|
|
985
|
-
}
|
|
986
|
-
const placementsStartingSoon = await firebaseQuery.getCount("placements", constraints);
|
|
987
|
-
if (placementsStartingSoon === 0)
|
|
988
|
-
return;
|
|
989
|
-
if (placementsStartingSoon === 1) {
|
|
990
|
-
const placement = Object.entries(await firebaseQuery.getDocsWhere("placements", constraints) || {})[0];
|
|
991
|
-
const student = placement[1].uid ? await firebaseQuery.getDocData(["users", placement[1].uid]) : {
|
|
992
|
-
details: {
|
|
993
|
-
forename: placement[1].studentForename,
|
|
994
|
-
surname: placement[1].studentSurname,
|
|
995
|
-
}
|
|
996
|
-
};
|
|
997
|
-
return {
|
|
998
|
-
dismissible: false,
|
|
999
|
-
severity: "success",
|
|
1000
|
-
title: `${student.details.forename} ${student.details.surname}'s placement from ${(0, util_2.convertDate)(placement[1].startDate, "visual")} to ${(0, util_2.convertDate)(placement[1].endDate, "visual")} is starting in less than a week.`,
|
|
1001
|
-
message: `Click to view the placement and acquaint yourself with the student.`,
|
|
1002
|
-
link: `/${user.product}/placements/${placement[0]}`,
|
|
1003
|
-
buttonTitle: "View",
|
|
1004
|
-
};
|
|
1005
|
-
}
|
|
1006
|
-
return {
|
|
1007
|
-
dismissible: false,
|
|
1008
|
-
severity: "success",
|
|
1009
|
-
title: `${placementsStartingSoon} placements starting soon.`,
|
|
1010
|
-
message: `Click to view scheduled placements.`,
|
|
1011
|
-
link: `/${user.product}/placementListings/placements`,
|
|
1012
|
-
buttonTitle: "View placements",
|
|
1013
|
-
};
|
|
1014
|
-
},
|
|
1015
|
-
},
|
|
1016
|
-
completeFeedback: {
|
|
1017
|
-
callback: async (user) => {
|
|
1018
|
-
return;
|
|
1019
|
-
return {};
|
|
1020
|
-
},
|
|
1021
|
-
},
|
|
1022
|
-
setUpFeedback: {
|
|
1023
|
-
callback: async (user) => {
|
|
1024
|
-
return;
|
|
1025
|
-
return {};
|
|
1026
|
-
},
|
|
1027
|
-
},
|
|
1028
|
-
};
|
|
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
|
+
// }
|
|
1029
1030
|
const getTips = async (user, organisation, addresses) => {
|
|
1030
1031
|
const tipsObject = {
|
|
1031
1032
|
providers: providerTips,
|
|
@@ -1049,16 +1050,16 @@ const getTips = async (user, organisation, addresses) => {
|
|
|
1049
1050
|
return processedTips;
|
|
1050
1051
|
};
|
|
1051
1052
|
exports.getTips = getTips;
|
|
1052
|
-
const getTasks = async (user, organisation, cohort) => {
|
|
1053
|
+
const getTasks = async ({ user, organisation, cohort, school }) => {
|
|
1053
1054
|
// Cohort is either a specific one or all.
|
|
1054
1055
|
if (user.product === "institutes" && user.userType === "Staff" && organisation) {
|
|
1055
|
-
return await getInstituteTasks(user, organisation, cohort);
|
|
1056
|
+
return await getInstituteTasks({ user, organisation, cohort, school });
|
|
1056
1057
|
}
|
|
1057
1058
|
if (user.product === "students" || user.userType === "Students") {
|
|
1058
1059
|
return await getStudentTasks(user, organisation, cohort);
|
|
1059
1060
|
}
|
|
1060
1061
|
if (user.product === "providers" && organisation) {
|
|
1061
|
-
return await getProviderTasks(user, organisation);
|
|
1062
|
+
// return await getProviderTasks(user, organisation);
|
|
1062
1063
|
}
|
|
1063
1064
|
return [];
|
|
1064
1065
|
};
|
|
@@ -1075,47 +1076,55 @@ const getStudentTasks = async (user, organisation, cohort) => {
|
|
|
1075
1076
|
}, Promise.resolve([]));
|
|
1076
1077
|
return processedTasks;
|
|
1077
1078
|
};
|
|
1078
|
-
const getProviderTasks = async (user, organisation, cohort) => {
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
};
|
|
1090
|
-
const getInstituteTasks = async (user, organisation, cohort) => {
|
|
1091
|
-
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 }) => {
|
|
1092
1090
|
let fCohort = cohort;
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1091
|
+
let fSchool = school;
|
|
1092
|
+
const getCohortsOrSchoolsIfNotProvided = async (type) => {
|
|
1093
|
+
var _a;
|
|
1094
|
+
if (user[`view${type}`] === "none")
|
|
1096
1095
|
return ([]);
|
|
1097
|
-
if (user.userGroup === "admin" || user
|
|
1098
|
-
const
|
|
1099
|
-
|
|
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);
|
|
1100
1103
|
}
|
|
1101
|
-
if (user
|
|
1102
|
-
const
|
|
1103
|
-
const
|
|
1104
|
-
if (
|
|
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") {
|
|
1105
1108
|
return acc;
|
|
1106
1109
|
}
|
|
1107
|
-
acc[
|
|
1110
|
+
acc[itemId] = item;
|
|
1108
1111
|
return acc;
|
|
1109
1112
|
}, Promise.resolve([])));
|
|
1110
|
-
|
|
1113
|
+
return items;
|
|
1111
1114
|
}
|
|
1115
|
+
};
|
|
1116
|
+
if (!fCohort) {
|
|
1117
|
+
fCohort = await getCohortsOrSchoolsIfNotProvided("cohorts");
|
|
1118
|
+
}
|
|
1119
|
+
if (!fSchool) {
|
|
1120
|
+
fSchool = await getCohortsOrSchoolsIfNotProvided("schools");
|
|
1112
1121
|
}
|
|
1113
1122
|
const processedTasks = await Object.entries(instituteTasks).reduce(async (acc, [itemName, item]) => {
|
|
1114
1123
|
if (!fCohort) {
|
|
1115
1124
|
console.log("No cohorts to retrieve tasks for");
|
|
1116
1125
|
return ([]);
|
|
1117
1126
|
}
|
|
1118
|
-
const queryResult = await item.callback(user, organisation, fCohort);
|
|
1127
|
+
const queryResult = await item.callback({ user, organisation, cohorts: fCohort, schools: fSchool });
|
|
1119
1128
|
if (!queryResult)
|
|
1120
1129
|
return await acc;
|
|
1121
1130
|
const queryResultArray = Array.isArray(queryResult) ? queryResult : [queryResult];
|