@zauru-sdk/redux 1.0.10
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/CHANGELOG.md +8 -0
- package/LICENCE.md +11 -0
- package/dist/slices/agency.slice.d.ts +8 -0
- package/dist/slices/agency.slice.js +20 -0
- package/dist/slices/automaticNumbers.slice.d.ts +17 -0
- package/dist/slices/automaticNumbers.slice.js +20 -0
- package/dist/slices/catalogs.slice.d.ts +50 -0
- package/dist/slices/catalogs.slice.js +61 -0
- package/dist/slices/formValidation.slice.d.ts +14 -0
- package/dist/slices/formValidation.slice.js +16 -0
- package/dist/slices/index.d.ts +11 -0
- package/dist/slices/index.js +11 -0
- package/dist/slices/profile.slice.d.ts +26 -0
- package/dist/slices/profile.slice.js +22 -0
- package/dist/slices/reception.slice.d.ts +43 -0
- package/dist/slices/reception.slice.js +57 -0
- package/dist/slices/session.slice.d.ts +9 -0
- package/dist/slices/session.slice.js +13 -0
- package/dist/slices/tables.slice.d.ts +12 -0
- package/dist/slices/tables.slice.js +17 -0
- package/dist/slices/templates.slice.d.ts +13 -0
- package/dist/slices/templates.slice.js +19 -0
- package/dist/slices/user.slice.d.ts +12 -0
- package/dist/slices/user.slice.js +38 -0
- package/dist/slices/webapp-tables.slice.d.ts +8 -0
- package/dist/slices/webapp-tables.slice.js +20 -0
- package/dist/store.d.ts +8 -0
- package/dist/store.js +125 -0
- package/package.json +31 -0
- package/src/slices/agency.slice.ts +32 -0
- package/src/slices/automaticNumbers.slice.ts +41 -0
- package/src/slices/catalogs.slice.ts +178 -0
- package/src/slices/formValidation.slice.ts +32 -0
- package/src/slices/index.ts +11 -0
- package/src/slices/profile.slice.ts +49 -0
- package/src/slices/reception.slice.ts +118 -0
- package/src/slices/session.slice.ts +25 -0
- package/src/slices/tables.slice.ts +33 -0
- package/src/slices/templates.slice.ts +34 -0
- package/src/slices/user.slice.ts +64 -0
- package/src/slices/webapp-tables.slice.ts +35 -0
- package/src/store.ts +152 -0
- package/tsconfig.json +24 -0
package/dist/store.js
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { Tuple, configureStore } from "@reduxjs/toolkit";
|
|
2
|
+
import catalogsReducer from "./slices/catalogs.slice.js";
|
|
3
|
+
import profilesReducer from "./slices/profile.slice.js";
|
|
4
|
+
import webappTablesReducer from "./slices/webapp-tables.slice.js";
|
|
5
|
+
import receptionsReducer from "./slices/reception.slice.js";
|
|
6
|
+
import sessionReducer from "./slices/session.slice.js";
|
|
7
|
+
import templateReducer from "./slices/templates.slice.js";
|
|
8
|
+
import automaticNumberReducer from "./slices/automaticNumbers.slice.js";
|
|
9
|
+
import tableReducer from "./slices/tables.slice.js";
|
|
10
|
+
import formValidationReducer from "./slices/formValidation.slice.js";
|
|
11
|
+
export const LOCAL_STORAGE_REDUX_NAME = "___redux__state__v2";
|
|
12
|
+
const persistanceLocalStorageMiddleware = (store) => (next) => (action) => {
|
|
13
|
+
const result = next(action);
|
|
14
|
+
if (!(typeof document === "undefined")) {
|
|
15
|
+
localStorage.setItem(LOCAL_STORAGE_REDUX_NAME, JSON.stringify(store.getState()));
|
|
16
|
+
}
|
|
17
|
+
return result;
|
|
18
|
+
};
|
|
19
|
+
const preloadedState = (() => {
|
|
20
|
+
try {
|
|
21
|
+
if (!(typeof document === "undefined")) {
|
|
22
|
+
const savedState = localStorage.getItem(LOCAL_STORAGE_REDUX_NAME);
|
|
23
|
+
if (savedState) {
|
|
24
|
+
return JSON.parse(savedState);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
catch (e) {
|
|
29
|
+
// Ignorar los errores, se utiliza el estado inicial definido en cada reducer
|
|
30
|
+
}
|
|
31
|
+
})();
|
|
32
|
+
export const cleanLocalStorage = () => {
|
|
33
|
+
const savedState = localStorage.getItem(LOCAL_STORAGE_REDUX_NAME);
|
|
34
|
+
const state = JSON.parse(savedState ?? "{}");
|
|
35
|
+
try {
|
|
36
|
+
//delete all cookies
|
|
37
|
+
// const deleteAllCookies = () => {
|
|
38
|
+
// const cookies = document.cookie.split(";");
|
|
39
|
+
// for (const cookie of cookies) {
|
|
40
|
+
// const eqPos = cookie.indexOf("=");
|
|
41
|
+
// const name = eqPos > -1 ? cookie.substring(0, eqPos) : cookie;
|
|
42
|
+
// document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT";
|
|
43
|
+
// }
|
|
44
|
+
// };
|
|
45
|
+
// deleteAllCookies();
|
|
46
|
+
// //delete caché
|
|
47
|
+
// caches.keys().then((names) => {
|
|
48
|
+
// for (const name of names) {
|
|
49
|
+
// caches.delete(name);
|
|
50
|
+
// }
|
|
51
|
+
// });
|
|
52
|
+
//unregister service workers
|
|
53
|
+
// navigator.serviceWorker.getRegistrations().then((registrations) => {
|
|
54
|
+
// for (const registration of registrations) {
|
|
55
|
+
// registration.unregister();
|
|
56
|
+
// }
|
|
57
|
+
// });
|
|
58
|
+
// Limpiar todo el localStorage
|
|
59
|
+
localStorage.clear();
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
console.error(error);
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
const whitelist = {
|
|
66
|
+
automaticNumbers: ["purchaseOrderIdNumber", "dischargeIdNumber"],
|
|
67
|
+
receptions: ["queueNewReceptions"],
|
|
68
|
+
};
|
|
69
|
+
if (!(typeof document === "undefined") && Object.keys(state)?.length > 0) {
|
|
70
|
+
const initialState = {
|
|
71
|
+
catalogs: catalogsReducer(undefined, { type: "" }),
|
|
72
|
+
profiles: profilesReducer(undefined, { type: "" }),
|
|
73
|
+
webappTables: webappTablesReducer(undefined, { type: "" }),
|
|
74
|
+
receptions: receptionsReducer(undefined, { type: "" }),
|
|
75
|
+
session: sessionReducer(undefined, { type: "" }),
|
|
76
|
+
templates: templateReducer(undefined, { type: "" }),
|
|
77
|
+
automaticNumbers: automaticNumberReducer(undefined, { type: "" }),
|
|
78
|
+
tables: tableReducer(undefined, { type: "" }),
|
|
79
|
+
formValidation: formValidationReducer(undefined, { type: "" }),
|
|
80
|
+
};
|
|
81
|
+
const newState = { ...initialState };
|
|
82
|
+
for (const reducerName in whitelist) {
|
|
83
|
+
if (state.hasOwnProperty(reducerName)) {
|
|
84
|
+
const key = reducerName;
|
|
85
|
+
const reducerState = state[key];
|
|
86
|
+
const whitelistKey = whitelist[key];
|
|
87
|
+
if (whitelistKey && whitelistKey.length > 0) {
|
|
88
|
+
newState[key] = newState[key] ? { ...newState[key] } : {};
|
|
89
|
+
for (const propertyName of whitelistKey) {
|
|
90
|
+
if (reducerState?.hasOwnProperty(propertyName)) {
|
|
91
|
+
const propKey = propertyName;
|
|
92
|
+
if (newState[key] && reducerState) {
|
|
93
|
+
newState[key][propKey] = reducerState[propKey];
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
else if (reducerState) {
|
|
99
|
+
newState[key] = reducerState;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
// Guarda el nuevo estado en el almacenamiento local
|
|
104
|
+
localStorage.setItem(LOCAL_STORAGE_REDUX_NAME, JSON.stringify(newState));
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
catch (e) {
|
|
108
|
+
console.error("Ocurrió un error al clonar y eliminar el viejo localStorage");
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
export const store = configureStore({
|
|
112
|
+
reducer: {
|
|
113
|
+
catalogs: catalogsReducer,
|
|
114
|
+
profiles: profilesReducer,
|
|
115
|
+
webappTables: webappTablesReducer,
|
|
116
|
+
receptions: receptionsReducer,
|
|
117
|
+
session: sessionReducer,
|
|
118
|
+
templates: templateReducer,
|
|
119
|
+
automaticNumbers: automaticNumberReducer,
|
|
120
|
+
tables: tableReducer,
|
|
121
|
+
formValidation: formValidationReducer,
|
|
122
|
+
},
|
|
123
|
+
preloadedState,
|
|
124
|
+
middleware: (getDefaultMiddleware) => new Tuple(persistanceLocalStorageMiddleware),
|
|
125
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zauru-sdk/redux",
|
|
3
|
+
"version": "1.0.10",
|
|
4
|
+
"description": "Estructura de Redux propuesta para el desarrollo de webapps en Zauru.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
14
|
+
},
|
|
15
|
+
"author": "Oscar Cuéllar",
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"typescript": "^5.1.6"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@reduxjs/toolkit": "^2.2.1",
|
|
22
|
+
"@zauru-sdk/graphql": "^1.0.9",
|
|
23
|
+
"@zauru-sdk/services": "^1.0.10",
|
|
24
|
+
"@zauru-sdk/types": "^1.0.10",
|
|
25
|
+
"@zauru-sdk/utils": "^1.0.10"
|
|
26
|
+
},
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=18.0.0"
|
|
29
|
+
},
|
|
30
|
+
"gitHead": "92bcefbeded758ac406e0436dc5c1894390a319d"
|
|
31
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { PayloadAction } from "@reduxjs/toolkit";
|
|
2
|
+
import { createSlice } from "@reduxjs/toolkit";
|
|
3
|
+
import { AgencyGraphQL } from "@zauru-sdk/types";
|
|
4
|
+
|
|
5
|
+
export interface AgencyState {
|
|
6
|
+
agencyProfile: AgencyGraphQL;
|
|
7
|
+
loadingAgencyProfile: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const initialState: AgencyState = {
|
|
11
|
+
agencyProfile: {} as AgencyGraphQL,
|
|
12
|
+
loadingAgencyProfile: false,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const agencySlice = createSlice({
|
|
16
|
+
name: "agency",
|
|
17
|
+
initialState,
|
|
18
|
+
reducers: {
|
|
19
|
+
setAgencyProfile: (state, action: PayloadAction<AgencyGraphQL>) => {
|
|
20
|
+
state.agencyProfile = action.payload;
|
|
21
|
+
},
|
|
22
|
+
setLoadingAgencyProfile: (state, action: PayloadAction<boolean>) => {
|
|
23
|
+
state.loadingAgencyProfile = action.payload;
|
|
24
|
+
state.loadingAgencyProfile = false;
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export const { setAgencyProfile, setLoadingAgencyProfile } =
|
|
30
|
+
agencySlice.actions;
|
|
31
|
+
|
|
32
|
+
export default agencySlice.reducer;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { PayloadAction } from "@reduxjs/toolkit";
|
|
2
|
+
import { createSlice } from "@reduxjs/toolkit";
|
|
3
|
+
|
|
4
|
+
export type AUTOMATIC_NUMBER_NAMES =
|
|
5
|
+
| "dischargeIdNumber"
|
|
6
|
+
| "purchaseOrderIdNumber";
|
|
7
|
+
|
|
8
|
+
export interface AutomaticNumberState {
|
|
9
|
+
purchaseOrderIdNumber: { loading: boolean; data: number | string };
|
|
10
|
+
dischargeIdNumber: { loading: boolean; data: number | string };
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const initialState: AutomaticNumberState = {
|
|
14
|
+
purchaseOrderIdNumber: { data: "", loading: false },
|
|
15
|
+
dischargeIdNumber: { data: "NCB00000", loading: false },
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const automaticNumbersSlice = createSlice({
|
|
19
|
+
name: "automaticNumbers",
|
|
20
|
+
initialState,
|
|
21
|
+
reducers: {
|
|
22
|
+
automaticNumberFetchStart: (
|
|
23
|
+
state,
|
|
24
|
+
action: PayloadAction<AUTOMATIC_NUMBER_NAMES>
|
|
25
|
+
) => {
|
|
26
|
+
state[action.payload].loading = true;
|
|
27
|
+
},
|
|
28
|
+
automaticNumberFetchSuccess: (
|
|
29
|
+
state,
|
|
30
|
+
action: PayloadAction<{ name: AUTOMATIC_NUMBER_NAMES; data: any }>
|
|
31
|
+
) => {
|
|
32
|
+
state[action.payload.name].data = action.payload.data;
|
|
33
|
+
state[action.payload.name].loading = false;
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
export const { automaticNumberFetchStart, automaticNumberFetchSuccess } =
|
|
39
|
+
automaticNumbersSlice.actions;
|
|
40
|
+
|
|
41
|
+
export default automaticNumbersSlice.reducer;
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import type { PayloadAction } from "@reduxjs/toolkit";
|
|
2
|
+
import { createSlice } from "@reduxjs/toolkit";
|
|
3
|
+
import type {
|
|
4
|
+
AgencyGraphQL,
|
|
5
|
+
BitacoraPOMassive,
|
|
6
|
+
BundleGraphQL,
|
|
7
|
+
CaseGraphQL,
|
|
8
|
+
CurrencyGraphQL,
|
|
9
|
+
EmployeeGraphQL,
|
|
10
|
+
FormGraphQL,
|
|
11
|
+
FormSubmissionGraphQL,
|
|
12
|
+
InvoiceGraphQL,
|
|
13
|
+
ItemCategoryGraphQL,
|
|
14
|
+
ItemGraphQL,
|
|
15
|
+
LotStockGraphQL,
|
|
16
|
+
MotivoRechazo,
|
|
17
|
+
PayeeCategoryGraphQL,
|
|
18
|
+
PayeeGraphQL,
|
|
19
|
+
PaymentTermGraphQL,
|
|
20
|
+
ReceptionType,
|
|
21
|
+
ShipmentGraphQL,
|
|
22
|
+
SuggestedPriceGraphQL,
|
|
23
|
+
Template,
|
|
24
|
+
TipoMuestra,
|
|
25
|
+
WebAppRowGraphQL,
|
|
26
|
+
} from "@zauru-sdk/types";
|
|
27
|
+
|
|
28
|
+
export type ONLINE_CATALOGS_NAMES =
|
|
29
|
+
| "invoiceFormSubmissionsByInvoiceId"
|
|
30
|
+
| "invoiceFormSubmissionsByAgencyId";
|
|
31
|
+
|
|
32
|
+
export type CATALOGS_NAMES =
|
|
33
|
+
| "agencies"
|
|
34
|
+
| "suggestedPrices"
|
|
35
|
+
| "providers"
|
|
36
|
+
| "providerCategories"
|
|
37
|
+
| "receptionTypes"
|
|
38
|
+
| "tiposDeMuestra"
|
|
39
|
+
| "motivosRechazo"
|
|
40
|
+
| "bitacoraRechazoMasivo"
|
|
41
|
+
| "items"
|
|
42
|
+
| "itemsByReception"
|
|
43
|
+
| "itemsByLab"
|
|
44
|
+
| "itemServicesByLab"
|
|
45
|
+
| "itemCategoriesForLab"
|
|
46
|
+
| "payees"
|
|
47
|
+
| "payeesForLab"
|
|
48
|
+
| "payeeCategoriesLabPrices"
|
|
49
|
+
| "clientCategories"
|
|
50
|
+
| "bundlesRecipForLab"
|
|
51
|
+
| "currencies"
|
|
52
|
+
| "paymentTerms"
|
|
53
|
+
| "employeesByLab"
|
|
54
|
+
| "employeesByCurrentAgency"
|
|
55
|
+
| "invoicesByLab"
|
|
56
|
+
| "invoiceForms"
|
|
57
|
+
| "caseForms"
|
|
58
|
+
| "invoiceFormSubmissions"
|
|
59
|
+
| "myCases"
|
|
60
|
+
| "myCaseFormSubmissions"
|
|
61
|
+
| "shipmentsToMyAgency"
|
|
62
|
+
| "myAgencyLotStocks"
|
|
63
|
+
| "shipments"
|
|
64
|
+
| "bookings"
|
|
65
|
+
| "templates"
|
|
66
|
+
| "bundlesForLab";
|
|
67
|
+
|
|
68
|
+
type LoadingState<T> = {
|
|
69
|
+
data: T;
|
|
70
|
+
loading: boolean;
|
|
71
|
+
reFetch: boolean;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
type CatalogState = {
|
|
75
|
+
agencies: LoadingState<AgencyGraphQL[]>;
|
|
76
|
+
suggestedPrices: LoadingState<SuggestedPriceGraphQL[]>;
|
|
77
|
+
providers: LoadingState<PayeeGraphQL[]>;
|
|
78
|
+
providerCategories: LoadingState<PayeeCategoryGraphQL[]>;
|
|
79
|
+
payees: LoadingState<PayeeGraphQL[]>;
|
|
80
|
+
payeesForLab: LoadingState<PayeeGraphQL[]>;
|
|
81
|
+
payeeCategoriesLabPrices: LoadingState<PayeeCategoryGraphQL[]>;
|
|
82
|
+
clientCategories: LoadingState<PayeeCategoryGraphQL[]>;
|
|
83
|
+
receptionTypes: LoadingState<WebAppRowGraphQL<ReceptionType>[]>;
|
|
84
|
+
tiposDeMuestra: LoadingState<WebAppRowGraphQL<TipoMuestra>[]>;
|
|
85
|
+
templates: LoadingState<WebAppRowGraphQL<Template>[]>;
|
|
86
|
+
shipments: LoadingState<ShipmentGraphQL[]>;
|
|
87
|
+
bookings: LoadingState<ShipmentGraphQL[]>;
|
|
88
|
+
motivosRechazo: LoadingState<WebAppRowGraphQL<MotivoRechazo>[]>;
|
|
89
|
+
bitacoraRechazoMasivo: LoadingState<WebAppRowGraphQL<BitacoraPOMassive>[]>;
|
|
90
|
+
items: LoadingState<ItemGraphQL[]>;
|
|
91
|
+
itemsByReception: LoadingState<ItemGraphQL[]>;
|
|
92
|
+
itemsByLab: LoadingState<ItemGraphQL[]>;
|
|
93
|
+
itemServicesByLab: LoadingState<ItemGraphQL[]>;
|
|
94
|
+
itemCategoriesForLab: LoadingState<ItemCategoryGraphQL[]>;
|
|
95
|
+
bundlesRecipForLab: LoadingState<BundleGraphQL[]>;
|
|
96
|
+
bundlesForLab: LoadingState<BundleGraphQL[]>;
|
|
97
|
+
currencies: LoadingState<CurrencyGraphQL[]>;
|
|
98
|
+
paymentTerms: LoadingState<PaymentTermGraphQL[]>;
|
|
99
|
+
employeesByLab: LoadingState<EmployeeGraphQL[]>;
|
|
100
|
+
employeesByCurrentAgency: LoadingState<EmployeeGraphQL[]>;
|
|
101
|
+
invoicesByLab: LoadingState<InvoiceGraphQL[]>;
|
|
102
|
+
invoiceForms: LoadingState<FormGraphQL[]>;
|
|
103
|
+
caseForms: LoadingState<FormGraphQL[]>;
|
|
104
|
+
invoiceFormSubmissions: LoadingState<FormSubmissionGraphQL[]>;
|
|
105
|
+
myCases: LoadingState<CaseGraphQL[]>;
|
|
106
|
+
myCaseFormSubmissions: LoadingState<FormSubmissionGraphQL[]>;
|
|
107
|
+
myAgencyLotStocks: LoadingState<LotStockGraphQL[]>;
|
|
108
|
+
shipmentsToMyAgency: LoadingState<ShipmentGraphQL[]>;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const createLoadingState = <T>(initialData: T): LoadingState<T> => ({
|
|
112
|
+
data: initialData,
|
|
113
|
+
loading: false,
|
|
114
|
+
reFetch: false,
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
const initialState: CatalogState = {
|
|
118
|
+
agencies: createLoadingState([]),
|
|
119
|
+
suggestedPrices: createLoadingState([]),
|
|
120
|
+
providers: createLoadingState([]),
|
|
121
|
+
providerCategories: createLoadingState([]),
|
|
122
|
+
receptionTypes: createLoadingState([]),
|
|
123
|
+
tiposDeMuestra: createLoadingState([]),
|
|
124
|
+
templates: createLoadingState([]),
|
|
125
|
+
shipments: createLoadingState([]),
|
|
126
|
+
bookings: createLoadingState([]),
|
|
127
|
+
motivosRechazo: createLoadingState([]),
|
|
128
|
+
bitacoraRechazoMasivo: createLoadingState([]),
|
|
129
|
+
items: createLoadingState([]),
|
|
130
|
+
itemsByReception: createLoadingState([]),
|
|
131
|
+
payees: createLoadingState([]),
|
|
132
|
+
payeesForLab: createLoadingState([]),
|
|
133
|
+
itemCategoriesForLab: createLoadingState([]),
|
|
134
|
+
payeeCategoriesLabPrices: createLoadingState([]),
|
|
135
|
+
clientCategories: createLoadingState([]),
|
|
136
|
+
itemsByLab: createLoadingState([]),
|
|
137
|
+
itemServicesByLab: createLoadingState([]),
|
|
138
|
+
bundlesRecipForLab: createLoadingState([]),
|
|
139
|
+
bundlesForLab: createLoadingState([]),
|
|
140
|
+
currencies: createLoadingState([]),
|
|
141
|
+
paymentTerms: createLoadingState([]),
|
|
142
|
+
employeesByLab: createLoadingState([]),
|
|
143
|
+
employeesByCurrentAgency: createLoadingState([]),
|
|
144
|
+
invoicesByLab: createLoadingState([]),
|
|
145
|
+
invoiceForms: createLoadingState([]),
|
|
146
|
+
caseForms: createLoadingState([]),
|
|
147
|
+
invoiceFormSubmissions: createLoadingState([]),
|
|
148
|
+
myCases: createLoadingState([]),
|
|
149
|
+
myCaseFormSubmissions: createLoadingState([]),
|
|
150
|
+
myAgencyLotStocks: createLoadingState([]),
|
|
151
|
+
shipmentsToMyAgency: createLoadingState([]),
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const catalogsSlice = createSlice({
|
|
155
|
+
name: "catalogs",
|
|
156
|
+
initialState,
|
|
157
|
+
reducers: {
|
|
158
|
+
catalogsSetReFetch: (state, action: PayloadAction<CATALOGS_NAMES>) => {
|
|
159
|
+
state[action.payload].reFetch = true;
|
|
160
|
+
},
|
|
161
|
+
catalogsFetchStart: (state, action: PayloadAction<CATALOGS_NAMES>) => {
|
|
162
|
+
state[action.payload].loading = true;
|
|
163
|
+
},
|
|
164
|
+
catalogsFetchSuccess: (
|
|
165
|
+
state,
|
|
166
|
+
action: PayloadAction<{ name: CATALOGS_NAMES; data: any[] }>
|
|
167
|
+
) => {
|
|
168
|
+
state[action.payload.name].data = action.payload.data;
|
|
169
|
+
state[action.payload.name].loading = false;
|
|
170
|
+
state[action.payload.name].reFetch = false;
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
export const { catalogsFetchStart, catalogsFetchSuccess, catalogsSetReFetch } =
|
|
176
|
+
catalogsSlice.actions;
|
|
177
|
+
|
|
178
|
+
export default catalogsSlice.reducer;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { createSlice, type PayloadAction } from "@reduxjs/toolkit";
|
|
2
|
+
|
|
3
|
+
export type FormValidations = {
|
|
4
|
+
formValidations: {
|
|
5
|
+
[key: string]: {
|
|
6
|
+
//formName
|
|
7
|
+
[key: string]: string; //fieldName
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const initialState: FormValidations = {
|
|
13
|
+
formValidations: {},
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const formValidationsSlice = createSlice({
|
|
17
|
+
name: "formValidations",
|
|
18
|
+
initialState,
|
|
19
|
+
reducers: {
|
|
20
|
+
setFieldError: (
|
|
21
|
+
state,
|
|
22
|
+
action: PayloadAction<{ formName: string; name: string; error: string }>
|
|
23
|
+
) => {
|
|
24
|
+
state.formValidations[action.payload.formName][action.payload.name] =
|
|
25
|
+
action.payload.error;
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export const { setFieldError } = formValidationsSlice.actions;
|
|
31
|
+
|
|
32
|
+
export default formValidationsSlice.reducer;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from "./agency.slice.js";
|
|
2
|
+
export * from "./automaticNumbers.slice.js";
|
|
3
|
+
export * from "./catalogs.slice.js";
|
|
4
|
+
export * from "./formValidation.slice.js";
|
|
5
|
+
export * from "./profile.slice.js";
|
|
6
|
+
export * from "./reception.slice.js";
|
|
7
|
+
export * from "./session.slice.js";
|
|
8
|
+
export * from "./tables.slice.js";
|
|
9
|
+
export * from "./templates.slice.js";
|
|
10
|
+
export * from "./user.slice.js";
|
|
11
|
+
export * from "./webapp-tables.slice.js";
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { PayloadAction } from "@reduxjs/toolkit";
|
|
2
|
+
import { createSlice } from "@reduxjs/toolkit";
|
|
3
|
+
import type {
|
|
4
|
+
AgencyGraphQL,
|
|
5
|
+
EmployeeGraphQL,
|
|
6
|
+
OauthProfile,
|
|
7
|
+
ProfileResponse,
|
|
8
|
+
} from "@zauru-sdk/types";
|
|
9
|
+
|
|
10
|
+
export type PROFILE_NAMES =
|
|
11
|
+
| "userProfile"
|
|
12
|
+
| "oauthProfile"
|
|
13
|
+
| "employeeProfile"
|
|
14
|
+
| "agencyProfile";
|
|
15
|
+
|
|
16
|
+
export interface ProfilesState {
|
|
17
|
+
userProfile: { loading: boolean; data: ProfileResponse };
|
|
18
|
+
oauthProfile: { loading: boolean; data: OauthProfile };
|
|
19
|
+
employeeProfile: { loading: boolean; data: EmployeeGraphQL };
|
|
20
|
+
agencyProfile: { loading: boolean; data: AgencyGraphQL };
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const initialState: ProfilesState = {
|
|
24
|
+
userProfile: { data: {} as ProfileResponse, loading: false },
|
|
25
|
+
oauthProfile: { data: {} as OauthProfile, loading: false },
|
|
26
|
+
employeeProfile: { data: {} as EmployeeGraphQL, loading: false },
|
|
27
|
+
agencyProfile: { data: {} as AgencyGraphQL, loading: false },
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const profileSlice = createSlice({
|
|
31
|
+
name: "profile",
|
|
32
|
+
initialState,
|
|
33
|
+
reducers: {
|
|
34
|
+
profileFetchStart: (state, action: PayloadAction<PROFILE_NAMES>) => {
|
|
35
|
+
state[action.payload].loading = true;
|
|
36
|
+
},
|
|
37
|
+
profileFetchSuccess: (
|
|
38
|
+
state,
|
|
39
|
+
action: PayloadAction<{ name: PROFILE_NAMES; data: any }>
|
|
40
|
+
) => {
|
|
41
|
+
state[action.payload.name].data = action.payload.data;
|
|
42
|
+
state[action.payload.name].loading = false;
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
export const { profileFetchStart, profileFetchSuccess } = profileSlice.actions;
|
|
48
|
+
|
|
49
|
+
export default profileSlice.reducer;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import type { PayloadAction } from "@reduxjs/toolkit";
|
|
2
|
+
import { createSlice } from "@reduxjs/toolkit";
|
|
3
|
+
import {
|
|
4
|
+
ItemAssociatedLots,
|
|
5
|
+
NewPurchaseOrderResponse,
|
|
6
|
+
PurchaseOrderGeneralInfo,
|
|
7
|
+
PurchaseOrderGraphQL,
|
|
8
|
+
RejectionWebAppTableObject,
|
|
9
|
+
WebAppRowGraphQL,
|
|
10
|
+
QueueFormReceptionWebAppTable,
|
|
11
|
+
} from "@zauru-sdk/types";
|
|
12
|
+
|
|
13
|
+
export type RECEPTION_NAMES =
|
|
14
|
+
| "basketLots"
|
|
15
|
+
| "rejectionInfo"
|
|
16
|
+
| "newPurchaseOrderInfo"
|
|
17
|
+
| "purchaseOrderGeneralInfo"
|
|
18
|
+
| "poReceptions"
|
|
19
|
+
| "queueNewReceptions";
|
|
20
|
+
|
|
21
|
+
export interface ReceptionState {
|
|
22
|
+
basketLots: { loading: boolean; data: ItemAssociatedLots; reFetch: boolean };
|
|
23
|
+
rejectionInfo: {
|
|
24
|
+
loading: boolean;
|
|
25
|
+
data: RejectionWebAppTableObject;
|
|
26
|
+
reFetch: boolean;
|
|
27
|
+
};
|
|
28
|
+
newPurchaseOrderInfo: {
|
|
29
|
+
loading: boolean;
|
|
30
|
+
data: NewPurchaseOrderResponse;
|
|
31
|
+
reFetch: boolean;
|
|
32
|
+
};
|
|
33
|
+
purchaseOrderGeneralInfo: {
|
|
34
|
+
loading: boolean;
|
|
35
|
+
data: PurchaseOrderGeneralInfo;
|
|
36
|
+
reFetch: boolean;
|
|
37
|
+
};
|
|
38
|
+
poReceptions: {
|
|
39
|
+
loading: boolean;
|
|
40
|
+
data: PurchaseOrderGraphQL[];
|
|
41
|
+
reFetch: boolean;
|
|
42
|
+
};
|
|
43
|
+
queueNewReceptions: {
|
|
44
|
+
loading: boolean;
|
|
45
|
+
data: WebAppRowGraphQL<QueueFormReceptionWebAppTable>[];
|
|
46
|
+
reFetch: boolean;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const initialState: ReceptionState = {
|
|
51
|
+
basketLots: {
|
|
52
|
+
data: {} as ItemAssociatedLots,
|
|
53
|
+
loading: false,
|
|
54
|
+
reFetch: false,
|
|
55
|
+
},
|
|
56
|
+
rejectionInfo: {
|
|
57
|
+
data: {} as RejectionWebAppTableObject,
|
|
58
|
+
loading: false,
|
|
59
|
+
reFetch: false,
|
|
60
|
+
},
|
|
61
|
+
newPurchaseOrderInfo: {
|
|
62
|
+
data: {} as NewPurchaseOrderResponse,
|
|
63
|
+
loading: false,
|
|
64
|
+
reFetch: false,
|
|
65
|
+
},
|
|
66
|
+
purchaseOrderGeneralInfo: {
|
|
67
|
+
data: {} as PurchaseOrderGeneralInfo,
|
|
68
|
+
loading: false,
|
|
69
|
+
reFetch: false,
|
|
70
|
+
},
|
|
71
|
+
poReceptions: {
|
|
72
|
+
data: [],
|
|
73
|
+
loading: false,
|
|
74
|
+
reFetch: false,
|
|
75
|
+
},
|
|
76
|
+
queueNewReceptions: {
|
|
77
|
+
data: [],
|
|
78
|
+
loading: false,
|
|
79
|
+
reFetch: false,
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const receptionSlice = createSlice({
|
|
84
|
+
name: "reception",
|
|
85
|
+
initialState,
|
|
86
|
+
reducers: {
|
|
87
|
+
receptionFetchStart: (state, action: PayloadAction<RECEPTION_NAMES>) => {
|
|
88
|
+
state[action.payload].loading = true;
|
|
89
|
+
},
|
|
90
|
+
receptionFetchSuccess: (
|
|
91
|
+
state,
|
|
92
|
+
action: PayloadAction<{ name: RECEPTION_NAMES; data: any }>
|
|
93
|
+
) => {
|
|
94
|
+
state[action.payload.name].data = action.payload.data;
|
|
95
|
+
state[action.payload.name].loading = false;
|
|
96
|
+
},
|
|
97
|
+
receptionConcatToArray: (
|
|
98
|
+
state,
|
|
99
|
+
action: PayloadAction<{ name: RECEPTION_NAMES; data: any }>
|
|
100
|
+
) => {
|
|
101
|
+
if (Array.isArray(state[action.payload.name].data)) {
|
|
102
|
+
state[action.payload.name].data = [
|
|
103
|
+
...(state[action.payload.name].data as any),
|
|
104
|
+
action.payload.data,
|
|
105
|
+
];
|
|
106
|
+
}
|
|
107
|
+
state[action.payload.name].loading = false;
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
export const {
|
|
113
|
+
receptionFetchStart,
|
|
114
|
+
receptionFetchSuccess,
|
|
115
|
+
receptionConcatToArray,
|
|
116
|
+
} = receptionSlice.actions;
|
|
117
|
+
|
|
118
|
+
export default receptionSlice.reducer;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { PayloadAction } from "@reduxjs/toolkit";
|
|
2
|
+
import { createSlice } from "@reduxjs/toolkit";
|
|
3
|
+
|
|
4
|
+
export interface SessionState {
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const initialState: SessionState = {};
|
|
9
|
+
|
|
10
|
+
const sessionSlice = createSlice({
|
|
11
|
+
name: "session",
|
|
12
|
+
initialState,
|
|
13
|
+
reducers: {
|
|
14
|
+
setSessionValue: (
|
|
15
|
+
state,
|
|
16
|
+
action: PayloadAction<{ name: string; data: any }>
|
|
17
|
+
) => {
|
|
18
|
+
state[action.payload.name] = action.payload.data;
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export const { setSessionValue } = sessionSlice.actions;
|
|
24
|
+
|
|
25
|
+
export default sessionSlice.reducer;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { PayloadAction } from "@reduxjs/toolkit";
|
|
2
|
+
import { createSlice } from "@reduxjs/toolkit";
|
|
3
|
+
|
|
4
|
+
export type TABLE_NAMES = "pageTable1" | "pageTable2" | "pageTable3";
|
|
5
|
+
|
|
6
|
+
export interface TableState {
|
|
7
|
+
pageTable1: number;
|
|
8
|
+
pageTable2: number;
|
|
9
|
+
pageTable3: number;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const initialState: TableState = {
|
|
13
|
+
pageTable1: 1,
|
|
14
|
+
pageTable2: 1,
|
|
15
|
+
pageTable3: 1,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const tableSlice = createSlice({
|
|
19
|
+
name: "table",
|
|
20
|
+
initialState,
|
|
21
|
+
reducers: {
|
|
22
|
+
tableSetPage: (
|
|
23
|
+
state,
|
|
24
|
+
action: PayloadAction<{ name: TABLE_NAMES; data: number }>
|
|
25
|
+
) => {
|
|
26
|
+
state[action.payload.name] = action.payload.data;
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export const { tableSetPage } = tableSlice.actions;
|
|
32
|
+
|
|
33
|
+
export default tableSlice.reducer;
|