@zauru-sdk/redux 1.0.50 → 1.0.52

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 (51) hide show
  1. package/dist/cjs/index.js +18 -0
  2. package/dist/{slices → cjs/slices}/agency.slice.js +8 -4
  3. package/dist/{slices → cjs/slices}/automaticNumbers.slice.js +8 -4
  4. package/dist/{slices → cjs/slices}/catalogs.slice.js +8 -4
  5. package/dist/cjs/slices/formValidation.slice.js +19 -0
  6. package/dist/cjs/slices/index.js +27 -0
  7. package/dist/{slices → cjs/slices}/profile.slice.js +8 -4
  8. package/dist/{slices → cjs/slices}/reception.slice.js +8 -4
  9. package/dist/cjs/slices/session.slice.js +16 -0
  10. package/dist/cjs/slices/tables.slice.js +20 -0
  11. package/dist/{slices → cjs/slices}/templates.slice.js +8 -4
  12. package/dist/{slices → cjs/slices}/user.slice.js +8 -4
  13. package/dist/cjs/slices/webapp-tables.slice.js +24 -0
  14. package/dist/{store.js → cjs/store.js} +46 -39
  15. package/dist/esm/index.js +18 -0
  16. package/dist/esm/slices/agency.slice.js +24 -0
  17. package/dist/esm/slices/automaticNumbers.slice.js +24 -0
  18. package/dist/esm/slices/catalogs.slice.js +65 -0
  19. package/dist/esm/slices/formValidation.slice.js +19 -0
  20. package/dist/esm/slices/index.js +27 -0
  21. package/dist/esm/slices/profile.slice.js +26 -0
  22. package/dist/esm/slices/reception.slice.js +61 -0
  23. package/dist/esm/slices/session.slice.js +16 -0
  24. package/dist/esm/slices/tables.slice.js +20 -0
  25. package/dist/esm/slices/templates.slice.js +23 -0
  26. package/dist/esm/slices/user.slice.js +42 -0
  27. package/dist/esm/slices/webapp-tables.slice.js +24 -0
  28. package/dist/esm/store.js +135 -0
  29. package/package.json +13 -11
  30. package/CHANGELOG.md +0 -192
  31. package/dist/index.js +0 -2
  32. package/dist/slices/formValidation.slice.js +0 -16
  33. package/dist/slices/index.js +0 -11
  34. package/dist/slices/session.slice.js +0 -13
  35. package/dist/slices/tables.slice.js +0 -17
  36. package/dist/slices/webapp-tables.slice.js +0 -20
  37. package/src/index.ts +0 -3
  38. package/src/slices/agency.slice.ts +0 -32
  39. package/src/slices/automaticNumbers.slice.ts +0 -41
  40. package/src/slices/catalogs.slice.ts +0 -178
  41. package/src/slices/formValidation.slice.ts +0 -32
  42. package/src/slices/index.ts +0 -11
  43. package/src/slices/profile.slice.ts +0 -49
  44. package/src/slices/reception.slice.ts +0 -118
  45. package/src/slices/session.slice.ts +0 -25
  46. package/src/slices/tables.slice.ts +0 -33
  47. package/src/slices/templates.slice.ts +0 -34
  48. package/src/slices/user.slice.ts +0 -64
  49. package/src/slices/webapp-tables.slice.ts +0 -35
  50. package/src/store.ts +0 -162
  51. package/tsconfig.json +0 -24
package/src/store.ts DELETED
@@ -1,162 +0,0 @@
1
- import type { TypedUseSelectorHook } from "react-redux";
2
- import { useDispatch, useSelector } from "react-redux";
3
- import type { MiddlewareAPI } from "@reduxjs/toolkit";
4
- import { Tuple, configureStore } from "@reduxjs/toolkit";
5
- import catalogsReducer from "./slices/catalogs.slice.js";
6
- import profilesReducer from "./slices/profile.slice.js";
7
- import webappTablesReducer from "./slices/webapp-tables.slice.js";
8
- import receptionsReducer from "./slices/reception.slice.js";
9
- import sessionReducer from "./slices/session.slice.js";
10
- import templateReducer from "./slices/templates.slice.js";
11
- import automaticNumberReducer from "./slices/automaticNumbers.slice.js";
12
- import tableReducer from "./slices/tables.slice.js";
13
- import formValidationReducer from "./slices/formValidation.slice.js";
14
-
15
- export const LOCAL_STORAGE_REDUX_NAME = "___redux__state__v2";
16
-
17
- const persistanceLocalStorageMiddleware =
18
- (store: MiddlewareAPI) => (next: (action: any) => any) => (action: any) => {
19
- const result = next(action);
20
- if (!(typeof document === "undefined")) {
21
- localStorage.setItem(
22
- LOCAL_STORAGE_REDUX_NAME,
23
- JSON.stringify(store.getState() as RootState)
24
- );
25
- }
26
- return result;
27
- };
28
-
29
- const preloadedState = (() => {
30
- try {
31
- if (!(typeof document === "undefined")) {
32
- const savedState = localStorage.getItem(LOCAL_STORAGE_REDUX_NAME);
33
- if (savedState) {
34
- return JSON.parse(savedState);
35
- }
36
- }
37
- } catch (e) {
38
- // Ignorar los errores, se utiliza el estado inicial definido en cada reducer
39
- }
40
- })();
41
-
42
- type Whitelist = {
43
- [K in keyof RootState]?: string[];
44
- };
45
-
46
- export const cleanLocalStorage = () => {
47
- const savedState = localStorage.getItem(LOCAL_STORAGE_REDUX_NAME);
48
- const state = JSON.parse(savedState ?? "{}") as RootState;
49
- try {
50
- //delete all cookies
51
- // const deleteAllCookies = () => {
52
- // const cookies = document.cookie.split(";");
53
- // for (const cookie of cookies) {
54
- // const eqPos = cookie.indexOf("=");
55
- // const name = eqPos > -1 ? cookie.substring(0, eqPos) : cookie;
56
- // document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT";
57
- // }
58
- // };
59
-
60
- // deleteAllCookies();
61
-
62
- // //delete caché
63
- // caches.keys().then((names) => {
64
- // for (const name of names) {
65
- // caches.delete(name);
66
- // }
67
- // });
68
-
69
- //unregister service workers
70
- // navigator.serviceWorker.getRegistrations().then((registrations) => {
71
- // for (const registration of registrations) {
72
- // registration.unregister();
73
- // }
74
- // });
75
-
76
- // Limpiar todo el localStorage
77
- localStorage.clear();
78
- } catch (error) {
79
- console.error(error);
80
- }
81
-
82
- try {
83
- const whitelist: Whitelist = {
84
- automaticNumbers: ["purchaseOrderIdNumber", "dischargeIdNumber"],
85
- receptions: ["queueNewReceptions"],
86
- };
87
-
88
- if (!(typeof document === "undefined") && Object.keys(state)?.length > 0) {
89
- const initialState: RootState = {
90
- catalogs: catalogsReducer(undefined, { type: "" }),
91
- profiles: profilesReducer(undefined, { type: "" }),
92
- webappTables: webappTablesReducer(undefined, { type: "" }),
93
- receptions: receptionsReducer(undefined, { type: "" }),
94
- session: sessionReducer(undefined, { type: "" }),
95
- templates: templateReducer(undefined, { type: "" }),
96
- automaticNumbers: automaticNumberReducer(undefined, { type: "" }),
97
- tables: tableReducer(undefined, { type: "" }),
98
- formValidation: formValidationReducer(undefined, { type: "" }),
99
- };
100
-
101
- const newState: RootState = { ...initialState };
102
-
103
- for (const reducerName in whitelist) {
104
- if (state.hasOwnProperty(reducerName)) {
105
- const key = reducerName as keyof RootState;
106
- const reducerState = state[key];
107
- const whitelistKey = whitelist[key as any];
108
-
109
- if (whitelistKey && whitelistKey.length > 0) {
110
- newState[key] = newState[key] ? { ...newState[key] } : ({} as any);
111
-
112
- for (const propertyName of whitelistKey) {
113
- if (reducerState?.hasOwnProperty(propertyName)) {
114
- const propKey = propertyName as keyof typeof reducerState;
115
- if (newState[key] && reducerState) {
116
- newState[key][propKey] = reducerState[propKey];
117
- }
118
- }
119
- }
120
- } else if (reducerState) {
121
- newState[key] = reducerState as any;
122
- }
123
- }
124
- }
125
-
126
- // Guarda el nuevo estado en el almacenamiento local
127
- localStorage.setItem(LOCAL_STORAGE_REDUX_NAME, JSON.stringify(newState));
128
- }
129
- } catch (e) {
130
- console.error(
131
- "Ocurrió un error al clonar y eliminar el viejo localStorage"
132
- );
133
- }
134
- };
135
-
136
- export const store = configureStore({
137
- reducer: {
138
- catalogs: catalogsReducer,
139
- profiles: profilesReducer,
140
- webappTables: webappTablesReducer,
141
- receptions: receptionsReducer,
142
- session: sessionReducer,
143
- templates: templateReducer,
144
- automaticNumbers: automaticNumberReducer,
145
- tables: tableReducer,
146
- formValidation: formValidationReducer,
147
- } as any,
148
- preloadedState,
149
- middleware: (getDefaultMiddleware) =>
150
- new Tuple(persistanceLocalStorageMiddleware),
151
- });
152
-
153
- export type RootState = ReturnType<typeof store.getState>;
154
- export type AppDispatch = typeof store.dispatch;
155
- export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector;
156
- export const useAppDispatch: () => AppDispatch = useDispatch;
157
-
158
- export type ReduxParamsConfig = {
159
- online?: boolean;
160
- wheres?: string[];
161
- otherParams?: { [key: string]: string };
162
- };
package/tsconfig.json DELETED
@@ -1,24 +0,0 @@
1
- {
2
- "include": ["env.d.ts", "**/*.ts", "**/*.tsx"],
3
- "compilerOptions": {
4
- "allowSyntheticDefaultImports": true,
5
- "lib": ["DOM", "DOM.Iterable", "ES2022"],
6
- "isolatedModules": true,
7
- "moduleResolution": "NodeNext",
8
- "module": "NodeNext",
9
- "esModuleInterop": true,
10
- "target": "ES2022",
11
- "strict": true,
12
- "allowJs": true,
13
- "skipLibCheck": true,
14
- "forceConsistentCasingInFileNames": true,
15
- "baseUrl": ".",
16
- "outDir": "./dist",
17
- "rootDir": "./src",
18
- "declaration": true,
19
- "declarationDir": "./dist",
20
- "paths": {
21
- "~/*": ["./src/*"]
22
- }
23
- }
24
- }