placementt-core 1.20.211 → 11.10.151
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/config.d.ts +0 -1
- package/lib/constants.d.ts +6 -2
- package/lib/constants.js +136 -136
- package/lib/constants.js.map +1 -1
- package/lib/features/analytics/useAnalytics.d.ts +0 -1
- package/lib/features/analytics/useAnalytics.js +3 -4
- package/lib/features/analytics/useAnalytics.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/contacts/contactsSlice.d.ts +5 -5
- package/lib/features/contacts/useContacts.js +1 -2
- package/lib/features/contacts/useContacts.js.map +1 -1
- package/lib/features/downtime/useDowntime.d.ts +11 -11
- package/lib/features/downtime/useDowntime.js +22 -22
- package/lib/features/dropdown/useDropdown.d.ts +2 -3
- package/lib/features/dropdown/useDropdown.js +1 -2
- package/lib/features/dropdown/useDropdown.js.map +1 -1
- package/lib/features/global/downtime/useDowntime.d.ts +0 -1
- package/lib/features/global/downtime/useDowntime.js +1 -2
- package/lib/features/global/downtime/useDowntime.js.map +1 -1
- package/lib/features/global/users/useUserFunctions.d.ts +0 -1
- package/lib/features/global/users/useUserFunctions.js +7 -8
- package/lib/features/global/users/useUserFunctions.js.map +1 -1
- package/lib/features/placements/studentPlacements/activePlacement.d.ts +1 -1
- package/lib/features/placements/studentPlacements/completedStudentPlacementsSlice.d.ts +2 -2
- package/lib/features/placements/studentPlacements/studentPlacementsSlice.d.ts +63 -63
- package/lib/features/placements/studentPlacements/studentPlacementsSlice.js +81 -81
- package/lib/features/placements/studentPlacements/upcomingStudentPlacementsSlice.d.ts +2 -2
- package/lib/features/placements/studentPlacements/useStudentPlacements.d.ts +0 -1
- package/lib/features/placements/studentPlacements/useStudentPlacements.js +1 -2
- package/lib/features/placements/studentPlacements/useStudentPlacements.js.map +1 -1
- package/lib/features/providerPlacements/providerPlacementsSlice.d.ts +19 -19
- package/lib/features/providerPlacements/providerPlacementsSlice.js +24 -24
- package/lib/features/referrals/useReferrals.d.ts +0 -1
- package/lib/features/referrals/useReferrals.js +1 -2
- package/lib/features/referrals/useReferrals.js.map +1 -1
- 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/updates/useUpdates.js +1 -2
- package/lib/features/updates/useUpdates.js.map +1 -1
- 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 +3 -1
- package/lib/firebase/firebase.js +9 -3
- package/lib/firebase/firebase.js.map +1 -1
- package/lib/firebase/firebaseConfig.js +3 -0
- package/lib/firebase/firebaseConfig.js.map +1 -1
- package/lib/firebase/firebaseQuery.d.ts +3 -1
- package/lib/firebase/firebaseQuery.js +11 -1
- package/lib/firebase/firebaseQuery.js.map +1 -1
- package/lib/firebase/persistence.js +2 -2
- package/lib/firebase/persistence.js.map +1 -1
- package/lib/firebase/readDatabase.d.ts +8 -7
- package/lib/firebase/readDatabase.js +41 -8
- package/lib/firebase/readDatabase.js.map +1 -1
- package/lib/firebase/util.d.ts +3 -4
- package/lib/firebase/util.js +49 -4
- package/lib/firebase/util.js.map +1 -1
- package/lib/firebase/writeDatabase.d.ts +7 -3
- package/lib/firebase/writeDatabase.js +9 -2
- package/lib/firebase/writeDatabase.js.map +1 -1
- package/lib/hooks.d.ts +476 -20
- package/lib/hooks.js +1855 -237
- package/lib/hooks.js.map +1 -1
- package/lib/images/GatsbyBenchmarks.d.ts +0 -1
- package/lib/images/GatsbyBenchmarks.js +1 -1
- package/lib/images/GatsbyBenchmarks.js.map +1 -1
- package/lib/reduxHooks.d.ts +9 -2
- package/lib/reduxHooks.js +36 -9
- package/lib/reduxHooks.js.map +1 -1
- package/lib/tasksAndTips.d.ts +25 -5
- package/lib/tasksAndTips.js +517 -48
- package/lib/tasksAndTips.js.map +1 -1
- package/lib/typeDefinitions.d.ts +472 -55
- package/lib/util.d.ts +1 -0
- package/lib/util.js +85 -7
- package/lib/util.js.map +1 -1
- package/package.json +52 -49
- package/src/DatabaseDefinitions.ts +18 -18
- package/src/apiCalls.ts +128 -128
- package/src/config.ts +50 -50
- package/src/constants.ts +714 -707
- package/src/databaseTypes.ts +42 -42
- package/src/features/analytics/useAnalytics.tsx +64 -64
- 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 +65 -65
- 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 +144 -138
- package/src/firebase/firebaseConfig.tsx +45 -42
- package/src/firebase/firebaseQuery.tsx +150 -140
- package/src/firebase/persistence.ts +84 -84
- package/src/firebase/readDatabase.tsx +235 -197
- package/src/firebase/util.tsx +352 -308
- package/src/firebase/writeDatabase.tsx +77 -68
- package/src/hooks.tsx +4029 -1928
- 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 +231 -200
- package/src/tasksAndTips.ts +917 -410
- package/src/tutorialTips.ts +58 -58
- package/src/typeDefinitions.ts +893 -503
- package/src/util.ts +137 -47
- package/tsconfig.dev.json +5 -5
- package/tsconfig.json +21 -21
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
import { documentId, where } from "firebase/firestore";
|
|
2
|
-
import { useState } from "react";
|
|
3
|
-
import FirebaseQuery from "../../firebase/firebaseQuery";
|
|
4
|
-
import { UserData } from "../../typeDefinitions";
|
|
5
|
-
|
|
6
|
-
export function useReferrals({user}: {user: UserData}){
|
|
7
|
-
const firebaseQuery = new FirebaseQuery();
|
|
8
|
-
const [showNameConsent, setShowNameConsent] = useState<boolean>(user?.shareNameWithReferralLeaderboardConsent === undefined ? true : false);
|
|
9
|
-
|
|
10
|
-
const getReferralCode = async (fiveLetterWords: string[]): Promise<string> => {
|
|
11
|
-
var potentialWord = fiveLetterWords[Math.floor(Math.random()*fiveLetterWords.length)];
|
|
12
|
-
const existingReferral = await firebaseQuery.getDocsWhere("referrals", where(documentId(), "==", potentialWord));
|
|
13
|
-
|
|
14
|
-
if (Object.keys(existingReferral || {}).length > 0) {
|
|
15
|
-
return await getReferralCode(fiveLetterWords);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
await firebaseQuery.set(["referrals", potentialWord], {
|
|
19
|
-
name: user?.id,
|
|
20
|
-
expiry: new Date(2040,10,30),
|
|
21
|
-
volume: 1000,
|
|
22
|
-
product: "students"
|
|
23
|
-
|
|
24
|
-
}).then(() => {
|
|
25
|
-
if (!user) return;
|
|
26
|
-
firebaseQuery.update(["users", user.id], {
|
|
27
|
-
referralCode: potentialWord
|
|
28
|
-
})
|
|
29
|
-
//dispatch(updateUser({userId: user.id, attributes: {referralCode: potentialWord}}))
|
|
30
|
-
// dispatch(setUser((state: UserData) => ({...state, referralCode: potentialWord})))
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
return potentialWord;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const consent = async (consent: boolean) => {
|
|
37
|
-
if (!user) return
|
|
38
|
-
|
|
39
|
-
try {
|
|
40
|
-
await firebaseQuery.update(["users", user.id], {
|
|
41
|
-
shareNameWithReferralLeaderboardConsent: consent,
|
|
42
|
-
shareNameWithReferralLeaderboardConsentDate: (new Date()).toISOString()
|
|
43
|
-
})
|
|
44
|
-
// dispatch(updateUser({userId: user.id, attributes: {
|
|
45
|
-
// shareNameWithReferralLeaderboardConsent: consent,
|
|
46
|
-
// shareNameWithReferralLeaderboardConsentDate: (new Date()).toISOString()}
|
|
47
|
-
// }))
|
|
48
|
-
}
|
|
49
|
-
catch(error) {
|
|
50
|
-
console.log(error)
|
|
51
|
-
}
|
|
52
|
-
setShowNameConsent(false);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return ({...{getReferralCode, showNameConsent, setShowNameConsent, consent}})
|
|
56
|
-
|
|
1
|
+
import { documentId, where } from "firebase/firestore";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import FirebaseQuery from "../../firebase/firebaseQuery";
|
|
4
|
+
import { UserData } from "../../typeDefinitions";
|
|
5
|
+
|
|
6
|
+
export function useReferrals({user}: {user: UserData}){
|
|
7
|
+
const firebaseQuery = new FirebaseQuery();
|
|
8
|
+
const [showNameConsent, setShowNameConsent] = useState<boolean>(user?.shareNameWithReferralLeaderboardConsent === undefined ? true : false);
|
|
9
|
+
|
|
10
|
+
const getReferralCode = async (fiveLetterWords: string[]): Promise<string> => {
|
|
11
|
+
var potentialWord = fiveLetterWords[Math.floor(Math.random()*fiveLetterWords.length)];
|
|
12
|
+
const existingReferral = await firebaseQuery.getDocsWhere("referrals", where(documentId(), "==", potentialWord));
|
|
13
|
+
|
|
14
|
+
if (Object.keys(existingReferral || {}).length > 0) {
|
|
15
|
+
return await getReferralCode(fiveLetterWords);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
await firebaseQuery.set(["referrals", potentialWord], {
|
|
19
|
+
name: user?.id,
|
|
20
|
+
expiry: new Date(2040,10,30),
|
|
21
|
+
volume: 1000,
|
|
22
|
+
product: "students"
|
|
23
|
+
|
|
24
|
+
}).then(() => {
|
|
25
|
+
if (!user) return;
|
|
26
|
+
firebaseQuery.update(["users", user.id], {
|
|
27
|
+
referralCode: potentialWord
|
|
28
|
+
})
|
|
29
|
+
//dispatch(updateUser({userId: user.id, attributes: {referralCode: potentialWord}}))
|
|
30
|
+
// dispatch(setUser((state: UserData) => ({...state, referralCode: potentialWord})))
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
return potentialWord;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const consent = async (consent: boolean) => {
|
|
37
|
+
if (!user) return
|
|
38
|
+
|
|
39
|
+
try {
|
|
40
|
+
await firebaseQuery.update(["users", user.id], {
|
|
41
|
+
shareNameWithReferralLeaderboardConsent: consent,
|
|
42
|
+
shareNameWithReferralLeaderboardConsentDate: (new Date()).toISOString()
|
|
43
|
+
})
|
|
44
|
+
// dispatch(updateUser({userId: user.id, attributes: {
|
|
45
|
+
// shareNameWithReferralLeaderboardConsent: consent,
|
|
46
|
+
// shareNameWithReferralLeaderboardConsentDate: (new Date()).toISOString()}
|
|
47
|
+
// }))
|
|
48
|
+
}
|
|
49
|
+
catch(error) {
|
|
50
|
+
console.log(error)
|
|
51
|
+
}
|
|
52
|
+
setShowNameConsent(false);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return ({...{getReferralCode, showNameConsent, setShowNameConsent, consent}})
|
|
56
|
+
|
|
57
57
|
}
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import FirebaseQuery from "../../firebase/firebaseQuery";
|
|
2
|
-
import {orderBy, limit, arrayUnion} from "firebase/firestore";
|
|
3
|
-
import {useState} from "react";
|
|
4
|
-
import { UserData } from "../../typeDefinitions";
|
|
5
|
-
|
|
6
|
-
export function useUpdates({user}: {user: UserData}){
|
|
7
|
-
const [active, setActive] = useState<{title: string, body: string, id: string}>();
|
|
8
|
-
const firebaseQuery = new FirebaseQuery();
|
|
9
|
-
|
|
10
|
-
const fetchUpdates = async () => {
|
|
11
|
-
try {
|
|
12
|
-
const docs = await firebaseQuery.getDocsWhere("updates", [orderBy("created", "desc"), limit(1)])
|
|
13
|
-
const item = Object.values(docs as {[key:string]: {title: string, body: string, id: string}})[0];
|
|
14
|
-
if (!user?.readUpdates?.includes(item.id)) setActive(item);
|
|
15
|
-
|
|
16
|
-
} catch(error) {
|
|
17
|
-
console.log(error)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const dismiss = () => {
|
|
24
|
-
if (!user) return
|
|
25
|
-
|
|
26
|
-
try {
|
|
27
|
-
firebaseQuery.update(["users", user.id], {readUpdates: arrayUnion(active?.id)})
|
|
28
|
-
//dispatch(updateUser({userId: user.id, attributes: {readUpdates: arrayUnion(active?.id)}}))
|
|
29
|
-
setActive(undefined);
|
|
30
|
-
}
|
|
31
|
-
catch(error) {
|
|
32
|
-
console.log(error)
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return ({...{active, dismiss, fetchUpdates}})
|
|
37
|
-
|
|
38
|
-
}
|
|
1
|
+
import FirebaseQuery from "../../firebase/firebaseQuery";
|
|
2
|
+
import {orderBy, limit, arrayUnion} from "firebase/firestore";
|
|
3
|
+
import {useState} from "react";
|
|
4
|
+
import { UserData } from "../../typeDefinitions";
|
|
5
|
+
|
|
6
|
+
export function useUpdates({user}: {user: UserData}){
|
|
7
|
+
const [active, setActive] = useState<{title: string, body: string, id: string}>();
|
|
8
|
+
const firebaseQuery = new FirebaseQuery();
|
|
9
|
+
|
|
10
|
+
const fetchUpdates = async () => {
|
|
11
|
+
try {
|
|
12
|
+
const docs = await firebaseQuery.getDocsWhere("updates", [orderBy("created", "desc"), limit(1)])
|
|
13
|
+
const item = Object.values(docs as {[key:string]: {title: string, body: string, id: string}})[0];
|
|
14
|
+
if (!user?.readUpdates?.includes(item.id)) setActive(item);
|
|
15
|
+
|
|
16
|
+
} catch(error) {
|
|
17
|
+
console.log(error)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
const dismiss = () => {
|
|
24
|
+
if (!user) return
|
|
25
|
+
|
|
26
|
+
try {
|
|
27
|
+
firebaseQuery.update(["users", user.id], {readUpdates: arrayUnion(active?.id)})
|
|
28
|
+
//dispatch(updateUser({userId: user.id, attributes: {readUpdates: arrayUnion(active?.id)}}))
|
|
29
|
+
setActive(undefined);
|
|
30
|
+
}
|
|
31
|
+
catch(error) {
|
|
32
|
+
console.log(error)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return ({...{active, dismiss, fetchUpdates}})
|
|
37
|
+
|
|
38
|
+
}
|
|
@@ -1,138 +1,144 @@
|
|
|
1
|
-
import {onAuthStateChanged, signInWithEmailAndPassword} from "firebase/auth";
|
|
2
|
-
import {httpsCallable} from "firebase/functions";
|
|
3
|
-
import {SetStateAction} from "react";
|
|
4
|
-
import {getUser} from "./readDatabase";
|
|
5
|
-
import {UserData} from "../typeDefinitions";
|
|
6
|
-
import FirebaseQuery from "./firebaseQuery";
|
|
7
|
-
import {auth, functions} from "./firebaseConfig";
|
|
8
|
-
import {addJob, setJobStatus} from "../features/jobs/jobsSlice";
|
|
9
|
-
import { useAppDispatch } from "../reduxHooks";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export const authListener = (setUser: SetStateAction<any>) => {
|
|
13
|
-
return onAuthStateChanged(auth, (aUser) => {
|
|
14
|
-
if (!aUser) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"address-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
};
|
|
80
|
-
case "userManagement-
|
|
81
|
-
return {
|
|
82
|
-
title: "
|
|
83
|
-
description: `
|
|
84
|
-
"multiple" : Object.entries((data as {users:{[key: string]: UserData}}).users).length
|
|
85
|
-
};
|
|
86
|
-
case "userManagement-
|
|
87
|
-
return {
|
|
88
|
-
title: "
|
|
89
|
-
description: `
|
|
90
|
-
"multiple" : Object.entries((data as {users:{[key: string]: UserData}}).users).length || "multiple"} users.`,
|
|
91
|
-
};
|
|
92
|
-
case "
|
|
93
|
-
return {
|
|
94
|
-
title: "
|
|
95
|
-
description: `Attempting
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
1
|
+
import {onAuthStateChanged, signInWithEmailAndPassword} from "firebase/auth";
|
|
2
|
+
import {httpsCallable} from "firebase/functions";
|
|
3
|
+
import {SetStateAction} from "react";
|
|
4
|
+
import {getUser} from "./readDatabase";
|
|
5
|
+
import {UserData} from "../typeDefinitions";
|
|
6
|
+
import FirebaseQuery from "./firebaseQuery";
|
|
7
|
+
import {auth, functions} from "./firebaseConfig";
|
|
8
|
+
import {addJob, setJobStatus} from "../features/jobs/jobsSlice";
|
|
9
|
+
import { useAppDispatch } from "../reduxHooks";
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
export const authListener = (setUser: SetStateAction<any>) => {
|
|
13
|
+
return onAuthStateChanged(auth, (aUser) => {
|
|
14
|
+
if (!aUser) {
|
|
15
|
+
console.log("User not logged in.");
|
|
16
|
+
setUser(false)
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
console.log("User logged in.");
|
|
20
|
+
getUser(aUser.uid, setUser);
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const login = async (credentials: {email: string, password: string}) => {
|
|
25
|
+
console.log("creds", credentials);
|
|
26
|
+
return signInWithEmailAndPassword(auth, credentials.email, credentials.password);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type RegistrationData = {
|
|
30
|
+
email: string,
|
|
31
|
+
passwordOne: string,
|
|
32
|
+
instituteName: string,
|
|
33
|
+
"address-line1": string,
|
|
34
|
+
"address-line2": string,
|
|
35
|
+
locality: string,
|
|
36
|
+
postal_code: string,
|
|
37
|
+
country: string,
|
|
38
|
+
first_name: string,
|
|
39
|
+
family_name: string
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const register = async (credentials: RegistrationData, type:"Institute"|"Provider"|"Student") => {
|
|
43
|
+
console.log("creds", credentials);
|
|
44
|
+
return await executeCallable(`registration-register${type}`, credentials).catch((e) => {
|
|
45
|
+
console.log("Error in regsiter", e);
|
|
46
|
+
throw e;
|
|
47
|
+
}).then(async (res) => {
|
|
48
|
+
if (type === "Student") {
|
|
49
|
+
await login({email: credentials.email, password: credentials.passwordOne});
|
|
50
|
+
}
|
|
51
|
+
return (res.data as { msg: {uid: string}}).msg.uid as string;
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export const executeCallable = async (functionName: string, data: unknown) => {
|
|
56
|
+
const funcCallable = httpsCallable(functions, functionName);
|
|
57
|
+
const res = await funcCallable(data).catch((e) => {
|
|
58
|
+
console.log("callableError", functionName, e);
|
|
59
|
+
throw e;
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
return res as {data: any};
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
export function useExecuteCallableJob({user}:{user: UserData}) {
|
|
67
|
+
type CallableFunctionJobs = "userManagement-addUsers"|"userManagement-activateUsers"|
|
|
68
|
+
"userManagement-deactivateUsers"|"userManagement-deleteUsers"|"admissions-createCohort"|"userManagement-uploadAnalytics"|
|
|
69
|
+
"placementListing-add"
|
|
70
|
+
const dispatch = useAppDispatch();
|
|
71
|
+
|
|
72
|
+
const execute = async (functionName:CallableFunctionJobs, data:{[key:string]:unknown}) => {
|
|
73
|
+
const getCode = () => {
|
|
74
|
+
switch (functionName) {
|
|
75
|
+
case "userManagement-addUsers":
|
|
76
|
+
return {
|
|
77
|
+
title: "Add users",
|
|
78
|
+
description: `Adding ${(data as {users:unknown[]}).users.length} ${(data as {userType:string}).userType.toLowerCase()}`,
|
|
79
|
+
};
|
|
80
|
+
case "userManagement-activateUsers":
|
|
81
|
+
return {
|
|
82
|
+
title: "Activating users",
|
|
83
|
+
description: `Attempting activation of ${Array.isArray((data as {users:{[key:string]:unknown}}).users) ?
|
|
84
|
+
"multiple" : Object.entries((data as {users:{[key: string]: UserData}}).users).length} users.`,
|
|
85
|
+
};
|
|
86
|
+
case "userManagement-deactivateUsers":
|
|
87
|
+
return {
|
|
88
|
+
title: "Deactivating users",
|
|
89
|
+
description: `Deactivating ${Array.isArray((data as {users:{[key:string]:unknown}}).users) ?
|
|
90
|
+
"multiple" : Object.entries((data as {users:{[key: string]: UserData}}).users).length || "multiple"} users.`,
|
|
91
|
+
};
|
|
92
|
+
case "userManagement-deleteUsers":
|
|
93
|
+
return {
|
|
94
|
+
title: "Deleting users",
|
|
95
|
+
description: `Attempting deletion of ${Array.isArray((data as {users:{[key:string]:unknown}}).users) ?
|
|
96
|
+
"multiple" : Object.entries((data as {users:{[key: string]: UserData}}).users).length || "multiple"} users.`,
|
|
97
|
+
};
|
|
98
|
+
case "placementListing-add":
|
|
99
|
+
return {
|
|
100
|
+
title: "Adding placements",
|
|
101
|
+
description: `Attempting addition of ${(data as {data:[]}).data.length} placements`,
|
|
102
|
+
};
|
|
103
|
+
default:
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const date = new Date();
|
|
109
|
+
const firebaseQuery = new FirebaseQuery();
|
|
110
|
+
|
|
111
|
+
const jobObject = {
|
|
112
|
+
title: getCode()?.title,
|
|
113
|
+
description: getCode()?.description,
|
|
114
|
+
status: "processing",
|
|
115
|
+
viewedBy: [],
|
|
116
|
+
started: date.toISOString(),
|
|
117
|
+
updated: date.toISOString(),
|
|
118
|
+
oId: user.oId,
|
|
119
|
+
product: user.product,
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const jobId = (await firebaseQuery.add(["jobs"], jobObject)).id;
|
|
123
|
+
|
|
124
|
+
console.log("jobId", jobId);
|
|
125
|
+
dispatch(addJob({
|
|
126
|
+
jobId: jobId,
|
|
127
|
+
job: jobObject,
|
|
128
|
+
}));
|
|
129
|
+
|
|
130
|
+
const items = {...data, jobId: jobId};
|
|
131
|
+
|
|
132
|
+
const funcCallable = httpsCallable(functions, functionName);
|
|
133
|
+
console.log(items);
|
|
134
|
+
funcCallable(items).then(() => {
|
|
135
|
+
dispatch(setJobStatus({
|
|
136
|
+
jobId: jobId,
|
|
137
|
+
status: "success",
|
|
138
|
+
}));
|
|
139
|
+
});
|
|
140
|
+
return;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
return {execute};
|
|
144
|
+
}
|
|
@@ -1,42 +1,45 @@
|
|
|
1
|
-
/* eslint-disable no-multiple-empty-lines */
|
|
2
|
-
import AsyncStorage from "@react-native-async-storage/async-storage";
|
|
3
|
-
import {getApp, getApps, initializeApp} from "firebase/app";
|
|
4
|
-
import {getAuth, initializeAuth} from "firebase/auth";
|
|
5
|
-
import {getFirestore} from "firebase/firestore";
|
|
6
|
-
import {getFunctions} from "firebase/functions";
|
|
7
|
-
import {getStorage} from "firebase/storage";
|
|
8
|
-
import {getReactNativePersistence} from "./persistence";
|
|
9
|
-
|
|
10
|
-
export const credentialsDev = {
|
|
11
|
-
apiKey: "AIzaSyBpGWwNsYsitD-yer3bS0jPe1jZgDCvfYI",
|
|
12
|
-
authDomain: "placementt-dev.firebaseapp.com",
|
|
13
|
-
projectId: "placementt-dev",
|
|
14
|
-
storageBucket: "placementt-dev.appspot.com",
|
|
15
|
-
messagingSenderId: "735359304180",
|
|
16
|
-
appId: "1:735359304180:web:0ffd3bb86db13e140339a1",
|
|
17
|
-
measurementId: "G-F34T7Y8YYT"
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export const credentialsProd = {
|
|
21
|
-
apiKey: "AIzaSyBOSSi4iHxOoAS9tLAJUAC_46HlZ6-D5Ss",
|
|
22
|
-
authDomain: "placementt-dfa17.firebaseapp.com",
|
|
23
|
-
projectId: "placementt-dfa17",
|
|
24
|
-
storageBucket: "placementt-dfa17.appspot.com",
|
|
25
|
-
messagingSenderId: "728019353765",
|
|
26
|
-
appId: "1:728019353765:web:954b5547d62a6dd6a64d4c",
|
|
27
|
-
measurementId: "G-NW5YMC6JN8",
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const firebaseConfig = !getApps().length ? initializeApp(process.env.NODE_ENV === "development" ? credentialsDev : credentialsProd) : getApp();
|
|
31
|
-
|
|
32
|
-
initializeAuth(firebaseConfig, {
|
|
33
|
-
persistence: getReactNativePersistence(AsyncStorage),
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
export const
|
|
41
|
-
|
|
42
|
-
|
|
1
|
+
/* eslint-disable no-multiple-empty-lines */
|
|
2
|
+
import AsyncStorage from "@react-native-async-storage/async-storage";
|
|
3
|
+
import {getApp, getApps, initializeApp} from "firebase/app";
|
|
4
|
+
import {getAuth, initializeAuth} from "firebase/auth";
|
|
5
|
+
import {getFirestore, initializeFirestore} from "firebase/firestore";
|
|
6
|
+
import {getFunctions} from "firebase/functions";
|
|
7
|
+
import {getStorage} from "firebase/storage";
|
|
8
|
+
import {getReactNativePersistence} from "./persistence";
|
|
9
|
+
|
|
10
|
+
export const credentialsDev = {
|
|
11
|
+
apiKey: "AIzaSyBpGWwNsYsitD-yer3bS0jPe1jZgDCvfYI",
|
|
12
|
+
authDomain: "placementt-dev.firebaseapp.com",
|
|
13
|
+
projectId: "placementt-dev",
|
|
14
|
+
storageBucket: "placementt-dev.appspot.com",
|
|
15
|
+
messagingSenderId: "735359304180",
|
|
16
|
+
appId: "1:735359304180:web:0ffd3bb86db13e140339a1",
|
|
17
|
+
measurementId: "G-F34T7Y8YYT"
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const credentialsProd = {
|
|
21
|
+
apiKey: "AIzaSyBOSSi4iHxOoAS9tLAJUAC_46HlZ6-D5Ss",
|
|
22
|
+
authDomain: "placementt-dfa17.firebaseapp.com",
|
|
23
|
+
projectId: "placementt-dfa17",
|
|
24
|
+
storageBucket: "placementt-dfa17.appspot.com",
|
|
25
|
+
messagingSenderId: "728019353765",
|
|
26
|
+
appId: "1:728019353765:web:954b5547d62a6dd6a64d4c",
|
|
27
|
+
measurementId: "G-NW5YMC6JN8",
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const firebaseConfig = !getApps().length ? initializeApp(process.env.NODE_ENV === "development" ? credentialsDev : credentialsProd) : getApp();
|
|
31
|
+
|
|
32
|
+
initializeAuth(firebaseConfig, {
|
|
33
|
+
persistence: getReactNativePersistence(AsyncStorage),
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
initializeFirestore(firebaseConfig, {
|
|
37
|
+
ignoreUndefinedProperties: true,
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
export const auth = getAuth(firebaseConfig);
|
|
41
|
+
export const db = getFirestore(firebaseConfig);
|
|
42
|
+
export const functions = getFunctions(firebaseConfig, "europe-west2");
|
|
43
|
+
export const storage = getStorage(firebaseConfig);
|
|
44
|
+
|
|
45
|
+
|