npm-pkg-hook 1.1.5 → 1.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/.eslintrc.js +19 -113
  2. package/.eslintrc.json +127 -108
  3. package/next.config.js +2 -5
  4. package/package.json +27 -24
  5. package/src/config/client/errors.js +14 -14
  6. package/src/config/client/index.js +1 -1
  7. package/src/hooks/getCategoriesWithProduct/helpers/index.js +7 -0
  8. package/src/hooks/getCategoriesWithProduct/index.js +62 -0
  9. package/src/hooks/getSession/index.js +18 -18
  10. package/src/hooks/index.js +13 -9
  11. package/src/hooks/useAcumulateDate/index.js +1 -1
  12. package/src/hooks/useAnimationFrame/index.js +45 -45
  13. package/src/hooks/useAsideCart/helpers/index.js +22 -0
  14. package/src/hooks/useAsideCart/index.js +156 -0
  15. package/src/hooks/useAsideCart/queries.js +10 -0
  16. package/src/hooks/useBanner/index.js +11 -11
  17. package/src/hooks/useCart/index.js +2 -0
  18. package/src/hooks/useCart/queries.js +164 -0
  19. package/src/hooks/useCart/useCart/helpers/index.js +75 -0
  20. package/src/hooks/useCart/useCart/index.js +411 -0
  21. package/src/hooks/useCart/useGetCart/index.js +31 -0
  22. package/src/hooks/useCatWithProduct/index.js +15 -15
  23. package/src/hooks/useCatWithProduct/queries.js +1 -1
  24. package/src/hooks/useCatWithProductClient/index.js +48 -0
  25. package/src/hooks/useCatWithProductClient/queries.js +55 -0
  26. package/src/hooks/useCategoriesProduct/index.js +12 -12
  27. package/src/hooks/useCategoriesProduct/queries.js +16 -16
  28. package/src/hooks/useCategoryInStore/index.js +39 -36
  29. package/src/hooks/useCategoryInStore/queries.js +78 -78
  30. package/src/hooks/useCategoryStore/index.js +2 -2
  31. package/src/hooks/useChartData/index.js +159 -156
  32. package/src/hooks/useChartData/useChartData/index.js +199 -197
  33. package/src/hooks/useChartData/useChartDataAllOrders/index.js +94 -94
  34. package/src/hooks/useCheckbox/index.js +115 -115
  35. package/src/hooks/useClients/index.js +12 -14
  36. package/src/hooks/useClients/queries.js +1 -1
  37. package/src/hooks/useConnection/index.js +20 -21
  38. package/src/hooks/useCreateProduct/helpers/useEditImageProduct/index.js +6 -2
  39. package/src/hooks/useCreateProduct/index.js +22 -19
  40. package/src/hooks/useDeleteSubProductOptional/index.js +31 -30
  41. package/src/hooks/useDeleteSubProductOptional/queries.js +10 -10
  42. package/src/hooks/useDessert/helpers/index.js +51 -51
  43. package/src/hooks/useDessert/index.js +56 -65
  44. package/src/hooks/useDevices/index.js +35 -36
  45. package/src/hooks/useDevices/queries.js +19 -19
  46. package/src/hooks/useDropzone/index.js +94 -79
  47. package/src/hooks/useDynamicAuth/index.js +13 -13
  48. package/src/hooks/useDynamicAuth/queries.js +24 -24
  49. package/src/hooks/useEmployee/queries.js +1 -1
  50. package/src/hooks/useEvent/index.js +33 -33
  51. package/src/hooks/useFavoriteStores/index.js +19 -0
  52. package/src/hooks/useFavoriteStores/queries.js +47 -0
  53. package/src/hooks/useFetchJson/index.js +25 -25
  54. package/src/hooks/useFingerprintjs/index.js +172 -176
  55. package/src/hooks/useFormTools/index.js +12 -11
  56. package/src/hooks/useFormatDate/index.js +20 -21
  57. package/src/hooks/useFormatNumberPhone/index.js +9 -9
  58. package/src/hooks/useFullScreenMode/index.js +65 -65
  59. package/src/hooks/useGenerateNumberArray/index.js +17 -17
  60. package/src/hooks/useGetExtProductFoodsSubOptionalAll/index.js +14 -0
  61. package/src/hooks/useGetFoodRecomended/index.js +33 -0
  62. package/src/hooks/useGetFoodRecomended/queries.js +47 -0
  63. package/src/hooks/useGetMinPrice/index.js +8 -0
  64. package/src/hooks/useGetMinPrice/queries.js +7 -0
  65. package/src/hooks/useGetOneStoreRating/index.js +40 -0
  66. package/src/hooks/useGetOneStoreRating/queries.js +18 -0
  67. package/src/hooks/useGoogleLogin/index.js +160 -161
  68. package/src/hooks/useHover/index.js +29 -29
  69. package/src/hooks/useImageOptimization/index.js +15 -15
  70. package/src/hooks/useImageWeight/index.js +18 -19
  71. package/src/hooks/useImagesStore/index.js +139 -140
  72. package/src/hooks/useImagesStore/queries.js +19 -18
  73. package/src/hooks/useInnerHtml/index.js +39 -38
  74. package/src/hooks/useIntersection/index.js +4 -4
  75. package/src/hooks/useKeypress/index.js +28 -28
  76. package/src/hooks/useLazyScript/index.js +35 -36
  77. package/src/hooks/useLocalSorage/index.js +2 -2
  78. package/src/hooks/useLogout/index.js +23 -23
  79. package/src/hooks/useManageQueryParams/index.js +36 -37
  80. package/src/hooks/useMobile/index.js +39 -38
  81. package/src/hooks/useMutateHeight/index.js +15 -16
  82. package/src/hooks/useOrderClient/index.js +5 -0
  83. package/src/hooks/useOrders/index.js +10 -16
  84. package/src/hooks/useOrders/queries.js +1 -1
  85. package/src/hooks/useProductsFood/index.js +32 -32
  86. package/src/hooks/useProductsFood/queriesStore.js +49 -48
  87. package/src/hooks/useProductsFood/useEditProduct.js +2 -4
  88. package/src/hooks/useProductsFood/usetagsProducts.js +83 -83
  89. package/src/hooks/useProviders/index.js +3 -3
  90. package/src/hooks/useProviders/queries.js +31 -31
  91. package/src/hooks/useProviders/useProvidersCreateStore/index.js +12 -13
  92. package/src/hooks/useProviders/useProvidersDataStore/index.js +24 -24
  93. package/src/hooks/useProvidersStore/index.js +24 -24
  94. package/src/hooks/useProvidersStore/queries.js +31 -31
  95. package/src/hooks/useRatingArrayData/index.js +54 -0
  96. package/src/hooks/{useRatingData → useRatingArrayData}/queries.js +19 -18
  97. package/src/hooks/useReactToPrint/index.js +1120 -1098
  98. package/src/hooks/useRemoveExtraProductFoodsOptional/index.js +23 -23
  99. package/src/hooks/useRemoveExtraProductFoodsOptional/queries.js +48 -48
  100. package/src/hooks/useReport/index.js +9 -9
  101. package/src/hooks/useReport/queries.js +1 -1
  102. package/src/hooks/useRestaurant/index.js +19 -19
  103. package/src/hooks/useRestaurant/queries.js +80 -80
  104. package/src/hooks/useSales/index.js +476 -451
  105. package/src/hooks/useSales/queries.js +14 -15
  106. package/src/hooks/useSales/useGetAllSales/index.js +25 -25
  107. package/src/hooks/useSales/useTotalSales.js +18 -18
  108. package/src/hooks/useSaveAvailableProduct/helpers/index.js +29 -29
  109. package/src/hooks/useSaveAvailableProduct/index.js +16 -16
  110. package/src/hooks/useSaveAvailableProduct/queries.js +1 -1
  111. package/src/hooks/useSchedule/index.js +33 -36
  112. package/src/hooks/useSchedule/index.jsx +22 -22
  113. package/src/hooks/useSchedule/queries.js +34 -35
  114. package/src/hooks/useScheduleData/index.js +123 -171
  115. package/src/hooks/useScroll/index.js +56 -57
  116. package/src/hooks/useScrollRotate/index.js +16 -14
  117. package/src/hooks/useSetSession/index.js +16 -16
  118. package/src/hooks/useSetState/index.js +3 -3
  119. package/src/hooks/useStatusOpenStore/helpers/index.js +101 -102
  120. package/src/hooks/useStatusOpenStore/index.js +172 -173
  121. package/src/hooks/useStatusOrdersClient/helpers/index.js +14 -0
  122. package/src/hooks/useStatusOrdersClient/index.js +17 -0
  123. package/src/hooks/useStatusOrdersClient/queries.js +80 -0
  124. package/src/hooks/useStore/index.js +40 -25
  125. package/src/hooks/useStore/queries.js +162 -136
  126. package/src/hooks/useStoreCalendar/index.js +5 -7
  127. package/src/hooks/useStoreContacts/index.js +16 -16
  128. package/src/hooks/useStoreContacts/queries.js +1 -1
  129. package/src/hooks/useTimeAgo/useTimeAgo.js +39 -39
  130. package/src/hooks/useUpdateCart/index.js +34 -28
  131. package/src/hooks/useUpdateExistingOrders/index.js +35 -35
  132. package/src/hooks/useUpdateExtProductFoodsSubOptional/index.js +38 -37
  133. package/src/hooks/useUser/index.js +1 -1
  134. package/src/hooks/useUser/queries.js +1 -1
  135. package/src/hooks/useWindowSize/index.js +38 -38
  136. package/src/mock/dessert/index.js +16 -16
  137. package/src/mock/index.js +1 -2
  138. package/src/utils/index.js +42 -45
  139. package/src/hooks/useRatingData/index.js +0 -53
  140. package/src/hooks/useSalesClient/index.js +0 -1
@@ -1,115 +1,115 @@
1
- import { useCallback, useState } from 'react'
2
-
3
- /**
4
- * Hook for managing multiple checkbox states
5
- *
6
- * @param {Array<String | Number>} elem - list of all elem
7
- * @param {Array<String | Number>} selectedIds - list of selected elem (optional)
8
- *
9
- * @returns {Object}
10
- * - checkboxStates (state object),
11
- * - numSelectedItems (number),
12
- * - handleChangeCheck (callback),
13
- * - toggleAll (callback),
14
- * - selectAll (callback),
15
- * - clearAll (callback)
16
- */
17
-
18
- export const useCheckboxState = (elem, selectedIds = [], disabledIds = []) => {
19
- const numTotalItems = elem?.length
20
- const [checkedItems, setCheckedItems] = useState(new Set(selectedIds))
21
- const [disabledItems, setDisabledItems] = useState(new Set(disabledIds))
22
-
23
- const handleChangeCheck = useCallback((event, id) => {
24
- const target = event.target
25
- setCheckedItems(prevState => {
26
- const newState = new Set(prevState)
27
- if (target.checked) {
28
- newState.add(id)
29
- } else {
30
- newState.delete(id)
31
- }
32
- return newState
33
- })
34
- }, [])
35
-
36
- const setAll = useCallback(
37
- isChecked => {
38
- setCheckedItems(prevState => {
39
- const newState = new Set(prevState)
40
- for (const id of elem) {
41
- if (disabledItems.has(id)) {
42
- continue
43
- }
44
- if (isChecked) {
45
- newState.add(id)
46
- } else {
47
- newState.delete(id)
48
- }
49
- }
50
- return newState
51
- })
52
- },
53
- [elem, disabledItems]
54
- )
55
-
56
- const selectAll = useCallback(() => {
57
- if (checkedItems.size === numTotalItems) {
58
- return
59
- }
60
- setAll(true)
61
- }, [checkedItems, numTotalItems, setAll])
62
-
63
- const clearAll = useCallback(() => {
64
- if (checkedItems.size === 0) {
65
- return
66
- }
67
- setAll(false)
68
- }, [checkedItems, setAll])
69
-
70
- const toggleAll = useCallback(() => {
71
- const numDisabledAndChecked = [...disabledItems].reduce((count, id) => {
72
- if (checkedItems.has(id)) {
73
- return count + 1
74
- }
75
- return count
76
- }, 0)
77
- if (checkedItems.size - numDisabledAndChecked === 0) {
78
- selectAll()
79
- } else {
80
- clearAll()
81
- }
82
- }, [checkedItems, disabledItems, selectAll, clearAll])
83
-
84
- const enableCheckboxes = useCallback((...elem) => {
85
- setDisabledItems(prevState => {
86
- const newState = new Set(prevState)
87
- for (const id of elem) {
88
- newState.delete(id)
89
- }
90
- return newState
91
- })
92
- }, [])
93
-
94
- const disableCheckboxes = useCallback((...elem) => {
95
- setDisabledItems(prevState => {
96
- const newState = new Set(prevState)
97
- for (const id of elem) {
98
- newState.add(id)
99
- }
100
- return newState
101
- })
102
- }, [])
103
-
104
- return {
105
- checkedItems,
106
- disabledItems,
107
- handleChangeCheck,
108
- toggleAll,
109
- selectAll,
110
- clearAll,
111
- setCheckedItems,
112
- enableCheckboxes,
113
- disableCheckboxes
114
- }
115
- }
1
+ import { useCallback, useState } from 'react'
2
+
3
+ /**
4
+ * Hook for managing multiple checkbox states
5
+ *
6
+ * @param {Array<String | Number>} elem - list of all elem
7
+ * @param {Array<String | Number>} selectedIds - list of selected elem (optional)
8
+ *
9
+ * @returns {Object}
10
+ * - checkboxStates (state object),
11
+ * - numSelectedItems (number),
12
+ * - handleChangeCheck (callback),
13
+ * - toggleAll (callback),
14
+ * - selectAll (callback),
15
+ * - clearAll (callback)
16
+ */
17
+
18
+ export const useCheckboxState = (elem, selectedIds = [], disabledIds = []) => {
19
+ const numTotalItems = elem?.length
20
+ const [checkedItems, setCheckedItems] = useState(new Set(selectedIds))
21
+ const [disabledItems, setDisabledItems] = useState(new Set(disabledIds))
22
+
23
+ const handleChangeCheck = useCallback((event, id) => {
24
+ const target = event.target
25
+ setCheckedItems(prevState => {
26
+ const newState = new Set(prevState)
27
+ if (target.checked) {
28
+ newState.add(id)
29
+ } else {
30
+ newState.delete(id)
31
+ }
32
+ return newState
33
+ })
34
+ }, [])
35
+
36
+ const setAll = useCallback(
37
+ isChecked => {
38
+ setCheckedItems(prevState => {
39
+ const newState = new Set(prevState)
40
+ for (const id of elem) {
41
+ if (disabledItems.has(id)) {
42
+ continue
43
+ }
44
+ if (isChecked) {
45
+ newState.add(id)
46
+ } else {
47
+ newState.delete(id)
48
+ }
49
+ }
50
+ return newState
51
+ })
52
+ },
53
+ [elem, disabledItems]
54
+ )
55
+
56
+ const selectAll = useCallback(() => {
57
+ if (checkedItems.size === numTotalItems) {
58
+ return
59
+ }
60
+ setAll(true)
61
+ }, [checkedItems, numTotalItems, setAll])
62
+
63
+ const clearAll = useCallback(() => {
64
+ if (checkedItems.size === 0) {
65
+ return
66
+ }
67
+ setAll(false)
68
+ }, [checkedItems, setAll])
69
+
70
+ const toggleAll = useCallback(() => {
71
+ const numDisabledAndChecked = [...disabledItems].reduce((count, id) => {
72
+ if (checkedItems.has(id)) {
73
+ return count + 1
74
+ }
75
+ return count
76
+ }, 0)
77
+ if (checkedItems.size - numDisabledAndChecked === 0) {
78
+ selectAll()
79
+ } else {
80
+ clearAll()
81
+ }
82
+ }, [checkedItems, disabledItems, selectAll, clearAll])
83
+
84
+ const enableCheckboxes = useCallback((...elem) => {
85
+ setDisabledItems(prevState => {
86
+ const newState = new Set(prevState)
87
+ for (const id of elem) {
88
+ newState.delete(id)
89
+ }
90
+ return newState
91
+ })
92
+ }, [])
93
+
94
+ const disableCheckboxes = useCallback((...elem) => {
95
+ setDisabledItems(prevState => {
96
+ const newState = new Set(prevState)
97
+ for (const id of elem) {
98
+ newState.add(id)
99
+ }
100
+ return newState
101
+ })
102
+ }, [])
103
+
104
+ return {
105
+ checkedItems,
106
+ disabledItems,
107
+ handleChangeCheck,
108
+ toggleAll,
109
+ selectAll,
110
+ clearAll,
111
+ setCheckedItems,
112
+ enableCheckboxes,
113
+ disableCheckboxes
114
+ }
115
+ }
@@ -1,5 +1,4 @@
1
1
  import { useQuery, useMutation, useLazyQuery } from '@apollo/client'
2
- import { useState } from 'react'
3
2
  import {
4
3
  CREATE_CLIENTS,
5
4
  DELETE_ONE_CLIENTS,
@@ -11,22 +10,22 @@ import {
11
10
  export const useGetClients = ({
12
11
  max,
13
12
  search,
14
- sendNotification = () => { return }
13
+ sendNotification = () => { }
15
14
  } = {}) => {
16
- const { loading, error, called, data } = useQuery(GET_ALL_CLIENTS, {
17
- variables: {
18
- search: search
19
- }
15
+ const { loading, error, called, data } = useQuery(GET_ALL_CLIENTS, {
16
+ variables: {
17
+ search
18
+ }
20
19
  })
21
20
  return [data?.getAllClients || [], { loading: called ? false : loading, error }]
22
21
  }
23
22
 
24
- export const useDeleteClients = ({ sendNotification = () => { return } } = {}) => {
25
- const [deleteClient, { loading, error }] = useMutation(DELETE_ONE_CLIENTS)
23
+ export const useDeleteClients = ({ sendNotification = () => { } } = {}) => {
24
+ const [deleteClient, { loading, error }] = useMutation(DELETE_ONE_CLIENTS)
26
25
  return [deleteClient, { loading, error }]
27
26
  }
28
27
 
29
- export const useCreateClient = ({ sendNotification = () => { return } } = {}) => {
28
+ export const useCreateClient = ({ sendNotification = () => { } } = {}) => {
30
29
  const [createClients, { loading, error }] = useMutation(CREATE_CLIENTS, {
31
30
  onError: (data) => {
32
31
  // sendNotification({
@@ -40,13 +39,12 @@ export const useCreateClient = ({ sendNotification = () => { return } } = {}) =>
40
39
  return [createClients || [], { loading, error }]
41
40
  }
42
41
 
43
- export const useEditClient = ({ sendNotification = () => { return } } = {}) => {
42
+ export const useEditClient = ({ sendNotification = () => { } } = {}) => {
44
43
  const [editOneClient, { loading, error, data }] = useMutation(EDIT_ONE_CLIENT, {
45
44
  onCompleted: (data) => {
46
- console.log(data)
47
45
  if (data?.editOneClient?.success) {
48
46
  return sendNotification({
49
- title: 'Exito',
47
+ title: 'Exito',
50
48
  description: data?.editOneClient?.message,
51
49
  backgroundColor: 'success'
52
50
  })
@@ -55,7 +53,7 @@ export const useEditClient = ({ sendNotification = () => { return } } = {}) => {
55
53
  onError: (data) => {
56
54
  if (data?.editOneClient) {
57
55
  return sendNotification({
58
- title: 'Error',
56
+ title: 'Error',
59
57
  description: data?.editOneClient?.message,
60
58
  backgroundColor: 'error'
61
59
  })
@@ -66,7 +64,7 @@ export const useEditClient = ({ sendNotification = () => { return } } = {}) => {
66
64
  return [editOneClient, { loading, error, data }]
67
65
  }
68
66
 
69
- export const useGetOneClient = ({ sendNotification = () => { return } } = {}) => {
67
+ export const useGetOneClient = ({ sendNotification = () => { } } = {}) => {
70
68
  const [getOneClients, { data, loading, error }] = useLazyQuery(GET_ONE_CLIENT)
71
69
 
72
70
  return [getOneClients || [], { loading, error, data }]
@@ -124,4 +124,4 @@ mutation registerSalesStore($input: [IShoppingCard], $id: ID, $idStore: ID, $pC
124
124
  }
125
125
  }
126
126
  }
127
- `
127
+ `
@@ -1,23 +1,22 @@
1
1
  export const useConnection = ({ setConnectionStatus }) => {
2
- async function updateConnectionStatus() {
3
- if (navigator.onLine) {
4
- setConnectionStatus(navigator.onLine);
5
- } else {
6
- setConnectionStatus(navigator.onLine);
7
- }
2
+ async function updateConnectionStatus () {
3
+ if (navigator.onLine) {
4
+ setConnectionStatus(navigator.onLine)
5
+ } else {
6
+ setConnectionStatus(navigator.onLine)
8
7
  }
9
-
10
- // Attaching event handler for the load event
11
- // window.addEventListener('load', updateConnectionStatus);
12
-
13
- // Attaching event handler for the online event
14
- window.addEventListener('online', function(e) {
15
- updateConnectionStatus();
16
- });
17
-
18
- // Attaching event handler for the offline event
19
- window.addEventListener('offline', function(e) {
20
- updateConnectionStatus();
21
- });
22
- };
23
-
8
+ }
9
+
10
+ // Attaching event handler for the load event
11
+ // window.addEventListener('load', updateConnectionStatus);
12
+
13
+ // Attaching event handler for the online event
14
+ window.addEventListener('online', function (e) {
15
+ updateConnectionStatus()
16
+ })
17
+
18
+ // Attaching event handler for the offline event
19
+ window.addEventListener('offline', function (e) {
20
+ updateConnectionStatus()
21
+ })
22
+ }
@@ -1,8 +1,11 @@
1
+ /* eslint-disable no-unused-vars */
1
2
  import { useRef, useState } from 'react'
2
3
 
3
4
  export const useEditImageProduct = ({ sendNotification = () => { }, initialState }) => {
4
5
  const [openEditImage, setopenEditImage] = useState(false)
6
+ // eslint-disable-next-line no-unused-vars
5
7
  const [tags, setTags] = useState([])
8
+ const [{ src, alt }, setPreviewImg] = useState([])
6
9
  const [errors, setErrors] = useState({})
7
10
  const handleOpenEditImage = () => {
8
11
  setopenEditImage(!openEditImage)
@@ -83,7 +86,8 @@ export const useEditImageProduct = ({ sendNotification = () => { }, initialState
83
86
  sendNotification({
84
87
  backgroundColor: 'success',
85
88
  title: 'Exito',
86
- description: 'Imagen editada' })
89
+ description: 'Imagen editada'
90
+ })
87
91
  setExistImage(true)
88
92
  handleOpenEditImage()
89
93
  })
@@ -91,7 +95,7 @@ export const useEditImageProduct = ({ sendNotification = () => { }, initialState
91
95
  sendNotification({
92
96
  backgroundColor: 'error',
93
97
  title: 'Error',
94
- description: 'Ha ocurrido un error!'
98
+ description: 'Ha ocurrido un error!'
95
99
  })
96
100
  })
97
101
  // You can use the file object to send it to a server or to download it
@@ -1,3 +1,4 @@
1
+ /* eslint-disable no-unused-vars */
1
2
  import { useMutation } from '@apollo/client'
2
3
  import { useRef, useState } from 'react'
3
4
  import { convertBase64, RandomCode } from '../../utils'
@@ -46,12 +47,12 @@ export const useCreateProduct = ({
46
47
  // HANDLESS
47
48
  const [check, setCheck] = useState({
48
49
  availability: true,
49
- noAvailability: false,
50
+ noAvailability: false
50
51
  })
51
52
 
52
53
  const handleCheck = (e) => {
53
54
  const { name, checked } = e.target
54
- return setCheck((prev) =>({ ...prev, [name]: checked }))
55
+ return setCheck((prev) => ({ ...prev, [name]: checked }))
55
56
  }
56
57
 
57
58
  const handleUpdateBanner = event => {
@@ -59,9 +60,9 @@ export const useCreateProduct = ({
59
60
  setPreviewImg(
60
61
  files.length
61
62
  ? {
62
- src: URL.createObjectURL(files[0]),
63
- alt: files[0].name
64
- }
63
+ src: URL.createObjectURL(files[0]),
64
+ alt: files[0].name
65
+ }
65
66
  : initialState
66
67
  )
67
68
  }
@@ -94,7 +95,7 @@ export const useCreateProduct = ({
94
95
  handleCheck(e)
95
96
  setValues({
96
97
  ...values,
97
- ValueDelivery: '',
98
+ ValueDelivery: ''
98
99
  })
99
100
  }
100
101
 
@@ -116,17 +117,18 @@ export const useCreateProduct = ({
116
117
  setPreviewImg(
117
118
  files.length
118
119
  ? {
119
- src: URL.createObjectURL(files[0]),
120
- alt: files[0].name
121
- }
120
+ src: URL.createObjectURL(files[0]),
121
+ alt: files[0].name
122
+ }
122
123
  : initialState
123
- )
124
+ )
124
125
  }
125
126
  const onTargetClick = () => {
126
127
  fileInputRef.current.click()
127
128
  }
129
+ // eslint-disable-next-line no-unused-vars
128
130
  const { img } = useEditImageProduct({ sendNotification, initialState })
129
- console.log(values)
131
+
130
132
  const handleRegister = async () => {
131
133
  const {
132
134
  ProPrice,
@@ -202,11 +204,13 @@ export const useCreateProduct = ({
202
204
  }
203
205
  handleRegisterTags(objTag)
204
206
  // setValues({})
205
- }).catch(err => { return sendNotification({
206
- backgroundColor: 'error',
207
- title: `${err}`,
208
- description: 'Error inesperado'
209
- }) })
207
+ }).catch(err => {
208
+ return sendNotification({
209
+ backgroundColor: 'error',
210
+ title: `${err}`,
211
+ description: 'Error inesperado'
212
+ })
213
+ })
210
214
  if (image !== null) {
211
215
  setImageProducts({
212
216
  variables: {
@@ -216,10 +220,10 @@ export const useCreateProduct = ({
216
220
  }
217
221
  }
218
222
  }).then((response) => {
219
- }).catch((error) => {
223
+ }).catch(() => {
220
224
  sendNotification({
221
225
  backgroundColor: 'error',
222
- title: `Ocurrió un error en la imagen en el producto ${names}`,
226
+ title: `Ocurrió un error en la imagen en el producto ${names}`,
223
227
  description: 'error'
224
228
  })
225
229
  })
@@ -256,7 +260,6 @@ export const useCreateProduct = ({
256
260
  pId,
257
261
  dataTags: data,
258
262
  tags,
259
- tags,
260
263
  active,
261
264
  idStore: dataStore?.getStore?.idStore || '',
262
265
  arrTags,
@@ -1,30 +1,31 @@
1
- import { useMutation } from '@apollo/client'
2
- import { DELETE_CAT_EXTRA_SUB_OPTIONAL_PRODUCTS } from './queries'
3
- import { updateCacheMod } from '../../utils'
4
- import { GET_EXTRAS_PRODUCT_FOOD_OPTIONAL } from '../useRemoveExtraProductFoodsOptional/queries'
5
-
6
- export const useDeleteSubProductOptional = ({ setAlertBox = () => { return } } = {}) => {
7
- const [DeleteExtFoodSubsOptional, {
8
- loading,
9
- error,
10
- called
11
- }] = useMutation(DELETE_CAT_EXTRA_SUB_OPTIONAL_PRODUCTS)
12
-
13
- const handleRemoveSubProductOptional = ({ state, opSubExPid }) => {
14
- console.log(state, opSubExPid )
15
- DeleteExtFoodSubsOptional({
16
- variables: {
17
- state: state,
18
- opSubExPid: opSubExPid
19
- }, update: (cache, { data: { ExtProductFoodsOptionalAll } }) => {
20
- return updateCacheMod({
21
- cache,
22
- query: GET_EXTRAS_PRODUCT_FOOD_OPTIONAL,
23
- nameFun: 'ExtProductFoodsOptionalAll',
24
- dataNew: ExtProductFoodsOptionalAll
25
- })
26
- }
27
- }).then(res => { return setAlertBox({ message: res?.message?.DeleteExtFoodSubsOptional?.message }) })
28
- }
29
- return [DeleteExtFoodSubsOptional, handleRemoveSubProductOptional, { loading, error, called }]
30
- }
1
+ import { useMutation } from '@apollo/client'
2
+ import { DELETE_CAT_EXTRA_SUB_OPTIONAL_PRODUCTS } from './queries'
3
+ import { updateCacheMod } from '../../utils'
4
+ import { GET_EXTRAS_PRODUCT_FOOD_OPTIONAL } from '../useRemoveExtraProductFoodsOptional/queries'
5
+
6
+ export const useDeleteSubProductOptional = ({ setAlertBox = () => { } } = {}) => {
7
+ const [DeleteExtFoodSubsOptional, {
8
+ loading,
9
+ error,
10
+ called
11
+ }] = useMutation(DELETE_CAT_EXTRA_SUB_OPTIONAL_PRODUCTS)
12
+
13
+ const handleRemoveSubProductOptional = ({ state, opSubExPid }) => {
14
+ console.log(state, opSubExPid)
15
+ DeleteExtFoodSubsOptional({
16
+ variables: {
17
+ state,
18
+ opSubExPid
19
+ },
20
+ update: (cache, { data: { ExtProductFoodsOptionalAll } }) => {
21
+ return updateCacheMod({
22
+ cache,
23
+ query: GET_EXTRAS_PRODUCT_FOOD_OPTIONAL,
24
+ nameFun: 'ExtProductFoodsOptionalAll',
25
+ dataNew: ExtProductFoodsOptionalAll
26
+ })
27
+ }
28
+ }).then(res => { return setAlertBox({ message: res?.message?.DeleteExtFoodSubsOptional?.message }) })
29
+ }
30
+ return [DeleteExtFoodSubsOptional, handleRemoveSubProductOptional, { loading, error, called }]
31
+ }
@@ -1,10 +1,10 @@
1
- import { gql } from "@apollo/client";
2
-
3
- export const DELETE_CAT_EXTRA_SUB_OPTIONAL_PRODUCTS = gql`
4
- mutation DeleteExtFoodSubsOptional($opSubExPid: ID, $state: Int, $isCustomSubOpExPid: Boolean){
5
- DeleteExtFoodSubsOptional(opSubExPid: $opSubExPid, state: $state, isCustomSubOpExPid: $isCustomSubOpExPid){
6
- success,
7
- message
8
- }
9
- }
10
- `
1
+ import { gql } from '@apollo/client'
2
+
3
+ export const DELETE_CAT_EXTRA_SUB_OPTIONAL_PRODUCTS = gql`
4
+ mutation DeleteExtFoodSubsOptional($opSubExPid: ID, $state: Int, $isCustomSubOpExPid: Boolean){
5
+ DeleteExtFoodSubsOptional(opSubExPid: $opSubExPid, state: $state, isCustomSubOpExPid: $isCustomSubOpExPid){
6
+ success,
7
+ message
8
+ }
9
+ }
10
+ `