@zauru-sdk/hooks 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 (46) hide show
  1. package/dist/alerts.d.ts +1 -1
  2. package/dist/{alerts.js → cjs/alerts.js} +13 -9
  3. package/dist/{automaticNumbers.js → cjs/automaticNumbers.js} +20 -16
  4. package/dist/cjs/catalogs.js +267 -0
  5. package/dist/{components → cjs/components}/Alert.js +18 -15
  6. package/dist/cjs/components/index.js +17 -0
  7. package/dist/cjs/index.js +26 -0
  8. package/dist/{onlineStatus.js → cjs/onlineStatus.js} +8 -4
  9. package/dist/cjs/profiles.js +64 -0
  10. package/dist/{receptions.js → cjs/receptions.js} +67 -52
  11. package/dist/{session.js → cjs/session.js} +19 -15
  12. package/dist/{templates.js → cjs/templates.js} +20 -16
  13. package/dist/{useWindowDimensions.js → cjs/useWindowDimensions.js} +8 -4
  14. package/dist/esm/alerts.js +37 -0
  15. package/dist/esm/automaticNumbers.js +57 -0
  16. package/dist/esm/catalogs.js +267 -0
  17. package/dist/esm/components/Alert.js +100 -0
  18. package/dist/esm/components/index.js +17 -0
  19. package/dist/esm/index.js +26 -0
  20. package/dist/esm/onlineStatus.js +31 -0
  21. package/dist/esm/profiles.js +64 -0
  22. package/dist/esm/receptions.js +348 -0
  23. package/dist/esm/session.js +55 -0
  24. package/dist/esm/templates.js +58 -0
  25. package/dist/esm/useWindowDimensions.js +31 -0
  26. package/dist/receptions.d.ts +2 -2
  27. package/package.json +14 -19
  28. package/.eslintrc.cjs +0 -83
  29. package/CHANGELOG.md +0 -232
  30. package/dist/catalogs.js +0 -230
  31. package/dist/components/index.js +0 -1
  32. package/dist/index.js +0 -10
  33. package/dist/profiles.js +0 -57
  34. package/src/alerts.ts +0 -43
  35. package/src/automaticNumbers.ts +0 -74
  36. package/src/catalogs.ts +0 -557
  37. package/src/components/Alert.tsx +0 -149
  38. package/src/components/index.ts +0 -1
  39. package/src/index.ts +0 -11
  40. package/src/onlineStatus.ts +0 -34
  41. package/src/profiles.ts +0 -103
  42. package/src/receptions.ts +0 -548
  43. package/src/session.ts +0 -69
  44. package/src/templates.ts +0 -84
  45. package/src/useWindowDimensions.ts +0 -34
  46. package/tsconfig.json +0 -26
@@ -1,13 +1,16 @@
1
- import { useFetcher } from "@remix-run/react";
2
- import { receptionFetchStart, receptionFetchSuccess, useAppDispatch, useAppSelector, } from "@zauru-sdk/redux";
3
- import { useEffect, useMemo, useState } from "react";
4
- import { showAlert } from "./index.js";
5
- import { getBasketsSchema, reduceAdd, toFixedIfNeeded, } from "@zauru-sdk/common";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useGetItemNameByPurchaseOrder = exports.useGetProviderNameByPurchaseOrder = exports.getBasketDetailsByForm = exports.useGetBasketDetails = exports.getPesadasByForm = exports.useGetPesadas = exports.useGetPurchaseOrderGeneralInfo = exports.useGetNewPurchaseOrderInfo = exports.useGetRejectionInfo = exports.useGetBasketLots = exports.useGetPOReceptions = exports.useGetProcesses = void 0;
4
+ const react_1 = require("@remix-run/react");
5
+ const redux_1 = require("@zauru-sdk/redux");
6
+ const react_2 = require("react");
7
+ const index_js_1 = require("./index.js");
8
+ const common_1 = require("@zauru-sdk/common");
6
9
  const useGetReceptionObject = (RECEPTION_NAME, { online = false, wheres = [] } = {}) => {
7
- const fetcher = useFetcher();
8
- const dispatch = useAppDispatch();
9
- const objectData = useAppSelector((state) => state.receptions[RECEPTION_NAME]);
10
- const [data, setData] = useState({
10
+ const fetcher = (0, react_1.useFetcher)();
11
+ const dispatch = (0, redux_1.useAppDispatch)();
12
+ const objectData = (0, redux_1.useAppSelector)((state) => state.receptions[RECEPTION_NAME]);
13
+ const [data, setData] = (0, react_2.useState)({
11
14
  data: Array.isArray(objectData?.data)
12
15
  ? objectData?.data.length
13
16
  ? objectData?.data
@@ -17,35 +20,35 @@ const useGetReceptionObject = (RECEPTION_NAME, { online = false, wheres = [] } =
17
20
  : {},
18
21
  loading: objectData.loading,
19
22
  });
20
- useEffect(() => {
23
+ (0, react_2.useEffect)(() => {
21
24
  if (fetcher.data?.title) {
22
- showAlert({
25
+ (0, index_js_1.showAlert)({
23
26
  description: fetcher.data?.description?.toString(),
24
27
  title: fetcher.data?.title?.toString(),
25
28
  type: fetcher.data?.type?.toString(),
26
29
  });
27
30
  }
28
31
  }, [fetcher.data]);
29
- useEffect(() => {
32
+ (0, react_2.useEffect)(() => {
30
33
  if (fetcher.state === "idle" && fetcher.data != null) {
31
34
  const receivedData = fetcher.data;
32
35
  if (receivedData) {
33
36
  setData({ data: receivedData[RECEPTION_NAME], loading: false });
34
- dispatch(receptionFetchSuccess({
37
+ dispatch((0, redux_1.receptionFetchSuccess)({
35
38
  name: RECEPTION_NAME,
36
39
  data: receivedData[RECEPTION_NAME],
37
40
  }));
38
41
  }
39
42
  }
40
43
  }, [fetcher, dispatch, RECEPTION_NAME]);
41
- useEffect(() => {
44
+ (0, react_2.useEffect)(() => {
42
45
  const isEmptyData = Array.isArray(objectData?.data)
43
46
  ? objectData?.data.length <= 0
44
47
  : Object.keys(objectData?.data || {}).length <= 0;
45
48
  if (isEmptyData || objectData.reFetch || online) {
46
49
  try {
47
50
  setData({ ...data, loading: true });
48
- dispatch(receptionFetchStart(RECEPTION_NAME));
51
+ dispatch((0, redux_1.receptionFetchStart)(RECEPTION_NAME));
49
52
  // Convierte cada elemento del array a una cadena codificada para URL
50
53
  const encodedWheres = wheres.map((where) => encodeURIComponent(where));
51
54
  // Une los elementos codificados con '&'
@@ -53,7 +56,7 @@ const useGetReceptionObject = (RECEPTION_NAME, { online = false, wheres = [] } =
53
56
  fetcher.load(`/api/receptions?object=${RECEPTION_NAME}&wheres=${wheresQueryParam}`);
54
57
  }
55
58
  catch (ex) {
56
- showAlert({
59
+ (0, index_js_1.showAlert)({
57
60
  type: "error",
58
61
  title: `Ocurrió un error al cargar el object de receptions: ${RECEPTION_NAME}.`,
59
62
  description: "Error: " + ex,
@@ -63,14 +66,20 @@ const useGetReceptionObject = (RECEPTION_NAME, { online = false, wheres = [] } =
63
66
  }, []);
64
67
  return data;
65
68
  };
66
- export const useGetProcesses = (config) => useGetReceptionObject("queueNewReceptions", config);
67
- export const useGetPOReceptions = (config) => useGetReceptionObject("poReceptions", config);
68
- export const useGetBasketLots = () => useGetReceptionObject("basketLots");
69
- export const useGetRejectionInfo = () => useGetReceptionObject("rejectionInfo");
70
- export const useGetNewPurchaseOrderInfo = () => useGetReceptionObject("newPurchaseOrderInfo");
71
- export const useGetPurchaseOrderGeneralInfo = () => useGetReceptionObject("purchaseOrderGeneralInfo");
72
- export const useGetPesadas = (purchaseOrder) => {
73
- const [pesadas, footerPesadas, headersPesadas] = useMemo(() => {
69
+ const useGetProcesses = (config) => useGetReceptionObject("queueNewReceptions", config);
70
+ exports.useGetProcesses = useGetProcesses;
71
+ const useGetPOReceptions = (config) => useGetReceptionObject("poReceptions", config);
72
+ exports.useGetPOReceptions = useGetPOReceptions;
73
+ const useGetBasketLots = () => useGetReceptionObject("basketLots");
74
+ exports.useGetBasketLots = useGetBasketLots;
75
+ const useGetRejectionInfo = () => useGetReceptionObject("rejectionInfo");
76
+ exports.useGetRejectionInfo = useGetRejectionInfo;
77
+ const useGetNewPurchaseOrderInfo = () => useGetReceptionObject("newPurchaseOrderInfo");
78
+ exports.useGetNewPurchaseOrderInfo = useGetNewPurchaseOrderInfo;
79
+ const useGetPurchaseOrderGeneralInfo = () => useGetReceptionObject("purchaseOrderGeneralInfo");
80
+ exports.useGetPurchaseOrderGeneralInfo = useGetPurchaseOrderGeneralInfo;
81
+ const useGetPesadas = (purchaseOrder) => {
82
+ const [pesadas, footerPesadas, headersPesadas] = (0, react_2.useMemo)(() => {
74
83
  const tempPesadas = [
75
84
  ...purchaseOrder.purchase_order_details?.map((x, index) => {
76
85
  const parsedReference = x.reference?.split(","); //eg: "reference": "698,25,0", // peso neto, canastas, descuento
@@ -97,8 +106,8 @@ export const useGetPesadas = (purchaseOrder) => {
97
106
  baskets,
98
107
  totalWeight,
99
108
  discount,
100
- netWeight: toFixedIfNeeded(netWeight),
101
- weightByBasket: toFixedIfNeeded(weightByBasket),
109
+ netWeight: (0, common_1.toFixedIfNeeded)(netWeight),
110
+ weightByBasket: (0, common_1.toFixedIfNeeded)(weightByBasket),
102
111
  probableUtilization,
103
112
  lbDiscounted,
104
113
  };
@@ -106,15 +115,15 @@ export const useGetPesadas = (purchaseOrder) => {
106
115
  ];
107
116
  const totales = {
108
117
  id: "",
109
- baskets: toFixedIfNeeded(tempPesadas?.map((x) => x.baskets).reduce(reduceAdd, 0)),
110
- totalWeight: toFixedIfNeeded(tempPesadas?.map((x) => x.totalWeight).reduce(reduceAdd, 0)),
118
+ baskets: (0, common_1.toFixedIfNeeded)(tempPesadas?.map((x) => x.baskets).reduce(common_1.reduceAdd, 0)),
119
+ totalWeight: (0, common_1.toFixedIfNeeded)(tempPesadas?.map((x) => x.totalWeight).reduce(common_1.reduceAdd, 0)),
111
120
  discount: "-",
112
- netWeight: toFixedIfNeeded(tempPesadas?.map((x) => Number(x.netWeight)).reduce(reduceAdd, 0)),
121
+ netWeight: (0, common_1.toFixedIfNeeded)(tempPesadas?.map((x) => Number(x.netWeight)).reduce(common_1.reduceAdd, 0)),
113
122
  weightByBasket: "-",
114
- lbDiscounted: toFixedIfNeeded(tempPesadas?.map((x) => Number(x.lbDiscounted)).reduce(reduceAdd, 0)),
115
- probableUtilization: toFixedIfNeeded(tempPesadas
123
+ lbDiscounted: (0, common_1.toFixedIfNeeded)(tempPesadas?.map((x) => Number(x.lbDiscounted)).reduce(common_1.reduceAdd, 0)),
124
+ probableUtilization: (0, common_1.toFixedIfNeeded)(tempPesadas
116
125
  ?.map((x) => Number(x.probableUtilization))
117
- .reduce(reduceAdd, 0)),
126
+ .reduce(common_1.reduceAdd, 0)),
118
127
  };
119
128
  const headers = [
120
129
  { label: "#", name: "id", type: "label", width: 5 },
@@ -142,12 +151,13 @@ export const useGetPesadas = (purchaseOrder) => {
142
151
  }, [purchaseOrder]);
143
152
  return [pesadas, footerPesadas, headersPesadas];
144
153
  };
154
+ exports.useGetPesadas = useGetPesadas;
145
155
  /**
146
156
  * Sirve para imprimir offline
147
157
  * @param formInput
148
158
  * @returns
149
159
  */
150
- export const getPesadasByForm = (formInput) => {
160
+ const getPesadasByForm = (formInput) => {
151
161
  // Inicializar array de pesadas
152
162
  const tempPesadas = [];
153
163
  // Iterar sobre los campos del formulario y extraer la información de pesadas
@@ -171,8 +181,8 @@ export const getPesadasByForm = (formInput) => {
171
181
  baskets,
172
182
  totalWeight,
173
183
  discount,
174
- netWeight: toFixedIfNeeded(netWeight),
175
- weightByBasket: toFixedIfNeeded(weightByBasket),
184
+ netWeight: (0, common_1.toFixedIfNeeded)(netWeight),
185
+ weightByBasket: (0, common_1.toFixedIfNeeded)(weightByBasket),
176
186
  probableUtilization,
177
187
  lbDiscounted,
178
188
  });
@@ -180,15 +190,15 @@ export const getPesadasByForm = (formInput) => {
180
190
  }
181
191
  const totales = {
182
192
  id: "",
183
- baskets: toFixedIfNeeded(tempPesadas?.map((x) => x.baskets).reduce(reduceAdd, 0)),
184
- totalWeight: toFixedIfNeeded(tempPesadas?.map((x) => x.totalWeight).reduce(reduceAdd, 0)),
193
+ baskets: (0, common_1.toFixedIfNeeded)(tempPesadas?.map((x) => x.baskets).reduce(common_1.reduceAdd, 0)),
194
+ totalWeight: (0, common_1.toFixedIfNeeded)(tempPesadas?.map((x) => x.totalWeight).reduce(common_1.reduceAdd, 0)),
185
195
  discount: "-",
186
- netWeight: toFixedIfNeeded(tempPesadas?.map((x) => Number(x.netWeight)).reduce(reduceAdd, 0)),
196
+ netWeight: (0, common_1.toFixedIfNeeded)(tempPesadas?.map((x) => Number(x.netWeight)).reduce(common_1.reduceAdd, 0)),
187
197
  weightByBasket: "-",
188
- lbDiscounted: toFixedIfNeeded(tempPesadas?.map((x) => Number(x.lbDiscounted)).reduce(reduceAdd, 0)),
189
- probableUtilization: toFixedIfNeeded(tempPesadas
198
+ lbDiscounted: (0, common_1.toFixedIfNeeded)(tempPesadas?.map((x) => Number(x.lbDiscounted)).reduce(common_1.reduceAdd, 0)),
199
+ probableUtilization: (0, common_1.toFixedIfNeeded)(tempPesadas
190
200
  ?.map((x) => Number(x.probableUtilization))
191
- .reduce(reduceAdd, 0)),
201
+ .reduce(common_1.reduceAdd, 0)),
192
202
  };
193
203
  const headers = [
194
204
  { label: "#", name: "id", type: "label", width: 5 },
@@ -214,15 +224,16 @@ export const getPesadasByForm = (formInput) => {
214
224
  ];
215
225
  return { tempPesadas, totales, headers };
216
226
  };
217
- export const useGetBasketDetails = (purchaseOrder) => {
218
- const [basketsJoined, footerBasketsJoined, headersBasketsJoined] = useMemo(() => {
227
+ exports.getPesadasByForm = getPesadasByForm;
228
+ const useGetBasketDetails = (purchaseOrder) => {
229
+ const [basketsJoined, footerBasketsJoined, headersBasketsJoined] = (0, react_2.useMemo)(() => {
219
230
  const bsq = purchaseOrder?.lots
220
231
  ?.map((x) => {
221
- const basket = getBasketsSchema(x.description);
232
+ const basket = (0, common_1.getBasketsSchema)(x.description);
222
233
  return basket;
223
234
  })
224
235
  .flat(2) ?? [];
225
- const bsqToCC = getBasketsSchema(purchaseOrder.memo);
236
+ const bsqToCC = (0, common_1.getBasketsSchema)(purchaseOrder.memo);
226
237
  const joinedBaskets = [];
227
238
  for (let i = 0; i < bsq.length; i++) {
228
239
  const found = joinedBaskets.find((item) => item.color === bsq[i].color);
@@ -241,8 +252,8 @@ export const useGetBasketDetails = (purchaseOrder) => {
241
252
  }
242
253
  const totales = {
243
254
  id: "",
244
- total: toFixedIfNeeded(joinedBaskets?.map((x) => x.total).reduce(reduceAdd, 0)),
245
- cc: joinedBaskets?.map((x) => x.cc).reduce(reduceAdd, 0),
255
+ total: (0, common_1.toFixedIfNeeded)(joinedBaskets?.map((x) => x.total).reduce(common_1.reduceAdd, 0)),
256
+ cc: joinedBaskets?.map((x) => x.cc).reduce(common_1.reduceAdd, 0),
246
257
  };
247
258
  const headers = [
248
259
  { label: "Color", name: "color", type: "label" },
@@ -253,12 +264,13 @@ export const useGetBasketDetails = (purchaseOrder) => {
253
264
  }, [purchaseOrder]);
254
265
  return [basketsJoined, footerBasketsJoined, headersBasketsJoined];
255
266
  };
267
+ exports.useGetBasketDetails = useGetBasketDetails;
256
268
  /**
257
269
  * Para imprimir en modo offline
258
270
  * @param formInput
259
271
  * @returns
260
272
  */
261
- export const getBasketDetailsByForm = (formInput) => {
273
+ const getBasketDetailsByForm = (formInput) => {
262
274
  const basketDetailsArray = [];
263
275
  // Regex para identificar los campos relevantes
264
276
  const recPattern = /^rec\d+-(.+)$/;
@@ -311,8 +323,9 @@ export const getBasketDetailsByForm = (formInput) => {
311
323
  ];
312
324
  return { basketDetailsArray, totales, headers };
313
325
  };
314
- export const useGetProviderNameByPurchaseOrder = (payees, purchaseOrder) => {
315
- const providerName = useMemo(() => {
326
+ exports.getBasketDetailsByForm = getBasketDetailsByForm;
327
+ const useGetProviderNameByPurchaseOrder = (payees, purchaseOrder) => {
328
+ const providerName = (0, react_2.useMemo)(() => {
316
329
  const provider = payees.find((x) => x.id == purchaseOrder.payee_id);
317
330
  if (provider) {
318
331
  return `<${provider.id_number}> ${provider.tin ? `${provider.tin} | ` : ""}${provider.name}`;
@@ -321,8 +334,9 @@ export const useGetProviderNameByPurchaseOrder = (payees, purchaseOrder) => {
321
334
  }, [payees, purchaseOrder]);
322
335
  return providerName;
323
336
  };
324
- export const useGetItemNameByPurchaseOrder = (items, purchaseOrder) => {
325
- const itemName = useMemo(() => {
337
+ exports.useGetProviderNameByPurchaseOrder = useGetProviderNameByPurchaseOrder;
338
+ const useGetItemNameByPurchaseOrder = (items, purchaseOrder) => {
339
+ const itemName = (0, react_2.useMemo)(() => {
326
340
  if (purchaseOrder.purchase_order_details.length > 0 && items.length > 0) {
327
341
  const item = items.find((x) => x.id == purchaseOrder.purchase_order_details[0].item_id);
328
342
  return `${item?.id} - ${item?.code} - ${item?.name}`;
@@ -331,3 +345,4 @@ export const useGetItemNameByPurchaseOrder = (items, purchaseOrder) => {
331
345
  }, [items, purchaseOrder]);
332
346
  return itemName;
333
347
  };
348
+ exports.useGetItemNameByPurchaseOrder = useGetItemNameByPurchaseOrder;
@@ -1,45 +1,48 @@
1
- import { useFetcher } from "@remix-run/react";
2
- import { setSessionValue, useAppDispatch, useAppSelector, } from "@zauru-sdk/redux";
3
- import { useEffect, useState } from "react";
4
- import { showAlert } from "./index.js";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useGetSessionAttribute = void 0;
4
+ const react_1 = require("@remix-run/react");
5
+ const redux_1 = require("@zauru-sdk/redux");
6
+ const react_2 = require("react");
7
+ const index_js_1 = require("./index.js");
5
8
  /**
6
9
  *
7
10
  * @param attribute
8
11
  * @returns
9
12
  */
10
- export const useGetSessionAttribute = (name, type) => {
11
- const fetcher = useFetcher();
12
- const dispatch = useAppDispatch();
13
- const sessionData = useAppSelector((state) => state.session[name]);
14
- const [data, setData] = useState(sessionData);
15
- useEffect(() => {
13
+ const useGetSessionAttribute = (name, type) => {
14
+ const fetcher = (0, react_1.useFetcher)();
15
+ const dispatch = (0, redux_1.useAppDispatch)();
16
+ const sessionData = (0, redux_1.useAppSelector)((state) => state.session[name]);
17
+ const [data, setData] = (0, react_2.useState)(sessionData);
18
+ (0, react_2.useEffect)(() => {
16
19
  if (fetcher.data?.title) {
17
- showAlert({
20
+ (0, index_js_1.showAlert)({
18
21
  description: fetcher.data?.description,
19
22
  title: fetcher.data?.title,
20
23
  type: fetcher.data?.type,
21
24
  });
22
25
  }
23
26
  }, [fetcher.data]);
24
- useEffect(() => {
27
+ (0, react_2.useEffect)(() => {
25
28
  if (fetcher.state === "idle" && fetcher.data != null) {
26
29
  const receivedData = fetcher.data;
27
30
  if (receivedData) {
28
31
  setData(receivedData.data);
29
- dispatch(setSessionValue({
32
+ dispatch((0, redux_1.setSessionValue)({
30
33
  name: name,
31
34
  data: receivedData.data,
32
35
  }));
33
36
  }
34
37
  }
35
38
  }, [fetcher, dispatch, name]);
36
- useEffect(() => {
39
+ (0, react_2.useEffect)(() => {
37
40
  if (!sessionData) {
38
41
  try {
39
42
  fetcher.load(`/api/session?name=${name}&type=${type}`);
40
43
  }
41
44
  catch (ex) {
42
- showAlert({
45
+ (0, index_js_1.showAlert)({
43
46
  type: "error",
44
47
  title: `Ocurrió un error al cargar la variable de configuración: ${name}.`,
45
48
  description: "Error: " + ex,
@@ -49,3 +52,4 @@ export const useGetSessionAttribute = (name, type) => {
49
52
  }, []);
50
53
  return data;
51
54
  };
55
+ exports.useGetSessionAttribute = useGetSessionAttribute;
@@ -1,47 +1,50 @@
1
- import { useFetcher } from "@remix-run/react";
2
- import { templateFetchStart, templateFetchSuccess, useAppDispatch, useAppSelector, } from "@zauru-sdk/redux";
3
- import { useEffect, useState } from "react";
4
- import { showAlert } from "./index.js";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useGetReceptionTemplate = void 0;
4
+ const react_1 = require("@remix-run/react");
5
+ const redux_1 = require("@zauru-sdk/redux");
6
+ const react_2 = require("react");
7
+ const index_js_1 = require("./index.js");
5
8
  const useGetTemplateObject = (TEMPLATE_NAME, config = { online: false }) => {
6
- const fetcher = useFetcher();
7
- const dispatch = useAppDispatch();
8
- const objectData = useAppSelector((state) => state.templates[TEMPLATE_NAME]);
9
- const [data, setData] = useState({
9
+ const fetcher = (0, react_1.useFetcher)();
10
+ const dispatch = (0, redux_1.useAppDispatch)();
11
+ const objectData = (0, redux_1.useAppSelector)((state) => state.templates[TEMPLATE_NAME]);
12
+ const [data, setData] = (0, react_2.useState)({
10
13
  data: Object.keys(objectData?.data).length
11
14
  ? objectData?.data
12
15
  : {},
13
16
  loading: objectData.loading,
14
17
  });
15
- useEffect(() => {
18
+ (0, react_2.useEffect)(() => {
16
19
  if (fetcher.data?.title) {
17
- showAlert({
20
+ (0, index_js_1.showAlert)({
18
21
  description: fetcher.data?.description,
19
22
  title: fetcher.data?.title,
20
23
  type: fetcher.data?.type,
21
24
  });
22
25
  }
23
26
  }, [fetcher.data]);
24
- useEffect(() => {
27
+ (0, react_2.useEffect)(() => {
25
28
  if (fetcher.state === "idle" && fetcher.data != null) {
26
29
  const receivedData = fetcher.data;
27
30
  if (receivedData) {
28
31
  setData({ data: receivedData[TEMPLATE_NAME], loading: false });
29
- dispatch(templateFetchSuccess({
32
+ dispatch((0, redux_1.templateFetchSuccess)({
30
33
  name: TEMPLATE_NAME,
31
34
  data: receivedData[TEMPLATE_NAME],
32
35
  }));
33
36
  }
34
37
  }
35
38
  }, [fetcher, dispatch, TEMPLATE_NAME]);
36
- useEffect(() => {
39
+ (0, react_2.useEffect)(() => {
37
40
  if (Object.keys(objectData?.data).length <= 0 || config?.online) {
38
41
  try {
39
42
  setData({ ...data, loading: true });
40
- dispatch(templateFetchStart(TEMPLATE_NAME));
43
+ dispatch((0, redux_1.templateFetchStart)(TEMPLATE_NAME));
41
44
  fetcher.load(`/api/templates?object=${TEMPLATE_NAME}`);
42
45
  }
43
46
  catch (ex) {
44
- showAlert({
47
+ (0, index_js_1.showAlert)({
45
48
  type: "error",
46
49
  title: `Ocurrió un error al cargar el object de templates: ${TEMPLATE_NAME}.`,
47
50
  description: "Error: " + ex,
@@ -51,4 +54,5 @@ const useGetTemplateObject = (TEMPLATE_NAME, config = { online: false }) => {
51
54
  }, []);
52
55
  return data;
53
56
  };
54
- export const useGetReceptionTemplate = (config) => useGetTemplateObject("receptionTemplate", config);
57
+ const useGetReceptionTemplate = (config) => useGetTemplateObject("receptionTemplate", config);
58
+ exports.useGetReceptionTemplate = useGetReceptionTemplate;
@@ -1,4 +1,7 @@
1
- import { useState, useEffect } from "react";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useWindowDimensions = void 0;
4
+ const react_1 = require("react");
2
5
  function getWindowDimensions() {
3
6
  if (typeof window !== "undefined") {
4
7
  const { innerWidth: width } = window;
@@ -7,9 +10,9 @@ function getWindowDimensions() {
7
10
  // Devolver un valor predeterminado si window no está definido
8
11
  return 1000;
9
12
  }
10
- export const useWindowDimensions = () => {
11
- const [windowDimensions, setWindowDimensions] = useState(getWindowDimensions);
12
- useEffect(() => {
13
+ const useWindowDimensions = () => {
14
+ const [windowDimensions, setWindowDimensions] = (0, react_1.useState)(getWindowDimensions);
15
+ (0, react_1.useEffect)(() => {
13
16
  if (typeof window !== "undefined") {
14
17
  const handleResize = () => {
15
18
  setWindowDimensions(getWindowDimensions());
@@ -25,3 +28,4 @@ export const useWindowDimensions = () => {
25
28
  }, []);
26
29
  return windowDimensions;
27
30
  };
31
+ exports.useWindowDimensions = useWindowDimensions;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useValidateNotifications = void 0;
4
+ const react_1 = require("react");
5
+ const index_js_1 = require("./index.js");
6
+ const useValidateNotifications = (source) => {
7
+ const { actionData, fetcher, loaderData } = source;
8
+ (0, react_1.useEffect)(() => {
9
+ if (loaderData?.title) {
10
+ (0, index_js_1.showAlert)({
11
+ description: loaderData?.description?.toString() ?? "",
12
+ title: loaderData?.title,
13
+ type: loaderData?.type,
14
+ });
15
+ }
16
+ }, [loaderData]);
17
+ (0, react_1.useEffect)(() => {
18
+ if (fetcher?.data?.title) {
19
+ (0, index_js_1.showAlert)({
20
+ description: fetcher.data?.description,
21
+ title: fetcher.data?.title,
22
+ type: fetcher.data?.type,
23
+ });
24
+ }
25
+ }, [fetcher?.data]);
26
+ (0, react_1.useEffect)(() => {
27
+ if (actionData?.title) {
28
+ (0, index_js_1.showAlert)({
29
+ description: actionData?.description ?? "",
30
+ title: actionData?.title,
31
+ type: actionData?.type,
32
+ });
33
+ }
34
+ }, [actionData]);
35
+ return null;
36
+ };
37
+ exports.useValidateNotifications = useValidateNotifications;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useGetAutomaticNumber = void 0;
4
+ const react_1 = require("@remix-run/react");
5
+ const redux_1 = require("@zauru-sdk/redux");
6
+ const react_2 = require("react");
7
+ const index_js_1 = require("./index.js");
8
+ const useGetAutomaticNumber = (AUTOMATIC_NUMBER_NAME) => {
9
+ const fetcher = (0, react_1.useFetcher)();
10
+ const dispatch = (0, redux_1.useAppDispatch)();
11
+ const objectData = (0, redux_1.useAppSelector)((state) => state.automaticNumbers[AUTOMATIC_NUMBER_NAME]);
12
+ const [data, setData] = (0, react_2.useState)({
13
+ data: Object.keys(objectData?.data).length
14
+ ? objectData?.data
15
+ : {},
16
+ loading: objectData.loading,
17
+ });
18
+ (0, react_2.useEffect)(() => {
19
+ if (fetcher.data?.title) {
20
+ (0, index_js_1.showAlert)({
21
+ description: fetcher.data?.description,
22
+ title: fetcher.data?.title,
23
+ type: fetcher.data?.type,
24
+ });
25
+ }
26
+ }, [fetcher.data]);
27
+ (0, react_2.useEffect)(() => {
28
+ if (fetcher.state === "idle" && fetcher.data != null) {
29
+ const receivedData = fetcher.data;
30
+ if (receivedData) {
31
+ setData({ data: receivedData[AUTOMATIC_NUMBER_NAME], loading: false });
32
+ dispatch((0, redux_1.automaticNumberFetchSuccess)({
33
+ name: AUTOMATIC_NUMBER_NAME,
34
+ data: receivedData[AUTOMATIC_NUMBER_NAME],
35
+ }));
36
+ }
37
+ }
38
+ }, [fetcher, dispatch, AUTOMATIC_NUMBER_NAME]);
39
+ (0, react_2.useEffect)(() => {
40
+ if (Object.keys(objectData?.data).length <= 0) {
41
+ try {
42
+ setData({ ...data, loading: true });
43
+ dispatch((0, redux_1.automaticNumberFetchStart)(AUTOMATIC_NUMBER_NAME));
44
+ fetcher.load(`/api/automaticNumbers?object=${AUTOMATIC_NUMBER_NAME}`);
45
+ }
46
+ catch (ex) {
47
+ (0, index_js_1.showAlert)({
48
+ type: "error",
49
+ title: `Ocurrió un error al cargar el object de automatic numbers: ${AUTOMATIC_NUMBER_NAME}.`,
50
+ description: "Error: " + ex,
51
+ });
52
+ }
53
+ }
54
+ }, []);
55
+ return data;
56
+ };
57
+ exports.useGetAutomaticNumber = useGetAutomaticNumber;