@zauru-sdk/hooks 1.0.49 → 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 +16 -21
- package/.eslintrc.cjs +0 -83
- package/CHANGELOG.md +0 -224
- 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/CHANGELOG.md
DELETED
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
# Change Log
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
-
|
|
6
|
-
## [1.0.49](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.48...v1.0.49) (2024-04-02)
|
|
7
|
-
|
|
8
|
-
**Note:** Version bump only for package @zauru-sdk/hooks
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
## [1.0.48](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.47...v1.0.48) (2024-04-02)
|
|
15
|
-
|
|
16
|
-
**Note:** Version bump only for package @zauru-sdk/hooks
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
## [1.0.47](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.46...v1.0.47) (2024-04-02)
|
|
23
|
-
|
|
24
|
-
**Note:** Version bump only for package @zauru-sdk/hooks
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
## [1.0.46](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.45...v1.0.46) (2024-04-02)
|
|
31
|
-
|
|
32
|
-
**Note:** Version bump only for package @zauru-sdk/hooks
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
## [1.0.45](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.44...v1.0.45) (2024-04-01)
|
|
39
|
-
|
|
40
|
-
**Note:** Version bump only for package @zauru-sdk/hooks
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
## [1.0.44](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.43...v1.0.44) (2024-04-01)
|
|
47
|
-
|
|
48
|
-
**Note:** Version bump only for package @zauru-sdk/hooks
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
## [1.0.41](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.40...v1.0.41) (2024-03-26)
|
|
55
|
-
|
|
56
|
-
**Note:** Version bump only for package @zauru-sdk/hooks
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
## [1.0.40](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.39...v1.0.40) (2024-03-26)
|
|
63
|
-
|
|
64
|
-
**Note:** Version bump only for package @zauru-sdk/hooks
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
## [1.0.39](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.38...v1.0.39) (2024-03-26)
|
|
71
|
-
|
|
72
|
-
**Note:** Version bump only for package @zauru-sdk/hooks
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
## [1.0.38](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.37...v1.0.38) (2024-03-25)
|
|
79
|
-
|
|
80
|
-
**Note:** Version bump only for package @zauru-sdk/hooks
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
## [1.0.33](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.32...v1.0.33) (2024-03-25)
|
|
87
|
-
|
|
88
|
-
**Note:** Version bump only for package @zauru-sdk/hooks
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
## [1.0.32](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.31...v1.0.32) (2024-03-25)
|
|
95
|
-
|
|
96
|
-
**Note:** Version bump only for package @zauru-sdk/hooks
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
## [1.0.31](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.30...v1.0.31) (2024-03-25)
|
|
103
|
-
|
|
104
|
-
**Note:** Version bump only for package @zauru-sdk/hooks
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
## [1.0.30](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.29...v1.0.30) (2024-03-25)
|
|
111
|
-
|
|
112
|
-
**Note:** Version bump only for package @zauru-sdk/hooks
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
## [1.0.29](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.28...v1.0.29) (2024-03-25)
|
|
119
|
-
|
|
120
|
-
**Note:** Version bump only for package @zauru-sdk/hooks
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
## [1.0.27](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.26...v1.0.27) (2024-03-25)
|
|
127
|
-
|
|
128
|
-
**Note:** Version bump only for package @zauru-sdk/hooks
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
## [1.0.26](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.25...v1.0.26) (2024-03-25)
|
|
135
|
-
|
|
136
|
-
**Note:** Version bump only for package @zauru-sdk/hooks
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
## [1.0.25](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.24...v1.0.25) (2024-03-25)
|
|
143
|
-
|
|
144
|
-
**Note:** Version bump only for package @zauru-sdk/hooks
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
## [1.0.24](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.23...v1.0.24) (2024-03-25)
|
|
151
|
-
|
|
152
|
-
**Note:** Version bump only for package @zauru-sdk/hooks
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
## [1.0.23](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.22...v1.0.23) (2024-03-22)
|
|
159
|
-
|
|
160
|
-
**Note:** Version bump only for package @zauru-sdk/hooks
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
## [1.0.21](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.20...v1.0.21) (2024-03-22)
|
|
167
|
-
|
|
168
|
-
**Note:** Version bump only for package @zauru-sdk/hooks
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
## [1.0.20](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.19...v1.0.20) (2024-03-22)
|
|
175
|
-
|
|
176
|
-
**Note:** Version bump only for package @zauru-sdk/hooks
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
## [1.0.19](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.18...v1.0.19) (2024-03-22)
|
|
183
|
-
|
|
184
|
-
**Note:** Version bump only for package @zauru-sdk/hooks
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
## [1.0.18](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.17...v1.0.18) (2024-03-22)
|
|
191
|
-
|
|
192
|
-
**Note:** Version bump only for package @zauru-sdk/hooks
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
## [1.0.17](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.16...v1.0.17) (2024-03-21)
|
|
199
|
-
|
|
200
|
-
**Note:** Version bump only for package @zauru-sdk/hooks
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
## [1.0.16](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.15...v1.0.16) (2024-03-21)
|
|
207
|
-
|
|
208
|
-
**Note:** Version bump only for package @zauru-sdk/hooks
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
## [1.0.15](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.14...v1.0.15) (2024-03-21)
|
|
215
|
-
|
|
216
|
-
**Note:** Version bump only for package @zauru-sdk/hooks
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
## [1.0.13](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.12...v1.0.13) (2024-03-21)
|
|
223
|
-
|
|
224
|
-
**Note:** Version bump only for package @zauru-sdk/hooks
|
package/dist/catalogs.js
DELETED
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
import { useFetcher } from "@remix-run/react";
|
|
2
|
-
import { useEffect, useState } from "react";
|
|
3
|
-
import { showAlert } from "./components/index.js";
|
|
4
|
-
import { catalogsFetchStart, catalogsFetchSuccess, useAppDispatch, useAppSelector, } from "@zauru-sdk/redux";
|
|
5
|
-
const useApiCatalog = (CATALOG_NAME, otherParams) => {
|
|
6
|
-
const fetcher = useFetcher();
|
|
7
|
-
const [data, setData] = useState({
|
|
8
|
-
data: [],
|
|
9
|
-
loading: true,
|
|
10
|
-
});
|
|
11
|
-
useEffect(() => {
|
|
12
|
-
if (fetcher.data?.title) {
|
|
13
|
-
showAlert({
|
|
14
|
-
description: fetcher.data?.description?.toString(),
|
|
15
|
-
title: fetcher.data?.title?.toString(),
|
|
16
|
-
type: fetcher.data?.type?.toString(),
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
}, [fetcher.data]);
|
|
20
|
-
useEffect(() => {
|
|
21
|
-
if (fetcher.state === "idle" && fetcher.data != null) {
|
|
22
|
-
const receivedData = fetcher.data;
|
|
23
|
-
if (receivedData) {
|
|
24
|
-
setData({ data: receivedData[CATALOG_NAME], loading: false });
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}, [fetcher, CATALOG_NAME]);
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
try {
|
|
30
|
-
setData({ ...data, loading: true });
|
|
31
|
-
// Convert otherParams to query string
|
|
32
|
-
const paramsString = otherParams
|
|
33
|
-
? Object.entries(otherParams)
|
|
34
|
-
.map(([key, value]) => `${key}=${value}`)
|
|
35
|
-
.join("&")
|
|
36
|
-
: "";
|
|
37
|
-
const url = `/api/catalogs?catalog=${CATALOG_NAME}${paramsString ? `&${paramsString}` : ""}`;
|
|
38
|
-
fetcher.load(url);
|
|
39
|
-
}
|
|
40
|
-
catch (ex) {
|
|
41
|
-
showAlert({
|
|
42
|
-
type: "error",
|
|
43
|
-
title: `Ocurrió un error al cargar el catálogo: ${CATALOG_NAME}.`,
|
|
44
|
-
description: "Error: " + ex,
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}, []);
|
|
48
|
-
return data;
|
|
49
|
-
};
|
|
50
|
-
const useGetReduxCatalog = (CATALOG_NAME, { online = false, wheres = [], otherParams } = {}) => {
|
|
51
|
-
const fetcher = useFetcher();
|
|
52
|
-
const dispatch = useAppDispatch();
|
|
53
|
-
const catalogData = useAppSelector((state) => state.catalogs[CATALOG_NAME]);
|
|
54
|
-
const [data, setData] = useState({
|
|
55
|
-
data: catalogData?.data?.length ? catalogData.data : [],
|
|
56
|
-
loading: catalogData.loading,
|
|
57
|
-
});
|
|
58
|
-
useEffect(() => {
|
|
59
|
-
if (fetcher.data?.description) {
|
|
60
|
-
showAlert({
|
|
61
|
-
description: fetcher.data?.description?.toString(),
|
|
62
|
-
title: fetcher.data?.title?.toString(),
|
|
63
|
-
type: fetcher.data?.type?.toString(),
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
}, [fetcher.data]);
|
|
67
|
-
useEffect(() => {
|
|
68
|
-
if (fetcher.state === "idle" && fetcher.data != null) {
|
|
69
|
-
const receivedData = fetcher.data;
|
|
70
|
-
if (receivedData) {
|
|
71
|
-
setData({ data: receivedData[CATALOG_NAME], loading: false });
|
|
72
|
-
dispatch(catalogsFetchSuccess({
|
|
73
|
-
name: CATALOG_NAME,
|
|
74
|
-
data: receivedData[CATALOG_NAME],
|
|
75
|
-
}));
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}, [fetcher, dispatch, CATALOG_NAME]);
|
|
79
|
-
useEffect(() => {
|
|
80
|
-
if (catalogData?.data?.length <= 0 || catalogData?.reFetch || online) {
|
|
81
|
-
try {
|
|
82
|
-
setData({ ...data, loading: true });
|
|
83
|
-
dispatch(catalogsFetchStart(CATALOG_NAME));
|
|
84
|
-
// Convierte cada elemento del array a una cadena codificada para URL
|
|
85
|
-
const encodedWheres = wheres.map((where) => encodeURIComponent(where));
|
|
86
|
-
// Une los elementos codificados con '&'
|
|
87
|
-
const wheresQueryParam = encodedWheres.join("&");
|
|
88
|
-
// Convert otherParams to query string
|
|
89
|
-
const paramsString = otherParams
|
|
90
|
-
? Object.entries(otherParams)
|
|
91
|
-
.map(([key, value]) => `${key}=${value}`)
|
|
92
|
-
.join("&")
|
|
93
|
-
: "";
|
|
94
|
-
fetcher.load(`/api/catalogs?catalog=${CATALOG_NAME}&wheres=${wheresQueryParam}${paramsString ? `&${paramsString}` : ""}`);
|
|
95
|
-
}
|
|
96
|
-
catch (ex) {
|
|
97
|
-
showAlert({
|
|
98
|
-
type: "error",
|
|
99
|
-
title: `Ocurrió un error al cargar el catálogo: ${CATALOG_NAME}.`,
|
|
100
|
-
description: "Error: " + ex,
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}, []);
|
|
105
|
-
return data;
|
|
106
|
-
};
|
|
107
|
-
/**
|
|
108
|
-
*
|
|
109
|
-
* ======================= HOOKS
|
|
110
|
-
*/
|
|
111
|
-
export const useGetItems = (config) => useGetReduxCatalog("items", config);
|
|
112
|
-
export const useGetItemsByReception = (config) => useGetReduxCatalog("itemsByReception", config);
|
|
113
|
-
export const useGetItemsByLab = (config) => useGetReduxCatalog("itemsByLab", config);
|
|
114
|
-
export const useGetMyAgencyLotStocks = (config) => useGetReduxCatalog("myAgencyLotStocks", config);
|
|
115
|
-
export const useGetItemServicesByLab = (config) => useGetReduxCatalog("itemServicesByLab", config);
|
|
116
|
-
export const useGetItemCategoriesForLab = (config) => useGetReduxCatalog("itemCategoriesForLab", config);
|
|
117
|
-
export const useGetBookings = (config) => useGetReduxCatalog("bookings", config);
|
|
118
|
-
export const useGetTemplates = (config) => useGetReduxCatalog("templates", config);
|
|
119
|
-
export const useGetPayeeCategoriesLabPrices = (config = { withPriceListIdNull: false }) => {
|
|
120
|
-
const data = useGetReduxCatalog("payeeCategoriesLabPrices");
|
|
121
|
-
let tempData = data.data;
|
|
122
|
-
if (!config.withPriceListIdNull) {
|
|
123
|
-
tempData = data.data.filter((x) => x.price_list_id);
|
|
124
|
-
}
|
|
125
|
-
return { ...data, data: tempData };
|
|
126
|
-
};
|
|
127
|
-
export const useGetBundlesRecipForLab = (config) => useGetReduxCatalog("bundlesRecipForLab", config);
|
|
128
|
-
export const useGetBundlesForLab = (config) => useGetReduxCatalog("bundlesForLab", config);
|
|
129
|
-
export const useGetCurrencies = (config) => useGetReduxCatalog("currencies", config);
|
|
130
|
-
export const useGetReceptionTypes = (config) => useGetReduxCatalog("receptionTypes", config);
|
|
131
|
-
export const useGetProviders = (config) => useGetReduxCatalog("providers", config);
|
|
132
|
-
export const useGetMyCases = (config) => useGetReduxCatalog("myCases", config);
|
|
133
|
-
export const useGetProviderCategories = (config) => useGetReduxCatalog("providerCategories", config);
|
|
134
|
-
export const useGetClientCategories = (config) => useGetReduxCatalog("clientCategories", config);
|
|
135
|
-
export const useGetPayees = (config) => useGetReduxCatalog("payees", config);
|
|
136
|
-
export const useGetPayeesForLab = (config) => useGetReduxCatalog("payeesForLab", config);
|
|
137
|
-
export const useGetAgencies = (config) => useGetReduxCatalog("agencies", config);
|
|
138
|
-
export const useGetSuggestedPrices = (config) => useGetReduxCatalog("suggestedPrices", config);
|
|
139
|
-
export const useGetPaymentTerms = (config) => useGetReduxCatalog("paymentTerms", config);
|
|
140
|
-
export const useGetEmployeesByLab = (config) => useGetReduxCatalog("employeesByLab", config);
|
|
141
|
-
export const useGetEmployeesByCurrentAgency = (config) => useGetReduxCatalog("employeesByCurrentAgency", config);
|
|
142
|
-
export const useGetShipmentsToMyAgency = (config) => useGetReduxCatalog("shipmentsToMyAgency", config);
|
|
143
|
-
export const useGetInvoicesByLab = (config) => useGetReduxCatalog("invoicesByLab", config);
|
|
144
|
-
export const useGetTiposDeMuestra = (config) => useGetReduxCatalog("tiposDeMuestra", config);
|
|
145
|
-
export const useGetMotivosDeRechazo = (config) => useGetReduxCatalog("motivosRechazo", config);
|
|
146
|
-
export const useGetBitacoraRechazoMasivo = (config) => useGetReduxCatalog("bitacoraRechazoMasivo", config);
|
|
147
|
-
export const useGetInvoiceForms = (config) => {
|
|
148
|
-
const data = useGetReduxCatalog("invoiceForms", config);
|
|
149
|
-
// Filtrar los registros para obtener sólo los de la versión más alta.
|
|
150
|
-
const groupedByVersion = (data.data || []).reduce((acc, record) => {
|
|
151
|
-
const zid = record.zid;
|
|
152
|
-
if (!acc[zid]) {
|
|
153
|
-
acc[zid] = record;
|
|
154
|
-
}
|
|
155
|
-
return acc;
|
|
156
|
-
}, {});
|
|
157
|
-
const latestVersionRecords = Object.values(groupedByVersion);
|
|
158
|
-
return {
|
|
159
|
-
loading: data.loading,
|
|
160
|
-
data: latestVersionRecords.filter((x) => x.active),
|
|
161
|
-
};
|
|
162
|
-
};
|
|
163
|
-
export const useGetCaseForms = (config) => {
|
|
164
|
-
const data = useGetReduxCatalog("caseForms", config);
|
|
165
|
-
// Filtrar los registros para obtener sólo el primero de cada zid.
|
|
166
|
-
const firstRecordByZid = (data.data || []).reduce((acc, record) => {
|
|
167
|
-
const zid = record.zid;
|
|
168
|
-
if (!acc[zid]) {
|
|
169
|
-
acc[zid] = record;
|
|
170
|
-
}
|
|
171
|
-
return acc;
|
|
172
|
-
}, {});
|
|
173
|
-
const firstRecords = Object.values(firstRecordByZid);
|
|
174
|
-
return {
|
|
175
|
-
loading: data.loading,
|
|
176
|
-
data: firstRecords.filter((x) => x.active),
|
|
177
|
-
};
|
|
178
|
-
};
|
|
179
|
-
export const useGetInvoiceFormSubmissionsByAgencyId = (agency_id) => {
|
|
180
|
-
const data = useApiCatalog("invoiceFormSubmissionsByAgencyId", {
|
|
181
|
-
agency_id: `${agency_id}`,
|
|
182
|
-
});
|
|
183
|
-
// Filtrar los registros para obtener sólo los de la versión más alta.
|
|
184
|
-
const groupedByVersion = (data.data || []).reduce((acc, record) => {
|
|
185
|
-
const zid = record.settings_form_submission.zid;
|
|
186
|
-
if (!acc[zid]) {
|
|
187
|
-
acc[zid] = record;
|
|
188
|
-
}
|
|
189
|
-
return acc;
|
|
190
|
-
}, {});
|
|
191
|
-
const latestVersionRecords = Object.values(groupedByVersion);
|
|
192
|
-
return {
|
|
193
|
-
loading: data.loading,
|
|
194
|
-
data: latestVersionRecords,
|
|
195
|
-
};
|
|
196
|
-
};
|
|
197
|
-
export const useGetMyCaseFormSubmissions = (config) => {
|
|
198
|
-
const data = useGetReduxCatalog("myCaseFormSubmissions", 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.settings_form_submission.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,
|
|
211
|
-
};
|
|
212
|
-
};
|
|
213
|
-
export const useGetInvoiceFormSubmissionsByInvoiceId = (invoice_id) => {
|
|
214
|
-
const data = useApiCatalog("invoiceFormSubmissionsByInvoiceId", {
|
|
215
|
-
invoice_id: `${invoice_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
|
-
};
|
package/dist/components/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./Alert.js";
|
package/dist/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export * from "./components/index.js";
|
|
2
|
-
export * from "./alerts.js";
|
|
3
|
-
export * from "./automaticNumbers.js";
|
|
4
|
-
export * from "./catalogs.js";
|
|
5
|
-
export * from "./onlineStatus.js";
|
|
6
|
-
export * from "./profiles.js";
|
|
7
|
-
export * from "./receptions.js";
|
|
8
|
-
export * from "./session.js";
|
|
9
|
-
export * from "./templates.js";
|
|
10
|
-
export * from "./useWindowDimensions.js";
|
package/dist/profiles.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { useFetcher } from "@remix-run/react";
|
|
2
|
-
import { useEffect, useState } from "react";
|
|
3
|
-
import { showAlert } from "./index.js";
|
|
4
|
-
import { profileFetchStart, profileFetchSuccess, useAppDispatch, useAppSelector, } from "@zauru-sdk/redux";
|
|
5
|
-
const useGetProfile = (PROFILE_NAME) => {
|
|
6
|
-
const fetcher = useFetcher();
|
|
7
|
-
const dispatch = useAppDispatch();
|
|
8
|
-
const profileData = useAppSelector((state) => state.profiles[PROFILE_NAME]);
|
|
9
|
-
const [data, setData] = useState({
|
|
10
|
-
data: Object.keys(profileData?.data)?.length
|
|
11
|
-
? profileData?.data
|
|
12
|
-
: {},
|
|
13
|
-
loading: profileData?.loading,
|
|
14
|
-
});
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
if (fetcher.data?.title) {
|
|
17
|
-
showAlert({
|
|
18
|
-
description: fetcher.data?.description?.toString(),
|
|
19
|
-
title: fetcher.data?.title?.toString(),
|
|
20
|
-
type: fetcher.data?.type?.toString(),
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
}, [fetcher.data]);
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
if (fetcher.state === "idle" && fetcher.data != null) {
|
|
26
|
-
const receivedData = fetcher.data;
|
|
27
|
-
if (receivedData) {
|
|
28
|
-
setData({ data: receivedData[PROFILE_NAME], loading: false });
|
|
29
|
-
dispatch(profileFetchSuccess({
|
|
30
|
-
name: PROFILE_NAME,
|
|
31
|
-
data: receivedData[PROFILE_NAME],
|
|
32
|
-
}));
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}, [fetcher, dispatch, PROFILE_NAME]);
|
|
36
|
-
useEffect(() => {
|
|
37
|
-
if (Object.keys(profileData?.data).length <= 0) {
|
|
38
|
-
try {
|
|
39
|
-
setData({ ...data, loading: true });
|
|
40
|
-
dispatch(profileFetchStart(PROFILE_NAME));
|
|
41
|
-
fetcher.load(`/api/profiles?profile=${PROFILE_NAME}`);
|
|
42
|
-
}
|
|
43
|
-
catch (ex) {
|
|
44
|
-
showAlert({
|
|
45
|
-
type: "error",
|
|
46
|
-
title: `Ocurrió un error al cargar el perfil: ${PROFILE_NAME}.`,
|
|
47
|
-
description: "Error: " + ex,
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}, []);
|
|
52
|
-
return data;
|
|
53
|
-
};
|
|
54
|
-
export const useGetAgencyProfile = () => useGetProfile("agencyProfile");
|
|
55
|
-
export const useGetUserProfile = () => useGetProfile("userProfile");
|
|
56
|
-
export const useGetOauthProfile = () => useGetProfile("oauthProfile");
|
|
57
|
-
export const useGetEmployeeProfile = () => useGetProfile("employeeProfile");
|
package/src/alerts.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import type { FetcherWithComponents } from "@remix-run/react";
|
|
2
|
-
import { useEffect } from "react";
|
|
3
|
-
import { showAlert } from "./index.js";
|
|
4
|
-
|
|
5
|
-
export const useValidateNotifications = (source: {
|
|
6
|
-
fetcher?: FetcherWithComponents<any>;
|
|
7
|
-
actionData?: any;
|
|
8
|
-
loaderData?: any;
|
|
9
|
-
}) => {
|
|
10
|
-
const { actionData, fetcher, loaderData } = source;
|
|
11
|
-
|
|
12
|
-
useEffect(() => {
|
|
13
|
-
if (loaderData?.title) {
|
|
14
|
-
showAlert({
|
|
15
|
-
description: loaderData?.description?.toString() ?? "",
|
|
16
|
-
title: loaderData?.title,
|
|
17
|
-
type: loaderData?.type as any,
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
}, [loaderData]);
|
|
21
|
-
|
|
22
|
-
useEffect(() => {
|
|
23
|
-
if (fetcher?.data?.title) {
|
|
24
|
-
showAlert({
|
|
25
|
-
description: fetcher.data?.description,
|
|
26
|
-
title: fetcher.data?.title,
|
|
27
|
-
type: fetcher.data?.type,
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
}, [fetcher?.data]);
|
|
31
|
-
|
|
32
|
-
useEffect(() => {
|
|
33
|
-
if (actionData?.title) {
|
|
34
|
-
showAlert({
|
|
35
|
-
description: actionData?.description ?? "",
|
|
36
|
-
title: actionData?.title,
|
|
37
|
-
type: actionData?.type as any,
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
}, [actionData]);
|
|
41
|
-
|
|
42
|
-
return null;
|
|
43
|
-
};
|
package/src/automaticNumbers.ts
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { useFetcher } from "@remix-run/react";
|
|
2
|
-
import {
|
|
3
|
-
AUTOMATIC_NUMBER_NAMES,
|
|
4
|
-
automaticNumberFetchStart,
|
|
5
|
-
automaticNumberFetchSuccess,
|
|
6
|
-
useAppDispatch,
|
|
7
|
-
useAppSelector,
|
|
8
|
-
} from "@zauru-sdk/redux";
|
|
9
|
-
import { useEffect, useState } from "react";
|
|
10
|
-
import { showAlert } from "./index.js";
|
|
11
|
-
|
|
12
|
-
type ProfileType<T> = {
|
|
13
|
-
data: T;
|
|
14
|
-
loading: boolean;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export const useGetAutomaticNumber = <T>(
|
|
18
|
-
AUTOMATIC_NUMBER_NAME: AUTOMATIC_NUMBER_NAMES
|
|
19
|
-
): ProfileType<T> => {
|
|
20
|
-
const fetcher = useFetcher<any>();
|
|
21
|
-
const dispatch = useAppDispatch();
|
|
22
|
-
const objectData = useAppSelector(
|
|
23
|
-
(state) => state.automaticNumbers[AUTOMATIC_NUMBER_NAME]
|
|
24
|
-
);
|
|
25
|
-
const [data, setData] = useState<ProfileType<T>>({
|
|
26
|
-
data: Object.keys(objectData?.data).length
|
|
27
|
-
? (objectData?.data as T)
|
|
28
|
-
: ({} as T),
|
|
29
|
-
loading: objectData.loading,
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
useEffect(() => {
|
|
33
|
-
if (fetcher.data?.title) {
|
|
34
|
-
showAlert({
|
|
35
|
-
description: fetcher.data?.description,
|
|
36
|
-
title: fetcher.data?.title,
|
|
37
|
-
type: fetcher.data?.type,
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
}, [fetcher.data]);
|
|
41
|
-
|
|
42
|
-
useEffect(() => {
|
|
43
|
-
if (fetcher.state === "idle" && fetcher.data != null) {
|
|
44
|
-
const receivedData = fetcher.data as { [key: string]: T };
|
|
45
|
-
if (receivedData) {
|
|
46
|
-
setData({ data: receivedData[AUTOMATIC_NUMBER_NAME], loading: false });
|
|
47
|
-
dispatch(
|
|
48
|
-
automaticNumberFetchSuccess({
|
|
49
|
-
name: AUTOMATIC_NUMBER_NAME,
|
|
50
|
-
data: receivedData[AUTOMATIC_NUMBER_NAME],
|
|
51
|
-
})
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}, [fetcher, dispatch, AUTOMATIC_NUMBER_NAME]);
|
|
56
|
-
|
|
57
|
-
useEffect(() => {
|
|
58
|
-
if (Object.keys(objectData?.data).length <= 0) {
|
|
59
|
-
try {
|
|
60
|
-
setData({ ...data, loading: true });
|
|
61
|
-
dispatch(automaticNumberFetchStart(AUTOMATIC_NUMBER_NAME));
|
|
62
|
-
fetcher.load(`/api/automaticNumbers?object=${AUTOMATIC_NUMBER_NAME}`);
|
|
63
|
-
} catch (ex) {
|
|
64
|
-
showAlert({
|
|
65
|
-
type: "error",
|
|
66
|
-
title: `Ocurrió un error al cargar el object de automatic numbers: ${AUTOMATIC_NUMBER_NAME}.`,
|
|
67
|
-
description: "Error: " + ex,
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}, []);
|
|
72
|
-
|
|
73
|
-
return data;
|
|
74
|
-
};
|