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.
- package/.eslintrc.js +40 -40
- package/.gitattributes +2 -2
- package/lib/constants.js +10 -1
- package/lib/constants.js.map +1 -1
- package/lib/features/config.d.ts +133 -133
- package/lib/features/config.js +35 -35
- package/lib/features/contacts/contacts.d.ts +75 -75
- package/lib/features/contacts/contacts.js +105 -105
- package/lib/features/downtime/useDowntime.d.ts +11 -11
- package/lib/features/downtime/useDowntime.js +22 -22
- package/lib/features/placements/studentPlacements/studentPlacementsSlice.d.ts +63 -63
- package/lib/features/placements/studentPlacements/studentPlacementsSlice.js +81 -81
- package/lib/features/providerPlacements/providerPlacementsSlice.d.ts +19 -19
- package/lib/features/providerPlacements/providerPlacementsSlice.js +24 -24
- package/lib/features/studentPlacements/studentPlacementsSlice.d.ts +62 -62
- package/lib/features/studentPlacements/studentPlacementsSlice.js +87 -87
- package/lib/features/studentPlacements/useStudentPlacements.d.ts +6 -6
- package/lib/features/studentPlacements/useStudentPlacements.js +18 -18
- package/lib/features/userSlice.d.ts +26 -26
- package/lib/features/userSlice.js +23 -23
- package/lib/features/users/useUserFunctions.d.ts +25 -25
- package/lib/features/users/useUserFunctions.js +124 -124
- package/lib/features/users/userSlice.d.ts +46 -46
- package/lib/features/users/userSlice.js +48 -48
- package/lib/firebase/firebase.d.ts +1 -1
- package/lib/firebase/firebase.js +6 -2
- package/lib/firebase/firebase.js.map +1 -1
- package/lib/firebase/readDatabase.js +3 -1
- package/lib/firebase/readDatabase.js.map +1 -1
- package/lib/hooks.d.ts +33 -5
- package/lib/hooks.js +143 -107
- package/lib/hooks.js.map +1 -1
- package/lib/images/GatsbyBenchmarks.d.ts +1 -2
- package/lib/reduxHooks.d.ts +1 -66
- package/lib/reduxHooks.js +9 -69
- package/lib/reduxHooks.js.map +1 -1
- package/lib/tasksAndTips.d.ts +2 -2
- package/lib/tasksAndTips.js +37 -6
- package/lib/tasksAndTips.js.map +1 -1
- package/lib/typeDefinitions.d.ts +50 -5
- package/lib/util.d.ts +1 -1
- package/lib/util.js +12 -1
- package/lib/util.js.map +1 -1
- package/package.json +52 -56
- package/src/DatabaseDefinitions.ts +18 -18
- package/src/apiCalls.ts +128 -128
- package/src/config.ts +50 -50
- package/src/constants.ts +796 -787
- package/src/databaseTypes.ts +42 -42
- package/src/features/analytics/useAnalytics.tsx +63 -63
- package/src/features/contacts/contactsSlice.ts +147 -147
- package/src/features/contacts/useContacts.tsx +73 -73
- package/src/features/dropdown/useDropdown.tsx +52 -52
- package/src/features/global/downtime/useDowntime.tsx +23 -23
- package/src/features/global/users/useUserFunctions.tsx +132 -132
- package/src/features/jobs/jobsSlice.ts +71 -71
- package/src/features/placements/studentPlacements/activePlacement.ts +68 -68
- package/src/features/placements/studentPlacements/completedStudentPlacementsSlice.ts +97 -97
- package/src/features/placements/studentPlacements/upcomingStudentPlacementsSlice.ts +108 -108
- package/src/features/placements/studentPlacements/useStudentPlacements.tsx +9 -9
- package/src/features/placements/types.ts +10 -10
- package/src/features/referrals/useReferrals.tsx +56 -56
- package/src/features/updates/useUpdates.tsx +38 -38
- package/src/firebase/firebase.tsx +149 -145
- package/src/firebase/firebaseConfig.tsx +45 -45
- package/src/firebase/firebaseQuery.tsx +151 -151
- package/src/firebase/persistence.ts +84 -84
- package/src/firebase/readDatabase.tsx +236 -235
- package/src/firebase/util.tsx +352 -352
- package/src/firebase/writeDatabase.tsx +77 -77
- package/src/hooks.tsx +4353 -4323
- package/src/images/GatsbyBenchmarks.tsx +711 -711
- package/src/images/LogFuturePlacement.jsx +64 -64
- package/src/images/LogPreviousPlacement.jsx +228 -228
- package/src/images/gatsby_benchmarks.svg +466 -466
- package/src/images/log_future_placement.svg +114 -114
- package/src/images/log_previous_placement.svg +199 -199
- package/src/index.ts +34 -34
- package/src/readDatabase.tsx +3 -3
- package/src/reduxHooks.ts +232 -297
- package/src/tasksAndTips.ts +1209 -1177
- package/src/tutorialTips.ts +58 -58
- package/src/typeDefinitions.ts +1003 -958
- package/src/util.ts +160 -150
- package/tsconfig.dev.json +5 -5
- package/tsconfig.json +21 -22
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { UserData } from "../typeDefinitions";
|
|
2
|
-
export declare const userSlice: import("@reduxjs/toolkit").Slice<{
|
|
3
|
-
user: UserData | null;
|
|
4
|
-
status: "normal" | "loading" | "success";
|
|
5
|
-
}, {
|
|
6
|
-
setUser: (state: import("immer/dist/internal").WritableDraft<{
|
|
7
|
-
user: UserData | null;
|
|
8
|
-
status: "normal" | "loading" | "success";
|
|
9
|
-
}>, action: {
|
|
10
|
-
payload: any;
|
|
11
|
-
type: string;
|
|
12
|
-
}) => void;
|
|
13
|
-
setStatus: (state: import("immer/dist/internal").WritableDraft<{
|
|
14
|
-
user: UserData | null;
|
|
15
|
-
status: "normal" | "loading" | "success";
|
|
16
|
-
}>, action: {
|
|
17
|
-
payload: any;
|
|
18
|
-
type: string;
|
|
19
|
-
}) => void;
|
|
20
|
-
}, "user">;
|
|
21
|
-
export declare const setUser: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "user/setUser">, setStatus: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "user/setStatus">;
|
|
22
|
-
declare const _default: import("redux").Reducer<{
|
|
23
|
-
user: UserData | null;
|
|
24
|
-
status: "normal" | "loading" | "success";
|
|
25
|
-
}>;
|
|
26
|
-
export default _default;
|
|
1
|
+
import { UserData } from "../typeDefinitions";
|
|
2
|
+
export declare const userSlice: import("@reduxjs/toolkit").Slice<{
|
|
3
|
+
user: UserData | null;
|
|
4
|
+
status: "normal" | "loading" | "success";
|
|
5
|
+
}, {
|
|
6
|
+
setUser: (state: import("immer/dist/internal").WritableDraft<{
|
|
7
|
+
user: UserData | null;
|
|
8
|
+
status: "normal" | "loading" | "success";
|
|
9
|
+
}>, action: {
|
|
10
|
+
payload: any;
|
|
11
|
+
type: string;
|
|
12
|
+
}) => void;
|
|
13
|
+
setStatus: (state: import("immer/dist/internal").WritableDraft<{
|
|
14
|
+
user: UserData | null;
|
|
15
|
+
status: "normal" | "loading" | "success";
|
|
16
|
+
}>, action: {
|
|
17
|
+
payload: any;
|
|
18
|
+
type: string;
|
|
19
|
+
}) => void;
|
|
20
|
+
}, "user">;
|
|
21
|
+
export declare const setUser: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "user/setUser">, setStatus: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "user/setStatus">;
|
|
22
|
+
declare const _default: import("redux").Reducer<{
|
|
23
|
+
user: UserData | null;
|
|
24
|
+
status: "normal" | "loading" | "success";
|
|
25
|
+
}>;
|
|
26
|
+
export default _default;
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var _a;
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.setStatus = exports.setUser = exports.userSlice = void 0;
|
|
5
|
-
const toolkit_1 = require("@reduxjs/toolkit");
|
|
6
|
-
const initialState = {
|
|
7
|
-
user: null,
|
|
8
|
-
status: "normal",
|
|
9
|
-
};
|
|
10
|
-
exports.userSlice = (0, toolkit_1.createSlice)({
|
|
11
|
-
name: "user",
|
|
12
|
-
initialState,
|
|
13
|
-
reducers: {
|
|
14
|
-
setUser: (state, action) => {
|
|
15
|
-
state.user = action.payload;
|
|
16
|
-
},
|
|
17
|
-
setStatus: (state, action) => {
|
|
18
|
-
state.status = action.payload;
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
});
|
|
22
|
-
_a = exports.userSlice.actions, exports.setUser = _a.setUser, exports.setStatus = _a.setStatus;
|
|
23
|
-
exports.default = exports.userSlice.reducer;
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.setStatus = exports.setUser = exports.userSlice = void 0;
|
|
5
|
+
const toolkit_1 = require("@reduxjs/toolkit");
|
|
6
|
+
const initialState = {
|
|
7
|
+
user: null,
|
|
8
|
+
status: "normal",
|
|
9
|
+
};
|
|
10
|
+
exports.userSlice = (0, toolkit_1.createSlice)({
|
|
11
|
+
name: "user",
|
|
12
|
+
initialState,
|
|
13
|
+
reducers: {
|
|
14
|
+
setUser: (state, action) => {
|
|
15
|
+
state.user = action.payload;
|
|
16
|
+
},
|
|
17
|
+
setStatus: (state, action) => {
|
|
18
|
+
state.status = action.payload;
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
_a = exports.userSlice.actions, exports.setUser = _a.setUser, exports.setStatus = _a.setStatus;
|
|
23
|
+
exports.default = exports.userSlice.reducer;
|
|
24
24
|
//# sourceMappingURL=userSlice.js.map
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { UserData, StudentPlacementData } from '../../typeDefinitions';
|
|
3
|
-
export default function useUserFunctions(): {
|
|
4
|
-
update: (attributes: any) => Promise<void>;
|
|
5
|
-
};
|
|
6
|
-
export declare function useActivationCode(): {
|
|
7
|
-
code: string;
|
|
8
|
-
setCode: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
9
|
-
submitCode: (skip?: boolean) => Promise<void>;
|
|
10
|
-
resendCode: () => Promise<void>;
|
|
11
|
-
newCodeSent: boolean | undefined;
|
|
12
|
-
timer: number;
|
|
13
|
-
};
|
|
14
|
-
export declare function useContactProviderConsent(): {
|
|
15
|
-
active: boolean;
|
|
16
|
-
setActive: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
17
|
-
consent: (consent: boolean) => Promise<void>;
|
|
18
|
-
};
|
|
19
|
-
export declare function useGuidance(): {
|
|
20
|
-
updateUserTutorials: () => void;
|
|
21
|
-
};
|
|
22
|
-
export declare function useStudents(user: UserData | null): void;
|
|
23
|
-
export declare function useStudentData(placement: StudentPlacementData, student: UserData): {
|
|
24
|
-
studentData: UserData | undefined;
|
|
25
|
-
};
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { UserData, StudentPlacementData } from '../../typeDefinitions';
|
|
3
|
+
export default function useUserFunctions(): {
|
|
4
|
+
update: (attributes: any) => Promise<void>;
|
|
5
|
+
};
|
|
6
|
+
export declare function useActivationCode(): {
|
|
7
|
+
code: string;
|
|
8
|
+
setCode: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
9
|
+
submitCode: (skip?: boolean) => Promise<void>;
|
|
10
|
+
resendCode: () => Promise<void>;
|
|
11
|
+
newCodeSent: boolean | undefined;
|
|
12
|
+
timer: number;
|
|
13
|
+
};
|
|
14
|
+
export declare function useContactProviderConsent(): {
|
|
15
|
+
active: boolean;
|
|
16
|
+
setActive: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
17
|
+
consent: (consent: boolean) => Promise<void>;
|
|
18
|
+
};
|
|
19
|
+
export declare function useGuidance(): {
|
|
20
|
+
updateUserTutorials: () => void;
|
|
21
|
+
};
|
|
22
|
+
export declare function useStudents(user: UserData | null): void;
|
|
23
|
+
export declare function useStudentData(placement: StudentPlacementData, student: UserData): {
|
|
24
|
+
studentData: UserData | undefined;
|
|
25
|
+
};
|
|
@@ -1,125 +1,125 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.useStudentData = exports.useStudents = exports.useGuidance = exports.useContactProviderConsent = exports.useActivationCode = void 0;
|
|
7
|
-
const reduxHooks_1 = require("../../reduxHooks");
|
|
8
|
-
const react_1 = require("react");
|
|
9
|
-
const util_1 = require("../../firebase/util");
|
|
10
|
-
const firebase_1 = require("../../firebase/firebase");
|
|
11
|
-
const userSlice_1 = require("./userSlice");
|
|
12
|
-
const firestore_1 = require("firebase/firestore");
|
|
13
|
-
const firebaseQuery_1 = __importDefault(require("../../firebase/firebaseQuery"));
|
|
14
|
-
function useUserFunctions() {
|
|
15
|
-
const dispatch = (0, reduxHooks_1.useAppDispatch)();
|
|
16
|
-
const { user } = (0, reduxHooks_1.useAppSelector)((state) => state.user);
|
|
17
|
-
const update = async (attributes) => {
|
|
18
|
-
if (!user)
|
|
19
|
-
return;
|
|
20
|
-
dispatch((0, userSlice_1.updateUser)({ userId: user.id, attributes: attributes }));
|
|
21
|
-
};
|
|
22
|
-
return ({ ...{ update } });
|
|
23
|
-
}
|
|
24
|
-
exports.default = useUserFunctions;
|
|
25
|
-
function useActivationCode() {
|
|
26
|
-
const [code, setCode] = (0, react_1.useState)("");
|
|
27
|
-
const [newCodeSent, setNewCodeSent] = (0, react_1.useState)(false);
|
|
28
|
-
const [timer, setTimer] = (0, react_1.useState)(30);
|
|
29
|
-
const { user } = (0, reduxHooks_1.useAppSelector)((state) => state.user);
|
|
30
|
-
const dispatch = (0, reduxHooks_1.useAppDispatch)();
|
|
31
|
-
(0, react_1.useEffect)(() => {
|
|
32
|
-
setInterval(() => {
|
|
33
|
-
setTimer((t) => t > 0 ? t - 1 : t);
|
|
34
|
-
}, 1000);
|
|
35
|
-
}, []);
|
|
36
|
-
const submitCode = async (skip) => {
|
|
37
|
-
if (!user)
|
|
38
|
-
return;
|
|
39
|
-
if (skip || (parseInt(code) === user.activationCode)) {
|
|
40
|
-
//firebaseQuery.update(["users", user.id], {activated: dateToString(new Date()), status: "active"})
|
|
41
|
-
dispatch((0, userSlice_1.updateUser)({ userId: user.id, attributes: { activated: (0, util_1.dateToString)(new Date()), status: "active" } }));
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
const resendCode = async () => {
|
|
45
|
-
setNewCodeSent(undefined);
|
|
46
|
-
await (0, firebase_1.executeCallable)("registration-resendCode", {});
|
|
47
|
-
setNewCodeSent(true);
|
|
48
|
-
setTimer(30);
|
|
49
|
-
};
|
|
50
|
-
return ({ ...{ code, setCode, submitCode, resendCode, newCodeSent, timer } });
|
|
51
|
-
}
|
|
52
|
-
exports.useActivationCode = useActivationCode;
|
|
53
|
-
function useContactProviderConsent() {
|
|
54
|
-
const [active, setActive] = (0, react_1.useState)(false);
|
|
55
|
-
const { user } = (0, reduxHooks_1.useAppSelector)((state) => state.user);
|
|
56
|
-
const dispatch = (0, reduxHooks_1.useAppDispatch)();
|
|
57
|
-
const consent = async (consent) => {
|
|
58
|
-
if (!user)
|
|
59
|
-
return;
|
|
60
|
-
try {
|
|
61
|
-
// await firebaseQuery.update(["users", user.id], {
|
|
62
|
-
// contactProviderConsent: consent,
|
|
63
|
-
// contactProviderConsenDate: (new Date()).toISOString()
|
|
64
|
-
// })
|
|
65
|
-
dispatch((0, userSlice_1.updateUser)({ userId: user.id, attributes: {
|
|
66
|
-
contactProviderConsent: consent,
|
|
67
|
-
contactProviderConsentDate: (new Date()).toISOString()
|
|
68
|
-
}
|
|
69
|
-
}));
|
|
70
|
-
setActive(false);
|
|
71
|
-
}
|
|
72
|
-
catch (error) {
|
|
73
|
-
console.log(error);
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
return ({ ...{ active, setActive, consent } });
|
|
77
|
-
}
|
|
78
|
-
exports.useContactProviderConsent = useContactProviderConsent;
|
|
79
|
-
function useGuidance() {
|
|
80
|
-
const { user } = (0, reduxHooks_1.useAppSelector)((state) => state.user);
|
|
81
|
-
const dispatch = (0, reduxHooks_1.useAppDispatch)();
|
|
82
|
-
const updateUserTutorials = () => {
|
|
83
|
-
if (!user)
|
|
84
|
-
return;
|
|
85
|
-
try {
|
|
86
|
-
//firebaseQuery.update(["users", user.id], {dismissedTutorials: arrayUnion("studentIntro")});
|
|
87
|
-
dispatch((0, userSlice_1.updateUser)({ userId: user.id, attributes: { dismissedTutorials: (0, firestore_1.arrayUnion)("studentIntro") } }));
|
|
88
|
-
}
|
|
89
|
-
catch (error) {
|
|
90
|
-
console.log(error);
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
return ({ ...{ updateUserTutorials } });
|
|
94
|
-
}
|
|
95
|
-
exports.useGuidance = useGuidance;
|
|
96
|
-
function useStudents(user) {
|
|
97
|
-
const dispatch = (0, reduxHooks_1.useAppDispatch)();
|
|
98
|
-
(0, react_1.useEffect)(() => {
|
|
99
|
-
if (!(user === null || user === void 0 ? void 0 : user.id))
|
|
100
|
-
return;
|
|
101
|
-
// firebaseQuery.update(["users", user?.id], {lastAccessed: convertDate(new Date(), "dbstring")})
|
|
102
|
-
dispatch((0, userSlice_1.updateUser)({ userId: user.id, attributes: { lastAccessed: (0, util_1.convertDate)(new Date(), "dbstring") } }));
|
|
103
|
-
if (!(user === null || user === void 0 ? void 0 : user.phone) && (user === null || user === void 0 ? void 0 : user.status) === "inactive") {
|
|
104
|
-
// firebaseQuery.update(["users", user.id], {status: "active"})
|
|
105
|
-
dispatch((0, userSlice_1.updateUser)({ userId: user.id, attributes: { status: "active" } }));
|
|
106
|
-
}
|
|
107
|
-
;
|
|
108
|
-
}, []);
|
|
109
|
-
}
|
|
110
|
-
exports.useStudents = useStudents;
|
|
111
|
-
function useStudentData(placement, student) {
|
|
112
|
-
const firebaseQuery = new firebaseQuery_1.default();
|
|
113
|
-
const [studentData, setStudentData] = (0, react_1.useState)();
|
|
114
|
-
(0, react_1.useEffect)(() => {
|
|
115
|
-
const getStudentData = async () => {
|
|
116
|
-
return student ? student : (await firebaseQuery.getDocData(["users", placement.uid]));
|
|
117
|
-
};
|
|
118
|
-
getStudentData().then((data) => {
|
|
119
|
-
setStudentData(data);
|
|
120
|
-
});
|
|
121
|
-
}, []);
|
|
122
|
-
return ({ ...{ studentData } });
|
|
123
|
-
}
|
|
124
|
-
exports.useStudentData = useStudentData;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.useStudentData = exports.useStudents = exports.useGuidance = exports.useContactProviderConsent = exports.useActivationCode = void 0;
|
|
7
|
+
const reduxHooks_1 = require("../../reduxHooks");
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const util_1 = require("../../firebase/util");
|
|
10
|
+
const firebase_1 = require("../../firebase/firebase");
|
|
11
|
+
const userSlice_1 = require("./userSlice");
|
|
12
|
+
const firestore_1 = require("firebase/firestore");
|
|
13
|
+
const firebaseQuery_1 = __importDefault(require("../../firebase/firebaseQuery"));
|
|
14
|
+
function useUserFunctions() {
|
|
15
|
+
const dispatch = (0, reduxHooks_1.useAppDispatch)();
|
|
16
|
+
const { user } = (0, reduxHooks_1.useAppSelector)((state) => state.user);
|
|
17
|
+
const update = async (attributes) => {
|
|
18
|
+
if (!user)
|
|
19
|
+
return;
|
|
20
|
+
dispatch((0, userSlice_1.updateUser)({ userId: user.id, attributes: attributes }));
|
|
21
|
+
};
|
|
22
|
+
return ({ ...{ update } });
|
|
23
|
+
}
|
|
24
|
+
exports.default = useUserFunctions;
|
|
25
|
+
function useActivationCode() {
|
|
26
|
+
const [code, setCode] = (0, react_1.useState)("");
|
|
27
|
+
const [newCodeSent, setNewCodeSent] = (0, react_1.useState)(false);
|
|
28
|
+
const [timer, setTimer] = (0, react_1.useState)(30);
|
|
29
|
+
const { user } = (0, reduxHooks_1.useAppSelector)((state) => state.user);
|
|
30
|
+
const dispatch = (0, reduxHooks_1.useAppDispatch)();
|
|
31
|
+
(0, react_1.useEffect)(() => {
|
|
32
|
+
setInterval(() => {
|
|
33
|
+
setTimer((t) => t > 0 ? t - 1 : t);
|
|
34
|
+
}, 1000);
|
|
35
|
+
}, []);
|
|
36
|
+
const submitCode = async (skip) => {
|
|
37
|
+
if (!user)
|
|
38
|
+
return;
|
|
39
|
+
if (skip || (parseInt(code) === user.activationCode)) {
|
|
40
|
+
//firebaseQuery.update(["users", user.id], {activated: dateToString(new Date()), status: "active"})
|
|
41
|
+
dispatch((0, userSlice_1.updateUser)({ userId: user.id, attributes: { activated: (0, util_1.dateToString)(new Date()), status: "active" } }));
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const resendCode = async () => {
|
|
45
|
+
setNewCodeSent(undefined);
|
|
46
|
+
await (0, firebase_1.executeCallable)("registration-resendCode", {});
|
|
47
|
+
setNewCodeSent(true);
|
|
48
|
+
setTimer(30);
|
|
49
|
+
};
|
|
50
|
+
return ({ ...{ code, setCode, submitCode, resendCode, newCodeSent, timer } });
|
|
51
|
+
}
|
|
52
|
+
exports.useActivationCode = useActivationCode;
|
|
53
|
+
function useContactProviderConsent() {
|
|
54
|
+
const [active, setActive] = (0, react_1.useState)(false);
|
|
55
|
+
const { user } = (0, reduxHooks_1.useAppSelector)((state) => state.user);
|
|
56
|
+
const dispatch = (0, reduxHooks_1.useAppDispatch)();
|
|
57
|
+
const consent = async (consent) => {
|
|
58
|
+
if (!user)
|
|
59
|
+
return;
|
|
60
|
+
try {
|
|
61
|
+
// await firebaseQuery.update(["users", user.id], {
|
|
62
|
+
// contactProviderConsent: consent,
|
|
63
|
+
// contactProviderConsenDate: (new Date()).toISOString()
|
|
64
|
+
// })
|
|
65
|
+
dispatch((0, userSlice_1.updateUser)({ userId: user.id, attributes: {
|
|
66
|
+
contactProviderConsent: consent,
|
|
67
|
+
contactProviderConsentDate: (new Date()).toISOString()
|
|
68
|
+
}
|
|
69
|
+
}));
|
|
70
|
+
setActive(false);
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
console.log(error);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
return ({ ...{ active, setActive, consent } });
|
|
77
|
+
}
|
|
78
|
+
exports.useContactProviderConsent = useContactProviderConsent;
|
|
79
|
+
function useGuidance() {
|
|
80
|
+
const { user } = (0, reduxHooks_1.useAppSelector)((state) => state.user);
|
|
81
|
+
const dispatch = (0, reduxHooks_1.useAppDispatch)();
|
|
82
|
+
const updateUserTutorials = () => {
|
|
83
|
+
if (!user)
|
|
84
|
+
return;
|
|
85
|
+
try {
|
|
86
|
+
//firebaseQuery.update(["users", user.id], {dismissedTutorials: arrayUnion("studentIntro")});
|
|
87
|
+
dispatch((0, userSlice_1.updateUser)({ userId: user.id, attributes: { dismissedTutorials: (0, firestore_1.arrayUnion)("studentIntro") } }));
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
console.log(error);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
return ({ ...{ updateUserTutorials } });
|
|
94
|
+
}
|
|
95
|
+
exports.useGuidance = useGuidance;
|
|
96
|
+
function useStudents(user) {
|
|
97
|
+
const dispatch = (0, reduxHooks_1.useAppDispatch)();
|
|
98
|
+
(0, react_1.useEffect)(() => {
|
|
99
|
+
if (!(user === null || user === void 0 ? void 0 : user.id))
|
|
100
|
+
return;
|
|
101
|
+
// firebaseQuery.update(["users", user?.id], {lastAccessed: convertDate(new Date(), "dbstring")})
|
|
102
|
+
dispatch((0, userSlice_1.updateUser)({ userId: user.id, attributes: { lastAccessed: (0, util_1.convertDate)(new Date(), "dbstring") } }));
|
|
103
|
+
if (!(user === null || user === void 0 ? void 0 : user.phone) && (user === null || user === void 0 ? void 0 : user.status) === "inactive") {
|
|
104
|
+
// firebaseQuery.update(["users", user.id], {status: "active"})
|
|
105
|
+
dispatch((0, userSlice_1.updateUser)({ userId: user.id, attributes: { status: "active" } }));
|
|
106
|
+
}
|
|
107
|
+
;
|
|
108
|
+
}, []);
|
|
109
|
+
}
|
|
110
|
+
exports.useStudents = useStudents;
|
|
111
|
+
function useStudentData(placement, student) {
|
|
112
|
+
const firebaseQuery = new firebaseQuery_1.default();
|
|
113
|
+
const [studentData, setStudentData] = (0, react_1.useState)();
|
|
114
|
+
(0, react_1.useEffect)(() => {
|
|
115
|
+
const getStudentData = async () => {
|
|
116
|
+
return student ? student : (await firebaseQuery.getDocData(["users", placement.uid]));
|
|
117
|
+
};
|
|
118
|
+
getStudentData().then((data) => {
|
|
119
|
+
setStudentData(data);
|
|
120
|
+
});
|
|
121
|
+
}, []);
|
|
122
|
+
return ({ ...{ studentData } });
|
|
123
|
+
}
|
|
124
|
+
exports.useStudentData = useStudentData;
|
|
125
125
|
//# sourceMappingURL=useUserFunctions.js.map
|
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import { UserData } from "../../typeDefinitions";
|
|
2
|
-
export declare const updateUser: import("@reduxjs/toolkit").AsyncThunk<any, {
|
|
3
|
-
userId: string;
|
|
4
|
-
attributes: any;
|
|
5
|
-
}, {
|
|
6
|
-
state?: unknown;
|
|
7
|
-
dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
|
|
8
|
-
extra?: unknown;
|
|
9
|
-
rejectValue?: unknown;
|
|
10
|
-
serializedErrorType?: unknown;
|
|
11
|
-
pendingMeta?: unknown;
|
|
12
|
-
fulfilledMeta?: unknown;
|
|
13
|
-
rejectedMeta?: unknown;
|
|
14
|
-
}>;
|
|
15
|
-
export declare const userSlice: import("@reduxjs/toolkit").Slice<{
|
|
16
|
-
user: UserData | null;
|
|
17
|
-
status: "normal" | "loading" | "success";
|
|
18
|
-
}, {
|
|
19
|
-
setUser: (state: import("immer/dist/internal").WritableDraft<{
|
|
20
|
-
user: UserData | null;
|
|
21
|
-
status: "normal" | "loading" | "success";
|
|
22
|
-
}>, action: {
|
|
23
|
-
payload: any;
|
|
24
|
-
type: string;
|
|
25
|
-
}) => void;
|
|
26
|
-
setStatus: (state: import("immer/dist/internal").WritableDraft<{
|
|
27
|
-
user: UserData | null;
|
|
28
|
-
status: "normal" | "loading" | "success";
|
|
29
|
-
}>, action: {
|
|
30
|
-
payload: any;
|
|
31
|
-
type: string;
|
|
32
|
-
}) => void;
|
|
33
|
-
setUserReferralCode: (state: import("immer/dist/internal").WritableDraft<{
|
|
34
|
-
user: UserData | null;
|
|
35
|
-
status: "normal" | "loading" | "success";
|
|
36
|
-
}>, action: {
|
|
37
|
-
payload: any;
|
|
38
|
-
type: string;
|
|
39
|
-
}) => void;
|
|
40
|
-
}, "user">;
|
|
41
|
-
export declare const setUser: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "user/setUser">, setStatus: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "user/setStatus">;
|
|
42
|
-
declare const _default: import("redux").Reducer<{
|
|
43
|
-
user: UserData | null;
|
|
44
|
-
status: "normal" | "loading" | "success";
|
|
45
|
-
}>;
|
|
46
|
-
export default _default;
|
|
1
|
+
import { UserData } from "../../typeDefinitions";
|
|
2
|
+
export declare const updateUser: import("@reduxjs/toolkit").AsyncThunk<any, {
|
|
3
|
+
userId: string;
|
|
4
|
+
attributes: any;
|
|
5
|
+
}, {
|
|
6
|
+
state?: unknown;
|
|
7
|
+
dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
|
|
8
|
+
extra?: unknown;
|
|
9
|
+
rejectValue?: unknown;
|
|
10
|
+
serializedErrorType?: unknown;
|
|
11
|
+
pendingMeta?: unknown;
|
|
12
|
+
fulfilledMeta?: unknown;
|
|
13
|
+
rejectedMeta?: unknown;
|
|
14
|
+
}>;
|
|
15
|
+
export declare const userSlice: import("@reduxjs/toolkit").Slice<{
|
|
16
|
+
user: UserData | null;
|
|
17
|
+
status: "normal" | "loading" | "success";
|
|
18
|
+
}, {
|
|
19
|
+
setUser: (state: import("immer/dist/internal").WritableDraft<{
|
|
20
|
+
user: UserData | null;
|
|
21
|
+
status: "normal" | "loading" | "success";
|
|
22
|
+
}>, action: {
|
|
23
|
+
payload: any;
|
|
24
|
+
type: string;
|
|
25
|
+
}) => void;
|
|
26
|
+
setStatus: (state: import("immer/dist/internal").WritableDraft<{
|
|
27
|
+
user: UserData | null;
|
|
28
|
+
status: "normal" | "loading" | "success";
|
|
29
|
+
}>, action: {
|
|
30
|
+
payload: any;
|
|
31
|
+
type: string;
|
|
32
|
+
}) => void;
|
|
33
|
+
setUserReferralCode: (state: import("immer/dist/internal").WritableDraft<{
|
|
34
|
+
user: UserData | null;
|
|
35
|
+
status: "normal" | "loading" | "success";
|
|
36
|
+
}>, action: {
|
|
37
|
+
payload: any;
|
|
38
|
+
type: string;
|
|
39
|
+
}) => void;
|
|
40
|
+
}, "user">;
|
|
41
|
+
export declare const setUser: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "user/setUser">, setStatus: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "user/setStatus">;
|
|
42
|
+
declare const _default: import("redux").Reducer<{
|
|
43
|
+
user: UserData | null;
|
|
44
|
+
status: "normal" | "loading" | "success";
|
|
45
|
+
}>;
|
|
46
|
+
export default _default;
|
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
var _a;
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.setStatus = exports.setUser = exports.userSlice = exports.updateUser = void 0;
|
|
8
|
-
const toolkit_1 = require("@reduxjs/toolkit");
|
|
9
|
-
const firebaseQuery_1 = __importDefault(require("../../firebase/firebaseQuery"));
|
|
10
|
-
const initialState = {
|
|
11
|
-
user: null,
|
|
12
|
-
status: "normal",
|
|
13
|
-
};
|
|
14
|
-
exports.updateUser = (0, toolkit_1.createAsyncThunk)("user/update", async ({ userId, attributes }, { rejectWithValue }) => {
|
|
15
|
-
const firebaseQuery = new firebaseQuery_1.default();
|
|
16
|
-
try {
|
|
17
|
-
await firebaseQuery.update(["users", userId], attributes);
|
|
18
|
-
return attributes;
|
|
19
|
-
}
|
|
20
|
-
catch (error) {
|
|
21
|
-
return rejectWithValue(error);
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
exports.userSlice = (0, toolkit_1.createSlice)({
|
|
25
|
-
name: "user",
|
|
26
|
-
initialState,
|
|
27
|
-
reducers: {
|
|
28
|
-
setUser: (state, action) => {
|
|
29
|
-
state.user = action.payload;
|
|
30
|
-
},
|
|
31
|
-
setStatus: (state, action) => {
|
|
32
|
-
state.status = action.payload;
|
|
33
|
-
},
|
|
34
|
-
setUserReferralCode: (state, action) => {
|
|
35
|
-
if (!state.user)
|
|
36
|
-
return;
|
|
37
|
-
state.user.referralCode = action.payload;
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
extraReducers: (builder) => {
|
|
41
|
-
builder
|
|
42
|
-
.addCase(exports.updateUser.fulfilled, (state, action) => {
|
|
43
|
-
state.user = { ...state.user, ...action.payload };
|
|
44
|
-
});
|
|
45
|
-
},
|
|
46
|
-
});
|
|
47
|
-
_a = exports.userSlice.actions, exports.setUser = _a.setUser, exports.setStatus = _a.setStatus;
|
|
48
|
-
exports.default = exports.userSlice.reducer;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
var _a;
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.setStatus = exports.setUser = exports.userSlice = exports.updateUser = void 0;
|
|
8
|
+
const toolkit_1 = require("@reduxjs/toolkit");
|
|
9
|
+
const firebaseQuery_1 = __importDefault(require("../../firebase/firebaseQuery"));
|
|
10
|
+
const initialState = {
|
|
11
|
+
user: null,
|
|
12
|
+
status: "normal",
|
|
13
|
+
};
|
|
14
|
+
exports.updateUser = (0, toolkit_1.createAsyncThunk)("user/update", async ({ userId, attributes }, { rejectWithValue }) => {
|
|
15
|
+
const firebaseQuery = new firebaseQuery_1.default();
|
|
16
|
+
try {
|
|
17
|
+
await firebaseQuery.update(["users", userId], attributes);
|
|
18
|
+
return attributes;
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
return rejectWithValue(error);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
exports.userSlice = (0, toolkit_1.createSlice)({
|
|
25
|
+
name: "user",
|
|
26
|
+
initialState,
|
|
27
|
+
reducers: {
|
|
28
|
+
setUser: (state, action) => {
|
|
29
|
+
state.user = action.payload;
|
|
30
|
+
},
|
|
31
|
+
setStatus: (state, action) => {
|
|
32
|
+
state.status = action.payload;
|
|
33
|
+
},
|
|
34
|
+
setUserReferralCode: (state, action) => {
|
|
35
|
+
if (!state.user)
|
|
36
|
+
return;
|
|
37
|
+
state.user.referralCode = action.payload;
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
extraReducers: (builder) => {
|
|
41
|
+
builder
|
|
42
|
+
.addCase(exports.updateUser.fulfilled, (state, action) => {
|
|
43
|
+
state.user = { ...state.user, ...action.payload };
|
|
44
|
+
});
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
_a = exports.userSlice.actions, exports.setUser = _a.setUser, exports.setStatus = _a.setStatus;
|
|
48
|
+
exports.default = exports.userSlice.reducer;
|
|
49
49
|
//# sourceMappingURL=userSlice.js.map
|
|
@@ -24,7 +24,7 @@ export declare const executeCallable: (functionName: string, data: unknown) => P
|
|
|
24
24
|
export declare function useExecuteCallableJob({ user }: {
|
|
25
25
|
user: UserData;
|
|
26
26
|
}): {
|
|
27
|
-
execute: (functionName: "userManagement-addUsers" | "userManagement-activateUsers" | "userManagement-deactivateUsers" | "userManagement-deleteUsers" | "admissions-createCohort" | "userManagement-uploadAnalytics" | "placementListing-add", data: {
|
|
27
|
+
execute: (functionName: "userManagement-addUsers" | "userManagement-activateUsers" | "userManagement-deactivateUsers" | "userManagement-deleteUsers" | "admissions-createCohort" | "userManagement-uploadAnalytics" | "placementListing-add" | "userManagement-sendParentWelcomeEmail", data: {
|
|
28
28
|
[key: string]: unknown;
|
|
29
29
|
}) => Promise<string>;
|
|
30
30
|
};
|
package/lib/firebase/firebase.js
CHANGED
|
@@ -25,12 +25,10 @@ const authListener = (setUser) => {
|
|
|
25
25
|
};
|
|
26
26
|
exports.authListener = authListener;
|
|
27
27
|
const login = async (credentials) => {
|
|
28
|
-
console.log("creds", credentials);
|
|
29
28
|
return (0, auth_1.signInWithEmailAndPassword)(firebaseConfig_1.auth, credentials.email, credentials.password);
|
|
30
29
|
};
|
|
31
30
|
exports.login = login;
|
|
32
31
|
const register = async (credentials, type) => {
|
|
33
|
-
console.log("creds", credentials);
|
|
34
32
|
return await (0, exports.executeCallable)(`registration-register${type}`, credentials).catch((e) => {
|
|
35
33
|
console.log("Error in regsiter", e);
|
|
36
34
|
throw e;
|
|
@@ -85,6 +83,12 @@ function useExecuteCallableJob({ user }) {
|
|
|
85
83
|
title: "Adding placements",
|
|
86
84
|
description: `Attempting addition of ${data.data.length} placements`,
|
|
87
85
|
};
|
|
86
|
+
case "userManagement-sendParentWelcomeEmail":
|
|
87
|
+
return {
|
|
88
|
+
title: "Sending parent welcome emails",
|
|
89
|
+
description: `Sending parent welcome emails to ${Array.isArray(data.users) ?
|
|
90
|
+
"multiple" : Object.entries(data.users).length || "multiple"} users.`,
|
|
91
|
+
};
|
|
88
92
|
default:
|
|
89
93
|
return;
|
|
90
94
|
}
|