@zauru-sdk/hooks 1.0.117 → 1.0.120
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/package.json +8 -9
- package/dist/cjs/alerts.js +0 -37
- package/dist/cjs/automaticNumbers.js +0 -57
- package/dist/cjs/catalogs.js +0 -302
- package/dist/cjs/components/Alert.js +0 -100
- package/dist/cjs/components/index.js +0 -17
- package/dist/cjs/index.js +0 -26
- package/dist/cjs/onlineStatus.js +0 -31
- package/dist/cjs/profiles.js +0 -64
- package/dist/cjs/receptions.js +0 -405
- package/dist/cjs/session.js +0 -55
- package/dist/cjs/templates.js +0 -58
- package/dist/cjs/useWindowDimensions.js +0 -31
package/package.json
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zauru-sdk/hooks",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.120",
|
|
4
4
|
"description": "Hooks reutilizables dentro de las webapps de Zauru.",
|
|
5
|
-
"main": "./dist/
|
|
5
|
+
"main": "./dist/esm/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
8
|
"publishConfig": {
|
|
9
9
|
"access": "public"
|
|
10
10
|
},
|
|
11
11
|
"scripts": {
|
|
12
|
-
"build": "npm run build:
|
|
13
|
-
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
12
|
+
"build": "npm run build:esm",
|
|
14
13
|
"build:esm": "tsc -p tsconfig.esm.json",
|
|
15
14
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
16
15
|
},
|
|
@@ -27,12 +26,12 @@
|
|
|
27
26
|
},
|
|
28
27
|
"dependencies": {
|
|
29
28
|
"@remix-run/react": "^2.8.1",
|
|
30
|
-
"@zauru-sdk/common": "^1.0.
|
|
31
|
-
"@zauru-sdk/icons": "^1.0.
|
|
32
|
-
"@zauru-sdk/redux": "^1.0.
|
|
33
|
-
"@zauru-sdk/types": "^1.0.
|
|
29
|
+
"@zauru-sdk/common": "^1.0.120",
|
|
30
|
+
"@zauru-sdk/icons": "^1.0.120",
|
|
31
|
+
"@zauru-sdk/redux": "^1.0.120",
|
|
32
|
+
"@zauru-sdk/types": "^1.0.120",
|
|
34
33
|
"react": "^18.2.0",
|
|
35
34
|
"react-dom": "^18.2.0"
|
|
36
35
|
},
|
|
37
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "5c8b84d1723fc1342ecd45b49df51d4d96682f75"
|
|
38
37
|
}
|
package/dist/cjs/alerts.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
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 && fetcher.state === "idle") {
|
|
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, fetcher?.state]);
|
|
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;
|
|
@@ -1,57 +0,0 @@
|
|
|
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;
|
package/dist/cjs/catalogs.js
DELETED
|
@@ -1,302 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useGetInvoiceFormSubmissionsByInvoiceId = exports.useGetMyCaseFormSubmissions = exports.useGetInvoiceFormSubmissionsByAgencyId = exports.useGetCaseForms = exports.useGetInvoiceForms = exports.useGetAllForms = exports.useGetBitacoraRechazoMasivo = exports.useGetMotivosDeRechazo = exports.useGetTiposDeMuestra = exports.useGetInvoicesByLab = exports.useGetShipmentsToMyAgency = exports.useGetEmployeesByCurrentAgency = exports.useGetEmployeesByLab = exports.useGetPaymentMethods = exports.useGetPaymentTerms = exports.useGetSuggestedPrices = exports.useGetAgencies = exports.useGetPrintTemplates = exports.useGetPayeesForLab = exports.useGetPayees = exports.useGetClientCategories = exports.useGetProviderCategories = exports.useGetMyCases = exports.useGetProviders = exports.useGetReceptionTypes = exports.useGetCurrencies = exports.useGetBundlesForLab = exports.useGetBundlesRecipForLab = exports.useGetPayeeCategoriesLabPrices = exports.useGetPayeeCategories = exports.useGetTemplates = exports.useGetBookings = exports.useGetItemCategoriesForLab = exports.useGetItemServicesByLab = exports.useGetMyAgencyLotStocks = exports.useGetItemsByLab = exports.useGetItemsByReception = exports.useGetItems = void 0;
|
|
4
|
-
const react_1 = require("@remix-run/react");
|
|
5
|
-
const react_2 = require("react");
|
|
6
|
-
const index_js_1 = require("./components/index.js");
|
|
7
|
-
const redux_1 = require("@zauru-sdk/redux");
|
|
8
|
-
const useApiCatalog = (CATALOG_NAME, otherParams) => {
|
|
9
|
-
const fetcher = (0, react_1.useFetcher)();
|
|
10
|
-
const [data, setData] = (0, react_2.useState)({
|
|
11
|
-
data: [],
|
|
12
|
-
loading: true,
|
|
13
|
-
});
|
|
14
|
-
(0, react_2.useEffect)(() => {
|
|
15
|
-
if (fetcher.data?.title) {
|
|
16
|
-
(0, index_js_1.showAlert)({
|
|
17
|
-
description: fetcher.data?.description?.toString(),
|
|
18
|
-
title: fetcher.data?.title?.toString(),
|
|
19
|
-
type: fetcher.data?.type?.toString(),
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
}, [fetcher.data]);
|
|
23
|
-
(0, react_2.useEffect)(() => {
|
|
24
|
-
if (fetcher.state === "idle" && fetcher.data != null) {
|
|
25
|
-
const receivedData = fetcher.data;
|
|
26
|
-
if (receivedData) {
|
|
27
|
-
setData({ data: receivedData[CATALOG_NAME], loading: false });
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}, [fetcher, CATALOG_NAME]);
|
|
31
|
-
(0, react_2.useEffect)(() => {
|
|
32
|
-
try {
|
|
33
|
-
setData({ ...data, loading: true });
|
|
34
|
-
// Convert otherParams to query string
|
|
35
|
-
const paramsString = otherParams
|
|
36
|
-
? Object.entries(otherParams)
|
|
37
|
-
.map(([key, value]) => `${key}=${value}`)
|
|
38
|
-
.join("&")
|
|
39
|
-
: "";
|
|
40
|
-
const url = `/api/catalogs?catalog=${CATALOG_NAME}${paramsString ? `&${paramsString}` : ""}`;
|
|
41
|
-
fetcher.load(url);
|
|
42
|
-
}
|
|
43
|
-
catch (ex) {
|
|
44
|
-
(0, index_js_1.showAlert)({
|
|
45
|
-
type: "error",
|
|
46
|
-
title: `Ocurrió un error al cargar el catálogo: ${CATALOG_NAME}.`,
|
|
47
|
-
description: "Error: " + ex,
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
}, []);
|
|
51
|
-
return data;
|
|
52
|
-
};
|
|
53
|
-
/**
|
|
54
|
-
*
|
|
55
|
-
* @param CATALOG_NAME
|
|
56
|
-
* @param param1
|
|
57
|
-
* @returns
|
|
58
|
-
*
|
|
59
|
-
* otherParams usage example:
|
|
60
|
-
*
|
|
61
|
-
* otherParams: {
|
|
62
|
-
includeDiscounts: "true",
|
|
63
|
-
}
|
|
64
|
-
*/
|
|
65
|
-
const useGetReduxCatalog = (CATALOG_NAME, { online = false, wheres = [], otherParams } = {}) => {
|
|
66
|
-
const fetcher = (0, react_1.useFetcher)();
|
|
67
|
-
const dispatch = (0, redux_1.useAppDispatch)();
|
|
68
|
-
const catalogData = (0, redux_1.useAppSelector)((state) => state.catalogs[CATALOG_NAME]);
|
|
69
|
-
const [data, setData] = (0, react_2.useState)({
|
|
70
|
-
data: catalogData?.data?.length ? catalogData.data : [],
|
|
71
|
-
loading: catalogData.loading,
|
|
72
|
-
});
|
|
73
|
-
(0, react_2.useEffect)(() => {
|
|
74
|
-
if (fetcher.data?.description) {
|
|
75
|
-
(0, index_js_1.showAlert)({
|
|
76
|
-
description: fetcher.data?.description?.toString(),
|
|
77
|
-
title: fetcher.data?.title?.toString(),
|
|
78
|
-
type: fetcher.data?.type?.toString(),
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
}, [fetcher.data]);
|
|
82
|
-
(0, react_2.useEffect)(() => {
|
|
83
|
-
if (fetcher.state === "idle" && fetcher.data != null) {
|
|
84
|
-
const receivedData = fetcher.data;
|
|
85
|
-
if (receivedData) {
|
|
86
|
-
setData({ data: receivedData[CATALOG_NAME], loading: false });
|
|
87
|
-
dispatch((0, redux_1.catalogsFetchSuccess)({
|
|
88
|
-
name: CATALOG_NAME,
|
|
89
|
-
data: receivedData[CATALOG_NAME],
|
|
90
|
-
}));
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}, [fetcher, dispatch, CATALOG_NAME]);
|
|
94
|
-
(0, react_2.useEffect)(() => {
|
|
95
|
-
if (catalogData?.data?.length <= 0 || catalogData?.reFetch || online) {
|
|
96
|
-
try {
|
|
97
|
-
setData({ ...data, loading: true });
|
|
98
|
-
dispatch((0, redux_1.catalogsFetchStart)(CATALOG_NAME));
|
|
99
|
-
// Convierte cada elemento del array a una cadena codificada para URL
|
|
100
|
-
const encodedWheres = wheres.map((where) => encodeURIComponent(where));
|
|
101
|
-
// Une los elementos codificados con '&'
|
|
102
|
-
const wheresQueryParam = encodedWheres.join("&");
|
|
103
|
-
// Convert otherParams to query string
|
|
104
|
-
const paramsString = otherParams
|
|
105
|
-
? Object.entries(otherParams)
|
|
106
|
-
.map(([key, value]) => `${key}=${value}`)
|
|
107
|
-
.join("&")
|
|
108
|
-
: "";
|
|
109
|
-
fetcher.load(`/api/catalogs?catalog=${CATALOG_NAME}&wheres=${wheresQueryParam}${paramsString ? `&${paramsString}` : ""}`);
|
|
110
|
-
}
|
|
111
|
-
catch (ex) {
|
|
112
|
-
(0, index_js_1.showAlert)({
|
|
113
|
-
type: "error",
|
|
114
|
-
title: `Ocurrió un error al cargar el catálogo: ${CATALOG_NAME}.`,
|
|
115
|
-
description: "Error: " + ex,
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}, []);
|
|
120
|
-
return data;
|
|
121
|
-
};
|
|
122
|
-
/**
|
|
123
|
-
*
|
|
124
|
-
* ======================= HOOKS
|
|
125
|
-
*/
|
|
126
|
-
const useGetItems = (config) => useGetReduxCatalog("items", config);
|
|
127
|
-
exports.useGetItems = useGetItems;
|
|
128
|
-
const useGetItemsByReception = (config) => useGetReduxCatalog("itemsByReception", config);
|
|
129
|
-
exports.useGetItemsByReception = useGetItemsByReception;
|
|
130
|
-
const useGetItemsByLab = (config) => useGetReduxCatalog("itemsByLab", config);
|
|
131
|
-
exports.useGetItemsByLab = useGetItemsByLab;
|
|
132
|
-
const useGetMyAgencyLotStocks = (config) => useGetReduxCatalog("myAgencyLotStocks", config);
|
|
133
|
-
exports.useGetMyAgencyLotStocks = useGetMyAgencyLotStocks;
|
|
134
|
-
const useGetItemServicesByLab = (config) => useGetReduxCatalog("itemServicesByLab", config);
|
|
135
|
-
exports.useGetItemServicesByLab = useGetItemServicesByLab;
|
|
136
|
-
const useGetItemCategoriesForLab = (config) => useGetReduxCatalog("itemCategoriesForLab", config);
|
|
137
|
-
exports.useGetItemCategoriesForLab = useGetItemCategoriesForLab;
|
|
138
|
-
const useGetBookings = (config) => useGetReduxCatalog("bookings", config);
|
|
139
|
-
exports.useGetBookings = useGetBookings;
|
|
140
|
-
const useGetTemplates = (config) => useGetReduxCatalog("templates", config);
|
|
141
|
-
exports.useGetTemplates = useGetTemplates;
|
|
142
|
-
const useGetPayeeCategories = (config) => useGetReduxCatalog("payeeCategories", config);
|
|
143
|
-
exports.useGetPayeeCategories = useGetPayeeCategories;
|
|
144
|
-
const useGetPayeeCategoriesLabPrices = (config = { withPriceListIdNull: false }) => {
|
|
145
|
-
const data = useGetReduxCatalog("payeeCategoriesLabPrices");
|
|
146
|
-
let tempData = data.data;
|
|
147
|
-
if (!config.withPriceListIdNull) {
|
|
148
|
-
tempData = data.data.filter((x) => x.price_list_id);
|
|
149
|
-
}
|
|
150
|
-
return { ...data, data: tempData };
|
|
151
|
-
};
|
|
152
|
-
exports.useGetPayeeCategoriesLabPrices = useGetPayeeCategoriesLabPrices;
|
|
153
|
-
const useGetBundlesRecipForLab = (config) => useGetReduxCatalog("bundlesRecipForLab", config);
|
|
154
|
-
exports.useGetBundlesRecipForLab = useGetBundlesRecipForLab;
|
|
155
|
-
const useGetBundlesForLab = (config) => useGetReduxCatalog("bundlesForLab", config);
|
|
156
|
-
exports.useGetBundlesForLab = useGetBundlesForLab;
|
|
157
|
-
const useGetCurrencies = (config) => useGetReduxCatalog("currencies", config);
|
|
158
|
-
exports.useGetCurrencies = useGetCurrencies;
|
|
159
|
-
const useGetReceptionTypes = (config) => useGetReduxCatalog("receptionTypes", config);
|
|
160
|
-
exports.useGetReceptionTypes = useGetReceptionTypes;
|
|
161
|
-
const useGetProviders = (config) => useGetReduxCatalog("providers", config);
|
|
162
|
-
exports.useGetProviders = useGetProviders;
|
|
163
|
-
const useGetMyCases = (config) => useGetReduxCatalog("myCases", config);
|
|
164
|
-
exports.useGetMyCases = useGetMyCases;
|
|
165
|
-
const useGetProviderCategories = (config) => useGetReduxCatalog("providerCategories", config);
|
|
166
|
-
exports.useGetProviderCategories = useGetProviderCategories;
|
|
167
|
-
const useGetClientCategories = (config) => useGetReduxCatalog("clientCategories", config);
|
|
168
|
-
exports.useGetClientCategories = useGetClientCategories;
|
|
169
|
-
const useGetPayees = (config) => useGetReduxCatalog("payees", config);
|
|
170
|
-
exports.useGetPayees = useGetPayees;
|
|
171
|
-
const useGetPayeesForLab = (config) => useGetReduxCatalog("payeesForLab", config);
|
|
172
|
-
exports.useGetPayeesForLab = useGetPayeesForLab;
|
|
173
|
-
const useGetPrintTemplates = (config) => useGetReduxCatalog("printTemplates", config);
|
|
174
|
-
exports.useGetPrintTemplates = useGetPrintTemplates;
|
|
175
|
-
const useGetAgencies = (config) => useGetReduxCatalog("agencies", config);
|
|
176
|
-
exports.useGetAgencies = useGetAgencies;
|
|
177
|
-
const useGetSuggestedPrices = (config) => useGetReduxCatalog("suggestedPrices", config);
|
|
178
|
-
exports.useGetSuggestedPrices = useGetSuggestedPrices;
|
|
179
|
-
const useGetPaymentTerms = (config) => useGetReduxCatalog("paymentTerms", config);
|
|
180
|
-
exports.useGetPaymentTerms = useGetPaymentTerms;
|
|
181
|
-
const useGetPaymentMethods = (config) => useGetReduxCatalog("paymentMethods", config);
|
|
182
|
-
exports.useGetPaymentMethods = useGetPaymentMethods;
|
|
183
|
-
const useGetEmployeesByLab = (config) => useGetReduxCatalog("employeesByLab", config);
|
|
184
|
-
exports.useGetEmployeesByLab = useGetEmployeesByLab;
|
|
185
|
-
const useGetEmployeesByCurrentAgency = (config) => useGetReduxCatalog("employeesByCurrentAgency", config);
|
|
186
|
-
exports.useGetEmployeesByCurrentAgency = useGetEmployeesByCurrentAgency;
|
|
187
|
-
const useGetShipmentsToMyAgency = (config) => useGetReduxCatalog("shipmentsToMyAgency", config);
|
|
188
|
-
exports.useGetShipmentsToMyAgency = useGetShipmentsToMyAgency;
|
|
189
|
-
const useGetInvoicesByLab = (config) => useGetReduxCatalog("invoicesByLab", config);
|
|
190
|
-
exports.useGetInvoicesByLab = useGetInvoicesByLab;
|
|
191
|
-
const useGetTiposDeMuestra = (config) => useGetReduxCatalog("tiposDeMuestra", config);
|
|
192
|
-
exports.useGetTiposDeMuestra = useGetTiposDeMuestra;
|
|
193
|
-
const useGetMotivosDeRechazo = (config) => useGetReduxCatalog("motivosRechazo", config);
|
|
194
|
-
exports.useGetMotivosDeRechazo = useGetMotivosDeRechazo;
|
|
195
|
-
const useGetBitacoraRechazoMasivo = (config) => useGetReduxCatalog("bitacoraRechazoMasivo", config);
|
|
196
|
-
exports.useGetBitacoraRechazoMasivo = useGetBitacoraRechazoMasivo;
|
|
197
|
-
const useGetAllForms = (config) => {
|
|
198
|
-
const data = useGetReduxCatalog("allForms", config);
|
|
199
|
-
// Filtrar los registros para obtener sólo los de la versión más alta.
|
|
200
|
-
const groupedByVersion = (data.data || []).reduce((acc, record) => {
|
|
201
|
-
const zid = record.zid;
|
|
202
|
-
if (!acc[zid]) {
|
|
203
|
-
acc[zid] = record;
|
|
204
|
-
}
|
|
205
|
-
return acc;
|
|
206
|
-
}, {});
|
|
207
|
-
const latestVersionRecords = Object.values(groupedByVersion);
|
|
208
|
-
return {
|
|
209
|
-
loading: data.loading,
|
|
210
|
-
data: latestVersionRecords.filter((x) => x.active),
|
|
211
|
-
};
|
|
212
|
-
};
|
|
213
|
-
exports.useGetAllForms = useGetAllForms;
|
|
214
|
-
const useGetInvoiceForms = (config) => {
|
|
215
|
-
const data = useGetReduxCatalog("invoiceForms", config);
|
|
216
|
-
// Filtrar los registros para obtener sólo los de la versión más alta.
|
|
217
|
-
const groupedByVersion = (data.data || []).reduce((acc, record) => {
|
|
218
|
-
const zid = record.zid;
|
|
219
|
-
if (!acc[zid]) {
|
|
220
|
-
acc[zid] = record;
|
|
221
|
-
}
|
|
222
|
-
return acc;
|
|
223
|
-
}, {});
|
|
224
|
-
const latestVersionRecords = Object.values(groupedByVersion);
|
|
225
|
-
return {
|
|
226
|
-
loading: data.loading,
|
|
227
|
-
data: latestVersionRecords.filter((x) => x.active),
|
|
228
|
-
};
|
|
229
|
-
};
|
|
230
|
-
exports.useGetInvoiceForms = useGetInvoiceForms;
|
|
231
|
-
const useGetCaseForms = (config) => {
|
|
232
|
-
const data = useGetReduxCatalog("caseForms", config);
|
|
233
|
-
// Filtrar los registros para obtener sólo el primero de cada zid.
|
|
234
|
-
const firstRecordByZid = (data.data || []).reduce((acc, record) => {
|
|
235
|
-
const zid = record.zid;
|
|
236
|
-
if (!acc[zid]) {
|
|
237
|
-
acc[zid] = record;
|
|
238
|
-
}
|
|
239
|
-
return acc;
|
|
240
|
-
}, {});
|
|
241
|
-
const firstRecords = Object.values(firstRecordByZid);
|
|
242
|
-
return {
|
|
243
|
-
loading: data.loading,
|
|
244
|
-
data: firstRecords.filter((x) => x.active),
|
|
245
|
-
};
|
|
246
|
-
};
|
|
247
|
-
exports.useGetCaseForms = useGetCaseForms;
|
|
248
|
-
const useGetInvoiceFormSubmissionsByAgencyId = (agency_id) => {
|
|
249
|
-
const data = useApiCatalog("invoiceFormSubmissionsByAgencyId", {
|
|
250
|
-
agency_id: `${agency_id}`,
|
|
251
|
-
});
|
|
252
|
-
// Filtrar los registros para obtener sólo los de la versión más alta.
|
|
253
|
-
const groupedByVersion = (data.data || []).reduce((acc, record) => {
|
|
254
|
-
const zid = record.settings_form_submission.zid;
|
|
255
|
-
if (!acc[zid]) {
|
|
256
|
-
acc[zid] = record;
|
|
257
|
-
}
|
|
258
|
-
return acc;
|
|
259
|
-
}, {});
|
|
260
|
-
const latestVersionRecords = Object.values(groupedByVersion);
|
|
261
|
-
return {
|
|
262
|
-
loading: data.loading,
|
|
263
|
-
data: latestVersionRecords,
|
|
264
|
-
};
|
|
265
|
-
};
|
|
266
|
-
exports.useGetInvoiceFormSubmissionsByAgencyId = useGetInvoiceFormSubmissionsByAgencyId;
|
|
267
|
-
const useGetMyCaseFormSubmissions = (config) => {
|
|
268
|
-
const data = useGetReduxCatalog("myCaseFormSubmissions", config);
|
|
269
|
-
// Filtrar los registros para obtener sólo los de la versión más alta.
|
|
270
|
-
const groupedByVersion = (data.data || []).reduce((acc, record) => {
|
|
271
|
-
const zid = record.settings_form_submission.zid;
|
|
272
|
-
if (!acc[zid]) {
|
|
273
|
-
acc[zid] = record;
|
|
274
|
-
}
|
|
275
|
-
return acc;
|
|
276
|
-
}, {});
|
|
277
|
-
const latestVersionRecords = Object.values(groupedByVersion);
|
|
278
|
-
return {
|
|
279
|
-
loading: data.loading,
|
|
280
|
-
data: latestVersionRecords,
|
|
281
|
-
};
|
|
282
|
-
};
|
|
283
|
-
exports.useGetMyCaseFormSubmissions = useGetMyCaseFormSubmissions;
|
|
284
|
-
const useGetInvoiceFormSubmissionsByInvoiceId = (invoice_id) => {
|
|
285
|
-
const data = useApiCatalog("invoiceFormSubmissionsByInvoiceId", {
|
|
286
|
-
invoice_id: `${invoice_id}`,
|
|
287
|
-
});
|
|
288
|
-
// Filtrar los registros para obtener sólo los de la versión más alta.
|
|
289
|
-
const groupedByVersion = (data.data || []).reduce((acc, record) => {
|
|
290
|
-
const zid = record.settings_form_submission.zid;
|
|
291
|
-
if (!acc[zid]) {
|
|
292
|
-
acc[zid] = record;
|
|
293
|
-
}
|
|
294
|
-
return acc;
|
|
295
|
-
}, {});
|
|
296
|
-
const latestVersionRecords = Object.values(groupedByVersion);
|
|
297
|
-
return {
|
|
298
|
-
loading: data.loading,
|
|
299
|
-
data: latestVersionRecords,
|
|
300
|
-
};
|
|
301
|
-
};
|
|
302
|
-
exports.useGetInvoiceFormSubmissionsByInvoiceId = useGetInvoiceFormSubmissionsByInvoiceId;
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.showAlert = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const react_1 = require("react");
|
|
6
|
-
const icons_1 = require("@zauru-sdk/icons");
|
|
7
|
-
const client_1 = require("react-dom/client");
|
|
8
|
-
const Alert = ({ type, title, description, onClose }) => {
|
|
9
|
-
const [, setLifetime] = (0, react_1.useState)(4000);
|
|
10
|
-
const [progress, setProgress] = (0, react_1.useState)(0);
|
|
11
|
-
const intervalRef = (0, react_1.useRef)(null);
|
|
12
|
-
const getColor = () => {
|
|
13
|
-
switch (type) {
|
|
14
|
-
case "success":
|
|
15
|
-
return "bg-green-100 text-green-800";
|
|
16
|
-
case "error":
|
|
17
|
-
return "bg-red-100 text-red-800";
|
|
18
|
-
case "info":
|
|
19
|
-
return "bg-blue-100 text-blue-800";
|
|
20
|
-
case "warning":
|
|
21
|
-
return "bg-yellow-400 text-yellow-900";
|
|
22
|
-
default:
|
|
23
|
-
return "bg-gray-100 text-gray-800";
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
(0, react_1.useEffect)(() => {
|
|
27
|
-
const startTimer = () => {
|
|
28
|
-
intervalRef.current = setInterval(() => {
|
|
29
|
-
setLifetime((lifetime) => {
|
|
30
|
-
if (lifetime <= 0) {
|
|
31
|
-
onClose && onClose();
|
|
32
|
-
clearInterval(intervalRef.current);
|
|
33
|
-
return 0;
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
setProgress((4000 - lifetime) / 4000);
|
|
37
|
-
return lifetime - 50;
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
}, 50);
|
|
41
|
-
};
|
|
42
|
-
const pauseTimer = () => {
|
|
43
|
-
clearInterval(intervalRef.current);
|
|
44
|
-
};
|
|
45
|
-
startTimer();
|
|
46
|
-
return () => {
|
|
47
|
-
pauseTimer();
|
|
48
|
-
};
|
|
49
|
-
}, [onClose]);
|
|
50
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: `fixed top-0 right-0 w-80 mt-10 mr-10 rounded-md shadow-lg ${getColor()} p-4 transition-transform duration-300`, style: {
|
|
51
|
-
zIndex: 1000,
|
|
52
|
-
transform: `translateY(calc(var(--alert-offset, 0)))`,
|
|
53
|
-
}, onMouseEnter: () => clearInterval(intervalRef.current), onMouseLeave: () => {
|
|
54
|
-
intervalRef.current = setInterval(() => {
|
|
55
|
-
setLifetime((lifetime) => {
|
|
56
|
-
if (lifetime <= 0) {
|
|
57
|
-
onClose && onClose();
|
|
58
|
-
clearInterval(intervalRef.current);
|
|
59
|
-
return 0;
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
setProgress((4000 - lifetime) / 4000);
|
|
63
|
-
return lifetime - 50;
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
}, 50);
|
|
67
|
-
}, children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("h3", { className: "font-semibold", children: title }), (0, jsx_runtime_1.jsx)("button", { className: "text-gray-400 hover:text-gray-500 focus:outline-none focus:text-gray-500 transition duration-150 ease-in-out", onClick: () => {
|
|
68
|
-
setLifetime(0);
|
|
69
|
-
onClose && onClose();
|
|
70
|
-
}, children: (0, jsx_runtime_1.jsx)(icons_1.ExitSvg, {}) })] }), (0, jsx_runtime_1.jsx)("div", { className: "mt-2", children: (0, jsx_runtime_1.jsx)("p", { className: "text-sm overflow-wrap break-words", children: description }) }), (0, jsx_runtime_1.jsx)("div", { className: "relative h-1 mt-4 bg-gray-200 rounded", children: (0, jsx_runtime_1.jsx)("div", { className: `absolute left-0 top-0 h-full ${getColor()} rounded`, style: { width: `${progress * 100}%` } }) })] }));
|
|
71
|
-
};
|
|
72
|
-
let activeAlerts = [];
|
|
73
|
-
const showAlert = (alertProps) => {
|
|
74
|
-
if (typeof document === "undefined") {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
const container = document.createElement("div");
|
|
78
|
-
document.body.appendChild(container);
|
|
79
|
-
const onClose = () => {
|
|
80
|
-
root.unmount();
|
|
81
|
-
container.remove();
|
|
82
|
-
activeAlerts = activeAlerts.filter((alert) => alert !== container);
|
|
83
|
-
updateAlertOffsets();
|
|
84
|
-
};
|
|
85
|
-
const asyncOnClose = () => {
|
|
86
|
-
setTimeout(() => {
|
|
87
|
-
onClose();
|
|
88
|
-
}, 0);
|
|
89
|
-
};
|
|
90
|
-
activeAlerts.push(container);
|
|
91
|
-
updateAlertOffsets();
|
|
92
|
-
const root = (0, client_1.createRoot)(container);
|
|
93
|
-
root.render((0, jsx_runtime_1.jsx)(Alert, { ...alertProps, onClose: asyncOnClose }));
|
|
94
|
-
};
|
|
95
|
-
exports.showAlert = showAlert;
|
|
96
|
-
const updateAlertOffsets = () => {
|
|
97
|
-
activeAlerts.forEach((alertContainer, index) => {
|
|
98
|
-
alertContainer.style.setProperty("--alert-offset", `${index * 100}px`);
|
|
99
|
-
});
|
|
100
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./Alert.js"), exports);
|
package/dist/cjs/index.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./components/index.js"), exports);
|
|
18
|
-
__exportStar(require("./alerts.js"), exports);
|
|
19
|
-
__exportStar(require("./automaticNumbers.js"), exports);
|
|
20
|
-
__exportStar(require("./catalogs.js"), exports);
|
|
21
|
-
__exportStar(require("./onlineStatus.js"), exports);
|
|
22
|
-
__exportStar(require("./profiles.js"), exports);
|
|
23
|
-
__exportStar(require("./receptions.js"), exports);
|
|
24
|
-
__exportStar(require("./session.js"), exports);
|
|
25
|
-
__exportStar(require("./templates.js"), exports);
|
|
26
|
-
__exportStar(require("./useWindowDimensions.js"), exports);
|
package/dist/cjs/onlineStatus.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useIsOnline = void 0;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
// Hook personalizado para verificar el estado de conexión
|
|
6
|
-
const useIsOnline = () => {
|
|
7
|
-
// Verificar si estamos en el entorno del servidor o del cliente
|
|
8
|
-
const isServer = typeof window === "undefined";
|
|
9
|
-
// Estado local para almacenar si la aplicación está en línea o no
|
|
10
|
-
const [isOnline, setIsOnline] = (0, react_1.useState)(!isServer && navigator.onLine);
|
|
11
|
-
// Función para manejar el cambio de estado de conexión
|
|
12
|
-
const handleConnectionChange = () => {
|
|
13
|
-
setIsOnline(navigator.onLine);
|
|
14
|
-
};
|
|
15
|
-
(0, react_1.useEffect)(() => {
|
|
16
|
-
if (isServer) {
|
|
17
|
-
// Si estamos en el servidor, no añadir los event listeners
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
// Añadir event listeners
|
|
21
|
-
window.addEventListener("online", handleConnectionChange);
|
|
22
|
-
window.addEventListener("offline", handleConnectionChange);
|
|
23
|
-
// Limpiar event listeners al desmontar el componente
|
|
24
|
-
return () => {
|
|
25
|
-
window.removeEventListener("online", handleConnectionChange);
|
|
26
|
-
window.removeEventListener("offline", handleConnectionChange);
|
|
27
|
-
};
|
|
28
|
-
}, [isServer]);
|
|
29
|
-
return isOnline;
|
|
30
|
-
};
|
|
31
|
-
exports.useIsOnline = useIsOnline;
|
package/dist/cjs/profiles.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useGetEmployeeProfile = exports.useGetOauthProfile = exports.useGetUserProfile = exports.useGetAgencyProfile = void 0;
|
|
4
|
-
const react_1 = require("@remix-run/react");
|
|
5
|
-
const react_2 = require("react");
|
|
6
|
-
const index_js_1 = require("./index.js");
|
|
7
|
-
const redux_1 = require("@zauru-sdk/redux");
|
|
8
|
-
const useGetProfile = (PROFILE_NAME) => {
|
|
9
|
-
const fetcher = (0, react_1.useFetcher)();
|
|
10
|
-
const dispatch = (0, redux_1.useAppDispatch)();
|
|
11
|
-
const profileData = (0, redux_1.useAppSelector)((state) => state.profiles[PROFILE_NAME]);
|
|
12
|
-
const [data, setData] = (0, react_2.useState)({
|
|
13
|
-
data: Object.keys(profileData?.data)?.length
|
|
14
|
-
? profileData?.data
|
|
15
|
-
: {},
|
|
16
|
-
loading: profileData?.loading,
|
|
17
|
-
});
|
|
18
|
-
(0, react_2.useEffect)(() => {
|
|
19
|
-
if (fetcher.data?.title) {
|
|
20
|
-
(0, index_js_1.showAlert)({
|
|
21
|
-
description: fetcher.data?.description?.toString(),
|
|
22
|
-
title: fetcher.data?.title?.toString(),
|
|
23
|
-
type: fetcher.data?.type?.toString(),
|
|
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[PROFILE_NAME], loading: false });
|
|
32
|
-
dispatch((0, redux_1.profileFetchSuccess)({
|
|
33
|
-
name: PROFILE_NAME,
|
|
34
|
-
data: receivedData[PROFILE_NAME],
|
|
35
|
-
}));
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}, [fetcher, dispatch, PROFILE_NAME]);
|
|
39
|
-
(0, react_2.useEffect)(() => {
|
|
40
|
-
if (Object.keys(profileData?.data).length <= 0) {
|
|
41
|
-
try {
|
|
42
|
-
setData({ ...data, loading: true });
|
|
43
|
-
dispatch((0, redux_1.profileFetchStart)(PROFILE_NAME));
|
|
44
|
-
fetcher.load(`/api/profiles?profile=${PROFILE_NAME}`);
|
|
45
|
-
}
|
|
46
|
-
catch (ex) {
|
|
47
|
-
(0, index_js_1.showAlert)({
|
|
48
|
-
type: "error",
|
|
49
|
-
title: `Ocurrió un error al cargar el perfil: ${PROFILE_NAME}.`,
|
|
50
|
-
description: "Error: " + ex,
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}, []);
|
|
55
|
-
return data;
|
|
56
|
-
};
|
|
57
|
-
const useGetAgencyProfile = () => useGetProfile("agencyProfile");
|
|
58
|
-
exports.useGetAgencyProfile = useGetAgencyProfile;
|
|
59
|
-
const useGetUserProfile = () => useGetProfile("userProfile");
|
|
60
|
-
exports.useGetUserProfile = useGetUserProfile;
|
|
61
|
-
const useGetOauthProfile = () => useGetProfile("oauthProfile");
|
|
62
|
-
exports.useGetOauthProfile = useGetOauthProfile;
|
|
63
|
-
const useGetEmployeeProfile = () => useGetProfile("employeeProfile");
|
|
64
|
-
exports.useGetEmployeeProfile = useGetEmployeeProfile;
|
package/dist/cjs/receptions.js
DELETED
|
@@ -1,405 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useGetItemByPurchaseOrder = 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");
|
|
9
|
-
const useGetReceptionObject = (RECEPTION_NAME, { online = false, wheres = [] } = {}) => {
|
|
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)({
|
|
14
|
-
data: Array.isArray(objectData?.data)
|
|
15
|
-
? objectData?.data.length
|
|
16
|
-
? objectData?.data
|
|
17
|
-
: []
|
|
18
|
-
: Object.keys(objectData?.data || {}).length
|
|
19
|
-
? objectData?.data
|
|
20
|
-
: {},
|
|
21
|
-
loading: objectData.loading,
|
|
22
|
-
});
|
|
23
|
-
(0, react_2.useEffect)(() => {
|
|
24
|
-
if (fetcher.data?.title) {
|
|
25
|
-
(0, index_js_1.showAlert)({
|
|
26
|
-
description: fetcher.data?.description?.toString(),
|
|
27
|
-
title: fetcher.data?.title?.toString(),
|
|
28
|
-
type: fetcher.data?.type?.toString(),
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
}, [fetcher.data]);
|
|
32
|
-
(0, react_2.useEffect)(() => {
|
|
33
|
-
if (fetcher.state === "idle" && fetcher.data != null) {
|
|
34
|
-
const receivedData = fetcher.data;
|
|
35
|
-
if (receivedData) {
|
|
36
|
-
setData({ data: receivedData[RECEPTION_NAME], loading: false });
|
|
37
|
-
dispatch((0, redux_1.receptionFetchSuccess)({
|
|
38
|
-
name: RECEPTION_NAME,
|
|
39
|
-
data: receivedData[RECEPTION_NAME],
|
|
40
|
-
}));
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}, [fetcher, dispatch, RECEPTION_NAME]);
|
|
44
|
-
(0, react_2.useEffect)(() => {
|
|
45
|
-
const isEmptyData = Array.isArray(objectData?.data)
|
|
46
|
-
? objectData?.data.length <= 0
|
|
47
|
-
: Object.keys(objectData?.data || {}).length <= 0;
|
|
48
|
-
if (isEmptyData || objectData.reFetch || online) {
|
|
49
|
-
try {
|
|
50
|
-
setData({ ...data, loading: true });
|
|
51
|
-
dispatch((0, redux_1.receptionFetchStart)(RECEPTION_NAME));
|
|
52
|
-
// Convierte cada elemento del array a una cadena codificada para URL
|
|
53
|
-
const encodedWheres = wheres.map((where) => encodeURIComponent(where));
|
|
54
|
-
// Une los elementos codificados con '&'
|
|
55
|
-
const wheresQueryParam = encodedWheres.join("&");
|
|
56
|
-
fetcher.load(`/api/receptions?object=${RECEPTION_NAME}&wheres=${wheresQueryParam}`);
|
|
57
|
-
}
|
|
58
|
-
catch (ex) {
|
|
59
|
-
(0, index_js_1.showAlert)({
|
|
60
|
-
type: "error",
|
|
61
|
-
title: `Ocurrió un error al cargar el object de receptions: ${RECEPTION_NAME}.`,
|
|
62
|
-
description: "Error: " + ex,
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}, []);
|
|
67
|
-
return data;
|
|
68
|
-
};
|
|
69
|
-
const useGetProcesses = (config) => useGetReceptionObject("queueReceptions", 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, stocks_only_integer = false) => {
|
|
82
|
-
const [pesadas, footerPesadas, headersPesadas] = (0, react_2.useMemo)(() => {
|
|
83
|
-
if (!purchaseOrder)
|
|
84
|
-
return [[], {}, []];
|
|
85
|
-
const tempPesadas = [
|
|
86
|
-
...purchaseOrder.purchase_order_details?.map((x, index) => {
|
|
87
|
-
const parsedReference = x.reference?.split(","); //eg: "reference": "698,25,0", // peso neto, canastas, descuento
|
|
88
|
-
const totalWeight = parsedReference[0]
|
|
89
|
-
? Number(parsedReference[0]) ?? 0
|
|
90
|
-
: 0;
|
|
91
|
-
const baskets = parsedReference[1]
|
|
92
|
-
? Number(parsedReference[1]) ?? 0
|
|
93
|
-
: 0;
|
|
94
|
-
const discount = parsedReference[2]
|
|
95
|
-
? isNaN(Number(parsedReference[2]))
|
|
96
|
-
? 0
|
|
97
|
-
: Number(parsedReference[2])
|
|
98
|
-
: 0;
|
|
99
|
-
//TODO sacar el peso de la canasta de la API de Zauru, ahorita se supone que no debería cambiar de 5 libras.
|
|
100
|
-
const basketWeight = 5;
|
|
101
|
-
let netWeight = totalWeight - baskets * basketWeight; //Se le resta el peso de las canastas
|
|
102
|
-
netWeight = netWeight * ((100 - discount) / 100); //Se le aplica el descuento
|
|
103
|
-
if (stocks_only_integer)
|
|
104
|
-
netWeight = totalWeight; //si es en unidades no divido el peso entre las canastas
|
|
105
|
-
const weightByBasket = netWeight / baskets;
|
|
106
|
-
//Probable aprovechamiento en planta
|
|
107
|
-
const probableUtilization = netWeight * ((100 - purchaseOrder?.discount) / 100);
|
|
108
|
-
//libras o unidades descontadas
|
|
109
|
-
const lbDiscounted = netWeight - probableUtilization;
|
|
110
|
-
return {
|
|
111
|
-
id: index + 1,
|
|
112
|
-
baskets,
|
|
113
|
-
totalWeight,
|
|
114
|
-
discount,
|
|
115
|
-
netWeight: (0, common_1.toFixedIfNeeded)(netWeight)?.toString(),
|
|
116
|
-
weightByBasket: (0, common_1.toFixedIfNeeded)(weightByBasket)?.toString(),
|
|
117
|
-
probableUtilization,
|
|
118
|
-
lbDiscounted,
|
|
119
|
-
};
|
|
120
|
-
}),
|
|
121
|
-
];
|
|
122
|
-
const totales = {
|
|
123
|
-
id: "",
|
|
124
|
-
baskets: (0, common_1.toFixedIfNeeded)(tempPesadas?.map((x) => x.baskets).reduce(common_1.reduceAdd, 0))?.toString(),
|
|
125
|
-
totalWeight: (0, common_1.toFixedIfNeeded)(tempPesadas?.map((x) => x.totalWeight).reduce(common_1.reduceAdd, 0))?.toString(),
|
|
126
|
-
discount: "-",
|
|
127
|
-
netWeight: (0, common_1.toFixedIfNeeded)(tempPesadas?.map((x) => Number(x.netWeight)).reduce(common_1.reduceAdd, 0))?.toString(),
|
|
128
|
-
weightByBasket: "-",
|
|
129
|
-
lbDiscounted: (0, common_1.toFixedIfNeeded)(tempPesadas?.map((x) => Number(x.lbDiscounted)).reduce(common_1.reduceAdd, 0))?.toString(),
|
|
130
|
-
probableUtilization: (0, common_1.toFixedIfNeeded)(tempPesadas
|
|
131
|
-
?.map((x) => Number(x.probableUtilization))
|
|
132
|
-
.reduce(common_1.reduceAdd, 0)),
|
|
133
|
-
};
|
|
134
|
-
const headers = [
|
|
135
|
-
{ label: "#", name: "id", type: "label", width: 5 },
|
|
136
|
-
{ label: "Canastas", name: "baskets", type: "label" },
|
|
137
|
-
{
|
|
138
|
-
label: `${stocks_only_integer ? "Unidades" : "Peso báscula"}`,
|
|
139
|
-
name: "totalWeight",
|
|
140
|
-
type: "label",
|
|
141
|
-
},
|
|
142
|
-
{ label: "Descuento (%)", name: "discount", type: "label" },
|
|
143
|
-
{
|
|
144
|
-
label: `${stocks_only_integer ? "Unidades" : "Peso Neto"}`,
|
|
145
|
-
name: "netWeight",
|
|
146
|
-
type: "label",
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
label: `${stocks_only_integer ? "Unidades" : "Peso Neto"} - %Rechazo`,
|
|
150
|
-
name: "probableUtilization",
|
|
151
|
-
type: "label",
|
|
152
|
-
},
|
|
153
|
-
{
|
|
154
|
-
label: `${stocks_only_integer ? "Unidades" : "Libras"} descontadas`,
|
|
155
|
-
name: "lbDiscounted",
|
|
156
|
-
type: "label",
|
|
157
|
-
},
|
|
158
|
-
{
|
|
159
|
-
label: `${stocks_only_integer ? "Unidades" : "Peso Neto"} por canasta`,
|
|
160
|
-
name: "weightByBasket",
|
|
161
|
-
type: "label",
|
|
162
|
-
},
|
|
163
|
-
];
|
|
164
|
-
return [tempPesadas, totales, headers];
|
|
165
|
-
}, [purchaseOrder]);
|
|
166
|
-
return [pesadas, footerPesadas, headersPesadas];
|
|
167
|
-
};
|
|
168
|
-
exports.useGetPesadas = useGetPesadas;
|
|
169
|
-
/**
|
|
170
|
-
* Sirve para imprimir offline
|
|
171
|
-
* @param formInput
|
|
172
|
-
* @returns
|
|
173
|
-
*/
|
|
174
|
-
const getPesadasByForm = (formInput, stocks_only_integer = false) => {
|
|
175
|
-
// Inicializar array de pesadas
|
|
176
|
-
const tempPesadas = [];
|
|
177
|
-
// Iterar sobre los campos del formulario y extraer la información de pesadas
|
|
178
|
-
let index = 0;
|
|
179
|
-
while (formInput.hasOwnProperty(`basket${index}`)) {
|
|
180
|
-
const baskets = isNaN(Number(formInput[`basket${index}`]))
|
|
181
|
-
? 0
|
|
182
|
-
: Number(formInput[`basket${index}`]);
|
|
183
|
-
const totalWeight = isNaN(Number(formInput[`weight${index}`]))
|
|
184
|
-
? 0
|
|
185
|
-
: Number(formInput[`weight${index}`]);
|
|
186
|
-
const discount = isNaN(Number(formInput[`discount${index}`]))
|
|
187
|
-
? 0
|
|
188
|
-
: Number(formInput[`discount${index}`]);
|
|
189
|
-
// Realizar los cálculos necesarios
|
|
190
|
-
const basketWeight = 5;
|
|
191
|
-
let netWeight = totalWeight - baskets * basketWeight;
|
|
192
|
-
netWeight = netWeight * ((100 - discount) / 100);
|
|
193
|
-
netWeight = stocks_only_integer ? totalWeight : netWeight;
|
|
194
|
-
const weightByBasket = netWeight / baskets;
|
|
195
|
-
//Probable aprovechamiento en planta
|
|
196
|
-
const probableUtilization = netWeight * ((100 - (Number(formInput.porcentajeRechazo) ?? 0)) / 100);
|
|
197
|
-
//libras o unidades descontadas
|
|
198
|
-
const lbDiscounted = netWeight - probableUtilization;
|
|
199
|
-
// Añadir al array de pesadas
|
|
200
|
-
tempPesadas.push({
|
|
201
|
-
id: index + 1,
|
|
202
|
-
baskets,
|
|
203
|
-
totalWeight,
|
|
204
|
-
discount,
|
|
205
|
-
netWeight: (0, common_1.toFixedIfNeeded)(netWeight)?.toString(),
|
|
206
|
-
weightByBasket: (0, common_1.toFixedIfNeeded)(weightByBasket)?.toString(),
|
|
207
|
-
probableUtilization,
|
|
208
|
-
lbDiscounted,
|
|
209
|
-
});
|
|
210
|
-
index++;
|
|
211
|
-
}
|
|
212
|
-
const totales = {
|
|
213
|
-
id: "",
|
|
214
|
-
baskets: (0, common_1.toFixedIfNeeded)(tempPesadas?.map((x) => x.baskets).reduce(common_1.reduceAdd, 0)),
|
|
215
|
-
totalWeight: (0, common_1.toFixedIfNeeded)(tempPesadas?.map((x) => x.totalWeight).reduce(common_1.reduceAdd, 0)),
|
|
216
|
-
netWeight: (0, common_1.toFixedIfNeeded)(tempPesadas?.map((x) => Number(x.netWeight)).reduce(common_1.reduceAdd, 0)),
|
|
217
|
-
weightByBasket: "-",
|
|
218
|
-
};
|
|
219
|
-
const headers = [
|
|
220
|
-
{ label: "#", name: "id", type: "label", width: 5 },
|
|
221
|
-
{ label: "Canastas", name: "baskets", type: "label" },
|
|
222
|
-
{
|
|
223
|
-
label: `${stocks_only_integer ? "Unidades" : "Peso báscula"}`,
|
|
224
|
-
name: "totalWeight",
|
|
225
|
-
type: "label",
|
|
226
|
-
},
|
|
227
|
-
{
|
|
228
|
-
label: `${stocks_only_integer ? "Unidades" : "Peso Neto"}`,
|
|
229
|
-
name: "netWeight",
|
|
230
|
-
type: "label",
|
|
231
|
-
},
|
|
232
|
-
{
|
|
233
|
-
label: `${stocks_only_integer ? "Unidades" : "Peso Neto"} por canasta`,
|
|
234
|
-
name: "weightByBasket",
|
|
235
|
-
type: "label",
|
|
236
|
-
},
|
|
237
|
-
];
|
|
238
|
-
return { tempPesadas, totales, headers };
|
|
239
|
-
};
|
|
240
|
-
exports.getPesadasByForm = getPesadasByForm;
|
|
241
|
-
const useGetBasketDetails = (purchaseOrder) => {
|
|
242
|
-
const [basketsJoined, footerBasketsJoined, headersBasketsJoined] = (0, react_2.useMemo)(() => {
|
|
243
|
-
if (!purchaseOrder)
|
|
244
|
-
return [[], {}, []];
|
|
245
|
-
const bsq = purchaseOrder?.lots.length > 0
|
|
246
|
-
? purchaseOrder?.lots
|
|
247
|
-
?.map((x) => {
|
|
248
|
-
const basket = (0, common_1.getBasketsSchema)(x.description);
|
|
249
|
-
return basket;
|
|
250
|
-
})
|
|
251
|
-
.flat(2)
|
|
252
|
-
: //------- INTENTO IMPRIMIR EL TOTAL DE CANASTAS DEL PURCHASE ORDER DETAILS, PORQUE DEPLANO HUBO UN ERROR EN LA CREACION DE LOS LOTES Y POR ESO VIENE VACIO
|
|
253
|
-
//ESTO SOLO ES UNA CONTINGENCIA PARA QUE POR LO MENOS PUEDAN IMPRIMIR EL NUMERO DE CANASTAS, PERO NO LES ESTARÁ MOSTRANDO EL COLOR
|
|
254
|
-
//--- TODO
|
|
255
|
-
purchaseOrder?.purchase_order_details.length > 0
|
|
256
|
-
? purchaseOrder?.purchase_order_details
|
|
257
|
-
?.map((x) => {
|
|
258
|
-
return {
|
|
259
|
-
id: 0,
|
|
260
|
-
color: "-",
|
|
261
|
-
total: Number(x.reference.split(",")[1]) ?? 0,
|
|
262
|
-
};
|
|
263
|
-
})
|
|
264
|
-
.flat(2)
|
|
265
|
-
: [];
|
|
266
|
-
const bsqToCC = (0, common_1.getBasketsSchema)(purchaseOrder.memo);
|
|
267
|
-
const joinedBaskets = [];
|
|
268
|
-
for (let i = 0; i < bsq.length; i++) {
|
|
269
|
-
let found = joinedBaskets.find((item) => item.color === bsq[i].color);
|
|
270
|
-
let foundCC = bsqToCC.find((item) => item.color === bsq[i].color);
|
|
271
|
-
if (found) {
|
|
272
|
-
found.total += bsq[i].total;
|
|
273
|
-
}
|
|
274
|
-
else {
|
|
275
|
-
joinedBaskets.push({
|
|
276
|
-
id: i,
|
|
277
|
-
total: bsq[i].total - (foundCC ? foundCC.total : 0),
|
|
278
|
-
//granTotal: bsq[i].total,
|
|
279
|
-
color: bsq[i].color,
|
|
280
|
-
cc: foundCC ? foundCC.total : 0,
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
const totales = {
|
|
285
|
-
id: "",
|
|
286
|
-
total: (0, common_1.toFixedIfNeeded)(joinedBaskets?.map((x) => x.total).reduce(common_1.reduceAdd, 0))?.toString(),
|
|
287
|
-
cc: joinedBaskets?.map((x) => x.cc).reduce(common_1.reduceAdd, 0),
|
|
288
|
-
//granTotal: joinedBaskets?.map((x) => x.granTotal).reduce(reduceAdd, 0),
|
|
289
|
-
};
|
|
290
|
-
const headers = [
|
|
291
|
-
{ label: "Color", name: "color", type: "label" },
|
|
292
|
-
{ label: "Canastas recibidas", name: "total", type: "label" },
|
|
293
|
-
{ label: "Enviadas a CC", name: "cc", type: "label" },
|
|
294
|
-
//{ label: "Total", name: "granTotal", type: "label" },
|
|
295
|
-
];
|
|
296
|
-
return [joinedBaskets, totales, headers];
|
|
297
|
-
}, [purchaseOrder]);
|
|
298
|
-
return [basketsJoined, footerBasketsJoined, headersBasketsJoined];
|
|
299
|
-
};
|
|
300
|
-
exports.useGetBasketDetails = useGetBasketDetails;
|
|
301
|
-
/**
|
|
302
|
-
* Para imprimir en modo offline
|
|
303
|
-
* @param formInput
|
|
304
|
-
* @returns
|
|
305
|
-
*/
|
|
306
|
-
const getBasketDetailsByForm = (formInput) => {
|
|
307
|
-
const basketDetailsArray = [];
|
|
308
|
-
if (!formInput)
|
|
309
|
-
return {
|
|
310
|
-
basketDetailsArray,
|
|
311
|
-
totales: {},
|
|
312
|
-
headers: [],
|
|
313
|
-
};
|
|
314
|
-
// Regex para identificar los campos relevantes
|
|
315
|
-
const recPattern = /^rec\d+-(.+)$/;
|
|
316
|
-
const qCPattern = /^qC\d+-(.+)$/;
|
|
317
|
-
for (const key in formInput) {
|
|
318
|
-
if (formInput.hasOwnProperty(key)) {
|
|
319
|
-
let match;
|
|
320
|
-
// Comprobar si la clave es un campo "rec" y extraer el color y la cantidad
|
|
321
|
-
if ((match = recPattern.exec(key))) {
|
|
322
|
-
const color = match[1];
|
|
323
|
-
const total = isNaN(Number(formInput[key]))
|
|
324
|
-
? 0
|
|
325
|
-
: Number(formInput[key]);
|
|
326
|
-
const existingBasket = basketDetailsArray.find((item) => item.color === color);
|
|
327
|
-
if (existingBasket) {
|
|
328
|
-
existingBasket.total += total;
|
|
329
|
-
}
|
|
330
|
-
else {
|
|
331
|
-
if (total > 0) {
|
|
332
|
-
basketDetailsArray.push({
|
|
333
|
-
id: basketDetailsArray.length,
|
|
334
|
-
total,
|
|
335
|
-
color,
|
|
336
|
-
cc: 0, // Inicializar cc a 0, se actualizará más adelante si existe
|
|
337
|
-
});
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
// Comprobar si la clave es un campo "qC" y actualizar el campo cc correspondiente
|
|
342
|
-
if ((match = qCPattern.exec(key))) {
|
|
343
|
-
const color = match[1];
|
|
344
|
-
const cc = isNaN(Number(formInput[key])) ? 0 : Number(formInput[key]);
|
|
345
|
-
const existingBasket = basketDetailsArray.find((item) => item.color === color);
|
|
346
|
-
if (existingBasket) {
|
|
347
|
-
existingBasket.cc += cc;
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
// Calcular los totales para footerBasketsDetails
|
|
353
|
-
const totales = {
|
|
354
|
-
id: "",
|
|
355
|
-
total: (0, common_1.toFixedIfNeeded)(basketDetailsArray.map((x) => x.total).reduce(common_1.reduceAdd, 0))?.toString(),
|
|
356
|
-
cc: basketDetailsArray.map((x) => x.cc).reduce(common_1.reduceAdd, 0),
|
|
357
|
-
};
|
|
358
|
-
// Definir los encabezados de la tabla
|
|
359
|
-
const headers = [
|
|
360
|
-
{ label: "Color", name: "color", type: "label" },
|
|
361
|
-
{ label: "Canastas recibidas", name: "total", type: "label" },
|
|
362
|
-
{ label: "Enviadas a CC", name: "cc", type: "label" },
|
|
363
|
-
];
|
|
364
|
-
return { basketDetailsArray, totales, headers };
|
|
365
|
-
};
|
|
366
|
-
exports.getBasketDetailsByForm = getBasketDetailsByForm;
|
|
367
|
-
const useGetProviderNameByPurchaseOrder = (payees, purchaseOrder) => {
|
|
368
|
-
const providerName = (0, react_2.useMemo)(() => {
|
|
369
|
-
if (!purchaseOrder)
|
|
370
|
-
return null;
|
|
371
|
-
const provider = payees.find((x) => x.id == purchaseOrder.payee_id);
|
|
372
|
-
if (provider) {
|
|
373
|
-
return `<${provider.id_number}> ${provider.tin ? `${provider.tin} | ` : ""}${provider.name}`;
|
|
374
|
-
}
|
|
375
|
-
return null;
|
|
376
|
-
}, [payees, purchaseOrder]);
|
|
377
|
-
return providerName;
|
|
378
|
-
};
|
|
379
|
-
exports.useGetProviderNameByPurchaseOrder = useGetProviderNameByPurchaseOrder;
|
|
380
|
-
const useGetItemNameByPurchaseOrder = (items, purchaseOrder) => {
|
|
381
|
-
const itemName = (0, react_2.useMemo)(() => {
|
|
382
|
-
if (!purchaseOrder)
|
|
383
|
-
return null;
|
|
384
|
-
if (purchaseOrder.purchase_order_details.length > 0 && items.length > 0) {
|
|
385
|
-
const item = items.find((x) => x.id == purchaseOrder.purchase_order_details[0].item_id);
|
|
386
|
-
return `${item?.id} - ${item?.code} - ${item?.name}`;
|
|
387
|
-
}
|
|
388
|
-
return null;
|
|
389
|
-
}, [items, purchaseOrder]);
|
|
390
|
-
return itemName;
|
|
391
|
-
};
|
|
392
|
-
exports.useGetItemNameByPurchaseOrder = useGetItemNameByPurchaseOrder;
|
|
393
|
-
const useGetItemByPurchaseOrder = (items, purchaseOrder) => {
|
|
394
|
-
const item = (0, react_2.useMemo)(() => {
|
|
395
|
-
if (!purchaseOrder)
|
|
396
|
-
return null;
|
|
397
|
-
if (purchaseOrder.purchase_order_details.length > 0 && items.length > 0) {
|
|
398
|
-
const item = items.find((x) => x.id == purchaseOrder.purchase_order_details[0].item_id);
|
|
399
|
-
return item;
|
|
400
|
-
}
|
|
401
|
-
return null;
|
|
402
|
-
}, [items, purchaseOrder]);
|
|
403
|
-
return item;
|
|
404
|
-
};
|
|
405
|
-
exports.useGetItemByPurchaseOrder = useGetItemByPurchaseOrder;
|
package/dist/cjs/session.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
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");
|
|
8
|
-
/**
|
|
9
|
-
*
|
|
10
|
-
* @param attribute
|
|
11
|
-
* @returns
|
|
12
|
-
*/
|
|
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)(() => {
|
|
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(receivedData.data);
|
|
32
|
-
dispatch((0, redux_1.setSessionValue)({
|
|
33
|
-
name: name,
|
|
34
|
-
data: receivedData.data,
|
|
35
|
-
}));
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}, [fetcher, dispatch, name]);
|
|
39
|
-
(0, react_2.useEffect)(() => {
|
|
40
|
-
if (!sessionData) {
|
|
41
|
-
try {
|
|
42
|
-
fetcher.load(`/api/session?name=${name}&type=${type}`);
|
|
43
|
-
}
|
|
44
|
-
catch (ex) {
|
|
45
|
-
(0, index_js_1.showAlert)({
|
|
46
|
-
type: "error",
|
|
47
|
-
title: `Ocurrió un error al cargar la variable de configuración: ${name}.`,
|
|
48
|
-
description: "Error: " + ex,
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}, []);
|
|
53
|
-
return data;
|
|
54
|
-
};
|
|
55
|
-
exports.useGetSessionAttribute = useGetSessionAttribute;
|
package/dist/cjs/templates.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
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");
|
|
8
|
-
const useGetTemplateObject = (TEMPLATE_NAME, config = { online: false }) => {
|
|
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)({
|
|
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[TEMPLATE_NAME], loading: false });
|
|
32
|
-
dispatch((0, redux_1.templateFetchSuccess)({
|
|
33
|
-
name: TEMPLATE_NAME,
|
|
34
|
-
data: receivedData[TEMPLATE_NAME],
|
|
35
|
-
}));
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}, [fetcher, dispatch, TEMPLATE_NAME]);
|
|
39
|
-
(0, react_2.useEffect)(() => {
|
|
40
|
-
if (Object.keys(objectData?.data).length <= 0 || config?.online) {
|
|
41
|
-
try {
|
|
42
|
-
setData({ ...data, loading: true });
|
|
43
|
-
dispatch((0, redux_1.templateFetchStart)(TEMPLATE_NAME));
|
|
44
|
-
fetcher.load(`/api/templates?object=${TEMPLATE_NAME}`);
|
|
45
|
-
}
|
|
46
|
-
catch (ex) {
|
|
47
|
-
(0, index_js_1.showAlert)({
|
|
48
|
-
type: "error",
|
|
49
|
-
title: `Ocurrió un error al cargar el object de templates: ${TEMPLATE_NAME}.`,
|
|
50
|
-
description: "Error: " + ex,
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}, []);
|
|
55
|
-
return data;
|
|
56
|
-
};
|
|
57
|
-
const useGetReceptionTemplate = (config) => useGetTemplateObject("receptionTemplate", config);
|
|
58
|
-
exports.useGetReceptionTemplate = useGetReceptionTemplate;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useWindowDimensions = void 0;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
function getWindowDimensions() {
|
|
6
|
-
if (typeof window !== "undefined") {
|
|
7
|
-
const { innerWidth: width } = window;
|
|
8
|
-
return width;
|
|
9
|
-
}
|
|
10
|
-
// Devolver un valor predeterminado si window no está definido
|
|
11
|
-
return 1000;
|
|
12
|
-
}
|
|
13
|
-
const useWindowDimensions = () => {
|
|
14
|
-
const [windowDimensions, setWindowDimensions] = (0, react_1.useState)(getWindowDimensions);
|
|
15
|
-
(0, react_1.useEffect)(() => {
|
|
16
|
-
if (typeof window !== "undefined") {
|
|
17
|
-
const handleResize = () => {
|
|
18
|
-
setWindowDimensions(getWindowDimensions());
|
|
19
|
-
};
|
|
20
|
-
// Use window load event to ensure accurate window size on initial load
|
|
21
|
-
window.addEventListener("load", handleResize);
|
|
22
|
-
window.addEventListener("resize", handleResize);
|
|
23
|
-
return () => {
|
|
24
|
-
window.removeEventListener("load", handleResize);
|
|
25
|
-
window.removeEventListener("resize", handleResize);
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
}, []);
|
|
29
|
-
return windowDimensions;
|
|
30
|
-
};
|
|
31
|
-
exports.useWindowDimensions = useWindowDimensions;
|