npm-pkg-hook 1.1.0 → 1.1.2

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 (69) hide show
  1. package/.eslintrc.js +132 -132
  2. package/next.config.js +0 -1
  3. package/package.json +46 -43
  4. package/src/config/client/errors.js +2 -1
  5. package/src/hooks/getSession/index.js +18 -0
  6. package/src/hooks/index.js +27 -7
  7. package/src/hooks/useAnimationFrame/index.js +45 -0
  8. package/src/hooks/useAnimationText/index.jsx +11 -13
  9. package/src/hooks/useCatWithProduct/index.js +37 -4
  10. package/src/hooks/useCatWithProduct/queries.js +0 -16
  11. package/src/hooks/useCategoriesProduct/index.js +12 -0
  12. package/src/hooks/useCategoriesProduct/queries.js +16 -0
  13. package/src/hooks/useChartData/index.js +182 -154
  14. package/src/hooks/useCheckbox/index.js +5 -1
  15. package/src/hooks/useClients/index.js +17 -8
  16. package/src/hooks/useCreateProduct/index.js +95 -65
  17. package/src/hooks/useDeleteSubProductOptional/index.js +30 -0
  18. package/src/hooks/useDeleteSubProductOptional/queries.js +10 -0
  19. package/src/hooks/useDessert/helpers/index.js +51 -0
  20. package/src/hooks/useDessert/index.js +319 -121
  21. package/src/hooks/useDevices/index.js +36 -0
  22. package/src/hooks/useDevices/queries.js +19 -0
  23. package/src/hooks/useDrag/index.js +1 -1
  24. package/src/hooks/useDropzone/index.js +79 -0
  25. package/src/hooks/useDynamicAuth/index.js +13 -0
  26. package/src/hooks/useDynamicAuth/queries.js +24 -0
  27. package/src/hooks/useEmployee/index.js +11 -8
  28. package/src/hooks/useFingerprintjs/index.js +176 -0
  29. package/src/hooks/useFormTools/index.js +1 -1
  30. package/src/hooks/useFullScreenMode/index.js +8 -9
  31. package/src/hooks/useGenerateNumberArray/index.js +17 -0
  32. package/src/hooks/useImagesStore/index.js +176 -143
  33. package/src/hooks/useImagesStore/queries.js +1 -28
  34. package/src/hooks/useKeypress/index.js +7 -1
  35. package/src/hooks/useLocalSorage/index.js +1 -1
  36. package/src/hooks/useLogout/index.js +22 -25
  37. package/src/hooks/useManageQueryParams/index.js +37 -0
  38. package/src/hooks/useProductsFood/queriesStore.js +3 -16
  39. package/src/hooks/useProductsFood/usetagsProducts.js +30 -5
  40. package/src/hooks/useProviders/index.js +3 -0
  41. package/src/hooks/useProviders/queries.js +31 -0
  42. package/src/hooks/useProviders/useProvidersCreateStore/index.js +13 -0
  43. package/src/hooks/useProviders/useProvidersDataStore/index.js +24 -0
  44. package/src/hooks/useProvidersStore/index.js +24 -0
  45. package/src/hooks/useProvidersStore/queries.js +31 -0
  46. package/src/hooks/useRatingData/index.js +53 -0
  47. package/src/hooks/useRatingData/queries.js +18 -0
  48. package/src/hooks/useRemoveExtraProductFoodsOptional/index.js +23 -0
  49. package/src/hooks/useRemoveExtraProductFoodsOptional/queries.js +48 -0
  50. package/src/hooks/useReport/index.js +16 -7
  51. package/src/hooks/useReport/queries.js +47 -32
  52. package/src/hooks/useSales/index.js +53 -22
  53. package/src/hooks/useSales/queries.js +48 -38
  54. package/src/hooks/useSales/useGetAllSales/index.js +25 -0
  55. package/src/hooks/useSales/useGetSale.js +16 -2
  56. package/src/hooks/useSchedule/index.js +36 -0
  57. package/src/hooks/useSchedule/queries.js +35 -0
  58. package/src/hooks/useScheduleData/index.js +171 -0
  59. package/src/hooks/useScroll/index.js +57 -0
  60. package/src/hooks/useScrollRotate/index.js +14 -0
  61. package/src/hooks/useStatusOpenStore/helpers/index.js +102 -0
  62. package/src/hooks/useStatusOpenStore/index.js +173 -0
  63. package/src/hooks/useUpdateExistingOrders/index.js +8 -8
  64. package/src/hooks/useUser/index.js +7 -2
  65. package/src/hooks/useUser/queries.js +40 -0
  66. package/src/index.jsx +3 -1
  67. package/.vscode/extensions.json +0 -6
  68. package/.vscode/settings.json +0 -8
  69. package/src/hooks/useSchedule/index.jsx +0 -23
@@ -1,6 +1,7 @@
1
1
  import { useMutation } from '@apollo/client';
2
2
  import {
3
3
  useRef,
4
+ useCallback,
4
5
  useState
5
6
  } from 'react';
6
7
  import {
@@ -11,158 +12,191 @@ import {
11
12
  GET_ONE_BANNER_STORE
12
13
  } from '../useProductsFood/queriesStore';
13
14
  import { GET_ONE_STORE } from '../useStore/queries';
14
-
15
- export const useImageStore = ({ idStore, sendNotification = () => { return } } = {}) => {
16
- // STATES
17
- const fileInputRef = useRef(null)
18
- const [{ altLogo, srcLogo }, setPreviewImgLogo] = useState({})
19
- const initialState = { alt: '/images/DEFAULTBANNER.png', src: '/images/DEFAULTBANNER.png' }
20
- const [{ alt, src }, setPreviewImg] = useState(initialState)
21
- const fileInputRefLogo = useRef(null)
22
- // HOOKS
23
- const [registerBanner] = useMutation(CREATE_BANNER_STORE, {
24
- onCompleted: (data) => { return console.log({ message: data?.registerBanner?.message }) },
25
- context: { clientName: 'admin-server' }
26
- })
27
- const [setALogoStore] = useMutation(CREATE_LOGO, {
28
- onCompleted: (data) => { return console.log({ message: data?.setALogoStore?.message }) },
29
- context: { clientName: 'admin-server' }
30
- })
31
- const [DeleteOneBanner] = useMutation(DELETE_ONE_BANNER_STORE, {
32
- onCompleted: (data) => { return console.log({ message: data?.DeleteOneBanner?.message }) },
33
- context: { clientName: 'admin-server' }
34
- })
35
- const [deleteALogoStore] = useMutation(DELETE_ONE_LOGO_STORE, {
36
- onCompleted: (data) => {
37
- console.log({
38
- message: data.deleteALogoStore.message
39
- })
40
- setPreviewImgLogo(initialState)
15
+ /**
16
+ * Custom hook to handle image upload and management for a store's banner and logo.
17
+ * @typedef {Object} ImageStoreHookResult
18
+ * @property {React.RefObject} fileInputRefLogo - Reference to the logo file input element.
19
+ * @property {string} src - Source URL of the store's banner image.
20
+ * @property {string} alt - Alternate text for the store's banner image.
21
+ * @property {Object} initialState - Initial state for the store's banner image.
22
+ * @property {string} srcLogo - Source URL of the store's logo image.
23
+ * @property {string} altLogo - Alternate text for the store's logo image.
24
+ * @property {React.RefObject} fileInputRef - Reference to the banner file input element.
25
+ * @property {function} handleDeleteLogo - Callback function to handle logo deletion.
26
+ * @property {function} onTargetClick - Callback function to trigger banner file input click.
27
+ * @property {function} onTargetClickLogo - Callback function to trigger logo file input click.
28
+ * @property {function} HandleDeleteBanner - Callback function to handle banner deletion.
29
+ * @property {function} handleInputChangeLogo - Callback function to handle logo file input change.
30
+ * @property {function} handleUpdateBanner - Callback function to handle banner file input change.
31
+ * @param {Object} options - Options for the hook.
32
+ * @param {string} options.idStore - ID of the store.
33
+ * @param {Function} options.sendNotification - Function to send a notification (optional).
34
+ * @returns {ImageStoreHookResult} Object containing image handling functions and state.
35
+ */
36
+ export const useImageStore = ({ idStore, sendNotification = () => {} } = {}) => {
37
+ // STATES
38
+ const fileInputRef = useRef(null);
39
+ const [{ altLogo, srcLogo }, setPreviewImgLogo] = useState({});
40
+ const initialState = { alt: '/images/DEFAULTBANNER.png', src: '/images/DEFAULTBANNER.png' };
41
+ const [{ alt, src }, setPreviewImg] = useState(initialState);
42
+ const fileInputRefLogo = useRef(null);
43
+ // HOOKS
44
+ const [registerBanner] = useMutation(CREATE_BANNER_STORE, {
45
+ onCompleted: (data) => console.log({ message: data?.registerBanner?.message }),
46
+ context: { clientName: 'admin-server' },
47
+ });
48
+ const [setALogoStore] = useMutation(CREATE_LOGO, {
49
+ onCompleted: (data) => console.log({ message: data?.setALogoStore?.message }),
50
+ context: { clientName: 'admin-server' },
51
+ });
52
+ const [DeleteOneBanner] = useMutation(DELETE_ONE_BANNER_STORE, {
53
+ onCompleted: (data) => console.log({ message: data?.DeleteOneBanner?.message }),
54
+ context: { clientName: 'admin-server' },
55
+ });
56
+ const [deleteALogoStore] = useMutation(DELETE_ONE_LOGO_STORE, {
57
+ onCompleted: (data) => {
58
+ console.log({ message: data.deleteALogoStore.message });
59
+ setPreviewImgLogo(initialState);
60
+ },
61
+ context: { clientName: 'admin-server' },
62
+ update(cache) {
63
+ cache.modify({
64
+ fields: {
65
+ getStore(dataOld = []) {
66
+ return cache.writeQuery({ query: GET_ONE_STORE, data: dataOld });
67
+ },
41
68
  },
42
- context: { clientName: 'admin-server' },
43
- update(cache) {
44
- cache.modify({
45
- fields: {
46
- getStore(dataOld = []) {
47
- return cache.writeQuery({ query: GET_ONE_STORE, data: dataOld })
48
- }
49
- }
50
- })
51
- }
52
- })
53
- // HANDLESS
54
- const handleDeleteLogo = () => {
55
- return deleteALogoStore({
56
- variables: {
57
- Image: ImageName || null
58
- }
59
- })
60
- }
69
+ });
70
+ },
71
+ });
61
72
 
62
- const handleUpdateBanner = event => {
63
- try {
64
- const { files } = event.target
65
- setPreviewImg(
66
- files.length
67
- ? {
68
- src: URL.createObjectURL(files[0]),
69
- alt: files[0].name
70
- }
71
- : initialState
72
- )
73
- registerBanner({
74
- variables: {
75
- input: {
76
- bnImage: files[0],
77
- idStore: idStore
78
- }
79
- }, update(cache) {
80
- cache.modify({
81
- fields: {
82
- getOneBanners(dataOld = []) {
83
- return cache.writeQuery({ query: GET_ONE_BANNER_STORE, data: dataOld })
84
- }
85
- }
86
- })
87
- }
88
- }).catch(() => {
89
- sendNotification({
90
- title: 'No pudimos cargar la imagen',
91
- description: 'Error',
92
- backgroundColor: 'error'
93
- })
94
- setPreviewImg(initialState)
95
- })
96
- } catch {
97
- setPreviewImg(initialState)
98
- sendNotification({
99
- title: 'No pudimos cargar la imagen',
100
- description: 'Error',
101
- backgroundColor: 'error'
102
- })
103
- }
104
- }
105
- const handleInputChangeLogo = event => {
106
- const { files } = event.target
107
- setPreviewImgLogo(
73
+ // HANDLESS
74
+ const handleDeleteLogo = useCallback(() => {
75
+ return deleteALogoStore({
76
+ variables: {
77
+ Image: ImageName || null,
78
+ },
79
+ });
80
+ }, [deleteALogoStore]);
81
+
82
+ const handleUpdateBanner = useCallback(
83
+ (event) => {
84
+ try {
85
+ const { files } = event.target;
86
+ setPreviewImg(
108
87
  files.length
109
88
  ? {
110
- srcLogo: URL.createObjectURL(files[0]),
111
- altLogo: files[0].name
112
- }
89
+ src: URL.createObjectURL(files[0]),
90
+ alt: files[0].name,
91
+ }
113
92
  : initialState
114
- )
115
- setALogoStore({
93
+ );
94
+ registerBanner({
116
95
  variables: {
117
- logo: files[0],
118
- idStore: idStore
119
- }, update(cache) {
96
+ input: {
97
+ bnImage: files[0],
98
+ idStore: idStore,
99
+ },
100
+ },
101
+ update(cache) {
120
102
  cache.modify({
121
103
  fields: {
122
- getStore(dataOld = []) {
123
- return cache.writeQuery({ query: GET_ONE_STORE, data: dataOld })
124
- }
125
- }
126
- })
127
- }
104
+ getOneBanners(dataOld = []) {
105
+ return cache.writeQuery({ query: GET_ONE_BANNER_STORE, data: dataOld });
106
+ },
107
+ },
108
+ });
109
+ },
128
110
  }).catch(() => {
129
111
  sendNotification({
130
112
  title: 'No pudimos cargar la imagen',
131
113
  description: 'Error',
132
- backgroundColor: 'error'
133
- })
134
- setPreviewImgLogo(initialState)
135
- })
136
- }
137
- const HandleDeleteBanner = async () => {
138
- setPreviewImg(initialState)
139
- DeleteOneBanner({
140
- variables: {
141
- bnState: bnState,
142
- bnImageFileName: bnImageFileName,
143
- idStore,
144
- bnId
145
- }, update(cache) {
146
- cache.modify({
147
- fields: {
148
- getOneBanners(dataOld = []) {
149
- return cache.writeQuery({ query: GET_ONE_BANNER_STORE, data: dataOld })
150
- }
151
- }
152
- })
153
- }
154
- }).then(() => {
155
- setPreviewImg(initialState)
156
- })
114
+ backgroundColor: 'error',
115
+ });
116
+ setPreviewImg(initialState);
117
+ });
118
+ } catch {
119
+ setPreviewImg(initialState);
120
+ sendNotification({
121
+ title: 'No pudimos cargar la imagen',
122
+ description: 'Error',
123
+ backgroundColor: 'error',
124
+ });
157
125
  }
158
- const onTargetClickLogo = e => {
159
- e.preventDefault()
160
- fileInputRefLogo.current.click()
161
- }
162
- const onTargetClick = e => {
163
- e.preventDefault()
164
- fileInputRef.current.click()
165
- }
126
+ },
127
+ [setPreviewImg, initialState, sendNotification, idStore, registerBanner]
128
+ );
129
+
130
+ const handleInputChangeLogo = useCallback(
131
+ (event) => {
132
+ const { files } = event.target;
133
+ setPreviewImgLogo(
134
+ files.length
135
+ ? {
136
+ srcLogo: URL.createObjectURL(files[0]),
137
+ altLogo: files[0].name,
138
+ }
139
+ : initialState
140
+ );
141
+ setALogoStore({
142
+ variables: {
143
+ logo: files[0],
144
+ idStore: idStore,
145
+ },
146
+ update(cache) {
147
+ cache.modify({
148
+ fields: {
149
+ getStore(dataOld = []) {
150
+ return cache.writeQuery({ query: GET_ONE_STORE, data: dataOld });
151
+ },
152
+ },
153
+ });
154
+ },
155
+ }).catch(() => {
156
+ sendNotification({
157
+ title: 'No pudimos cargar la imagen',
158
+ description: 'Error',
159
+ backgroundColor: 'error',
160
+ });
161
+ setPreviewImgLogo(initialState);
162
+ });
163
+ },
164
+ [setPreviewImgLogo, initialState, idStore, setALogoStore]
165
+ );
166
+
167
+ const HandleDeleteBanner = useCallback(async () => {
168
+ setPreviewImg(initialState);
169
+ DeleteOneBanner({
170
+ variables: {
171
+ bnState: bnState, // You should provide bnState and bnImageFileName
172
+ bnImageFileName: bnImageFileName,
173
+ idStore,
174
+ bnId,
175
+ },
176
+ update(cache) {
177
+ cache.modify({
178
+ fields: {
179
+ getOneBanners(dataOld = []) {
180
+ return cache.writeQuery({ query: GET_ONE_BANNER_STORE, data: dataOld });
181
+ },
182
+ },
183
+ });
184
+ },
185
+ }).then(() => {
186
+ setPreviewImg(initialState);
187
+ });
188
+ }, [setPreviewImg, initialState, DeleteOneBanner]);
189
+
190
+ const onTargetClickLogo = useCallback((e) => {
191
+ e.preventDefault();
192
+ fileInputRefLogo.current.click();
193
+ }, []);
194
+
195
+ const onTargetClick = useCallback((e) => {
196
+ e.preventDefault();
197
+ fileInputRef.current.click();
198
+ }, []);
199
+
166
200
  return {
167
201
  fileInputRefLogo,
168
202
  src,
@@ -176,7 +210,6 @@ export const useImageStore = ({ idStore, sendNotification = () => { return } } =
176
210
  onTargetClickLogo,
177
211
  HandleDeleteBanner,
178
212
  handleInputChangeLogo,
179
- handleUpdateBanner
180
- }
181
- }
182
-
213
+ handleUpdateBanner,
214
+ };
215
+ };
@@ -8,29 +8,7 @@ export const CREATE_SCHEDULE_STORE = gql`
8
8
  }
9
9
  }
10
10
  `;
11
- export const GET_SCHEDULE_STORE = gql`
12
- query getStoreSchedules($schDay: Int, $idStore: ID) {
13
- getStoreSchedules(schDay: $schDay, idStore: $idStore) {
14
- schId
15
- idStore
16
- schDay
17
- schHoSta
18
- schHoEnd
19
- schState
20
- }
21
- }
22
- `;
23
- export const GET_ONE_SCHEDULE_STORE = gql`
24
- query getOneStoreSchedules($schDay: Int, $idStore: ID) {
25
- getOneStoreSchedules(schDay: $schDay, idStore: $idStore) {
26
- schId
27
- schDay
28
- schHoSta
29
- schHoEnd
30
- schState
31
- }
32
- }
33
- `;
11
+
34
12
  export const GET_CAT_OF_PRODUCTS = gql`
35
13
  query getAllCatOfProducts($idStore: ID) {
36
14
  getAllCatOfProducts(idStore: $idStore) {
@@ -174,11 +152,6 @@ export const GET_ALL_VISITOR_STORE = gql`
174
152
  }
175
153
  }
176
154
  `;
177
- export const GET_MIN_PEDIDO = gql`
178
- query getMinPrice($idStore: ID) {
179
- getMinPrice(idStore: $idStore)
180
- }
181
- `;
182
155
 
183
156
  export const GET_All_RATING_STORE = gql`
184
157
  query getAllRating($idStore: ID) {
@@ -25,4 +25,10 @@ export const useKeyPress = (targetKey) => {
25
25
  }, [targetKey])
26
26
 
27
27
  return keyPressed
28
- }
28
+ }
29
+
30
+ export function useMultiKeyPress(targetKeyA, targetKeyB) {
31
+ const keyPressedA = useKeyPress(targetKeyA)
32
+ const keyPressedB = useKeyPress(targetKeyB)
33
+ return keyPressedA && keyPressedB
34
+ }
@@ -1,6 +1,6 @@
1
1
  import { useState } from 'react'
2
2
 
3
- export default function useLocalStorage(key, initialValue) {
3
+ export const useLocalStorage= (key, initialValue) => {
4
4
  // const { setAlertBox } = useContext(Context)
5
5
  // State to store our value
6
6
  // Pass initial state function to useState so logic is only executed once
@@ -1,36 +1,33 @@
1
- import { useApolloClient } from '@apollo/client';
1
+ import { useApolloClient } from '@apollo/client'
2
2
  import { useState, useCallback } from 'react'
3
- import { useRouter } from 'next/router';
4
- import { Cookies } from '../../cookies';
3
+ import { useRouter } from 'next/router'
4
+ import { Cookies } from '../../cookies'
5
+ import { fetchJson } from '../../hooks/useFetchJson'
5
6
 
6
7
  export const useLogout = ({ setAlertBox = () => { } } = {}) => {
7
8
  const [loading, setLoading] = useState(false)
8
9
  const [error, setError] = useState(false)
9
- const router = useRouter();
10
- const client = useApolloClient();
10
+ const router = useRouter()
11
+ const client = useApolloClient()
11
12
 
12
13
  const onClickLogout = async () => {
13
14
  setLoading(true)
14
- await window
15
- .fetch(`${process.env.URL_BASE}api/auth/logout/`, {})
16
- .then(res => {
17
- if (res) {
18
- localStorage.removeItem('session');
19
- localStorage.removeItem('usuario');
20
- localStorage.removeItem('location');
21
- localStorage.removeItem('sessionGoogle');
22
- localStorage.removeItem('longitude');
23
- localStorage.removeItem('latitude');
24
- localStorage.removeItem('restaurant');
25
- Cookies.remove('vp.store');
26
- Cookies.remove('app.cart.sales');
27
- Cookies.remove('restaurant');
28
- client?.clearStore();
29
- router.replace('/entrar');
30
- setLoading(false);
31
- }
32
- })
33
- .catch(() => {
15
+ await fetchJson(`${process.env.URL_BASE}api/auth/logout`, {
16
+ }).then(res => {
17
+ localStorage.removeItem('session')
18
+ localStorage.removeItem('usuario')
19
+ localStorage.removeItem('location')
20
+ localStorage.removeItem('sessionGoogle')
21
+ localStorage.removeItem('longitude')
22
+ localStorage.removeItem('latitude')
23
+ localStorage.removeItem('restaurant')
24
+ Cookies.remove(process.env.SESSION_NAME)
25
+ Cookies.remove(process.env.LOCAL_SALES_STORE)
26
+ Cookies.remove('restaurant')
27
+ client?.clearStore()
28
+ router.replace('/entrar')
29
+ setLoading(false)
30
+ }).catch(() => {
34
31
  setError(true)
35
32
  setAlertBox({ message: 'Ocurrió un error al cerrar session' })
36
33
  })
@@ -0,0 +1,37 @@
1
+ import { useRouter } from 'next/router'
2
+
3
+ export const useManageQueryParams = () => {
4
+ const router = useRouter()
5
+
6
+ const handleQuery = (name, value = '') => {
7
+ router.push(
8
+ {
9
+ query: {
10
+ ...router.query,
11
+ [name]: value
12
+ }
13
+ },
14
+ undefined,
15
+ { shallow: true }
16
+ )
17
+ }
18
+
19
+ const handleCleanQuery = (name, value = '') => {
20
+ router.push(
21
+ {
22
+ query: {
23
+ ...router.query,
24
+ [name]: value || ''
25
+ }
26
+ },
27
+ undefined,
28
+ { shallow: true }
29
+ )
30
+ }
31
+
32
+
33
+ return {
34
+ handleQuery,
35
+ handleCleanQuery
36
+ }
37
+ }
@@ -420,6 +420,7 @@ export const GET_EXTRAS_PRODUCT_FOOD_OPTIONAL = gql`
420
420
  }
421
421
  }
422
422
  `;
423
+
423
424
  export const GET_EXTRAS_PRODUCT_FOOD_SUB_OPTIONAL = gql`
424
425
  mutation updateExtProductFoodsSubOptional(
425
426
  $input: InputExtProductFoodSubOptional
@@ -701,14 +702,6 @@ export const GET_BANNER_PROMO_DASHBOARD = gql`
701
702
  }
702
703
  `;
703
704
 
704
- export const CREATE_STORE_CALENDAR = gql`
705
- mutation setStoreSchedule($input: ITstoreSchedule!) {
706
- setStoreSchedule(input: $input) {
707
- message
708
- success
709
- }
710
- }
711
- `;
712
705
  export const DELETE_ONE_CAT_PRODUCTS = gql`
713
706
  mutation deleteCatOfProducts($idPc: ID!, $pState: Int) {
714
707
  deleteCatOfProducts(idPc: $idPc, pState: $pState) {
@@ -741,14 +734,8 @@ export const EDIT_EXTRA_PRODUCTS = gql`
741
734
  }
742
735
  }
743
736
  `;
744
- export const DELETE_CAT_EXTRA_PRODUCTS = gql`
745
- mutation DeleteExtProductFoodsOptional($opExPid: ID, $state: Int) {
746
- DeleteExtProductFoodsOptional(opExPid: $opExPid, state: $state) {
747
- success
748
- message
749
- }
750
- }
751
- `;
737
+
738
+
752
739
  export const DELETE_CAT_EXTRA_SUB_OPTIONAL_PRODUCTS = gql`
753
740
  mutation DeleteExtFoodSubsOptional($opSubExPid: ID, $state: Int) {
754
741
  DeleteExtFoodSubsOptional(opSubExPid: $opSubExPid, state: $state) {
@@ -1,6 +1,6 @@
1
- import { useMutation } from "@apollo/client"
2
- import { useState } from "react"
3
- import { REGISTER_TAGS_PRODUCT } from "./queriesStore"
1
+ import { useState } from 'react'
2
+ import { useMutation } from '@apollo/client'
3
+ import { REGISTER_TAGS_PRODUCT } from './queriesStore'
4
4
 
5
5
  export const useTagsProducts = () => {
6
6
  const [registerTag] = useMutation(REGISTER_TAGS_PRODUCT)
@@ -20,8 +20,33 @@ export const useTagsProducts = () => {
20
20
  {
21
21
  id: 4,
22
22
  tag: 'Bebida sin alcohol'
23
- }
24
- ]
23
+ },
24
+ {
25
+ id: 5,
26
+ tag: 'Entrante'
27
+ },
28
+ {
29
+ id: 6,
30
+ tag: 'Plato principal'
31
+ },
32
+ {
33
+ id: 7,
34
+ tag: 'Postre'
35
+ },
36
+ {
37
+ id: 8,
38
+ tag: 'Sopa'
39
+ },
40
+ {
41
+ id: 9,
42
+ tag: 'Ensalada'
43
+ },
44
+ {
45
+ id: 10,
46
+ tag: 'Mariscos'
47
+ },
48
+ ];
49
+
25
50
  const [tags, setTags] = useState({
26
51
  id: '',
27
52
  tag: ''
@@ -0,0 +1,3 @@
1
+ export * from './useProvidersCreateStore'
2
+ export * from './useProvidersDataStore'
3
+ export * from './queries'
@@ -0,0 +1,31 @@
1
+ import { gql } from '@apollo/client'
2
+
3
+ export const CREATE_PROVIDERS = gql`
4
+ mutation registerProviders($input: IProviders) {
5
+ registerProviders(input: $input) {
6
+ success
7
+ message
8
+ }
9
+ }
10
+ `
11
+ export const GET_ALL_PROVIDERS = gql`
12
+ query getAllProviders($idStore: ID,$search: String, $min: Int, $max: Int $fromDate: DateTime, $toDate: DateTime ) {
13
+ getAllProviders(idStore: $idStore, search: $search, min: $min, max: $max, toDate: $toDate, fromDate: $fromDate) {
14
+ idProvider
15
+ idStore
16
+ prImage
17
+ prPathImage
18
+ PrNit
19
+ prName
20
+ PrNumberPhone
21
+ PrNumberIdentity
22
+ PrAdres
23
+ PrMail
24
+ TotalBysPr
25
+ TotalDeuda
26
+ prState
27
+ DatCre
28
+ DatMod
29
+ }
30
+ }
31
+ `
@@ -0,0 +1,13 @@
1
+ import { useMutation } from "@apollo/client"
2
+ import { CREATE_PROVIDERS } from "../queries"
3
+
4
+ export const useProvidersCreateStore = ({ setAlertBox = () => { return } } = {}) => {
5
+
6
+ const [registerProviders, { loading, error }] = useMutation(CREATE_PROVIDERS, {
7
+ onCompleted: (data) => {
8
+ setAlertBox({ message: `${data.registerProviders.message}` })
9
+ }
10
+ })
11
+
12
+ return [registerProviders, { loading, error }]
13
+ }
@@ -0,0 +1,24 @@
1
+ import { useQuery } from "@apollo/client"
2
+ import { GET_ALL_PROVIDERS } from "../queries"
3
+
4
+ export const useProvidersStore = () => {
5
+ const {
6
+ data,
7
+ fetchMore,
8
+ loading,
9
+ error,
10
+ called
11
+ } = useQuery(GET_ALL_PROVIDERS, {
12
+ fetchPolicy: 'cache-and-network',
13
+ notifyOnNetworkStatusChange: true,
14
+ nextFetchPolicy: 'cache-first',
15
+ refetchWritePolicy: 'merge'
16
+ })
17
+ const providerData = data?.getAllProviders || []
18
+ return [providerData, {
19
+ fetchMore,
20
+ called,
21
+ error,
22
+ loading
23
+ }]
24
+ }