npm-pkg-hook 1.1.5 → 1.1.9
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/.eslintrc.js +19 -113
- package/.eslintrc.json +127 -108
- package/.github/pull_request_template.md +17 -17
- package/.github/workflows/pepeline.yaml +29 -29
- package/next.config.js +2 -5
- package/package.json +27 -24
- package/script.txt +6 -6
- package/src/config/client/errors.js +14 -14
- package/src/config/client/index.js +1 -1
- package/src/hooks/getCategoriesWithProduct/helpers/index.js +7 -0
- package/src/hooks/getCategoriesWithProduct/index.js +62 -0
- package/src/hooks/getSession/index.js +18 -18
- package/src/hooks/index.js +13 -9
- package/src/hooks/useAcumulateDate/index.js +1 -1
- package/src/hooks/useAnimationFrame/index.js +45 -45
- package/src/hooks/useAsideCart/helpers/index.js +22 -0
- package/src/hooks/useAsideCart/index.js +156 -0
- package/src/hooks/useAsideCart/queries.js +10 -0
- package/src/hooks/useBanner/index.js +11 -11
- package/src/hooks/useCart/index.js +2 -0
- package/src/hooks/useCart/queries.js +164 -0
- package/src/hooks/useCart/useCart/helpers/index.js +75 -0
- package/src/hooks/useCart/useCart/index.js +411 -0
- package/src/hooks/useCart/useGetCart/index.js +31 -0
- package/src/hooks/useCatWithProduct/index.js +15 -15
- package/src/hooks/useCatWithProduct/queries.js +1 -1
- package/src/hooks/useCatWithProductClient/index.js +48 -0
- package/src/hooks/useCatWithProductClient/queries.js +55 -0
- package/src/hooks/useCategoriesProduct/index.js +12 -12
- package/src/hooks/useCategoriesProduct/queries.js +16 -16
- package/src/hooks/useCategoryInStore/index.js +39 -36
- package/src/hooks/useCategoryInStore/queries.js +78 -78
- package/src/hooks/useCategoryStore/index.js +2 -2
- package/src/hooks/useChartData/index.js +159 -156
- package/src/hooks/useChartData/useChartData/index.js +199 -197
- package/src/hooks/useChartData/useChartDataAllOrders/index.js +94 -94
- package/src/hooks/useCheckbox/index.js +115 -115
- package/src/hooks/useClients/index.js +12 -14
- package/src/hooks/useClients/queries.js +1 -1
- package/src/hooks/useConnection/index.js +20 -21
- package/src/hooks/useCreateProduct/helpers/useEditImageProduct/index.js +6 -2
- package/src/hooks/useCreateProduct/index.js +22 -19
- package/src/hooks/useDeleteSubProductOptional/index.js +31 -30
- package/src/hooks/useDeleteSubProductOptional/queries.js +10 -10
- package/src/hooks/useDessert/helpers/index.js +51 -51
- package/src/hooks/useDessert/index.js +56 -65
- package/src/hooks/useDevices/index.js +35 -36
- package/src/hooks/useDevices/queries.js +19 -19
- package/src/hooks/useDropzone/index.js +94 -79
- package/src/hooks/useDynamicAuth/index.js +13 -13
- package/src/hooks/useDynamicAuth/queries.js +24 -24
- package/src/hooks/useEmployee/queries.js +1 -1
- package/src/hooks/useEvent/index.js +33 -33
- package/src/hooks/useFavoriteStores/index.js +19 -0
- package/src/hooks/useFavoriteStores/queries.js +47 -0
- package/src/hooks/useFetchJson/index.js +25 -25
- package/src/hooks/useFingerprintjs/index.js +172 -176
- package/src/hooks/useFormTools/index.js +12 -11
- package/src/hooks/useFormatDate/index.js +20 -21
- package/src/hooks/useFormatNumberPhone/index.js +9 -9
- package/src/hooks/useFullScreenMode/index.js +65 -65
- package/src/hooks/useGenerateNumberArray/index.js +17 -17
- package/src/hooks/useGetExtProductFoodsSubOptionalAll/index.js +14 -0
- package/src/hooks/useGetFoodRecomended/index.js +33 -0
- package/src/hooks/useGetFoodRecomended/queries.js +47 -0
- package/src/hooks/useGetMinPrice/index.js +8 -0
- package/src/hooks/useGetMinPrice/queries.js +7 -0
- package/src/hooks/useGetOneStoreRating/index.js +40 -0
- package/src/hooks/useGetOneStoreRating/queries.js +18 -0
- package/src/hooks/useGoogleLogin/index.js +160 -161
- package/src/hooks/useHover/index.js +29 -29
- package/src/hooks/useImageOptimization/index.js +15 -15
- package/src/hooks/useImageWeight/index.js +18 -19
- package/src/hooks/useImagesStore/index.js +139 -140
- package/src/hooks/useImagesStore/queries.js +19 -18
- package/src/hooks/useInnerHtml/index.js +39 -38
- package/src/hooks/useIntersection/index.js +4 -4
- package/src/hooks/useKeypress/index.js +28 -28
- package/src/hooks/useLazyScript/index.js +35 -36
- package/src/hooks/useLocalSorage/index.js +2 -2
- package/src/hooks/useLocationNavigate/index.js +54 -54
- package/src/hooks/useLogout/index.js +24 -24
- package/src/hooks/useManageQueryParams/index.js +36 -37
- package/src/hooks/useMobile/index.js +39 -38
- package/src/hooks/useMutateHeight/index.js +15 -16
- package/src/hooks/useOrderClient/index.js +5 -0
- package/src/hooks/useOrders/index.js +10 -16
- package/src/hooks/useOrders/queries.js +1 -1
- package/src/hooks/useProductsFood/index.js +32 -32
- package/src/hooks/useProductsFood/queriesStore.js +49 -48
- package/src/hooks/useProductsFood/useEditProduct.js +2 -4
- package/src/hooks/useProductsFood/usetagsProducts.js +83 -83
- package/src/hooks/useProviders/index.js +3 -3
- package/src/hooks/useProviders/queries.js +31 -31
- package/src/hooks/useProviders/useProvidersCreateStore/index.js +12 -13
- package/src/hooks/useProviders/useProvidersDataStore/index.js +24 -24
- package/src/hooks/useProvidersStore/index.js +24 -24
- package/src/hooks/useProvidersStore/queries.js +31 -31
- package/src/hooks/useRatingArrayData/index.js +54 -0
- package/src/hooks/{useRatingData → useRatingArrayData}/queries.js +19 -18
- package/src/hooks/useReactToPrint/index.js +1120 -1098
- package/src/hooks/useRemoveExtraProductFoodsOptional/index.js +23 -23
- package/src/hooks/useRemoveExtraProductFoodsOptional/queries.js +48 -48
- package/src/hooks/useReport/index.js +9 -9
- package/src/hooks/useReport/queries.js +1 -1
- package/src/hooks/useRestaurant/index.js +19 -19
- package/src/hooks/useRestaurant/queries.js +80 -80
- package/src/hooks/useSales/index.js +476 -451
- package/src/hooks/useSales/queries.js +14 -15
- package/src/hooks/useSales/useGetAllSales/index.js +25 -25
- package/src/hooks/useSales/useTotalSales.js +18 -18
- package/src/hooks/useSaveAvailableProduct/helpers/index.js +29 -29
- package/src/hooks/useSaveAvailableProduct/index.js +16 -16
- package/src/hooks/useSaveAvailableProduct/queries.js +1 -1
- package/src/hooks/useSchedule/index.js +33 -36
- package/src/hooks/useSchedule/index.jsx +22 -22
- package/src/hooks/useSchedule/queries.js +34 -35
- package/src/hooks/useScheduleData/index.js +123 -171
- package/src/hooks/useScroll/index.js +56 -57
- package/src/hooks/useScrollRotate/index.js +16 -14
- package/src/hooks/useSetSession/index.js +16 -16
- package/src/hooks/useSetState/index.js +3 -3
- package/src/hooks/useStatusOpenStore/helpers/index.js +101 -102
- package/src/hooks/useStatusOpenStore/index.js +172 -173
- package/src/hooks/useStatusOrdersClient/helpers/index.js +14 -0
- package/src/hooks/useStatusOrdersClient/index.js +17 -0
- package/src/hooks/useStatusOrdersClient/queries.js +80 -0
- package/src/hooks/useStore/index.js +40 -25
- package/src/hooks/useStore/queries.js +162 -136
- package/src/hooks/useStoreCalendar/index.js +5 -7
- package/src/hooks/useStoreContacts/index.js +16 -16
- package/src/hooks/useStoreContacts/queries.js +1 -1
- package/src/hooks/useTimeAgo/useTimeAgo.js +39 -39
- package/src/hooks/useUpdateCart/index.js +34 -28
- package/src/hooks/useUpdateExistingOrders/index.js +35 -35
- package/src/hooks/useUpdateExtProductFoodsSubOptional/index.js +38 -37
- package/src/hooks/useUser/index.js +1 -1
- package/src/hooks/useUser/queries.js +1 -1
- package/src/hooks/useWindowSize/index.js +38 -38
- package/src/mock/dessert/index.js +16 -16
- package/src/mock/index.js +1 -2
- package/src/utils/index.js +42 -45
- package/src/hooks/useRatingData/index.js +0 -53
- package/src/hooks/useSalesClient/index.js +0 -1
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
import { MockData } from '../../../mock'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Transforms an array of objects into a specific data format suitable for desserts.
|
|
5
|
-
*
|
|
6
|
-
* @param {Array<Object>} dataArray - The array of objects to transform.
|
|
7
|
-
* @return {Object} The transformed data containing lists and listIds.
|
|
8
|
-
* @throws {Error} If dataArray is not an array or if the objects lack required properties.
|
|
9
|
-
*/
|
|
10
|
-
export const transformDataToDessert = (dataArray) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
1
|
+
import { MockData } from '../../../mock'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Transforms an array of objects into a specific data format suitable for desserts.
|
|
5
|
+
*
|
|
6
|
+
* @param {Array<Object>} dataArray - The array of objects to transform.
|
|
7
|
+
* @return {Object} The transformed data containing lists and listIds.
|
|
8
|
+
* @throws {Error} If dataArray is not an array or if the objects lack required properties.
|
|
9
|
+
*/
|
|
10
|
+
export const transformDataToDessert = (dataArray) => {
|
|
11
|
+
try {
|
|
12
|
+
if (!dataArray) {
|
|
13
|
+
return MockData
|
|
14
|
+
}
|
|
15
|
+
if (!Array.isArray(dataArray)) {
|
|
16
|
+
throw new Error('dataArray must be an array.')
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const transformedData = {
|
|
20
|
+
lists: {},
|
|
21
|
+
listIds: []
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
dataArray.forEach((item) => {
|
|
25
|
+
const listId = item.code
|
|
26
|
+
transformedData.listIds.push(listId)
|
|
27
|
+
transformedData.lists[listId] = {
|
|
28
|
+
id: listId,
|
|
29
|
+
title: item?.OptionalProName,
|
|
30
|
+
numberLimit: item?.numbersOptionalOnly,
|
|
31
|
+
required: item?.required,
|
|
32
|
+
value: '',
|
|
33
|
+
cards: item?.ExtProductFoodsSubOptionalAll?.length > 0
|
|
34
|
+
? item?.ExtProductFoodsSubOptionalAll?.map(subOptional => {
|
|
35
|
+
return {
|
|
36
|
+
id: subOptional?.exCode,
|
|
37
|
+
title: subOptional?.OptionalSubProName,
|
|
38
|
+
required: subOptional?.state,
|
|
39
|
+
value: ''
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
: []
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
return transformedData
|
|
47
|
+
} catch (error) {
|
|
48
|
+
console.error(error.message)
|
|
49
|
+
return MockData
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -15,17 +15,16 @@ import { useDeleteSubProductOptional } from '../useDeleteSubProductOptional'
|
|
|
15
15
|
export const useDessert = ({
|
|
16
16
|
pId = null,
|
|
17
17
|
initialData = null,
|
|
18
|
-
sendNotification = () => {
|
|
18
|
+
sendNotification = () => { }
|
|
19
19
|
}) => {
|
|
20
|
-
|
|
21
20
|
// Initialize state variables using the useState hook
|
|
22
|
-
const [setCheck, setChecker] = useState({})
|
|
23
|
-
const [valueItems, setValueItems] = useState('')
|
|
24
|
-
const [title, setTitle] = useState('')
|
|
21
|
+
const [setCheck, setChecker] = useState({}) // State for checkboxes
|
|
22
|
+
const [valueItems, setValueItems] = useState('') // State for input values
|
|
23
|
+
const [title, setTitle] = useState('') // State for title input value
|
|
25
24
|
|
|
26
25
|
// Initialize the data state with the transformedData or MockData
|
|
27
|
-
const [data, setData] = useState(MockData)
|
|
28
|
-
const dataListIds = data?.listIds?.filter(x => x !== '01list')
|
|
26
|
+
const [data, setData] = useState(MockData)
|
|
27
|
+
const dataListIds = data?.listIds?.filter(x => x !== '01list')
|
|
29
28
|
|
|
30
29
|
/**
|
|
31
30
|
* Checks if all required lists have the maximum number of cards.
|
|
@@ -35,42 +34,40 @@ export const useDessert = ({
|
|
|
35
34
|
const isCompleteRequired = dataListIds?.every(listID => {
|
|
36
35
|
try {
|
|
37
36
|
if (!Array.isArray(dataListIds) || data === null) {
|
|
38
|
-
throw new Error('Invalid arguments. dataListIds must be an array and data must be a non-null object.')
|
|
37
|
+
throw new Error('Invalid arguments. dataListIds must be an array and data must be a non-null object.')
|
|
39
38
|
}
|
|
40
39
|
const list = data.lists[listID]
|
|
41
40
|
// If list or list.cards is missing, assume the list is not complete
|
|
42
41
|
const verifiEmpyRequireCard = list?.cards?.length
|
|
43
42
|
if (list && list?.cards) {
|
|
44
|
-
return verifiEmpyRequireCard === list.numberLimit
|
|
43
|
+
return verifiEmpyRequireCard === list.numberLimit
|
|
45
44
|
}
|
|
46
45
|
|
|
47
46
|
// If list or list.cards is missing, assume the list is not complete
|
|
48
|
-
return false
|
|
47
|
+
return false
|
|
49
48
|
} catch (e) {
|
|
50
|
-
return false
|
|
49
|
+
return false
|
|
51
50
|
}
|
|
52
51
|
})
|
|
53
52
|
|
|
54
53
|
// Transform initialData using useMemo to prevent unnecessary re-computation
|
|
55
|
-
const transformedData = useMemo(() => transformDataToDessert(initialData), [initialData])
|
|
54
|
+
const transformedData = useMemo(() => transformDataToDessert(initialData), [initialData])
|
|
56
55
|
|
|
57
56
|
// Use useEffect to update the data state when the initialData prop changes
|
|
58
57
|
useEffect(() => {
|
|
59
58
|
if (initialData) {
|
|
60
|
-
setData(transformedData)
|
|
59
|
+
setData(transformedData)
|
|
61
60
|
}
|
|
62
|
-
}, [])
|
|
63
|
-
|
|
61
|
+
}, [])
|
|
64
62
|
|
|
65
63
|
// Filter the 'listIds' from 'data' and store the filtered result in 'dataListIds'
|
|
66
64
|
// Here, it seems to exclude a specific list ID ('01list') from the listIds.
|
|
67
65
|
|
|
68
|
-
|
|
69
66
|
// HOOKS
|
|
70
67
|
const { handleMutateExtProductFoodsSubOptional } = useUpdateExtProductFoodsSubOptional()
|
|
71
68
|
const { handleUpdateExtProduct } = useUpdateExtProductFoodsOptional()
|
|
72
69
|
const { DeleteExtProductFoodsOptional } = useRemoveExtraProductFoodsOptional()
|
|
73
|
-
const [DeleteExtFoodSubsOptional
|
|
70
|
+
const [DeleteExtFoodSubsOptional] = useDeleteSubProductOptional()
|
|
74
71
|
|
|
75
72
|
// HANDLESS
|
|
76
73
|
/**
|
|
@@ -79,12 +76,11 @@ export const useDessert = ({
|
|
|
79
76
|
*/
|
|
80
77
|
const handleCheck = (e) => {
|
|
81
78
|
// Extract the 'name' and 'checked' properties from the event target (checkbox)
|
|
82
|
-
const { name, checked } = e.target
|
|
79
|
+
const { name, checked } = e.target
|
|
83
80
|
|
|
84
81
|
// Update the setCheck state with the new value for the checkbox identified by the 'name' property
|
|
85
|
-
setChecker({ ...setCheck, [name]: checked })
|
|
86
|
-
}
|
|
87
|
-
|
|
82
|
+
setChecker({ ...setCheck, [name]: checked })
|
|
83
|
+
}
|
|
88
84
|
|
|
89
85
|
/**
|
|
90
86
|
* Handles the removal of a list from the data state and performs additional operations if needed.
|
|
@@ -97,26 +93,26 @@ export const useDessert = ({
|
|
|
97
93
|
const handleRemoveList = (i, listID) => {
|
|
98
94
|
// Validate that the provided index (i) is a non-negative number
|
|
99
95
|
if (typeof i !== 'number' || i < 0) {
|
|
100
|
-
throw new Error('Invalid index provided. The index must be a non-negative number.')
|
|
96
|
+
throw new Error('Invalid index provided. The index must be a non-negative number.')
|
|
101
97
|
}
|
|
102
98
|
|
|
103
99
|
// Make a copy of the listIds array from the data state
|
|
104
|
-
const listIdsCopy = [...data.listIds]
|
|
100
|
+
const listIdsCopy = [...data.listIds]
|
|
105
101
|
|
|
106
102
|
// Validate that the provided index (i) is within the range of the listIds array
|
|
107
103
|
if (i >= listIdsCopy.length) {
|
|
108
|
-
throw new Error('Invalid index provided. The index is out of range.')
|
|
104
|
+
throw new Error('Invalid index provided. The index is out of range.')
|
|
109
105
|
}
|
|
110
106
|
|
|
111
107
|
// Remove the list with the specified index from the listIdsCopy array
|
|
112
|
-
const Lines = data?.listIds.filter((_, index) => index !== i)?.filter(x => x !== '01list')
|
|
108
|
+
const Lines = data?.listIds.filter((_, index) => index !== i)?.filter(x => x !== '01list')
|
|
113
109
|
// Update the data state with the modified listIdsCopy array
|
|
114
110
|
setData({
|
|
115
111
|
listIds: listID ? Lines.filter((subItem) => { return subItem !== listID }) : Lines,
|
|
116
112
|
lists: {
|
|
117
|
-
...data.lists
|
|
118
|
-
}
|
|
119
|
-
})
|
|
113
|
+
...data.lists
|
|
114
|
+
}
|
|
115
|
+
})
|
|
120
116
|
|
|
121
117
|
// Perform additional operations if a valid listID is provided
|
|
122
118
|
if (listID) {
|
|
@@ -127,8 +123,9 @@ export const useDessert = ({
|
|
|
127
123
|
variables: {
|
|
128
124
|
state: 1,
|
|
129
125
|
opExPid: listID,
|
|
130
|
-
isCustomOpExPid: true
|
|
131
|
-
},
|
|
126
|
+
isCustomOpExPid: true
|
|
127
|
+
},
|
|
128
|
+
update: (cache, { data: { ExtProductFoodsOptionalAll } }) => {
|
|
132
129
|
return updateCacheMod({
|
|
133
130
|
cache,
|
|
134
131
|
query: GET_EXTRAS_PRODUCT_FOOD_OPTIONAL,
|
|
@@ -137,14 +134,12 @@ export const useDessert = ({
|
|
|
137
134
|
})
|
|
138
135
|
}
|
|
139
136
|
})
|
|
140
|
-
|
|
141
137
|
} catch (error) {
|
|
142
138
|
// Handle any errors that may occur during the deletion process
|
|
143
|
-
throw new Error('An error occurred while deleting the external product.')
|
|
139
|
+
throw new Error('An error occurred while deleting the external product.')
|
|
144
140
|
}
|
|
145
141
|
}
|
|
146
|
-
}
|
|
147
|
-
|
|
142
|
+
}
|
|
148
143
|
|
|
149
144
|
/**
|
|
150
145
|
* Removes a specific item from a list within the data state.
|
|
@@ -162,7 +157,7 @@ export const useDessert = ({
|
|
|
162
157
|
try {
|
|
163
158
|
const forRemove = Boolean(isCustomSubOpExPid && listID && id)
|
|
164
159
|
if (forRemove) {
|
|
165
|
-
|
|
160
|
+
DeleteExtFoodSubsOptional({
|
|
166
161
|
variables: {
|
|
167
162
|
isCustomSubOpExPid,
|
|
168
163
|
opSubExPid: listID,
|
|
@@ -172,19 +167,19 @@ export const useDessert = ({
|
|
|
172
167
|
}
|
|
173
168
|
// Ensure the provided listID exists in the data state
|
|
174
169
|
if (!data.lists[listID]) {
|
|
175
|
-
throw new Error(`List with ID "${listID}" does not exist.`)
|
|
170
|
+
throw new Error(`List with ID "${listID}" does not exist.`)
|
|
176
171
|
}
|
|
177
172
|
|
|
178
173
|
// Ensure the list has a cards array
|
|
179
174
|
if (!Array.isArray(data.lists[listID].cards)) {
|
|
180
|
-
throw new Error(`List with ID "${listID}" does not have a valid cards array.`)
|
|
175
|
+
throw new Error(`List with ID "${listID}" does not have a valid cards array.`)
|
|
181
176
|
}
|
|
182
177
|
|
|
183
178
|
// Get the current list from the data state using the provided listID
|
|
184
|
-
const currentList = data.lists[listID]
|
|
179
|
+
const currentList = data.lists[listID]
|
|
185
180
|
|
|
186
181
|
// Filter out the item with the specified ID from the current list's cards array
|
|
187
|
-
const totalCart = currentList.cards.filter((cart) => cart.id !== id)
|
|
182
|
+
const totalCart = currentList.cards.filter((cart) => cart.id !== id)
|
|
188
183
|
|
|
189
184
|
// Update the current list's cards with the filtered array to remove the specified item
|
|
190
185
|
setData({
|
|
@@ -193,22 +188,20 @@ export const useDessert = ({
|
|
|
193
188
|
...data.lists,
|
|
194
189
|
[listID]: {
|
|
195
190
|
...currentList,
|
|
196
|
-
cards: totalCart
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
})
|
|
191
|
+
cards: totalCart
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
})
|
|
200
195
|
} catch (error) {
|
|
201
196
|
console.error(error)
|
|
202
197
|
}
|
|
203
|
-
|
|
204
|
-
};
|
|
205
|
-
|
|
198
|
+
}
|
|
206
199
|
|
|
207
200
|
const addCard = async (title, listId) => {
|
|
208
201
|
const id = RandomCode(9)
|
|
209
202
|
const newCard = {
|
|
210
|
-
id
|
|
211
|
-
title
|
|
203
|
+
id,
|
|
204
|
+
title,
|
|
212
205
|
numberLimit: 5,
|
|
213
206
|
value: '',
|
|
214
207
|
required: setCheck.exState ? 1 : 0
|
|
@@ -238,7 +231,6 @@ export const useDessert = ({
|
|
|
238
231
|
setValueItems('')
|
|
239
232
|
}
|
|
240
233
|
|
|
241
|
-
|
|
242
234
|
/**
|
|
243
235
|
* Handles the addition of a new list with the given title and number limit.
|
|
244
236
|
* @param {Object} params - The parameters for adding the new list.
|
|
@@ -256,10 +248,10 @@ export const useDessert = ({
|
|
|
256
248
|
}
|
|
257
249
|
|
|
258
250
|
// Generate a new list ID using the RandomCode function (must be implemented elsewhere)
|
|
259
|
-
const newListId = RandomCode(9)
|
|
251
|
+
const newListId = RandomCode(9)
|
|
260
252
|
|
|
261
253
|
// Determine if the list is required based on the setCheck.exState state
|
|
262
|
-
const required = setCheck.exState ? 1 : 0
|
|
254
|
+
const required = setCheck.exState ? 1 : 0
|
|
263
255
|
|
|
264
256
|
// Add the new list to the data state
|
|
265
257
|
setData({
|
|
@@ -275,7 +267,7 @@ export const useDessert = ({
|
|
|
275
267
|
cards: []
|
|
276
268
|
}
|
|
277
269
|
}
|
|
278
|
-
})
|
|
270
|
+
})
|
|
279
271
|
|
|
280
272
|
// Update the external product with the information of the new list
|
|
281
273
|
handleUpdateExtProduct({
|
|
@@ -284,12 +276,11 @@ export const useDessert = ({
|
|
|
284
276
|
OptionalProName: title,
|
|
285
277
|
required,
|
|
286
278
|
numbersOptionalOnly: numberLimit
|
|
287
|
-
})
|
|
279
|
+
})
|
|
288
280
|
|
|
289
281
|
// Clear the title field after adding the list
|
|
290
|
-
setTitle('')
|
|
291
|
-
}
|
|
292
|
-
|
|
282
|
+
setTitle('')
|
|
283
|
+
}
|
|
293
284
|
|
|
294
285
|
/**
|
|
295
286
|
* Handles the change of items in a specific list.
|
|
@@ -298,11 +289,11 @@ export const useDessert = ({
|
|
|
298
289
|
* @param {Object} params.value - The event object containing the new value for the list items.
|
|
299
290
|
*/
|
|
300
291
|
const handleChangeItems = ({ listID, value: e }) => {
|
|
301
|
-
const value = e.target.value
|
|
302
|
-
setValueItems(value)
|
|
292
|
+
const value = e.target.value
|
|
293
|
+
setValueItems(value)
|
|
303
294
|
|
|
304
295
|
// Get the current list from the data state using the provided listID
|
|
305
|
-
const currentList = data.lists[listID]
|
|
296
|
+
const currentList = data.lists[listID]
|
|
306
297
|
|
|
307
298
|
// Update the value of the current list with the new value
|
|
308
299
|
setData({
|
|
@@ -311,14 +302,14 @@ export const useDessert = ({
|
|
|
311
302
|
...data.lists,
|
|
312
303
|
[listID]: {
|
|
313
304
|
...currentList,
|
|
314
|
-
value
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
})
|
|
305
|
+
value
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
})
|
|
318
309
|
|
|
319
310
|
// Note: The return statement seems to be unnecessary, and the map function doesn't serve a purpose here.
|
|
320
311
|
// If you want to map through dataListIds for some other reason, you should use it separately from this function.
|
|
321
|
-
}
|
|
312
|
+
}
|
|
322
313
|
|
|
323
314
|
return {
|
|
324
315
|
addCard,
|
|
@@ -334,6 +325,6 @@ export const useDessert = ({
|
|
|
334
325
|
setCheck,
|
|
335
326
|
setData,
|
|
336
327
|
setTitle,
|
|
337
|
-
title
|
|
328
|
+
title
|
|
338
329
|
}
|
|
339
330
|
}
|
|
@@ -1,36 +1,35 @@
|
|
|
1
|
-
import { useState, useEffect } from 'react'
|
|
2
|
-
import { useQuery } from '@apollo/client'
|
|
3
|
-
import { GET_ALL_DEVICES } from './queries'
|
|
4
|
-
import { useFormatDate } from '../useFormatDate'
|
|
5
|
-
|
|
6
|
-
export const useDevices = () => {
|
|
7
|
-
const { data, loading } = useQuery(GET_ALL_DEVICES,{
|
|
8
|
-
onError: (error) => {
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
})
|
|
12
|
-
const [deviceId, setDeviceId] = useState(false)
|
|
13
|
-
const [date, setDate] = useState('')
|
|
14
|
-
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
if (window) {
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
}, [])
|
|
20
|
-
|
|
21
|
-
// Función para formatear la fecha
|
|
22
|
-
const formatDate = useFormatDate({ date
|
|
23
|
-
|
|
24
|
-
const updateDate = (newDate) => {
|
|
25
|
-
setDate(newDate)
|
|
26
|
-
}
|
|
27
|
-
return {
|
|
28
|
-
data: data?.getDeviceUsers || [],
|
|
29
|
-
date,
|
|
30
|
-
deviceId,
|
|
31
|
-
formatDate,
|
|
32
|
-
loading,
|
|
33
|
-
updateDate
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
1
|
+
import { useState, useEffect } from 'react'
|
|
2
|
+
import { useQuery } from '@apollo/client'
|
|
3
|
+
import { GET_ALL_DEVICES } from './queries'
|
|
4
|
+
import { useFormatDate } from '../useFormatDate'
|
|
5
|
+
|
|
6
|
+
export const useDevices = () => {
|
|
7
|
+
const { data, loading } = useQuery(GET_ALL_DEVICES, {
|
|
8
|
+
onError: (error) => {
|
|
9
|
+
console.error(error)
|
|
10
|
+
}
|
|
11
|
+
})
|
|
12
|
+
const [deviceId, setDeviceId] = useState(false)
|
|
13
|
+
const [date, setDate] = useState('')
|
|
14
|
+
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
if (window) {
|
|
17
|
+
setDeviceId(window.localStorage.getItem('deviceid'))
|
|
18
|
+
}
|
|
19
|
+
}, [])
|
|
20
|
+
|
|
21
|
+
// Función para formatear la fecha
|
|
22
|
+
const formatDate = useFormatDate({ date })
|
|
23
|
+
|
|
24
|
+
const updateDate = (newDate) => {
|
|
25
|
+
setDate(newDate)
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
data: data?.getDeviceUsers || [],
|
|
29
|
+
date,
|
|
30
|
+
deviceId,
|
|
31
|
+
formatDate,
|
|
32
|
+
loading,
|
|
33
|
+
updateDate
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { gql } from '@apollo/client'
|
|
2
|
-
|
|
3
|
-
export const GET_ALL_DEVICES = gql`
|
|
4
|
-
query getDeviceUsers{
|
|
5
|
-
getDeviceUsers{
|
|
6
|
-
dId
|
|
7
|
-
locationFormat
|
|
8
|
-
deviceId
|
|
9
|
-
deviceName
|
|
10
|
-
type
|
|
11
|
-
short_name
|
|
12
|
-
platform
|
|
13
|
-
version
|
|
14
|
-
dState
|
|
15
|
-
DatCre
|
|
16
|
-
DatMod
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
`
|
|
1
|
+
import { gql } from '@apollo/client'
|
|
2
|
+
|
|
3
|
+
export const GET_ALL_DEVICES = gql`
|
|
4
|
+
query getDeviceUsers{
|
|
5
|
+
getDeviceUsers{
|
|
6
|
+
dId
|
|
7
|
+
locationFormat
|
|
8
|
+
deviceId
|
|
9
|
+
deviceName
|
|
10
|
+
type
|
|
11
|
+
short_name
|
|
12
|
+
platform
|
|
13
|
+
version
|
|
14
|
+
dState
|
|
15
|
+
DatCre
|
|
16
|
+
DatMod
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
`
|