@zauru-sdk/hooks 1.0.50 → 1.0.51
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/dist/alerts.d.ts +1 -1
- package/dist/{alerts.js → cjs/alerts.js} +13 -9
- package/dist/{automaticNumbers.js → cjs/automaticNumbers.js} +20 -16
- package/dist/cjs/catalogs.js +267 -0
- package/dist/{components → cjs/components}/Alert.js +18 -15
- package/dist/cjs/components/index.js +17 -0
- package/dist/cjs/index.js +26 -0
- package/dist/{onlineStatus.js → cjs/onlineStatus.js} +8 -4
- package/dist/cjs/profiles.js +64 -0
- package/dist/{receptions.js → cjs/receptions.js} +67 -52
- package/dist/{session.js → cjs/session.js} +19 -15
- package/dist/{templates.js → cjs/templates.js} +20 -16
- package/dist/{useWindowDimensions.js → cjs/useWindowDimensions.js} +8 -4
- package/dist/esm/alerts.js +37 -0
- package/dist/esm/automaticNumbers.js +57 -0
- package/dist/esm/catalogs.js +267 -0
- package/dist/esm/components/Alert.js +100 -0
- package/dist/esm/components/index.js +17 -0
- package/dist/esm/index.js +26 -0
- package/dist/esm/onlineStatus.js +31 -0
- package/dist/esm/profiles.js +64 -0
- package/dist/esm/receptions.js +348 -0
- package/dist/esm/session.js +55 -0
- package/dist/esm/templates.js +58 -0
- package/dist/esm/useWindowDimensions.js +31 -0
- package/dist/receptions.d.ts +2 -2
- package/package.json +12 -17
- package/.eslintrc.cjs +0 -83
- package/CHANGELOG.md +0 -232
- package/dist/catalogs.js +0 -230
- package/dist/components/index.js +0 -1
- package/dist/index.js +0 -10
- package/dist/profiles.js +0 -57
- package/src/alerts.ts +0 -43
- package/src/automaticNumbers.ts +0 -74
- package/src/catalogs.ts +0 -557
- package/src/components/Alert.tsx +0 -149
- package/src/components/index.ts +0 -1
- package/src/index.ts +0 -11
- package/src/onlineStatus.ts +0 -34
- package/src/profiles.ts +0 -103
- package/src/receptions.ts +0 -548
- package/src/session.ts +0 -69
- package/src/templates.ts +0 -84
- package/src/useWindowDimensions.ts +0 -34
- package/tsconfig.json +0 -26
package/dist/alerts.d.ts
CHANGED
|
@@ -1,28 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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) => {
|
|
4
7
|
const { actionData, fetcher, loaderData } = source;
|
|
5
|
-
useEffect(() => {
|
|
8
|
+
(0, react_1.useEffect)(() => {
|
|
6
9
|
if (loaderData?.title) {
|
|
7
|
-
showAlert({
|
|
10
|
+
(0, index_js_1.showAlert)({
|
|
8
11
|
description: loaderData?.description?.toString() ?? "",
|
|
9
12
|
title: loaderData?.title,
|
|
10
13
|
type: loaderData?.type,
|
|
11
14
|
});
|
|
12
15
|
}
|
|
13
16
|
}, [loaderData]);
|
|
14
|
-
useEffect(() => {
|
|
17
|
+
(0, react_1.useEffect)(() => {
|
|
15
18
|
if (fetcher?.data?.title) {
|
|
16
|
-
showAlert({
|
|
19
|
+
(0, index_js_1.showAlert)({
|
|
17
20
|
description: fetcher.data?.description,
|
|
18
21
|
title: fetcher.data?.title,
|
|
19
22
|
type: fetcher.data?.type,
|
|
20
23
|
});
|
|
21
24
|
}
|
|
22
25
|
}, [fetcher?.data]);
|
|
23
|
-
useEffect(() => {
|
|
26
|
+
(0, react_1.useEffect)(() => {
|
|
24
27
|
if (actionData?.title) {
|
|
25
|
-
showAlert({
|
|
28
|
+
(0, index_js_1.showAlert)({
|
|
26
29
|
description: actionData?.description ?? "",
|
|
27
30
|
title: actionData?.title,
|
|
28
31
|
type: actionData?.type,
|
|
@@ -31,3 +34,4 @@ export const useValidateNotifications = (source) => {
|
|
|
31
34
|
}, [actionData]);
|
|
32
35
|
return null;
|
|
33
36
|
};
|
|
37
|
+
exports.useValidateNotifications = useValidateNotifications;
|
|
@@ -1,47 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
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)({
|
|
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[AUTOMATIC_NUMBER_NAME], loading: false });
|
|
29
|
-
dispatch(automaticNumberFetchSuccess({
|
|
32
|
+
dispatch((0, redux_1.automaticNumberFetchSuccess)({
|
|
30
33
|
name: AUTOMATIC_NUMBER_NAME,
|
|
31
34
|
data: receivedData[AUTOMATIC_NUMBER_NAME],
|
|
32
35
|
}));
|
|
33
36
|
}
|
|
34
37
|
}
|
|
35
38
|
}, [fetcher, dispatch, AUTOMATIC_NUMBER_NAME]);
|
|
36
|
-
useEffect(() => {
|
|
39
|
+
(0, react_2.useEffect)(() => {
|
|
37
40
|
if (Object.keys(objectData?.data).length <= 0) {
|
|
38
41
|
try {
|
|
39
42
|
setData({ ...data, loading: true });
|
|
40
|
-
dispatch(automaticNumberFetchStart(AUTOMATIC_NUMBER_NAME));
|
|
43
|
+
dispatch((0, redux_1.automaticNumberFetchStart)(AUTOMATIC_NUMBER_NAME));
|
|
41
44
|
fetcher.load(`/api/automaticNumbers?object=${AUTOMATIC_NUMBER_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 automatic numbers: ${AUTOMATIC_NUMBER_NAME}.`,
|
|
47
50
|
description: "Error: " + ex,
|
|
@@ -51,3 +54,4 @@ export const useGetAutomaticNumber = (AUTOMATIC_NUMBER_NAME) => {
|
|
|
51
54
|
}, []);
|
|
52
55
|
return data;
|
|
53
56
|
};
|
|
57
|
+
exports.useGetAutomaticNumber = useGetAutomaticNumber;
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useGetInvoiceFormSubmissionsByInvoiceId = exports.useGetMyCaseFormSubmissions = exports.useGetInvoiceFormSubmissionsByAgencyId = exports.useGetCaseForms = exports.useGetInvoiceForms = exports.useGetBitacoraRechazoMasivo = exports.useGetMotivosDeRechazo = exports.useGetTiposDeMuestra = exports.useGetInvoicesByLab = exports.useGetShipmentsToMyAgency = exports.useGetEmployeesByCurrentAgency = exports.useGetEmployeesByLab = exports.useGetPaymentTerms = exports.useGetSuggestedPrices = exports.useGetAgencies = exports.useGetPayeesForLab = exports.useGetPayees = exports.useGetClientCategories = exports.useGetProviderCategories = exports.useGetMyCases = exports.useGetProviders = exports.useGetReceptionTypes = exports.useGetCurrencies = exports.useGetBundlesForLab = exports.useGetBundlesRecipForLab = exports.useGetPayeeCategoriesLabPrices = 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
|
+
const useGetReduxCatalog = (CATALOG_NAME, { online = false, wheres = [], otherParams } = {}) => {
|
|
54
|
+
const fetcher = (0, react_1.useFetcher)();
|
|
55
|
+
const dispatch = (0, redux_1.useAppDispatch)();
|
|
56
|
+
const catalogData = (0, redux_1.useAppSelector)((state) => state.catalogs[CATALOG_NAME]);
|
|
57
|
+
const [data, setData] = (0, react_2.useState)({
|
|
58
|
+
data: catalogData?.data?.length ? catalogData.data : [],
|
|
59
|
+
loading: catalogData.loading,
|
|
60
|
+
});
|
|
61
|
+
(0, react_2.useEffect)(() => {
|
|
62
|
+
if (fetcher.data?.description) {
|
|
63
|
+
(0, index_js_1.showAlert)({
|
|
64
|
+
description: fetcher.data?.description?.toString(),
|
|
65
|
+
title: fetcher.data?.title?.toString(),
|
|
66
|
+
type: fetcher.data?.type?.toString(),
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}, [fetcher.data]);
|
|
70
|
+
(0, react_2.useEffect)(() => {
|
|
71
|
+
if (fetcher.state === "idle" && fetcher.data != null) {
|
|
72
|
+
const receivedData = fetcher.data;
|
|
73
|
+
if (receivedData) {
|
|
74
|
+
setData({ data: receivedData[CATALOG_NAME], loading: false });
|
|
75
|
+
dispatch((0, redux_1.catalogsFetchSuccess)({
|
|
76
|
+
name: CATALOG_NAME,
|
|
77
|
+
data: receivedData[CATALOG_NAME],
|
|
78
|
+
}));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}, [fetcher, dispatch, CATALOG_NAME]);
|
|
82
|
+
(0, react_2.useEffect)(() => {
|
|
83
|
+
if (catalogData?.data?.length <= 0 || catalogData?.reFetch || online) {
|
|
84
|
+
try {
|
|
85
|
+
setData({ ...data, loading: true });
|
|
86
|
+
dispatch((0, redux_1.catalogsFetchStart)(CATALOG_NAME));
|
|
87
|
+
// Convierte cada elemento del array a una cadena codificada para URL
|
|
88
|
+
const encodedWheres = wheres.map((where) => encodeURIComponent(where));
|
|
89
|
+
// Une los elementos codificados con '&'
|
|
90
|
+
const wheresQueryParam = encodedWheres.join("&");
|
|
91
|
+
// Convert otherParams to query string
|
|
92
|
+
const paramsString = otherParams
|
|
93
|
+
? Object.entries(otherParams)
|
|
94
|
+
.map(([key, value]) => `${key}=${value}`)
|
|
95
|
+
.join("&")
|
|
96
|
+
: "";
|
|
97
|
+
fetcher.load(`/api/catalogs?catalog=${CATALOG_NAME}&wheres=${wheresQueryParam}${paramsString ? `&${paramsString}` : ""}`);
|
|
98
|
+
}
|
|
99
|
+
catch (ex) {
|
|
100
|
+
(0, index_js_1.showAlert)({
|
|
101
|
+
type: "error",
|
|
102
|
+
title: `Ocurrió un error al cargar el catálogo: ${CATALOG_NAME}.`,
|
|
103
|
+
description: "Error: " + ex,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}, []);
|
|
108
|
+
return data;
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
*
|
|
112
|
+
* ======================= HOOKS
|
|
113
|
+
*/
|
|
114
|
+
const useGetItems = (config) => useGetReduxCatalog("items", config);
|
|
115
|
+
exports.useGetItems = useGetItems;
|
|
116
|
+
const useGetItemsByReception = (config) => useGetReduxCatalog("itemsByReception", config);
|
|
117
|
+
exports.useGetItemsByReception = useGetItemsByReception;
|
|
118
|
+
const useGetItemsByLab = (config) => useGetReduxCatalog("itemsByLab", config);
|
|
119
|
+
exports.useGetItemsByLab = useGetItemsByLab;
|
|
120
|
+
const useGetMyAgencyLotStocks = (config) => useGetReduxCatalog("myAgencyLotStocks", config);
|
|
121
|
+
exports.useGetMyAgencyLotStocks = useGetMyAgencyLotStocks;
|
|
122
|
+
const useGetItemServicesByLab = (config) => useGetReduxCatalog("itemServicesByLab", config);
|
|
123
|
+
exports.useGetItemServicesByLab = useGetItemServicesByLab;
|
|
124
|
+
const useGetItemCategoriesForLab = (config) => useGetReduxCatalog("itemCategoriesForLab", config);
|
|
125
|
+
exports.useGetItemCategoriesForLab = useGetItemCategoriesForLab;
|
|
126
|
+
const useGetBookings = (config) => useGetReduxCatalog("bookings", config);
|
|
127
|
+
exports.useGetBookings = useGetBookings;
|
|
128
|
+
const useGetTemplates = (config) => useGetReduxCatalog("templates", config);
|
|
129
|
+
exports.useGetTemplates = useGetTemplates;
|
|
130
|
+
const useGetPayeeCategoriesLabPrices = (config = { withPriceListIdNull: false }) => {
|
|
131
|
+
const data = useGetReduxCatalog("payeeCategoriesLabPrices");
|
|
132
|
+
let tempData = data.data;
|
|
133
|
+
if (!config.withPriceListIdNull) {
|
|
134
|
+
tempData = data.data.filter((x) => x.price_list_id);
|
|
135
|
+
}
|
|
136
|
+
return { ...data, data: tempData };
|
|
137
|
+
};
|
|
138
|
+
exports.useGetPayeeCategoriesLabPrices = useGetPayeeCategoriesLabPrices;
|
|
139
|
+
const useGetBundlesRecipForLab = (config) => useGetReduxCatalog("bundlesRecipForLab", config);
|
|
140
|
+
exports.useGetBundlesRecipForLab = useGetBundlesRecipForLab;
|
|
141
|
+
const useGetBundlesForLab = (config) => useGetReduxCatalog("bundlesForLab", config);
|
|
142
|
+
exports.useGetBundlesForLab = useGetBundlesForLab;
|
|
143
|
+
const useGetCurrencies = (config) => useGetReduxCatalog("currencies", config);
|
|
144
|
+
exports.useGetCurrencies = useGetCurrencies;
|
|
145
|
+
const useGetReceptionTypes = (config) => useGetReduxCatalog("receptionTypes", config);
|
|
146
|
+
exports.useGetReceptionTypes = useGetReceptionTypes;
|
|
147
|
+
const useGetProviders = (config) => useGetReduxCatalog("providers", config);
|
|
148
|
+
exports.useGetProviders = useGetProviders;
|
|
149
|
+
const useGetMyCases = (config) => useGetReduxCatalog("myCases", config);
|
|
150
|
+
exports.useGetMyCases = useGetMyCases;
|
|
151
|
+
const useGetProviderCategories = (config) => useGetReduxCatalog("providerCategories", config);
|
|
152
|
+
exports.useGetProviderCategories = useGetProviderCategories;
|
|
153
|
+
const useGetClientCategories = (config) => useGetReduxCatalog("clientCategories", config);
|
|
154
|
+
exports.useGetClientCategories = useGetClientCategories;
|
|
155
|
+
const useGetPayees = (config) => useGetReduxCatalog("payees", config);
|
|
156
|
+
exports.useGetPayees = useGetPayees;
|
|
157
|
+
const useGetPayeesForLab = (config) => useGetReduxCatalog("payeesForLab", config);
|
|
158
|
+
exports.useGetPayeesForLab = useGetPayeesForLab;
|
|
159
|
+
const useGetAgencies = (config) => useGetReduxCatalog("agencies", config);
|
|
160
|
+
exports.useGetAgencies = useGetAgencies;
|
|
161
|
+
const useGetSuggestedPrices = (config) => useGetReduxCatalog("suggestedPrices", config);
|
|
162
|
+
exports.useGetSuggestedPrices = useGetSuggestedPrices;
|
|
163
|
+
const useGetPaymentTerms = (config) => useGetReduxCatalog("paymentTerms", config);
|
|
164
|
+
exports.useGetPaymentTerms = useGetPaymentTerms;
|
|
165
|
+
const useGetEmployeesByLab = (config) => useGetReduxCatalog("employeesByLab", config);
|
|
166
|
+
exports.useGetEmployeesByLab = useGetEmployeesByLab;
|
|
167
|
+
const useGetEmployeesByCurrentAgency = (config) => useGetReduxCatalog("employeesByCurrentAgency", config);
|
|
168
|
+
exports.useGetEmployeesByCurrentAgency = useGetEmployeesByCurrentAgency;
|
|
169
|
+
const useGetShipmentsToMyAgency = (config) => useGetReduxCatalog("shipmentsToMyAgency", config);
|
|
170
|
+
exports.useGetShipmentsToMyAgency = useGetShipmentsToMyAgency;
|
|
171
|
+
const useGetInvoicesByLab = (config) => useGetReduxCatalog("invoicesByLab", config);
|
|
172
|
+
exports.useGetInvoicesByLab = useGetInvoicesByLab;
|
|
173
|
+
const useGetTiposDeMuestra = (config) => useGetReduxCatalog("tiposDeMuestra", config);
|
|
174
|
+
exports.useGetTiposDeMuestra = useGetTiposDeMuestra;
|
|
175
|
+
const useGetMotivosDeRechazo = (config) => useGetReduxCatalog("motivosRechazo", config);
|
|
176
|
+
exports.useGetMotivosDeRechazo = useGetMotivosDeRechazo;
|
|
177
|
+
const useGetBitacoraRechazoMasivo = (config) => useGetReduxCatalog("bitacoraRechazoMasivo", config);
|
|
178
|
+
exports.useGetBitacoraRechazoMasivo = useGetBitacoraRechazoMasivo;
|
|
179
|
+
const useGetInvoiceForms = (config) => {
|
|
180
|
+
const data = useGetReduxCatalog("invoiceForms", config);
|
|
181
|
+
// Filtrar los registros para obtener sólo los de la versión más alta.
|
|
182
|
+
const groupedByVersion = (data.data || []).reduce((acc, record) => {
|
|
183
|
+
const zid = record.zid;
|
|
184
|
+
if (!acc[zid]) {
|
|
185
|
+
acc[zid] = record;
|
|
186
|
+
}
|
|
187
|
+
return acc;
|
|
188
|
+
}, {});
|
|
189
|
+
const latestVersionRecords = Object.values(groupedByVersion);
|
|
190
|
+
return {
|
|
191
|
+
loading: data.loading,
|
|
192
|
+
data: latestVersionRecords.filter((x) => x.active),
|
|
193
|
+
};
|
|
194
|
+
};
|
|
195
|
+
exports.useGetInvoiceForms = useGetInvoiceForms;
|
|
196
|
+
const useGetCaseForms = (config) => {
|
|
197
|
+
const data = useGetReduxCatalog("caseForms", config);
|
|
198
|
+
// Filtrar los registros para obtener sólo el primero de cada zid.
|
|
199
|
+
const firstRecordByZid = (data.data || []).reduce((acc, record) => {
|
|
200
|
+
const zid = record.zid;
|
|
201
|
+
if (!acc[zid]) {
|
|
202
|
+
acc[zid] = record;
|
|
203
|
+
}
|
|
204
|
+
return acc;
|
|
205
|
+
}, {});
|
|
206
|
+
const firstRecords = Object.values(firstRecordByZid);
|
|
207
|
+
return {
|
|
208
|
+
loading: data.loading,
|
|
209
|
+
data: firstRecords.filter((x) => x.active),
|
|
210
|
+
};
|
|
211
|
+
};
|
|
212
|
+
exports.useGetCaseForms = useGetCaseForms;
|
|
213
|
+
const useGetInvoiceFormSubmissionsByAgencyId = (agency_id) => {
|
|
214
|
+
const data = useApiCatalog("invoiceFormSubmissionsByAgencyId", {
|
|
215
|
+
agency_id: `${agency_id}`,
|
|
216
|
+
});
|
|
217
|
+
// Filtrar los registros para obtener sólo los de la versión más alta.
|
|
218
|
+
const groupedByVersion = (data.data || []).reduce((acc, record) => {
|
|
219
|
+
const zid = record.settings_form_submission.zid;
|
|
220
|
+
if (!acc[zid]) {
|
|
221
|
+
acc[zid] = record;
|
|
222
|
+
}
|
|
223
|
+
return acc;
|
|
224
|
+
}, {});
|
|
225
|
+
const latestVersionRecords = Object.values(groupedByVersion);
|
|
226
|
+
return {
|
|
227
|
+
loading: data.loading,
|
|
228
|
+
data: latestVersionRecords,
|
|
229
|
+
};
|
|
230
|
+
};
|
|
231
|
+
exports.useGetInvoiceFormSubmissionsByAgencyId = useGetInvoiceFormSubmissionsByAgencyId;
|
|
232
|
+
const useGetMyCaseFormSubmissions = (config) => {
|
|
233
|
+
const data = useGetReduxCatalog("myCaseFormSubmissions", config);
|
|
234
|
+
// Filtrar los registros para obtener sólo los de la versión más alta.
|
|
235
|
+
const groupedByVersion = (data.data || []).reduce((acc, record) => {
|
|
236
|
+
const zid = record.settings_form_submission.zid;
|
|
237
|
+
if (!acc[zid]) {
|
|
238
|
+
acc[zid] = record;
|
|
239
|
+
}
|
|
240
|
+
return acc;
|
|
241
|
+
}, {});
|
|
242
|
+
const latestVersionRecords = Object.values(groupedByVersion);
|
|
243
|
+
return {
|
|
244
|
+
loading: data.loading,
|
|
245
|
+
data: latestVersionRecords,
|
|
246
|
+
};
|
|
247
|
+
};
|
|
248
|
+
exports.useGetMyCaseFormSubmissions = useGetMyCaseFormSubmissions;
|
|
249
|
+
const useGetInvoiceFormSubmissionsByInvoiceId = (invoice_id) => {
|
|
250
|
+
const data = useApiCatalog("invoiceFormSubmissionsByInvoiceId", {
|
|
251
|
+
invoice_id: `${invoice_id}`,
|
|
252
|
+
});
|
|
253
|
+
// Filtrar los registros para obtener sólo los de la versión más alta.
|
|
254
|
+
const groupedByVersion = (data.data || []).reduce((acc, record) => {
|
|
255
|
+
const zid = record.settings_form_submission.zid;
|
|
256
|
+
if (!acc[zid]) {
|
|
257
|
+
acc[zid] = record;
|
|
258
|
+
}
|
|
259
|
+
return acc;
|
|
260
|
+
}, {});
|
|
261
|
+
const latestVersionRecords = Object.values(groupedByVersion);
|
|
262
|
+
return {
|
|
263
|
+
loading: data.loading,
|
|
264
|
+
data: latestVersionRecords,
|
|
265
|
+
};
|
|
266
|
+
};
|
|
267
|
+
exports.useGetInvoiceFormSubmissionsByInvoiceId = useGetInvoiceFormSubmissionsByInvoiceId;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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");
|
|
6
8
|
const Alert = ({ type, title, description, onClose }) => {
|
|
7
|
-
const [, setLifetime] = useState(4000);
|
|
8
|
-
const [progress, setProgress] = useState(0);
|
|
9
|
-
const intervalRef = useRef(null);
|
|
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);
|
|
10
12
|
const getColor = () => {
|
|
11
13
|
switch (type) {
|
|
12
14
|
case "success":
|
|
@@ -21,7 +23,7 @@ const Alert = ({ type, title, description, onClose }) => {
|
|
|
21
23
|
return "bg-gray-100 text-gray-800";
|
|
22
24
|
}
|
|
23
25
|
};
|
|
24
|
-
useEffect(() => {
|
|
26
|
+
(0, react_1.useEffect)(() => {
|
|
25
27
|
const startTimer = () => {
|
|
26
28
|
intervalRef.current = setInterval(() => {
|
|
27
29
|
setLifetime((lifetime) => {
|
|
@@ -45,7 +47,7 @@ const Alert = ({ type, title, description, onClose }) => {
|
|
|
45
47
|
pauseTimer();
|
|
46
48
|
};
|
|
47
49
|
}, [onClose]);
|
|
48
|
-
return (
|
|
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: {
|
|
49
51
|
zIndex: 1000,
|
|
50
52
|
transform: `translateY(calc(var(--alert-offset, 0)))`,
|
|
51
53
|
}, onMouseEnter: () => clearInterval(intervalRef.current), onMouseLeave: () => {
|
|
@@ -62,13 +64,13 @@ const Alert = ({ type, title, description, onClose }) => {
|
|
|
62
64
|
}
|
|
63
65
|
});
|
|
64
66
|
}, 50);
|
|
65
|
-
}, children: [
|
|
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: () => {
|
|
66
68
|
setLifetime(0);
|
|
67
69
|
onClose && onClose();
|
|
68
|
-
}, children:
|
|
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}%` } }) })] }));
|
|
69
71
|
};
|
|
70
72
|
let activeAlerts = [];
|
|
71
|
-
|
|
73
|
+
const showAlert = (alertProps) => {
|
|
72
74
|
if (typeof document === "undefined") {
|
|
73
75
|
return;
|
|
74
76
|
}
|
|
@@ -87,9 +89,10 @@ export const showAlert = (alertProps) => {
|
|
|
87
89
|
};
|
|
88
90
|
activeAlerts.push(container);
|
|
89
91
|
updateAlertOffsets();
|
|
90
|
-
const root = createRoot(container);
|
|
91
|
-
root.render(
|
|
92
|
+
const root = (0, client_1.createRoot)(container);
|
|
93
|
+
root.render((0, jsx_runtime_1.jsx)(Alert, { ...alertProps, onClose: asyncOnClose }));
|
|
92
94
|
};
|
|
95
|
+
exports.showAlert = showAlert;
|
|
93
96
|
const updateAlertOffsets = () => {
|
|
94
97
|
activeAlerts.forEach((alertContainer, index) => {
|
|
95
98
|
alertContainer.style.setProperty("--alert-offset", `${index * 100}px`);
|
|
@@ -0,0 +1,17 @@
|
|
|
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);
|
|
@@ -0,0 +1,26 @@
|
|
|
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);
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useIsOnline = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
2
5
|
// Hook personalizado para verificar el estado de conexión
|
|
3
|
-
|
|
6
|
+
const useIsOnline = () => {
|
|
4
7
|
// Verificar si estamos en el entorno del servidor o del cliente
|
|
5
8
|
const isServer = typeof window === "undefined";
|
|
6
9
|
// Estado local para almacenar si la aplicación está en línea o no
|
|
7
|
-
const [isOnline, setIsOnline] = useState(!isServer && navigator.onLine);
|
|
10
|
+
const [isOnline, setIsOnline] = (0, react_1.useState)(!isServer && navigator.onLine);
|
|
8
11
|
// Función para manejar el cambio de estado de conexión
|
|
9
12
|
const handleConnectionChange = () => {
|
|
10
13
|
setIsOnline(navigator.onLine);
|
|
11
14
|
};
|
|
12
|
-
useEffect(() => {
|
|
15
|
+
(0, react_1.useEffect)(() => {
|
|
13
16
|
if (isServer) {
|
|
14
17
|
// Si estamos en el servidor, no añadir los event listeners
|
|
15
18
|
return;
|
|
@@ -25,3 +28,4 @@ export const useIsOnline = () => {
|
|
|
25
28
|
}, [isServer]);
|
|
26
29
|
return isOnline;
|
|
27
30
|
};
|
|
31
|
+
exports.useIsOnline = useIsOnline;
|
|
@@ -0,0 +1,64 @@
|
|
|
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;
|