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.
Files changed (101) hide show
  1. package/.eslintrc.js +40 -40
  2. package/.gitattributes +2 -2
  3. package/deploy-all.js +75 -0
  4. package/lib/config.d.ts +0 -13
  5. package/lib/config.js +1 -3
  6. package/lib/config.js.map +1 -1
  7. package/lib/constants.d.ts +1 -0
  8. package/lib/constants.js +48 -1
  9. package/lib/constants.js.map +1 -1
  10. package/lib/features/config.d.ts +133 -133
  11. package/lib/features/config.js +35 -35
  12. package/lib/features/contacts/contacts.d.ts +75 -75
  13. package/lib/features/contacts/contacts.js +105 -105
  14. package/lib/features/downtime/useDowntime.d.ts +11 -11
  15. package/lib/features/downtime/useDowntime.js +22 -22
  16. package/lib/features/placements/studentPlacements/activePlacement.js +1 -1
  17. package/lib/features/placements/studentPlacements/activePlacement.js.map +1 -1
  18. package/lib/features/placements/studentPlacements/studentPlacementsSlice.d.ts +63 -63
  19. package/lib/features/placements/studentPlacements/studentPlacementsSlice.js +81 -81
  20. package/lib/features/providerPlacements/providerPlacementsSlice.d.ts +19 -19
  21. package/lib/features/providerPlacements/providerPlacementsSlice.js +24 -24
  22. package/lib/features/studentPlacements/studentPlacementsSlice.d.ts +62 -62
  23. package/lib/features/studentPlacements/studentPlacementsSlice.js +87 -87
  24. package/lib/features/studentPlacements/useStudentPlacements.d.ts +6 -6
  25. package/lib/features/studentPlacements/useStudentPlacements.js +18 -18
  26. package/lib/features/userSlice.d.ts +26 -26
  27. package/lib/features/userSlice.js +23 -23
  28. package/lib/features/users/useUserFunctions.d.ts +25 -25
  29. package/lib/features/users/useUserFunctions.js +124 -124
  30. package/lib/features/users/userSlice.d.ts +46 -46
  31. package/lib/features/users/userSlice.js +48 -48
  32. package/lib/firebase/firebase.d.ts +1 -1
  33. package/lib/firebase/firebase.js +8 -3
  34. package/lib/firebase/firebase.js.map +1 -1
  35. package/lib/firebase/firebaseConfig.js +1 -0
  36. package/lib/firebase/firebaseConfig.js.map +1 -1
  37. package/lib/firebase/readDatabase.js +7 -7
  38. package/lib/firebase/readDatabase.js.map +1 -1
  39. package/lib/hooks.d.ts +85 -192
  40. package/lib/hooks.js +731 -671
  41. package/lib/hooks.js.map +1 -1
  42. package/lib/images/GatsbyBenchmarks.d.ts +1 -2
  43. package/lib/index.d.ts +0 -1
  44. package/lib/index.js +0 -1
  45. package/lib/index.js.map +1 -1
  46. package/lib/reduxHooks.d.ts +9 -41
  47. package/lib/reduxHooks.js +1 -49
  48. package/lib/reduxHooks.js.map +1 -1
  49. package/lib/tasksAndTips.js +368 -418
  50. package/lib/tasksAndTips.js.map +1 -1
  51. package/lib/typeDefinitions.d.ts +162 -83
  52. package/lib/util.d.ts +25 -1
  53. package/lib/util.js +329 -2
  54. package/lib/util.js.map +1 -1
  55. package/package.json +56 -56
  56. package/src/DatabaseDefinitions.ts +18 -18
  57. package/src/apiCalls.ts +128 -128
  58. package/src/config.ts +50 -53
  59. package/src/constants.ts +846 -796
  60. package/src/databaseTypes.ts +42 -42
  61. package/src/features/analytics/useAnalytics.tsx +63 -63
  62. package/src/features/contacts/contactsSlice.ts +147 -147
  63. package/src/features/contacts/useContacts.tsx +73 -73
  64. package/src/features/dropdown/useDropdown.tsx +52 -52
  65. package/src/features/global/downtime/useDowntime.tsx +23 -23
  66. package/src/features/global/users/useUserFunctions.tsx +132 -132
  67. package/src/features/jobs/jobsSlice.ts +71 -71
  68. package/src/features/placements/studentPlacements/activePlacement.ts +68 -68
  69. package/src/features/placements/studentPlacements/completedStudentPlacementsSlice.ts +97 -97
  70. package/src/features/placements/studentPlacements/upcomingStudentPlacementsSlice.ts +108 -108
  71. package/src/features/placements/studentPlacements/useStudentPlacements.tsx +9 -9
  72. package/src/features/placements/types.ts +10 -10
  73. package/src/features/referrals/useReferrals.tsx +56 -56
  74. package/src/features/updates/useUpdates.tsx +38 -38
  75. package/src/firebase/firebase.tsx +158 -153
  76. package/src/firebase/firebaseConfig.tsx +47 -45
  77. package/src/firebase/firebaseQuery.tsx +151 -151
  78. package/src/firebase/persistence.ts +84 -84
  79. package/src/firebase/readDatabase.tsx +236 -236
  80. package/src/firebase/util.tsx +352 -352
  81. package/src/firebase/writeDatabase.tsx +77 -77
  82. package/src/hooks.tsx +4476 -4463
  83. package/src/images/GatsbyBenchmarks.tsx +711 -711
  84. package/src/images/LogFuturePlacement.jsx +64 -64
  85. package/src/images/LogPreviousPlacement.jsx +228 -228
  86. package/src/images/gatsby_benchmarks.svg +466 -466
  87. package/src/images/log_future_placement.svg +114 -114
  88. package/src/images/log_previous_placement.svg +199 -199
  89. package/src/index.ts +34 -35
  90. package/src/readDatabase.tsx +3 -3
  91. package/src/reduxHooks.ts +295 -352
  92. package/src/tasksAndTips.ts +1267 -1267
  93. package/src/tutorialTips.ts +58 -58
  94. package/src/typeDefinitions.ts +1260 -1129
  95. package/src/util.ts +523 -177
  96. package/tsconfig.dev.json +5 -5
  97. package/tsconfig.json +21 -21
  98. package/lib/features/logs/logsSlice.d.ts +0 -93
  99. package/lib/features/logs/logsSlice.js +0 -146
  100. package/lib/features/logs/logsSlice.js.map +0 -1
  101. package/src/features/logs/logsSlice.ts +0 -208
@@ -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;