placementt-core 1.20.232 → 1.300.4
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/deploy-all.js +75 -0
- package/lib/config.d.ts +0 -13
- package/lib/config.js +1 -3
- package/lib/config.js.map +1 -1
- package/lib/constants.d.ts +1 -0
- package/lib/constants.js +48 -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/activePlacement.js +1 -1
- package/lib/features/placements/studentPlacements/activePlacement.js.map +1 -1
- 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 +8 -3
- package/lib/firebase/firebase.js.map +1 -1
- package/lib/firebase/firebaseConfig.js +1 -0
- package/lib/firebase/firebaseConfig.js.map +1 -1
- package/lib/firebase/readDatabase.js +7 -7
- package/lib/firebase/readDatabase.js.map +1 -1
- package/lib/hooks.d.ts +85 -192
- package/lib/hooks.js +731 -671
- package/lib/hooks.js.map +1 -1
- package/lib/images/GatsbyBenchmarks.d.ts +1 -2
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -1
- package/lib/index.js.map +1 -1
- package/lib/reduxHooks.d.ts +9 -41
- package/lib/reduxHooks.js +1 -49
- package/lib/reduxHooks.js.map +1 -1
- package/lib/tasksAndTips.js +368 -418
- package/lib/tasksAndTips.js.map +1 -1
- package/lib/typeDefinitions.d.ts +162 -83
- package/lib/util.d.ts +25 -1
- package/lib/util.js +329 -2
- package/lib/util.js.map +1 -1
- package/package.json +56 -56
- package/src/DatabaseDefinitions.ts +18 -18
- package/src/apiCalls.ts +128 -128
- package/src/config.ts +50 -53
- package/src/constants.ts +846 -796
- 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 +158 -153
- package/src/firebase/firebaseConfig.tsx +47 -45
- package/src/firebase/firebaseQuery.tsx +151 -151
- package/src/firebase/persistence.ts +84 -84
- package/src/firebase/readDatabase.tsx +236 -236
- package/src/firebase/util.tsx +352 -352
- package/src/firebase/writeDatabase.tsx +77 -77
- package/src/hooks.tsx +4476 -4463
- 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 -35
- package/src/readDatabase.tsx +3 -3
- package/src/reduxHooks.ts +295 -352
- package/src/tasksAndTips.ts +1267 -1267
- package/src/tutorialTips.ts +58 -58
- package/src/typeDefinitions.ts +1260 -1129
- package/src/util.ts +523 -177
- package/tsconfig.dev.json +5 -5
- package/tsconfig.json +21 -21
- package/lib/features/logs/logsSlice.d.ts +0 -93
- package/lib/features/logs/logsSlice.js +0 -146
- package/lib/features/logs/logsSlice.js.map +0 -1
- package/src/features/logs/logsSlice.ts +0 -208
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,22 +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
|
-
},
|
|
18
|
-
"compileOnSave": true,
|
|
19
|
-
"include": [ "src", "../index.test.js", "prisma" ],
|
|
20
|
-
"exclude": [ "node_modules", "lib" ]
|
|
21
|
-
}
|
|
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
|
+
}
|
|
22
22
|
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { DocumentData } from "firebase/firestore";
|
|
2
|
-
type InitialLogsState = {
|
|
3
|
-
status: string;
|
|
4
|
-
values: {
|
|
5
|
-
[key: string]: DocumentData;
|
|
6
|
-
};
|
|
7
|
-
};
|
|
8
|
-
export declare const fetchLogs: import("@reduxjs/toolkit").AsyncThunk<{
|
|
9
|
-
data: DocumentData;
|
|
10
|
-
selectedDate: string;
|
|
11
|
-
}, {
|
|
12
|
-
placementId: string;
|
|
13
|
-
selectedDate: string;
|
|
14
|
-
}, {
|
|
15
|
-
state?: unknown;
|
|
16
|
-
dispatch?: import("redux").Dispatch;
|
|
17
|
-
extra?: unknown;
|
|
18
|
-
rejectValue?: unknown;
|
|
19
|
-
serializedErrorType?: unknown;
|
|
20
|
-
pendingMeta?: unknown;
|
|
21
|
-
fulfilledMeta?: unknown;
|
|
22
|
-
rejectedMeta?: unknown;
|
|
23
|
-
}>;
|
|
24
|
-
export declare const editLog: import("@reduxjs/toolkit").AsyncThunk<{
|
|
25
|
-
data: unknown;
|
|
26
|
-
selectedDate: string;
|
|
27
|
-
userType: string;
|
|
28
|
-
}, {
|
|
29
|
-
value: any[] | {
|
|
30
|
-
[key: string]: unknown;
|
|
31
|
-
};
|
|
32
|
-
selectedDate: string;
|
|
33
|
-
userType: string;
|
|
34
|
-
placementId: string;
|
|
35
|
-
}, {
|
|
36
|
-
state?: unknown;
|
|
37
|
-
dispatch?: import("redux").Dispatch;
|
|
38
|
-
extra?: unknown;
|
|
39
|
-
rejectValue?: unknown;
|
|
40
|
-
serializedErrorType?: unknown;
|
|
41
|
-
pendingMeta?: unknown;
|
|
42
|
-
fulfilledMeta?: unknown;
|
|
43
|
-
rejectedMeta?: unknown;
|
|
44
|
-
}>;
|
|
45
|
-
export declare const addLogFile: import("@reduxjs/toolkit").AsyncThunk<{
|
|
46
|
-
data: string[];
|
|
47
|
-
userType: string;
|
|
48
|
-
selectedDate: string;
|
|
49
|
-
}, {
|
|
50
|
-
files: {
|
|
51
|
-
file: FileList;
|
|
52
|
-
};
|
|
53
|
-
userType: string;
|
|
54
|
-
selectedDate: string;
|
|
55
|
-
placementId: string;
|
|
56
|
-
}, {
|
|
57
|
-
state?: unknown;
|
|
58
|
-
dispatch?: import("redux").Dispatch;
|
|
59
|
-
extra?: unknown;
|
|
60
|
-
rejectValue?: unknown;
|
|
61
|
-
serializedErrorType?: unknown;
|
|
62
|
-
pendingMeta?: unknown;
|
|
63
|
-
fulfilledMeta?: unknown;
|
|
64
|
-
rejectedMeta?: unknown;
|
|
65
|
-
}>;
|
|
66
|
-
export declare const deleteLogFile: import("@reduxjs/toolkit").AsyncThunk<{
|
|
67
|
-
openFile: {
|
|
68
|
-
name: string;
|
|
69
|
-
url: string;
|
|
70
|
-
};
|
|
71
|
-
userType: string;
|
|
72
|
-
selectedDate: string;
|
|
73
|
-
}, {
|
|
74
|
-
openFile: {
|
|
75
|
-
name: string;
|
|
76
|
-
url: string;
|
|
77
|
-
};
|
|
78
|
-
userType: string;
|
|
79
|
-
selectedDate: string;
|
|
80
|
-
placementId: string;
|
|
81
|
-
}, {
|
|
82
|
-
state?: unknown;
|
|
83
|
-
dispatch?: import("redux").Dispatch;
|
|
84
|
-
extra?: unknown;
|
|
85
|
-
rejectValue?: unknown;
|
|
86
|
-
serializedErrorType?: unknown;
|
|
87
|
-
pendingMeta?: unknown;
|
|
88
|
-
fulfilledMeta?: unknown;
|
|
89
|
-
rejectedMeta?: unknown;
|
|
90
|
-
}>;
|
|
91
|
-
export declare const logsSlice: import("@reduxjs/toolkit").Slice<InitialLogsState, {}, "logs">;
|
|
92
|
-
declare const _default: import("redux").Reducer<InitialLogsState>;
|
|
93
|
-
export default _default;
|
|
@@ -1,146 +0,0 @@
|
|
|
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.logsSlice = exports.deleteLogFile = exports.addLogFile = exports.editLog = exports.fetchLogs = void 0;
|
|
7
|
-
const toolkit_1 = require("@reduxjs/toolkit");
|
|
8
|
-
const firebaseQuery_1 = __importDefault(require("../../firebase/firebaseQuery"));
|
|
9
|
-
const firestore_1 = require("firebase/firestore");
|
|
10
|
-
const writeDatabase_1 = require("../../firebase/writeDatabase");
|
|
11
|
-
const initialState = {
|
|
12
|
-
status: "",
|
|
13
|
-
values: {}
|
|
14
|
-
};
|
|
15
|
-
exports.fetchLogs = (0, toolkit_1.createAsyncThunk)("logs/fetchLogs", async ({ placementId, selectedDate }, { rejectWithValue }) => {
|
|
16
|
-
const firebaseQuery = new firebaseQuery_1.default();
|
|
17
|
-
try {
|
|
18
|
-
const data = await firebaseQuery.getDocData(["logs", `${placementId}-${selectedDate}`]);
|
|
19
|
-
return { "data": data, "selectedDate": selectedDate };
|
|
20
|
-
}
|
|
21
|
-
catch (error) {
|
|
22
|
-
return { "data": {}, "selectedDate": selectedDate };
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
exports.editLog = (0, toolkit_1.createAsyncThunk)("logs/editLog", async ({ value, selectedDate, userType, placementId }, { rejectWithValue }) => {
|
|
26
|
-
const firebaseQuery = new firebaseQuery_1.default();
|
|
27
|
-
try {
|
|
28
|
-
const empty = (Array.isArray(value) && value.length === 0) ||
|
|
29
|
-
(Object.entries(Object.values(value)[0])
|
|
30
|
-
.filter(([k, v]) => (![`${userType}Uid`, "completed"].includes(k)) && v)
|
|
31
|
-
.length === 0);
|
|
32
|
-
const updatedValue = empty
|
|
33
|
-
? null
|
|
34
|
-
: Array.isArray(value)
|
|
35
|
-
? value
|
|
36
|
-
: Object.values(value)[0];
|
|
37
|
-
await firebaseQuery.set(["logs", `${placementId}-${selectedDate}`], { [userType]: updatedValue }, true);
|
|
38
|
-
await firebaseQuery.update(["placements", placementId], { [userType + "Logs"]: empty ? (0, firestore_1.arrayRemove)(selectedDate) : (0, firestore_1.arrayUnion)(selectedDate) });
|
|
39
|
-
return { "data": updatedValue, "selectedDate": selectedDate, "userType": userType };
|
|
40
|
-
}
|
|
41
|
-
catch (error) {
|
|
42
|
-
return rejectWithValue(error);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
exports.addLogFile = (0, toolkit_1.createAsyncThunk)("logs/addLogFile", async ({ files, userType, selectedDate, placementId }, { rejectWithValue }) => {
|
|
46
|
-
const firebaseQuery = new firebaseQuery_1.default();
|
|
47
|
-
try {
|
|
48
|
-
const newFileNames = Array.from(files.file).map(file => file.name);
|
|
49
|
-
await (0, writeDatabase_1.uploadFiles)(Array.from(files.file), ["placements", placementId, "log", `${userType}_files`, selectedDate]);
|
|
50
|
-
await firebaseQuery.set(["logs", `${placementId}-${selectedDate}`], { [`${userType}_files`]: (0, firestore_1.arrayUnion)(...newFileNames) }, true);
|
|
51
|
-
return { "data": newFileNames, "userType": userType, "selectedDate": selectedDate };
|
|
52
|
-
}
|
|
53
|
-
catch (error) {
|
|
54
|
-
return rejectWithValue(error);
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
exports.deleteLogFile = (0, toolkit_1.createAsyncThunk)("logs/deleteLogFile", async ({ openFile, userType, selectedDate, placementId }, { rejectWithValue }) => {
|
|
58
|
-
const firebaseQuery = new firebaseQuery_1.default();
|
|
59
|
-
try {
|
|
60
|
-
await (0, writeDatabase_1.deleteStorageItem)(`placements/${placementId}/log/${userType}_files/${selectedDate}/${openFile.name}`);
|
|
61
|
-
await firebaseQuery.set(["logs", `${placementId}-${selectedDate}`], { [`${userType}_files`]: (0, firestore_1.arrayRemove)(openFile.name) }, true);
|
|
62
|
-
return { "openFile": openFile, "userType": userType, "selectedDate": selectedDate };
|
|
63
|
-
}
|
|
64
|
-
catch (error) {
|
|
65
|
-
return rejectWithValue(error);
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
exports.logsSlice = (0, toolkit_1.createSlice)({
|
|
69
|
-
name: "logs",
|
|
70
|
-
initialState,
|
|
71
|
-
reducers: {},
|
|
72
|
-
extraReducers(builder) {
|
|
73
|
-
builder
|
|
74
|
-
.addCase(exports.fetchLogs.pending, (state) => {
|
|
75
|
-
state.status = "loading";
|
|
76
|
-
})
|
|
77
|
-
.addCase(exports.fetchLogs.fulfilled, (state, action) => {
|
|
78
|
-
state.status = "success";
|
|
79
|
-
const { data, selectedDate } = action.payload;
|
|
80
|
-
state.values = { ...state.values, [selectedDate]: data };
|
|
81
|
-
})
|
|
82
|
-
.addCase(exports.fetchLogs.rejected, (state) => {
|
|
83
|
-
state.status = "rejected";
|
|
84
|
-
});
|
|
85
|
-
builder
|
|
86
|
-
.addCase(exports.editLog.pending, (state) => {
|
|
87
|
-
state.status = "loading";
|
|
88
|
-
})
|
|
89
|
-
.addCase(exports.editLog.fulfilled, (state, action) => {
|
|
90
|
-
state.status = "success";
|
|
91
|
-
const { data, selectedDate, userType } = action.payload;
|
|
92
|
-
const updatedLog = {
|
|
93
|
-
...state.values,
|
|
94
|
-
[userType]: data
|
|
95
|
-
};
|
|
96
|
-
state.values = { ...state.values, [selectedDate]: updatedLog };
|
|
97
|
-
})
|
|
98
|
-
.addCase(exports.editLog.rejected, (state) => {
|
|
99
|
-
state.status = "rejected";
|
|
100
|
-
});
|
|
101
|
-
builder
|
|
102
|
-
.addCase(exports.addLogFile.pending, (state) => {
|
|
103
|
-
state.status = "loading";
|
|
104
|
-
})
|
|
105
|
-
.addCase(exports.addLogFile.fulfilled, (state, action) => {
|
|
106
|
-
var _a;
|
|
107
|
-
state.status = "success";
|
|
108
|
-
const { data, selectedDate, userType } = action.payload;
|
|
109
|
-
const currentFiles = ((_a = state.values[selectedDate]) === null || _a === void 0 ? void 0 : _a[`${userType}_files`]) || [];
|
|
110
|
-
const updatedFiles = [...currentFiles, ...data];
|
|
111
|
-
state.values = {
|
|
112
|
-
...state.values,
|
|
113
|
-
[selectedDate]: {
|
|
114
|
-
...state.values[selectedDate],
|
|
115
|
-
[`${userType}_files`]: updatedFiles
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
})
|
|
119
|
-
.addCase(exports.addLogFile.rejected, (state) => {
|
|
120
|
-
state.status = "rejected";
|
|
121
|
-
});
|
|
122
|
-
builder
|
|
123
|
-
.addCase(exports.deleteLogFile.pending, (state) => {
|
|
124
|
-
state.status = "loading";
|
|
125
|
-
})
|
|
126
|
-
.addCase(exports.deleteLogFile.fulfilled, (state, action) => {
|
|
127
|
-
var _a;
|
|
128
|
-
state.status = "success";
|
|
129
|
-
const { openFile, selectedDate, userType } = action.payload;
|
|
130
|
-
const currentLog = state.values[selectedDate] || {};
|
|
131
|
-
const updatedFiles = ((_a = currentLog[`${userType}_files`]) === null || _a === void 0 ? void 0 : _a.filter((file) => file !== openFile.name)) || [];
|
|
132
|
-
state.values = {
|
|
133
|
-
...state.values,
|
|
134
|
-
[selectedDate]: {
|
|
135
|
-
...currentLog,
|
|
136
|
-
[`${userType}_files`]: updatedFiles
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
})
|
|
140
|
-
.addCase(exports.deleteLogFile.rejected, (state) => {
|
|
141
|
-
state.status = "rejected";
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
exports.default = exports.logsSlice.reducer;
|
|
146
|
-
//# sourceMappingURL=logsSlice.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logsSlice.js","sourceRoot":"","sources":["../../../src/features/logs/logsSlice.ts"],"names":[],"mappings":";;;;;;AAAA,8CAA+D;AAC/D,iFAAyD;AACzD,kDAA2E;AAC3E,gEAA8E;AAS9E,MAAM,YAAY,GAAqB;IACnC,MAAM,EAAE,EAAE;IACV,MAAM,EAAE,EAAE;CACb,CAAC;AAEW,QAAA,SAAS,GAAG,IAAA,0BAAgB,EACrC,gBAAgB,EAChB,KAAK,EAAE,EAAC,WAAW,EAAE,YAAY,EAA8C,EAAE,EAAE,eAAe,EAAE,EAAE,EAAE;IACtG,MAAM,aAAa,GAAG,IAAI,uBAAa,EAAE,CAAC;IAC1C,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,aAAa,CAAC,UAAU,CAAC,CAAC,MAAM,EAAE,GAAG,WAAW,IAAI,YAAY,EAAE,CAAC,CAAC,CAAA;QACvF,OAAO,EAAC,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,YAAY,EAAC,CAAA;IAErD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,EAAC,MAAM,EAAE,EAAE,EAAE,cAAc,EAAE,YAAY,EAAC,CAAA;IACnD,CAAC;AACH,CAAC,CACF,CAAC;AAES,QAAA,OAAO,GAAG,IAAA,0BAAgB,EACnC,cAAc,EACd,KAAK,EAAE,EAAC,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAyG,EAAE,EAAE,eAAe,EAAE,EAAE,EAAE;IAChL,MAAM,aAAa,GAAG,IAAI,uBAAa,EAAE,CAAC;IAC1C,IAAI,C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QACN,CAAC,CAAC;aAED,OAAO,CAAC,qBAAa,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;YACzC,KAAK,CAAC,MAAM,GAAG,UAAU,CAAA;QAC3B,CAAC,CAAC,CAAA;IACN,CAAC;CACJ,CAAC,CAAA;AAEJ,kBAAe,iBAAS,CAAC,OAAO,CAAC"}
|
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
import {createSlice, createAsyncThunk} from "@reduxjs/toolkit";
|
|
2
|
-
import FirebaseQuery from "../../firebase/firebaseQuery";
|
|
3
|
-
import { arrayRemove, arrayUnion, DocumentData } from "firebase/firestore";
|
|
4
|
-
import { deleteStorageItem, uploadFiles } from "../../firebase/writeDatabase";
|
|
5
|
-
|
|
6
|
-
type InitialLogsState = {
|
|
7
|
-
status: string,
|
|
8
|
-
values: {
|
|
9
|
-
[key: string]: DocumentData
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const initialState: InitialLogsState = {
|
|
14
|
-
status: "",
|
|
15
|
-
values: {}
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export const fetchLogs = createAsyncThunk(
|
|
19
|
-
"logs/fetchLogs",
|
|
20
|
-
async ({placementId, selectedDate}: {placementId: string, selectedDate: string}, { rejectWithValue }) => {
|
|
21
|
-
const firebaseQuery = new FirebaseQuery();
|
|
22
|
-
try {
|
|
23
|
-
const data = await firebaseQuery.getDocData(["logs", `${placementId}-${selectedDate}`])
|
|
24
|
-
return {"data": data, "selectedDate": selectedDate}
|
|
25
|
-
|
|
26
|
-
} catch (error) {
|
|
27
|
-
return {"data": {}, "selectedDate": selectedDate}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
export const editLog = createAsyncThunk(
|
|
33
|
-
"logs/editLog",
|
|
34
|
-
async ({value, selectedDate, userType, placementId}: {value: any[] | {[key: string]: unknown}, selectedDate: string, userType: string, placementId: string}, { rejectWithValue }) => {
|
|
35
|
-
const firebaseQuery = new FirebaseQuery();
|
|
36
|
-
try {
|
|
37
|
-
const empty =
|
|
38
|
-
(Array.isArray(value) && value.length === 0) ||
|
|
39
|
-
(Object.entries(Object.values(value)[0] as { [key: string]: unknown })
|
|
40
|
-
.filter(([k, v]) => (![`${userType}Uid`, "completed"].includes(k)) && v)
|
|
41
|
-
.length === 0);
|
|
42
|
-
|
|
43
|
-
const updatedValue = empty
|
|
44
|
-
? null
|
|
45
|
-
: Array.isArray(value)
|
|
46
|
-
? value
|
|
47
|
-
: Object.values(value)[0];
|
|
48
|
-
|
|
49
|
-
await firebaseQuery.set(
|
|
50
|
-
["logs", `${placementId}-${selectedDate}`],
|
|
51
|
-
{ [userType]: updatedValue },
|
|
52
|
-
true
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
await firebaseQuery.update(
|
|
56
|
-
["placements", placementId],
|
|
57
|
-
{ [userType + "Logs"]: empty ? arrayRemove(selectedDate) : arrayUnion(selectedDate) }
|
|
58
|
-
);
|
|
59
|
-
return {"data": updatedValue, "selectedDate": selectedDate, "userType": userType}
|
|
60
|
-
|
|
61
|
-
} catch (error) {
|
|
62
|
-
return rejectWithValue(error);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
)
|
|
66
|
-
|
|
67
|
-
export const addLogFile = createAsyncThunk(
|
|
68
|
-
"logs/addLogFile",
|
|
69
|
-
async ({files, userType, selectedDate, placementId}: {files: {file: FileList}, userType: string, selectedDate: string, placementId: string}, { rejectWithValue }) => {
|
|
70
|
-
const firebaseQuery = new FirebaseQuery();
|
|
71
|
-
|
|
72
|
-
try {
|
|
73
|
-
const newFileNames = Array.from(files.file).map(file => file.name);
|
|
74
|
-
await uploadFiles(
|
|
75
|
-
Array.from(files.file),
|
|
76
|
-
["placements", placementId, "log", `${userType}_files`, selectedDate]
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
await firebaseQuery.set(
|
|
80
|
-
["logs", `${placementId}-${selectedDate}`],
|
|
81
|
-
{ [`${userType}_files`]: arrayUnion(...newFileNames) },
|
|
82
|
-
true
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
return {"data": newFileNames, "userType": userType, "selectedDate": selectedDate}
|
|
86
|
-
|
|
87
|
-
} catch (error) {
|
|
88
|
-
return rejectWithValue(error);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
)
|
|
93
|
-
|
|
94
|
-
export const deleteLogFile = createAsyncThunk(
|
|
95
|
-
"logs/deleteLogFile",
|
|
96
|
-
async ({openFile, userType, selectedDate, placementId}: {openFile: {name: string, url: string}, userType: string, selectedDate: string, placementId: string}, { rejectWithValue }) => {
|
|
97
|
-
const firebaseQuery = new FirebaseQuery();
|
|
98
|
-
|
|
99
|
-
try {
|
|
100
|
-
await deleteStorageItem(`placements/${placementId}/log/${userType}_files/${selectedDate}/${openFile.name}`);
|
|
101
|
-
await firebaseQuery.set(
|
|
102
|
-
["logs", `${placementId}-${selectedDate}`],
|
|
103
|
-
{ [`${userType}_files`]: arrayRemove(openFile.name) },
|
|
104
|
-
true
|
|
105
|
-
);
|
|
106
|
-
return {"openFile": openFile, "userType": userType, "selectedDate": selectedDate}
|
|
107
|
-
|
|
108
|
-
} catch (error) {
|
|
109
|
-
return rejectWithValue(error);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
)
|
|
114
|
-
|
|
115
|
-
export const logsSlice = createSlice({
|
|
116
|
-
name: "logs",
|
|
117
|
-
initialState,
|
|
118
|
-
|
|
119
|
-
reducers: {},
|
|
120
|
-
|
|
121
|
-
extraReducers(builder){
|
|
122
|
-
builder
|
|
123
|
-
.addCase(fetchLogs.pending, (state) => {
|
|
124
|
-
state.status = "loading"
|
|
125
|
-
})
|
|
126
|
-
|
|
127
|
-
.addCase(fetchLogs.fulfilled, (state, action) => {
|
|
128
|
-
state.status = "success";
|
|
129
|
-
const {data, selectedDate} = action.payload
|
|
130
|
-
state.values = {...state.values, [selectedDate]: data}
|
|
131
|
-
})
|
|
132
|
-
|
|
133
|
-
.addCase(fetchLogs.rejected, (state) => {
|
|
134
|
-
state.status = "rejected"
|
|
135
|
-
})
|
|
136
|
-
|
|
137
|
-
builder
|
|
138
|
-
.addCase(editLog.pending, (state) => {
|
|
139
|
-
state.status = "loading"
|
|
140
|
-
})
|
|
141
|
-
|
|
142
|
-
.addCase(editLog.fulfilled, (state, action) => {
|
|
143
|
-
state.status = "success";
|
|
144
|
-
const {data, selectedDate, userType} = action.payload
|
|
145
|
-
|
|
146
|
-
const updatedLog = {
|
|
147
|
-
...state.values,
|
|
148
|
-
[userType]: data
|
|
149
|
-
}
|
|
150
|
-
state.values = {...state.values, [selectedDate]: updatedLog}
|
|
151
|
-
})
|
|
152
|
-
|
|
153
|
-
.addCase(editLog.rejected, (state) => {
|
|
154
|
-
state.status = "rejected"
|
|
155
|
-
})
|
|
156
|
-
|
|
157
|
-
builder
|
|
158
|
-
.addCase(addLogFile.pending, (state) => {
|
|
159
|
-
state.status = "loading"
|
|
160
|
-
})
|
|
161
|
-
|
|
162
|
-
.addCase(addLogFile.fulfilled, (state, action) => {
|
|
163
|
-
state.status = "success";
|
|
164
|
-
const {data, selectedDate, userType} = action.payload;
|
|
165
|
-
const currentFiles = state.values[selectedDate]?.[`${userType}_files`] || [];
|
|
166
|
-
const updatedFiles = [...currentFiles, ...data];
|
|
167
|
-
|
|
168
|
-
state.values = {
|
|
169
|
-
...state.values,
|
|
170
|
-
[selectedDate]: {
|
|
171
|
-
...state.values[selectedDate],
|
|
172
|
-
[`${userType}_files`]: updatedFiles
|
|
173
|
-
}
|
|
174
|
-
};
|
|
175
|
-
})
|
|
176
|
-
|
|
177
|
-
.addCase(addLogFile.rejected, (state) => {
|
|
178
|
-
state.status = "rejected"
|
|
179
|
-
})
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
builder
|
|
183
|
-
.addCase(deleteLogFile.pending, (state) => {
|
|
184
|
-
state.status = "loading"
|
|
185
|
-
})
|
|
186
|
-
|
|
187
|
-
.addCase(deleteLogFile.fulfilled, (state, action) => {
|
|
188
|
-
state.status = "success";
|
|
189
|
-
const {openFile, selectedDate, userType} = action.payload;
|
|
190
|
-
const currentLog = state.values[selectedDate] || {}
|
|
191
|
-
const updatedFiles = currentLog[`${userType}_files`]?.filter((file: string) => file !== openFile.name) || [];
|
|
192
|
-
|
|
193
|
-
state.values = {
|
|
194
|
-
...state.values,
|
|
195
|
-
[selectedDate]: {
|
|
196
|
-
...currentLog,
|
|
197
|
-
[`${userType}_files`]: updatedFiles
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
})
|
|
201
|
-
|
|
202
|
-
.addCase(deleteLogFile.rejected, (state) => {
|
|
203
|
-
state.status = "rejected"
|
|
204
|
-
})
|
|
205
|
-
}
|
|
206
|
-
})
|
|
207
|
-
|
|
208
|
-
export default logsSlice.reducer;
|