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,53 +1,53 @@
|
|
|
1
|
-
import {useState, useEffect} from "react"
|
|
2
|
-
import FirebaseQuery from "../../firebase/firebaseQuery";
|
|
3
|
-
import {countryList} from "../../constants";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export interface DropdownProps {
|
|
7
|
-
defaultValue?: string;
|
|
8
|
-
required?: boolean;
|
|
9
|
-
id?: string;
|
|
10
|
-
disabled?: boolean,
|
|
11
|
-
onValueChange?: (value: string) => void;
|
|
12
|
-
value?: string;
|
|
13
|
-
mode?: "default" | "modal"
|
|
14
|
-
name?: string;
|
|
15
|
-
search?: boolean | false
|
|
16
|
-
data?: {key?: number, label: string, value: string}[]
|
|
17
|
-
path?: string;
|
|
18
|
-
label: string;
|
|
19
|
-
size?: "small" | "medium" | "large";
|
|
20
|
-
style?: any;
|
|
21
|
-
errorText?: string;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function useDropdown(props: DropdownProps){
|
|
25
|
-
const [value, setValue] = useState<string>(
|
|
26
|
-
props.defaultValue || props?.name === "country" ? countryList[0] : ""
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
const firebaseQuery = new FirebaseQuery();
|
|
30
|
-
|
|
31
|
-
const [data, setData] = useState<{key?: number, label: string, value: string}[]|undefined>(props.data);
|
|
32
|
-
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
// Get items from database if none are given as children.
|
|
35
|
-
if (!props.path) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
firebaseQuery.getDocsWhere(props.path).then((collectionResult: any) => {
|
|
40
|
-
const items = Object.keys(collectionResult).map((key) => {
|
|
41
|
-
const item = collectionResult[key];
|
|
42
|
-
return {
|
|
43
|
-
label: item.name,
|
|
44
|
-
value: key,
|
|
45
|
-
};
|
|
46
|
-
});
|
|
47
|
-
setData(items);
|
|
48
|
-
setValue(props.defaultValue || "");
|
|
49
|
-
});
|
|
50
|
-
}, []);
|
|
51
|
-
|
|
52
|
-
return ({...{value, setValue, data, setData}})
|
|
1
|
+
import {useState, useEffect} from "react"
|
|
2
|
+
import FirebaseQuery from "../../firebase/firebaseQuery";
|
|
3
|
+
import {countryList} from "../../constants";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export interface DropdownProps {
|
|
7
|
+
defaultValue?: string;
|
|
8
|
+
required?: boolean;
|
|
9
|
+
id?: string;
|
|
10
|
+
disabled?: boolean,
|
|
11
|
+
onValueChange?: (value: string) => void;
|
|
12
|
+
value?: string;
|
|
13
|
+
mode?: "default" | "modal"
|
|
14
|
+
name?: string;
|
|
15
|
+
search?: boolean | false
|
|
16
|
+
data?: {key?: number, label: string, value: string}[]
|
|
17
|
+
path?: string;
|
|
18
|
+
label: string;
|
|
19
|
+
size?: "small" | "medium" | "large";
|
|
20
|
+
style?: any;
|
|
21
|
+
errorText?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function useDropdown(props: DropdownProps){
|
|
25
|
+
const [value, setValue] = useState<string>(
|
|
26
|
+
props.defaultValue || props?.name === "country" ? countryList[0] : ""
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const firebaseQuery = new FirebaseQuery();
|
|
30
|
+
|
|
31
|
+
const [data, setData] = useState<{key?: number, label: string, value: string}[]|undefined>(props.data);
|
|
32
|
+
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
// Get items from database if none are given as children.
|
|
35
|
+
if (!props.path) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
firebaseQuery.getDocsWhere(props.path).then((collectionResult: any) => {
|
|
40
|
+
const items = Object.keys(collectionResult).map((key) => {
|
|
41
|
+
const item = collectionResult[key];
|
|
42
|
+
return {
|
|
43
|
+
label: item.name,
|
|
44
|
+
value: key,
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
setData(items);
|
|
48
|
+
setValue(props.defaultValue || "");
|
|
49
|
+
});
|
|
50
|
+
}, []);
|
|
51
|
+
|
|
52
|
+
return ({...{value, setValue, data, setData}})
|
|
53
53
|
}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import {where} from "firebase/firestore";
|
|
2
|
-
import FirebaseQuery from "../../../firebase/firebaseQuery";
|
|
3
|
-
import {useState} from "react";
|
|
4
|
-
import { UserData } from "../../../typeDefinitions";
|
|
5
|
-
|
|
6
|
-
export function useDowntime({user}: {user: UserData}){
|
|
7
|
-
const [downtime, setDowntime] = useState<{title: string, body: string}|false>();
|
|
8
|
-
const firebaseQuery = new FirebaseQuery();
|
|
9
|
-
|
|
10
|
-
const fetchDownTime = async () => {
|
|
11
|
-
try {
|
|
12
|
-
const docs = await firebaseQuery.getDocsWhere("downtime", [where("products", "array-contains", user?.product), where("active", "==", true)])
|
|
13
|
-
const downtimeDocs = { ...docs as {[key: string]: {title: string, body: string}}};
|
|
14
|
-
setDowntime(downtimeDocs[Object.keys(downtimeDocs)[0]] || false);
|
|
15
|
-
|
|
16
|
-
} catch(error) {
|
|
17
|
-
console.log(error)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return ({...{downtime, setDowntime, fetchDownTime}})
|
|
23
|
-
|
|
1
|
+
import {where} from "firebase/firestore";
|
|
2
|
+
import FirebaseQuery from "../../../firebase/firebaseQuery";
|
|
3
|
+
import {useState} from "react";
|
|
4
|
+
import { UserData } from "../../../typeDefinitions";
|
|
5
|
+
|
|
6
|
+
export function useDowntime({user}: {user: UserData}){
|
|
7
|
+
const [downtime, setDowntime] = useState<{title: string, body: string}|false>();
|
|
8
|
+
const firebaseQuery = new FirebaseQuery();
|
|
9
|
+
|
|
10
|
+
const fetchDownTime = async () => {
|
|
11
|
+
try {
|
|
12
|
+
const docs = await firebaseQuery.getDocsWhere("downtime", [where("products", "array-contains", user?.product), where("active", "==", true)])
|
|
13
|
+
const downtimeDocs = { ...docs as {[key: string]: {title: string, body: string}}};
|
|
14
|
+
setDowntime(downtimeDocs[Object.keys(downtimeDocs)[0]] || false);
|
|
15
|
+
|
|
16
|
+
} catch(error) {
|
|
17
|
+
console.log(error)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return ({...{downtime, setDowntime, fetchDownTime}})
|
|
23
|
+
|
|
24
24
|
}
|
|
@@ -1,133 +1,133 @@
|
|
|
1
|
-
import { useState, useEffect } from 'react'
|
|
2
|
-
import { dateToString, convertDate } from '../../../firebase/util'
|
|
3
|
-
import { executeCallable } from '../../../firebase/firebase'
|
|
4
|
-
import { UserData, StudentPlacementData } from '../../../typeDefinitions'
|
|
5
|
-
import { arrayUnion } from 'firebase/firestore'
|
|
6
|
-
import FirebaseQuery from '../../../firebase/firebaseQuery'
|
|
7
|
-
|
|
8
|
-
export function useUserFunctions({user}: {user: UserData}) {
|
|
9
|
-
const firebaseQuery = new FirebaseQuery()
|
|
10
|
-
|
|
11
|
-
const update = async (attributes: any) => {
|
|
12
|
-
if (!user) return
|
|
13
|
-
firebaseQuery.update(["users", user.id], {attributes})
|
|
14
|
-
// dispatch(updateUser({userId: user.id, attributes: attributes}))
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return ({...{update}});
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function useActivationCode({user}: {user: UserData}){
|
|
21
|
-
const [code, setCode] = useState<string>("");
|
|
22
|
-
const [newCodeSent, setNewCodeSent] = useState<boolean|undefined>(false);
|
|
23
|
-
const [timer, setTimer] = useState<number>(30);
|
|
24
|
-
const firebaseQuery = new FirebaseQuery()
|
|
25
|
-
|
|
26
|
-
useEffect(() => {
|
|
27
|
-
setInterval(() => {
|
|
28
|
-
setTimer((t) => t > 0 ? t-1 : t);
|
|
29
|
-
}, 1000)
|
|
30
|
-
}, [])
|
|
31
|
-
|
|
32
|
-
const submitCode = async (skip?: boolean) => {
|
|
33
|
-
if (!user) return;
|
|
34
|
-
|
|
35
|
-
if (skip || (parseInt(code) === user.activationCode)) {
|
|
36
|
-
firebaseQuery.update(["users", user.id], {activated: dateToString(new Date()), status: "active"})
|
|
37
|
-
//dispatch(updateUser({userId: user.id, attributes: {activated: dateToString(new Date()), status: "active"}}))
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const resendCode = async () => {
|
|
42
|
-
setNewCodeSent(undefined)
|
|
43
|
-
await executeCallable("registration-resendCode", {});
|
|
44
|
-
setNewCodeSent(true);
|
|
45
|
-
setTimer(30)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return ({...{code, setCode, submitCode, resendCode, newCodeSent, timer}})
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export function useContactProviderConsent({user}: {user: UserData}){
|
|
53
|
-
const [active, setActive] = useState<boolean>(false);
|
|
54
|
-
const firebaseQuery = new FirebaseQuery()
|
|
55
|
-
|
|
56
|
-
const consent = async (consent: boolean) => {
|
|
57
|
-
if (!user) return
|
|
58
|
-
|
|
59
|
-
try {
|
|
60
|
-
await firebaseQuery.update(["users", user.id], {
|
|
61
|
-
contactProviderConsent: consent,
|
|
62
|
-
contactProviderConsentDate: (new Date()).toISOString()
|
|
63
|
-
})
|
|
64
|
-
// dispatch(updateUser({userId: user.id, attributes: {
|
|
65
|
-
// contactProviderConsent: consent,
|
|
66
|
-
// contactProviderConsentDate: (new Date()).toISOString()}
|
|
67
|
-
// }))
|
|
68
|
-
|
|
69
|
-
setActive(false);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
catch(error) {
|
|
73
|
-
console.log(error)
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return ({...{active, setActive, consent}})
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
export function useGuidance({user}: {user: UserData}){
|
|
82
|
-
const firebaseQuery = new FirebaseQuery()
|
|
83
|
-
|
|
84
|
-
const updateUserTutorials = () => {
|
|
85
|
-
if (!user) return
|
|
86
|
-
try {
|
|
87
|
-
firebaseQuery.update(["users", user.id], {dismissedTutorials: arrayUnion("studentIntro")});
|
|
88
|
-
// dispatch(updateUser({userId: user.id, attributes: {dismissedTutorials: arrayUnion("studentIntro")}}))
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
catch (error) {
|
|
92
|
-
console.log(error)
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return ({...{updateUserTutorials}})
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export function useStudents(user: UserData | null){
|
|
100
|
-
const firebaseQuery = new FirebaseQuery()
|
|
101
|
-
|
|
102
|
-
useEffect(() => {
|
|
103
|
-
if (!user?.id) return;
|
|
104
|
-
firebaseQuery.update(["users", user?.id], {lastAccessed: convertDate(new Date(), "dbstring")})
|
|
105
|
-
//dispatch(updateUser({userId: user.id, attributes: {lastAccessed: convertDate(new Date(), "dbstring")}}))
|
|
106
|
-
|
|
107
|
-
if (!user?.phone && user?.status === "inactive") {
|
|
108
|
-
firebaseQuery.update(["users", user.id], {status: "active"})
|
|
109
|
-
// dispatch(updateUser({userId: user.id, attributes: {status: "active"}}))
|
|
110
|
-
};
|
|
111
|
-
}, []);
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export function useStudentData(placement: StudentPlacementData, student: UserData){
|
|
117
|
-
const firebaseQuery = new FirebaseQuery();
|
|
118
|
-
const [studentData, setStudentData] = useState<UserData | undefined>();
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
useEffect(() => {
|
|
122
|
-
const getStudentData = async () => {
|
|
123
|
-
return student ? student : (await firebaseQuery.getDocData(["users", placement.uid])) as UserData;
|
|
124
|
-
};
|
|
125
|
-
getStudentData().then((data) => {
|
|
126
|
-
setStudentData(data);
|
|
127
|
-
});
|
|
128
|
-
}, []);
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
return ({...{studentData}})
|
|
132
|
-
|
|
1
|
+
import { useState, useEffect } from 'react'
|
|
2
|
+
import { dateToString, convertDate } from '../../../firebase/util'
|
|
3
|
+
import { executeCallable } from '../../../firebase/firebase'
|
|
4
|
+
import { UserData, StudentPlacementData } from '../../../typeDefinitions'
|
|
5
|
+
import { arrayUnion } from 'firebase/firestore'
|
|
6
|
+
import FirebaseQuery from '../../../firebase/firebaseQuery'
|
|
7
|
+
|
|
8
|
+
export function useUserFunctions({user}: {user: UserData}) {
|
|
9
|
+
const firebaseQuery = new FirebaseQuery()
|
|
10
|
+
|
|
11
|
+
const update = async (attributes: any) => {
|
|
12
|
+
if (!user) return
|
|
13
|
+
firebaseQuery.update(["users", user.id], {attributes})
|
|
14
|
+
// dispatch(updateUser({userId: user.id, attributes: attributes}))
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return ({...{update}});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function useActivationCode({user}: {user: UserData}){
|
|
21
|
+
const [code, setCode] = useState<string>("");
|
|
22
|
+
const [newCodeSent, setNewCodeSent] = useState<boolean|undefined>(false);
|
|
23
|
+
const [timer, setTimer] = useState<number>(30);
|
|
24
|
+
const firebaseQuery = new FirebaseQuery()
|
|
25
|
+
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
setInterval(() => {
|
|
28
|
+
setTimer((t) => t > 0 ? t-1 : t);
|
|
29
|
+
}, 1000)
|
|
30
|
+
}, [])
|
|
31
|
+
|
|
32
|
+
const submitCode = async (skip?: boolean) => {
|
|
33
|
+
if (!user) return;
|
|
34
|
+
|
|
35
|
+
if (skip || (parseInt(code) === user.activationCode)) {
|
|
36
|
+
firebaseQuery.update(["users", user.id], {activated: dateToString(new Date()), status: "active"})
|
|
37
|
+
//dispatch(updateUser({userId: user.id, attributes: {activated: dateToString(new Date()), status: "active"}}))
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const resendCode = async () => {
|
|
42
|
+
setNewCodeSent(undefined)
|
|
43
|
+
await executeCallable("registration-resendCode", {});
|
|
44
|
+
setNewCodeSent(true);
|
|
45
|
+
setTimer(30)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return ({...{code, setCode, submitCode, resendCode, newCodeSent, timer}})
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function useContactProviderConsent({user}: {user: UserData}){
|
|
53
|
+
const [active, setActive] = useState<boolean>(false);
|
|
54
|
+
const firebaseQuery = new FirebaseQuery()
|
|
55
|
+
|
|
56
|
+
const consent = async (consent: boolean) => {
|
|
57
|
+
if (!user) return
|
|
58
|
+
|
|
59
|
+
try {
|
|
60
|
+
await firebaseQuery.update(["users", user.id], {
|
|
61
|
+
contactProviderConsent: consent,
|
|
62
|
+
contactProviderConsentDate: (new Date()).toISOString()
|
|
63
|
+
})
|
|
64
|
+
// dispatch(updateUser({userId: user.id, attributes: {
|
|
65
|
+
// contactProviderConsent: consent,
|
|
66
|
+
// contactProviderConsentDate: (new Date()).toISOString()}
|
|
67
|
+
// }))
|
|
68
|
+
|
|
69
|
+
setActive(false);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
catch(error) {
|
|
73
|
+
console.log(error)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return ({...{active, setActive, consent}})
|
|
77
|
+
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
export function useGuidance({user}: {user: UserData}){
|
|
82
|
+
const firebaseQuery = new FirebaseQuery()
|
|
83
|
+
|
|
84
|
+
const updateUserTutorials = () => {
|
|
85
|
+
if (!user) return
|
|
86
|
+
try {
|
|
87
|
+
firebaseQuery.update(["users", user.id], {dismissedTutorials: arrayUnion("studentIntro")});
|
|
88
|
+
// dispatch(updateUser({userId: user.id, attributes: {dismissedTutorials: arrayUnion("studentIntro")}}))
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
catch (error) {
|
|
92
|
+
console.log(error)
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return ({...{updateUserTutorials}})
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function useStudents(user: UserData | null){
|
|
100
|
+
const firebaseQuery = new FirebaseQuery()
|
|
101
|
+
|
|
102
|
+
useEffect(() => {
|
|
103
|
+
if (!user?.id) return;
|
|
104
|
+
firebaseQuery.update(["users", user?.id], {lastAccessed: convertDate(new Date(), "dbstring")})
|
|
105
|
+
//dispatch(updateUser({userId: user.id, attributes: {lastAccessed: convertDate(new Date(), "dbstring")}}))
|
|
106
|
+
|
|
107
|
+
if (!user?.phone && user?.status === "inactive") {
|
|
108
|
+
firebaseQuery.update(["users", user.id], {status: "active"})
|
|
109
|
+
// dispatch(updateUser({userId: user.id, attributes: {status: "active"}}))
|
|
110
|
+
};
|
|
111
|
+
}, []);
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export function useStudentData(placement: StudentPlacementData, student: UserData){
|
|
117
|
+
const firebaseQuery = new FirebaseQuery();
|
|
118
|
+
const [studentData, setStudentData] = useState<UserData | undefined>();
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
useEffect(() => {
|
|
122
|
+
const getStudentData = async () => {
|
|
123
|
+
return student ? student : (await firebaseQuery.getDocData(["users", placement.uid])) as UserData;
|
|
124
|
+
};
|
|
125
|
+
getStudentData().then((data) => {
|
|
126
|
+
setStudentData(data);
|
|
127
|
+
});
|
|
128
|
+
}, []);
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
return ({...{studentData}})
|
|
132
|
+
|
|
133
133
|
}
|
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
import {createSlice} from "@reduxjs/toolkit";
|
|
2
|
-
|
|
3
|
-
export type Job = {
|
|
4
|
-
id: string
|
|
5
|
-
description: string
|
|
6
|
-
finished: string
|
|
7
|
-
logs: Array<{
|
|
8
|
-
severity?: string,
|
|
9
|
-
title: string,
|
|
10
|
-
description: string,
|
|
11
|
-
}>
|
|
12
|
-
oId: string
|
|
13
|
-
outputMsg: string
|
|
14
|
-
product: string
|
|
15
|
-
started: string
|
|
16
|
-
status: string
|
|
17
|
-
title: string
|
|
18
|
-
updated: string
|
|
19
|
-
viewedBy: Array<string>
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
type InitialJobState = {
|
|
24
|
-
values: {
|
|
25
|
-
[jobId: string]: Job
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const initialState: InitialJobState = {
|
|
30
|
-
values: {},
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
export const JobsSlice = createSlice({
|
|
35
|
-
name: "jobs",
|
|
36
|
-
initialState,
|
|
37
|
-
|
|
38
|
-
reducers: {
|
|
39
|
-
setJobs: (state, action) => {
|
|
40
|
-
state.values = action.payload;
|
|
41
|
-
},
|
|
42
|
-
|
|
43
|
-
addJob: (state, action) => {
|
|
44
|
-
const {job, jobId} = action.payload;
|
|
45
|
-
console.log("j", job);
|
|
46
|
-
|
|
47
|
-
const newJobs = {...state.values};
|
|
48
|
-
newJobs[jobId] = job;
|
|
49
|
-
|
|
50
|
-
state.values = Object.fromEntries(Object.entries(newJobs).sort(([, a], [, b]) => b.started > a.started ? 1 : -1));
|
|
51
|
-
},
|
|
52
|
-
|
|
53
|
-
setMarkRead: (state, action) => {
|
|
54
|
-
console.log("Mark read", action.payload.data);
|
|
55
|
-
state.values[action.payload.jobId].viewedBy.push(action.payload.userId);
|
|
56
|
-
},
|
|
57
|
-
|
|
58
|
-
setJobStatus: (state, action) => {
|
|
59
|
-
state.values[action.payload.jobId].status = action.payload.status;
|
|
60
|
-
state.values[action.payload.jobId].updated = (new Date()).toISOString();
|
|
61
|
-
},
|
|
62
|
-
updateJob: (state, action) => {
|
|
63
|
-
state.values[action.payload.jobId] = action.payload.data;
|
|
64
|
-
},
|
|
65
|
-
|
|
66
|
-
},
|
|
67
|
-
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
export const {setJobs, addJob, setMarkRead, setJobStatus, updateJob} = JobsSlice.actions;
|
|
71
|
-
|
|
1
|
+
import {createSlice} from "@reduxjs/toolkit";
|
|
2
|
+
|
|
3
|
+
export type Job = {
|
|
4
|
+
id: string
|
|
5
|
+
description: string
|
|
6
|
+
finished: string
|
|
7
|
+
logs: Array<{
|
|
8
|
+
severity?: string,
|
|
9
|
+
title: string,
|
|
10
|
+
description: string,
|
|
11
|
+
}>
|
|
12
|
+
oId: string
|
|
13
|
+
outputMsg: string
|
|
14
|
+
product: string
|
|
15
|
+
started: string
|
|
16
|
+
status: string
|
|
17
|
+
title: string
|
|
18
|
+
updated: string
|
|
19
|
+
viewedBy: Array<string>
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
type InitialJobState = {
|
|
24
|
+
values: {
|
|
25
|
+
[jobId: string]: Job
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const initialState: InitialJobState = {
|
|
30
|
+
values: {},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
export const JobsSlice = createSlice({
|
|
35
|
+
name: "jobs",
|
|
36
|
+
initialState,
|
|
37
|
+
|
|
38
|
+
reducers: {
|
|
39
|
+
setJobs: (state, action) => {
|
|
40
|
+
state.values = action.payload;
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
addJob: (state, action) => {
|
|
44
|
+
const {job, jobId} = action.payload;
|
|
45
|
+
console.log("j", job);
|
|
46
|
+
|
|
47
|
+
const newJobs = {...state.values};
|
|
48
|
+
newJobs[jobId] = job;
|
|
49
|
+
|
|
50
|
+
state.values = Object.fromEntries(Object.entries(newJobs).sort(([, a], [, b]) => b.started > a.started ? 1 : -1));
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
setMarkRead: (state, action) => {
|
|
54
|
+
console.log("Mark read", action.payload.data);
|
|
55
|
+
state.values[action.payload.jobId].viewedBy.push(action.payload.userId);
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
setJobStatus: (state, action) => {
|
|
59
|
+
state.values[action.payload.jobId].status = action.payload.status;
|
|
60
|
+
state.values[action.payload.jobId].updated = (new Date()).toISOString();
|
|
61
|
+
},
|
|
62
|
+
updateJob: (state, action) => {
|
|
63
|
+
state.values[action.payload.jobId] = action.payload.data;
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
export const {setJobs, addJob, setMarkRead, setJobStatus, updateJob} = JobsSlice.actions;
|
|
71
|
+
|
|
72
72
|
export default JobsSlice.reducer;
|