placementt-core 1.20.217 → 11.0.803

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 (86) hide show
  1. package/.eslintrc.js +40 -40
  2. package/.gitattributes +2 -2
  3. package/lib/constants.js +10 -1
  4. package/lib/constants.js.map +1 -1
  5. package/lib/features/config.d.ts +133 -133
  6. package/lib/features/config.js +35 -35
  7. package/lib/features/contacts/contacts.d.ts +75 -75
  8. package/lib/features/contacts/contacts.js +105 -105
  9. package/lib/features/downtime/useDowntime.d.ts +11 -11
  10. package/lib/features/downtime/useDowntime.js +22 -22
  11. package/lib/features/placements/studentPlacements/studentPlacementsSlice.d.ts +63 -63
  12. package/lib/features/placements/studentPlacements/studentPlacementsSlice.js +81 -81
  13. package/lib/features/providerPlacements/providerPlacementsSlice.d.ts +19 -19
  14. package/lib/features/providerPlacements/providerPlacementsSlice.js +24 -24
  15. package/lib/features/studentPlacements/studentPlacementsSlice.d.ts +62 -62
  16. package/lib/features/studentPlacements/studentPlacementsSlice.js +87 -87
  17. package/lib/features/studentPlacements/useStudentPlacements.d.ts +6 -6
  18. package/lib/features/studentPlacements/useStudentPlacements.js +18 -18
  19. package/lib/features/userSlice.d.ts +26 -26
  20. package/lib/features/userSlice.js +23 -23
  21. package/lib/features/users/useUserFunctions.d.ts +25 -25
  22. package/lib/features/users/useUserFunctions.js +124 -124
  23. package/lib/features/users/userSlice.d.ts +46 -46
  24. package/lib/features/users/userSlice.js +48 -48
  25. package/lib/firebase/firebase.d.ts +1 -1
  26. package/lib/firebase/firebase.js +6 -2
  27. package/lib/firebase/firebase.js.map +1 -1
  28. package/lib/firebase/readDatabase.js +3 -1
  29. package/lib/firebase/readDatabase.js.map +1 -1
  30. package/lib/hooks.d.ts +33 -5
  31. package/lib/hooks.js +143 -107
  32. package/lib/hooks.js.map +1 -1
  33. package/lib/images/GatsbyBenchmarks.d.ts +1 -2
  34. package/lib/reduxHooks.d.ts +1 -66
  35. package/lib/reduxHooks.js +9 -69
  36. package/lib/reduxHooks.js.map +1 -1
  37. package/lib/tasksAndTips.d.ts +2 -2
  38. package/lib/tasksAndTips.js +37 -6
  39. package/lib/tasksAndTips.js.map +1 -1
  40. package/lib/typeDefinitions.d.ts +50 -5
  41. package/lib/util.d.ts +1 -1
  42. package/lib/util.js +12 -1
  43. package/lib/util.js.map +1 -1
  44. package/package.json +52 -56
  45. package/src/DatabaseDefinitions.ts +18 -18
  46. package/src/apiCalls.ts +128 -128
  47. package/src/config.ts +50 -50
  48. package/src/constants.ts +796 -787
  49. package/src/databaseTypes.ts +42 -42
  50. package/src/features/analytics/useAnalytics.tsx +63 -63
  51. package/src/features/contacts/contactsSlice.ts +147 -147
  52. package/src/features/contacts/useContacts.tsx +73 -73
  53. package/src/features/dropdown/useDropdown.tsx +52 -52
  54. package/src/features/global/downtime/useDowntime.tsx +23 -23
  55. package/src/features/global/users/useUserFunctions.tsx +132 -132
  56. package/src/features/jobs/jobsSlice.ts +71 -71
  57. package/src/features/placements/studentPlacements/activePlacement.ts +68 -68
  58. package/src/features/placements/studentPlacements/completedStudentPlacementsSlice.ts +97 -97
  59. package/src/features/placements/studentPlacements/upcomingStudentPlacementsSlice.ts +108 -108
  60. package/src/features/placements/studentPlacements/useStudentPlacements.tsx +9 -9
  61. package/src/features/placements/types.ts +10 -10
  62. package/src/features/referrals/useReferrals.tsx +56 -56
  63. package/src/features/updates/useUpdates.tsx +38 -38
  64. package/src/firebase/firebase.tsx +149 -145
  65. package/src/firebase/firebaseConfig.tsx +45 -45
  66. package/src/firebase/firebaseQuery.tsx +151 -151
  67. package/src/firebase/persistence.ts +84 -84
  68. package/src/firebase/readDatabase.tsx +236 -235
  69. package/src/firebase/util.tsx +352 -352
  70. package/src/firebase/writeDatabase.tsx +77 -77
  71. package/src/hooks.tsx +4353 -4323
  72. package/src/images/GatsbyBenchmarks.tsx +711 -711
  73. package/src/images/LogFuturePlacement.jsx +64 -64
  74. package/src/images/LogPreviousPlacement.jsx +228 -228
  75. package/src/images/gatsby_benchmarks.svg +466 -466
  76. package/src/images/log_future_placement.svg +114 -114
  77. package/src/images/log_previous_placement.svg +199 -199
  78. package/src/index.ts +34 -34
  79. package/src/readDatabase.tsx +3 -3
  80. package/src/reduxHooks.ts +232 -297
  81. package/src/tasksAndTips.ts +1209 -1177
  82. package/src/tutorialTips.ts +58 -58
  83. package/src/typeDefinitions.ts +1003 -958
  84. package/src/util.ts +160 -150
  85. package/tsconfig.dev.json +5 -5
  86. package/tsconfig.json +21 -22
package/src/util.ts CHANGED
@@ -1,150 +1,160 @@
1
- import {FlagCodes, InstituteData, StudentPlacementData, UserData, WorkflowStage} from "./typeDefinitions";
2
-
3
- type PlacementFlagCodeParams = {
4
- placement : StudentPlacementData, // Placement we get flag codes for
5
- studentData: UserData, // Student associated with the placement
6
- workflow: WorkflowStage[], // Workflow associated with the placement
7
- institute: InstituteData, // Associated institutes
8
- user: UserData // User that is fetching flag codes (staff or student)
9
- };
10
- /**
11
- * Description of function
12
- *
13
- */
14
-
15
- type PlaceFlagCodeReturn = FlagCodes[];
16
-
17
- export const getPlacementFlagCodes = ({placement, studentData, workflow, institute, user}: PlacementFlagCodeParams):PlaceFlagCodeReturn => {
18
- let flags:FlagCodes[] = placement.flags || [];
19
-
20
-
21
- if (!studentData.details.parentEmail && !flags.find((x) => x.includes("noParentEmail"))) {
22
- if (workflow.find((obj) => obj.id === placement.status)?.userType === "Parent") {
23
- flags.includes("noParentEmailWarning") || flags.push("noParentEmailError");
24
- } else if (workflow.find((obj) => obj.userType === "Parent")) {
25
- flags.includes("noParentEmailWarning") || flags.push("noParentEmailError");
26
- }
27
- }
28
-
29
- // If placement after provider review and not verified
30
- const placementIsPostProviderReview = placement.leadTimes.some((x) => x.split("_")[0] === "3");
31
- const placementNotEnded = !placement.leadTimes.some((x) => x.split("_")[0] === "8");
32
- const providerUnverified = placement.providerId && !institute?.verifiedProviders?.includes(placement.providerId);
33
- const awaitingProviderInsurance = placement.providerId && institute?.awaitingProviderInsurance?.includes(placement.providerId);
34
-
35
- const riskAssessmentNotVerified = !institute?.verifiedRiskAssessments?.includes(placement.placementId || placement.id);
36
- const awaitingRiskAssessment = !placement.riskAssessment || institute?.awaitingPlacementRiskAssessments?.includes(placement.placementId || placement.id);
37
-
38
- const dbsCheckNotVerified = !institute?.verifiedDbsChecks?.includes(placement.placementId || placement.id);
39
- const awaitingDbsCheck = !placement.dbsCheck || institute?.awaitingPlacementDbsChecks?.includes(placement.placementId || placement.id);
40
-
41
- if (user.userType === "Staff" && user.product === "institutes" && placement.insurance && placementIsPostProviderReview && placementNotEnded && providerUnverified && !awaitingProviderInsurance) {
42
- console.log("Add insurance flag!");
43
- flags.includes("noInsurance") || flags.push("noInsurance");
44
- } else {
45
- flags = flags.filter((x) => x !== "noInsurance");
46
- }
47
-
48
- if (user.product === "providers" && placement.statusType === "requested") {
49
- flags.includes("studentNotAccepted") || flags.push("studentNotAccepted");
50
- } else {
51
- flags = flags.filter((x) => x !== "studentNotAccepted");
52
- }
53
-
54
-
55
- if (user.userType === "Staff" && user.product === "institutes" && placementIsPostProviderReview && placementNotEnded && awaitingProviderInsurance) {
56
- flags.includes("awaitingInsurance") || flags.push("awaitingInsurance");
57
- } else {
58
- flags = flags.filter((x) => x !== "awaitingInsurance");
59
- }
60
-
61
- if (user.userType === "Staff" && user.product === "institutes" && placement.dbsCheck && workflow.find((stage) => stage.dbsCheck) && placement.dbsCheck !== true && placementIsPostProviderReview && placementNotEnded && dbsCheckNotVerified && !awaitingDbsCheck) {
62
- flags.includes("noDbsCheck") || flags.push("noDbsCheck");
63
- } else {
64
- flags = flags.filter((x) => x !== "noDbsCheck");
65
- }
66
-
67
- if (user.userType === "Staff" && user.product === "institutes" && placementIsPostProviderReview && workflow.find((stage) => stage.dbsCheck) && placementNotEnded && awaitingProviderInsurance) {
68
- flags.includes("awaitingDbsCheck") || flags.push("awaitingDbsCheck");
69
- } else {
70
- flags = flags.filter((x) => x !== "awaitingDbsCheck");
71
- }
72
-
73
- if (user.userType === "Staff" && user.product === "institutes" && placement.riskAssessment && workflow.find((stage) => stage.riskAssessment) && placement.riskAssessment !== true && placementIsPostProviderReview && placementNotEnded && riskAssessmentNotVerified && !awaitingRiskAssessment) {
74
- console.log("Add RA flag!");
75
- flags.includes("noRiskAssessment") || flags.push("noRiskAssessment");
76
- } else {
77
- flags = flags.filter((x) => x !== "noRiskAssessment");
78
- }
79
-
80
- if (user.userType === "Staff" && user.product === "institutes" && placementIsPostProviderReview && workflow.find((stage) => stage.riskAssessment) && placementNotEnded && awaitingProviderInsurance) {
81
- flags.includes("awaitingRiskAssessment") || flags.push("awaitingRiskAssessment");
82
- } else {
83
- flags = flags.filter((x) => x !== "awaitingRiskAssessment");
84
- }
85
-
86
- if (placement.inProgress && user.userType === "Staff" && user.product === "providers" && user.oId === placement.providerId && placement.onboarding === null) {
87
- flags.includes("addOnboarding") || flags.push("addOnboarding");
88
- } else {
89
- flags = flags.filter((x) => x !== "addOnboarding");
90
- }
91
-
92
- 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)) {
93
- flags.includes("reviewOnboarding") || flags.push("reviewOnboarding");
94
- } else {
95
- flags = flags.filter((x) => x !== "reviewOnboarding");
96
- }
97
-
98
- if (placement.inProgress && user.userType === "Students" && placement.onboarding && (!placement.onboarding.completed || (placement.onboarding.completed && !placement.onboarding.completed?.submitted)) && (placement.inProgress || placement.active)) {
99
- flags.includes("completeOnboarding") || flags.push("completeOnboarding");
100
- } else {
101
- flags = flags.filter((x) => x !== "completeOnboarding");
102
- }
103
-
104
-
105
- return flags;
106
- };
107
-
108
-
109
- export function objectsEqualNew(a: any, b: any): boolean { // Works with arrays or objects.
110
- if (a === b) {
111
- return true;
112
- }
113
-
114
- if (typeof a !== typeof b) {
115
- return false;
116
- }
117
-
118
- if (Array.isArray(a) && Array.isArray(b)) {
119
- if (a.length !== b.length) {
120
- return false;
121
- }
122
- for (let i = 0; i < a.length; i++) {
123
- if (!objectsEqualNew(a[i], b[i])) {
124
- return false;
125
- }
126
- }
127
- return true;
128
- }
129
-
130
- if (typeof a === "object" && typeof b === "object" && a !== null && b !== null) {
131
- const keysA = Object.keys(a);
132
- const keysB = Object.keys(b);
133
-
134
- if (keysA.length !== keysB.length) {
135
- return false;
136
- }
137
-
138
- for (const key of keysA) {
139
- if (!keysB.includes(key)) {
140
- return false;
141
- }
142
- if (!objectsEqualNew(a[key], b[key])) {
143
- return false;
144
- }
145
- }
146
- return true;
147
- }
148
-
149
- return false;
150
- }
1
+ import {where} from "firebase/firestore";
2
+ import FirebaseQuery from "./firebase/firebaseQuery";
3
+ import {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)
12
+ };
13
+ /**
14
+ * Description of function
15
+ *
16
+ */
17
+
18
+ type PlaceFlagCodeReturn = Promise<FlagCodes[]>;
19
+
20
+ export const getPlacementFlagCodes = async ({placement, studentData, workflow, institute, user}: PlacementFlagCodeParams):PlaceFlagCodeReturn => {
21
+ let flags:FlagCodes[] = placement.flags || [];
22
+
23
+ const firebaseQuery = new FirebaseQuery();
24
+
25
+ if (!studentData.details.parentEmail && !flags.find((x) => x.includes("noParentEmail"))) {
26
+ if (workflow.find((obj) => obj.id === placement.status)?.userType === "Parent") {
27
+ flags.includes("noParentEmailWarning") || flags.push("noParentEmailError");
28
+ } else if (workflow.find((obj) => obj.userType === "Parent")) {
29
+ flags.includes("noParentEmailWarning") || flags.push("noParentEmailError");
30
+ }
31
+ }
32
+
33
+ // If placement after provider review and not verified
34
+ const placementIsPostProviderReview = placement.leadTimes.some((x) => x.split("_")[0] === "3");
35
+ const placementNotEnded = !placement.leadTimes.some((x) => x.split("_")[0] === "8");
36
+ const providerUnverified = placement.providerId && !institute?.verifiedProviders?.includes(placement.providerId);
37
+ const awaitingProviderInsurance = placement.providerId && institute?.awaitingProviderInsurance?.includes(placement.providerId);
38
+
39
+ const riskAssessmentNotVerified = !institute?.verifiedRiskAssessments?.includes(placement.placementId || placement.id);
40
+ const awaitingRiskAssessment = !placement.riskAssessment || institute?.awaitingPlacementRiskAssessments?.includes(placement.placementId || placement.id);
41
+
42
+ const dbsCheckNotVerified = !institute?.verifiedDbsChecks?.includes(placement.placementId || placement.id);
43
+ const awaitingDbsCheck = !placement.dbsCheck || institute?.awaitingPlacementDbsChecks?.includes(placement.placementId || placement.id);
44
+
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) {
52
+ console.log("Add insurance flag!");
53
+ flags.includes("noInsurance") || flags.push("noInsurance");
54
+ } else {
55
+ flags = flags.filter((x) => x !== "noInsurance");
56
+ }
57
+
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) {
66
+ flags.includes("awaitingInsurance") || flags.push("awaitingInsurance");
67
+ } else {
68
+ flags = flags.filter((x) => x !== "awaitingInsurance");
69
+ }
70
+
71
+ if (user.userType === "Staff" && user.product === "institutes" && placement.dbsCheck && workflow.find((stage) => stage.dbsCheck) && placement.dbsCheck !== true && placementIsPostProviderReview && placementNotEnded && dbsCheckNotVerified && !awaitingDbsCheck) {
72
+ flags.includes("noDbsCheck") || flags.push("noDbsCheck");
73
+ } else {
74
+ flags = flags.filter((x) => x !== "noDbsCheck");
75
+ }
76
+
77
+ if (user.userType === "Staff" && user.product === "institutes" && placementIsPostProviderReview && workflow.find((stage) => stage.dbsCheck) && placementNotEnded && awaitingProviderInsurance) {
78
+ flags.includes("awaitingDbsCheck") || flags.push("awaitingDbsCheck");
79
+ } else {
80
+ flags = flags.filter((x) => x !== "awaitingDbsCheck");
81
+ }
82
+
83
+ if (user.userType === "Staff" && user.product === "institutes" && placement.riskAssessment && workflow.find((stage) => stage.riskAssessment) && placement.riskAssessment !== true && placementIsPostProviderReview && placementNotEnded && riskAssessmentNotVerified && !awaitingRiskAssessment) {
84
+ console.log("Add RA flag!");
85
+ flags.includes("noRiskAssessment") || flags.push("noRiskAssessment");
86
+ } else {
87
+ flags = flags.filter((x) => x !== "noRiskAssessment");
88
+ }
89
+
90
+ if (user.userType === "Staff" && user.product === "institutes" && placementIsPostProviderReview && workflow.find((stage) => stage.riskAssessment) && placementNotEnded && awaitingProviderInsurance) {
91
+ flags.includes("awaitingRiskAssessment") || flags.push("awaitingRiskAssessment");
92
+ } else {
93
+ flags = flags.filter((x) => x !== "awaitingRiskAssessment");
94
+ }
95
+
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)) {
103
+ flags.includes("reviewOnboarding") || flags.push("reviewOnboarding");
104
+ } else {
105
+ flags = flags.filter((x) => x !== "reviewOnboarding");
106
+ }
107
+
108
+ if (placement.inProgress && user.userType === "Students" && placement.onboarding && (!placement.onboarding.completed || (placement.onboarding.completed && !placement.onboarding.completed?.submitted)) && (placement.inProgress || placement.active)) {
109
+ flags.includes("completeOnboarding") || flags.push("completeOnboarding");
110
+ } else {
111
+ flags = flags.filter((x) => x !== "completeOnboarding");
112
+ }
113
+
114
+
115
+ return flags;
116
+ };
117
+
118
+
119
+ export function objectsEqualNew(a: any, b: any): boolean { // Works with arrays or objects.
120
+ if (a === b) {
121
+ return true;
122
+ }
123
+
124
+ if (typeof a !== typeof b) {
125
+ return false;
126
+ }
127
+
128
+ if (Array.isArray(a) && Array.isArray(b)) {
129
+ if (a.length !== b.length) {
130
+ return false;
131
+ }
132
+ for (let i = 0; i < a.length; i++) {
133
+ if (!objectsEqualNew(a[i], b[i])) {
134
+ return false;
135
+ }
136
+ }
137
+ return true;
138
+ }
139
+
140
+ if (typeof a === "object" && typeof b === "object" && a !== null && b !== null) {
141
+ const keysA = Object.keys(a);
142
+ const keysB = Object.keys(b);
143
+
144
+ if (keysA.length !== keysB.length) {
145
+ return false;
146
+ }
147
+
148
+ for (const key of keysA) {
149
+ if (!keysB.includes(key)) {
150
+ return false;
151
+ }
152
+ if (!objectsEqualNew(a[key], b[key])) {
153
+ return false;
154
+ }
155
+ }
156
+ return true;
157
+ }
158
+
159
+ return false;
160
+ }
package/tsconfig.dev.json CHANGED
@@ -1,5 +1,5 @@
1
- {
2
- "include": [
3
- ".eslintrc.js"
4
- ]
5
- }
1
+ {
2
+ "include": [
3
+ ".eslintrc.js"
4
+ ]
5
+ }
package/tsconfig.json CHANGED
@@ -1,23 +1,22 @@
1
- {
2
- "compilerOptions": {
3
- "module": "commonjs",
4
- "noImplicitReturns": true,
5
- "noImplicitAny": false,
6
- "noUnusedLocals": true,
7
- "outDir": "lib",
8
- "sourceMap": true,
9
- "strict": true,
10
- "target": "ES2019",
11
- "declaration": true,
12
- "declarationDir": "lib",
13
- "jsx": "react",
14
- "noEmit": false,
15
- "esModuleInterop": true,
16
- "experimentalDecorators": true
17
- // "skipLibCheck": true
18
- },
19
- "compileOnSave": true,
20
- "include": [ "src", "../index.test.js", "prisma" ],
21
- "exclude": [ "node_modules", "lib" ],
22
- }
1
+ {
2
+ "compilerOptions": {
3
+ "module": "commonjs",
4
+ "noImplicitReturns": true,
5
+ "noImplicitAny": false,
6
+ "noUnusedLocals": true,
7
+ "outDir": "lib",
8
+ "sourceMap": true,
9
+ "strict": true,
10
+ "target": "ES2019",
11
+ "declaration": true,
12
+ "declarationDir": "lib",
13
+ "jsx": "react",
14
+ "noEmit": false,
15
+ "esModuleInterop": true,
16
+ "experimentalDecorators": true
17
+ },
18
+ "compileOnSave": true,
19
+ "include": [ "src", "../index.test.js", "prisma" ],
20
+ "exclude": [ "node_modules", "lib" ]
21
+ }
23
22