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.
- package/lib/constants.d.ts +13 -1
- package/lib/constants.js +86 -1
- package/lib/constants.js.map +1 -1
- package/lib/features/analytics/useAnalytics.d.ts +2 -0
- package/lib/features/analytics/useAnalytics.js +22 -19
- package/lib/features/analytics/useAnalytics.js.map +1 -1
- package/lib/features/global/downtime/useDowntime.d.ts +1 -0
- package/lib/features/global/downtime/useDowntime.js +9 -7
- package/lib/features/global/downtime/useDowntime.js.map +1 -1
- package/lib/features/global/users/useUserFunctions.js +1 -1
- package/lib/features/global/users/useUserFunctions.js.map +1 -1
- package/lib/features/jobs/jobsSlice.d.ts +10 -2
- package/lib/features/jobs/jobsSlice.js +5 -2
- package/lib/features/jobs/jobsSlice.js.map +1 -1
- package/lib/features/placements/studentPlacements/activePlacement.d.ts +5 -1
- package/lib/features/placements/studentPlacements/activePlacement.js +7 -3
- package/lib/features/placements/studentPlacements/activePlacement.js.map +1 -1
- package/lib/features/placements/studentPlacements/completedStudentPlacementsSlice.d.ts +3 -2
- package/lib/features/placements/studentPlacements/completedStudentPlacementsSlice.js +4 -1
- package/lib/features/placements/studentPlacements/completedStudentPlacementsSlice.js.map +1 -1
- package/lib/features/placements/studentPlacements/upcomingStudentPlacementsSlice.d.ts +2 -2
- package/lib/features/placements/studentPlacements/upcomingStudentPlacementsSlice.js +1 -1
- package/lib/features/placements/studentPlacements/upcomingStudentPlacementsSlice.js.map +1 -1
- package/lib/features/placements/studentPlacements/useStudentPlacements.d.ts +2 -12
- package/lib/features/placements/studentPlacements/useStudentPlacements.js +1 -26
- package/lib/features/placements/studentPlacements/useStudentPlacements.js.map +1 -1
- package/lib/features/updates/useUpdates.d.ts +1 -0
- package/lib/features/updates/useUpdates.js +13 -12
- package/lib/features/updates/useUpdates.js.map +1 -1
- package/lib/firebase/firebase.d.ts +5 -3
- package/lib/firebase/firebase.js +23 -12
- package/lib/firebase/firebase.js.map +1 -1
- package/lib/firebase/firebaseConfig.js.map +1 -1
- package/lib/firebase/firebaseQuery.d.ts +6 -2
- package/lib/firebase/firebaseQuery.js +11 -3
- package/lib/firebase/firebaseQuery.js.map +1 -1
- package/lib/firebase/readDatabase.d.ts +2 -4
- package/lib/firebase/readDatabase.js +30 -5
- package/lib/firebase/readDatabase.js.map +1 -1
- package/lib/firebase/writeDatabase.d.ts +6 -2
- package/lib/firebase/writeDatabase.js +2 -1
- package/lib/firebase/writeDatabase.js.map +1 -1
- package/lib/hooks.d.ts +277 -192
- package/lib/hooks.js +1437 -704
- package/lib/hooks.js.map +1 -1
- package/lib/reduxHooks.d.ts +122 -5
- package/lib/reduxHooks.js +132 -29
- package/lib/reduxHooks.js.map +1 -1
- package/lib/tasksAndTips.d.ts +19 -7
- package/lib/tasksAndTips.js +637 -164
- package/lib/tasksAndTips.js.map +1 -1
- package/lib/typeDefinitions.d.ts +321 -110
- package/lib/util.d.ts +15 -3
- package/lib/util.js +47 -10
- package/lib/util.js.map +1 -1
- package/package.json +7 -4
- package/src/constants.ts +91 -3
- package/src/features/analytics/useAnalytics.tsx +25 -17
- package/src/features/global/downtime/useDowntime.tsx +11 -7
- package/src/features/global/users/useUserFunctions.tsx +1 -1
- package/src/features/jobs/jobsSlice.ts +9 -3
- package/src/features/placements/studentPlacements/activePlacement.ts +8 -3
- package/src/features/placements/studentPlacements/completedStudentPlacementsSlice.ts +5 -2
- package/src/features/placements/studentPlacements/upcomingStudentPlacementsSlice.ts +2 -2
- package/src/features/placements/studentPlacements/useStudentPlacements.tsx +4 -28
- package/src/features/updates/useUpdates.tsx +14 -12
- package/src/firebase/firebase.tsx +26 -15
- package/src/firebase/firebaseConfig.tsx +1 -1
- package/src/firebase/firebaseQuery.tsx +11 -3
- package/src/firebase/readDatabase.tsx +34 -6
- package/src/firebase/writeDatabase.tsx +3 -1
- package/src/hooks.tsx +1804 -935
- package/src/reduxHooks.ts +144 -32
- package/src/tasksAndTips.ts +689 -166
- package/src/typeDefinitions.ts +373 -109
- package/src/util.ts +63 -18
package/src/util.ts
CHANGED
|
@@ -1,16 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import {where} from "firebase/firestore";
|
|
2
|
+
import FirebaseQuery from "./firebase/firebaseQuery";
|
|
3
|
+
import {AlumniConversation, FlagCodes, InstituteData, StudentPlacementData, UserData, WorkflowStage} from "./typeDefinitions";
|
|
4
|
+
import {convertDate} from "./firebase/util";
|
|
5
|
+
|
|
6
|
+
type PlacementFlagCodeParams = {
|
|
7
|
+
placement : StudentPlacementData, // Placement we get flag codes for
|
|
8
|
+
studentData: UserData, // Student associated with the placement
|
|
9
|
+
workflow: WorkflowStage[], // Workflow associated with the placement
|
|
10
|
+
institute: InstituteData, // Associated institutes
|
|
11
|
+
user: UserData // User that is fetching flag codes (staff or student)
|
|
9
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* Description of function
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
10
17
|
|
|
11
|
-
|
|
18
|
+
type PlaceFlagCodeReturn = Promise<FlagCodes[]>;
|
|
19
|
+
|
|
20
|
+
export const getPlacementFlagCodes = async ({placement, studentData, workflow, institute, user}: PlacementFlagCodeParams):PlaceFlagCodeReturn => {
|
|
12
21
|
let flags:FlagCodes[] = placement.flags || [];
|
|
13
22
|
|
|
23
|
+
const firebaseQuery = new FirebaseQuery();
|
|
14
24
|
|
|
15
25
|
if (!studentData.details.parentEmail && !flags.find((x) => x.includes("noParentEmail"))) {
|
|
16
26
|
if (workflow.find((obj) => obj.id === placement.status)?.userType === "Parent") {
|
|
@@ -32,51 +42,70 @@ export const getPlacementFlagCodes = ({placement, studentData, workflow, institu
|
|
|
32
42
|
const dbsCheckNotVerified = !institute?.verifiedDbsChecks?.includes(placement.placementId || placement.id);
|
|
33
43
|
const awaitingDbsCheck = !placement.dbsCheck || institute?.awaitingPlacementDbsChecks?.includes(placement.placementId || placement.id);
|
|
34
44
|
|
|
35
|
-
|
|
45
|
+
const reminderCount = (await firebaseQuery.getCount(["reminders"], [where("oId", "==", user.oId), where("uid", "==", user.id), where("dueDate", "<=", convertDate(new Date(), "dbstring") as string), where("documentId", "==", placement.id), where("status", "==", "upcoming")]));
|
|
46
|
+
|
|
47
|
+
if (reminderCount) {
|
|
48
|
+
flags.push("reminder");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (user.userType === "Staff" && user.product === "institutes" && placement.insurance && placementIsPostProviderReview && placementNotEnded && providerUnverified && !awaitingProviderInsurance) {
|
|
36
52
|
console.log("Add insurance flag!");
|
|
37
53
|
flags.includes("noInsurance") || flags.push("noInsurance");
|
|
38
54
|
} else {
|
|
39
55
|
flags = flags.filter((x) => x !== "noInsurance");
|
|
40
56
|
}
|
|
41
57
|
|
|
42
|
-
if (user.
|
|
58
|
+
if (user.product === "providers" && placement.statusType === "requested") {
|
|
59
|
+
flags.includes("studentNotAccepted") || flags.push("studentNotAccepted");
|
|
60
|
+
} else {
|
|
61
|
+
flags = flags.filter((x) => x !== "studentNotAccepted");
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
if (user.userType === "Staff" && user.product === "institutes" && placementIsPostProviderReview && placementNotEnded && awaitingProviderInsurance) {
|
|
43
66
|
flags.includes("awaitingInsurance") || flags.push("awaitingInsurance");
|
|
44
67
|
} else {
|
|
45
68
|
flags = flags.filter((x) => x !== "awaitingInsurance");
|
|
46
69
|
}
|
|
47
70
|
|
|
48
|
-
if (user.userType === "Staff" && placement.dbsCheck && workflow.find((stage) => stage.dbsCheck) && placement.dbsCheck !== true && placementIsPostProviderReview && placementNotEnded && dbsCheckNotVerified && !awaitingDbsCheck) {
|
|
71
|
+
if (user.userType === "Staff" && user.product === "institutes" && placement.dbsCheck && workflow.find((stage) => stage.dbsCheck) && placement.dbsCheck !== true && placementIsPostProviderReview && placementNotEnded && dbsCheckNotVerified && !awaitingDbsCheck) {
|
|
49
72
|
flags.includes("noDbsCheck") || flags.push("noDbsCheck");
|
|
50
73
|
} else {
|
|
51
74
|
flags = flags.filter((x) => x !== "noDbsCheck");
|
|
52
75
|
}
|
|
53
76
|
|
|
54
|
-
if (user.userType === "Staff" && placementIsPostProviderReview && workflow.find((stage) => stage.dbsCheck) && placementNotEnded && awaitingProviderInsurance) {
|
|
77
|
+
if (user.userType === "Staff" && user.product === "institutes" && placementIsPostProviderReview && workflow.find((stage) => stage.dbsCheck) && placementNotEnded && awaitingProviderInsurance) {
|
|
55
78
|
flags.includes("awaitingDbsCheck") || flags.push("awaitingDbsCheck");
|
|
56
79
|
} else {
|
|
57
80
|
flags = flags.filter((x) => x !== "awaitingDbsCheck");
|
|
58
81
|
}
|
|
59
82
|
|
|
60
|
-
if (user.userType === "Staff" && placement.riskAssessment && workflow.find((stage) => stage.riskAssessment) && placement.riskAssessment !== true && placementIsPostProviderReview && placementNotEnded && riskAssessmentNotVerified && !awaitingRiskAssessment) {
|
|
83
|
+
if (user.userType === "Staff" && user.product === "institutes" && placement.riskAssessment && workflow.find((stage) => stage.riskAssessment) && placement.riskAssessment !== true && placementIsPostProviderReview && placementNotEnded && riskAssessmentNotVerified && !awaitingRiskAssessment) {
|
|
61
84
|
console.log("Add RA flag!");
|
|
62
85
|
flags.includes("noRiskAssessment") || flags.push("noRiskAssessment");
|
|
63
86
|
} else {
|
|
64
87
|
flags = flags.filter((x) => x !== "noRiskAssessment");
|
|
65
88
|
}
|
|
66
89
|
|
|
67
|
-
if (user.userType === "Staff" && placementIsPostProviderReview && workflow.find((stage) => stage.riskAssessment) && placementNotEnded && awaitingProviderInsurance) {
|
|
90
|
+
if (user.userType === "Staff" && user.product === "institutes" && placementIsPostProviderReview && workflow.find((stage) => stage.riskAssessment) && placementNotEnded && awaitingProviderInsurance) {
|
|
68
91
|
flags.includes("awaitingRiskAssessment") || flags.push("awaitingRiskAssessment");
|
|
69
92
|
} else {
|
|
70
93
|
flags = flags.filter((x) => x !== "awaitingRiskAssessment");
|
|
71
94
|
}
|
|
72
95
|
|
|
73
|
-
if (user.userType === "Staff" && user.product === "providers" && user.oId === placement.providerId && placement.onboarding
|
|
96
|
+
if (placement.inProgress && user.userType === "Staff" && user.product === "providers" && user.oId === placement.providerId && placement.onboarding === null) {
|
|
97
|
+
flags.includes("addOnboarding") || flags.push("addOnboarding");
|
|
98
|
+
} else {
|
|
99
|
+
flags = flags.filter((x) => x !== "addOnboarding");
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (placement.inProgress && user.userType === "Staff" && user.product === "providers" && user.oId === placement.providerId && placement.onboarding && (placement.onboarding.completed?.submitted && !placement.onboarding.completed.accepted) && (placement.inProgress || placement.active)) {
|
|
74
103
|
flags.includes("reviewOnboarding") || flags.push("reviewOnboarding");
|
|
75
104
|
} else {
|
|
76
105
|
flags = flags.filter((x) => x !== "reviewOnboarding");
|
|
77
106
|
}
|
|
78
107
|
|
|
79
|
-
if (user.userType === "Students" && placement.onboarding && (!placement.onboarding.completed || (placement.onboarding.completed && !placement.onboarding.completed?.submitted)) && (placement.inProgress || placement.active)) {
|
|
108
|
+
if (placement.inProgress && user.userType === "Students" && placement.onboarding && (!placement.onboarding.completed || (placement.onboarding.completed && !placement.onboarding.completed?.submitted)) && (placement.inProgress || placement.active)) {
|
|
80
109
|
flags.includes("completeOnboarding") || flags.push("completeOnboarding");
|
|
81
110
|
} else {
|
|
82
111
|
flags = flags.filter((x) => x !== "completeOnboarding");
|
|
@@ -87,7 +116,6 @@ export const getPlacementFlagCodes = ({placement, studentData, workflow, institu
|
|
|
87
116
|
};
|
|
88
117
|
|
|
89
118
|
|
|
90
|
-
|
|
91
119
|
export function objectsEqualNew(a: any, b: any): boolean { // Works with arrays or objects.
|
|
92
120
|
if (a === b) {
|
|
93
121
|
return true;
|
|
@@ -130,3 +158,20 @@ export function objectsEqualNew(a: any, b: any): boolean { // Works with arrays
|
|
|
130
158
|
|
|
131
159
|
return false;
|
|
132
160
|
}
|
|
161
|
+
|
|
162
|
+
export const getMostRecentAlumniMessage = (conversation: AlumniConversation) => {
|
|
163
|
+
const { messages } = conversation;
|
|
164
|
+
|
|
165
|
+
if (!messages || Object.keys(messages).length === 0) {
|
|
166
|
+
return null; // No messages available
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const mostRecent = Object.entries(messages)
|
|
170
|
+
.map(([id, message]) => ({
|
|
171
|
+
id,
|
|
172
|
+
...message,
|
|
173
|
+
}))
|
|
174
|
+
.sort((a, b) => new Date(b.sentAt).getTime() - new Date(a.sentAt).getTime())[0];
|
|
175
|
+
|
|
176
|
+
return mostRecent || null; // Return most recent or null if none found
|
|
177
|
+
};
|