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
@@ -0,0 +1,80 @@
1
+ import { gql } from '@apollo/client'
2
+
3
+ export const GET_ALL_PEDIDOS_STATUS = gql`
4
+ query getAllPedidoUserFinal($id: ID) {
5
+ getAllPedidoUserFinal(id: $id) {
6
+ pdpId
7
+ idStore
8
+ pCodeRef
9
+ payMethodPState
10
+ pPRecoger
11
+ totalProductsPrice
12
+ pSState
13
+ getOneStore {
14
+ idStore
15
+ cId
16
+ id
17
+ dId
18
+ ctId
19
+ neighborhoodStore
20
+ Viaprincipal
21
+ storeOwner
22
+ storeName
23
+ emailStore
24
+ storePhone
25
+ Image
26
+ pais {
27
+ cId
28
+ cName
29
+ }
30
+ city {
31
+ ctId
32
+ cName
33
+ dId
34
+ }
35
+ department {
36
+ dId
37
+ cId
38
+ dName
39
+ }
40
+ }
41
+ pDatCre
42
+ locationUser
43
+ pDatMod
44
+ getAllPedidoStore {
45
+ pdpId
46
+ pId
47
+ idStore
48
+ ShoppingCard
49
+ pCodeRef
50
+ pPStateP
51
+ payMethodPState
52
+ pPRecoger
53
+ pDatCre
54
+ pDatMod
55
+ getAllShoppingCard {
56
+ ShoppingCard
57
+ comments
58
+ cantProducts
59
+ pId
60
+ productFood {
61
+ pId
62
+ carProId
63
+ colorId
64
+ idStore
65
+ pName
66
+ ProPrice
67
+ ProDescuento
68
+ ProDescription
69
+ ValueDelivery
70
+ ProImage
71
+ ProStar
72
+ pState
73
+ pDatCre
74
+ pDatMod
75
+ }
76
+ }
77
+ }
78
+ }
79
+ }
80
+ `
@@ -1,61 +1,76 @@
1
- import { useState, useEffect } from 'react';
2
- import { useApolloClient, useQuery } from '@apollo/client';
3
- import { GET_ONE_STORE } from './queries'; // Reemplaza con la importación correcta de tu consulta
1
+ import { useState, useEffect } from 'react'
2
+ import { useApolloClient, useQuery } from '@apollo/client'
3
+ import { GET_ONE_STORE, GET_ONE_STORE_BY_ID } from './queries' // Reemplaza con la importación correcta de tu consulta
4
4
  import { errorHandler } from '../../config/client'
5
5
  import { useLogout } from '../useLogout'
6
6
 
7
- export const useStore = () => {
8
- const [store, setStore] = useState({});
9
- const client = useApolloClient();
10
- const [onClickLogout, { loading: load, error: err }] = useLogout();
7
+ export const useStore = ({ isClient = false, idStore = '' } = {}) => {
8
+ const { data, refetch, loading: loadingClient, error: errorStoreClient } = useQuery(GET_ONE_STORE_BY_ID, {
9
+ skip: !isClient,
10
+ variables: {
11
+ idStore
12
+ }
13
+ })
14
+
15
+ const [store, setStore] = useState({})
16
+ const client = useApolloClient()
17
+ const [onClickLogout, { loading: load }] = useLogout()
11
18
 
12
19
  // Intentar leer los datos de la caché
13
- const cachedData = client.readQuery({ query: GET_ONE_STORE });
20
+ const cachedData = client.readQuery({ query: GET_ONE_STORE })
14
21
 
15
22
  useEffect(() => {
16
23
  if (cachedData) {
17
24
  // Comprobar si los datos de la caché ya están establecidos en el estado
18
25
  if (!store || Object.keys(store).length === 0) {
19
- setStore(cachedData.getStore);
26
+ setStore(cachedData.getStore)
20
27
  }
21
28
  }
22
- }, [cachedData, store]);
29
+ }, [cachedData, store])
23
30
 
24
31
  const { loading, error } = useQuery(GET_ONE_STORE, {
32
+ skip: isClient,
25
33
  fetchPolicy: 'cache-first',
26
34
  onCompleted: (data) => {
27
- const { getStore } = data || {};
28
- setStore(getStore);
35
+ const { getStore } = data || {}
36
+ setStore(getStore)
29
37
  },
30
38
  onError: (err) => {
31
39
  if (err.networkError && err.networkError.result) {
32
- const response = errorHandler(err.networkError.result);
40
+ const response = errorHandler(err.networkError.result)
33
41
  if (response) {
34
- onClickLogout();
42
+ onClickLogout()
35
43
  }
36
44
  }
37
- },
38
- });
45
+ }
46
+ })
39
47
 
40
48
  // Ejecutar la consulta y almacenarla en la caché
41
49
  useEffect(() => {
42
50
  client.query({ query: GET_ONE_STORE }).then(() => {
43
51
  // Leer la consulta desde la caché
44
- const cacheData = client.readQuery({ query: GET_ONE_STORE });
52
+ const cacheData = client.readQuery({ query: GET_ONE_STORE })
45
53
  setStore(cacheData?.getStore)
46
- });
47
- }, [client]);
54
+ })
55
+ }, [client])
48
56
 
49
57
  // Actualizar manualmente la caché después de cada petición exitosa
50
58
  useEffect(() => {
51
59
  if (!loading && !error && !cachedData) {
52
60
  client.writeQuery({
53
61
  query: GET_ONE_STORE,
54
- data: { getStore: store },
55
- });
62
+ data: { getStore: store }
63
+ })
56
64
  }
57
- }, [loading, error, cachedData, client, store]);
58
-
59
- return [store, { loading: load || loading, error }];
60
- };
65
+ }, [loading, error, cachedData, client, store])
61
66
 
67
+ if (isClient) {
68
+ const dataOneStoreClient = !loadingClient ? data?.getOneStore : {}
69
+ return [dataOneStoreClient, {
70
+ refetch,
71
+ loading: loadingClient,
72
+ error: errorStoreClient
73
+ }]
74
+ }
75
+ return [store, { loading: load || loading, error }]
76
+ }
@@ -1,136 +1,162 @@
1
- import { gql } from '@apollo/client'
2
-
3
- export const CREATE_ONE_STORE = gql`
4
- mutation newRegisterStore($input: IStore){
5
- newRegisterStore(input: $input){
6
- success
7
- message
8
- idStore
9
- }
10
- }
11
- `
12
- export const GET_ONE_STORE = gql`
13
- query getStore($id: ID){
14
- getStore(id: $id ){
15
- cId
16
- id
17
- dId
18
- idStore
19
- ctId
20
- neighborhoodStore
21
- Viaprincipal
22
- catStore
23
- storeOwner
24
- storeName
25
- ImageName
26
- emailStore
27
- storePhone
28
- socialRaz
29
- Image
30
- banner
31
-
32
- documentIdentifier
33
- uPhoNum
34
- storeName
35
- ULocation
36
- upLat
37
- upLon
38
- uState
39
- siteWeb
40
-
41
- description
42
- createdAt
43
- secVia
44
- NitStore
45
- typeRegiments
46
- typeContribute
47
- addressStore
48
- pais {
49
- cId
50
- cName
51
- cCalCod
52
- cState
53
- cDatCre
54
- cDatMod
55
- }
56
- city {
57
- ctId
58
- dId
59
- cName
60
- cState
61
- cDatCre
62
- cDatMod
63
- }
64
- department {
65
- dId
66
- cId
67
- dName
68
- dState
69
- dDatCre
70
- dDatMod
71
- }
72
- getStoreSchedules {
73
- idStore
74
- schId
75
- id
76
- schDay
77
- schHoSta
78
- schHoEnd
79
- schState
80
- }
81
- cateStore {
82
- catStore
83
- cName
84
- cState
85
- cDatCre
86
- cDatMod
87
- csDescription
88
-
89
- }
90
- }
91
- }
92
- `
93
- export const GET_ONE_STORE_BY_ID = gql`
94
- query getOneStore($idStore: ID){
95
- getOneStore(idStore: $idStore ){
96
- cId
97
- id
98
- dId
99
- idStore
100
- ctId
101
- neighborhoodStore
102
- Viaprincipal
103
- catStore
104
- storeOwner
105
- storeName
106
- emailStore
107
- storePhone
108
- socialRaz
109
- Image
110
- banner
111
- documentIdentifier
112
- uPhoNum
113
- ULocation
114
- upLat
115
- upLon
116
- uState
117
- siteWeb
118
- description
119
- secVia
120
- NitStore
121
- typeRegiments
122
- typeContribute
123
- addressStore
124
- createAt
125
- cateStore {
126
- catStore
127
- cName
128
- cState
129
- cDatCre
130
- cDatMod
131
- csDescription
132
-
133
- }
134
- }
135
- }
136
- `
1
+ import { gql } from '@apollo/client'
2
+
3
+ export const CREATE_ONE_STORE = gql`
4
+ mutation newRegisterStore($input: IStore){
5
+ newRegisterStore(input: $input){
6
+ success
7
+ message
8
+ idStore
9
+ }
10
+ }
11
+ `
12
+
13
+ export const GET_ONE_STORE = gql`
14
+ query getStore($id: ID, $idStore: ID){
15
+ getStore(id: $id, idStore: $idStore){
16
+ cId
17
+ id
18
+ dId
19
+ idStore
20
+ ctId
21
+ neighborhoodStore
22
+ Viaprincipal
23
+ catStore
24
+ storeOwner
25
+ storeName
26
+ ImageName
27
+ emailStore
28
+ storePhone
29
+ socialRaz
30
+ Image
31
+ banner
32
+
33
+ documentIdentifier
34
+ uPhoNum
35
+ storeName
36
+ ULocation
37
+ upLat
38
+ upLon
39
+ uState
40
+ siteWeb
41
+
42
+ description
43
+ createdAt
44
+ secVia
45
+ NitStore
46
+ typeRegiments
47
+ typeContribute
48
+ addressStore
49
+ pais {
50
+ cId
51
+ cName
52
+ cCalCod
53
+ cState
54
+ cDatCre
55
+ cDatMod
56
+ }
57
+ city {
58
+ ctId
59
+ dId
60
+ cName
61
+ cState
62
+ cDatCre
63
+ cDatMod
64
+ }
65
+ department {
66
+ dId
67
+ cId
68
+ dName
69
+ dState
70
+ dDatCre
71
+ dDatMod
72
+ }
73
+ getStoreSchedules {
74
+ idStore
75
+ schId
76
+ id
77
+ schDay
78
+ schHoSta
79
+ schHoEnd
80
+ schState
81
+ }
82
+ cateStore {
83
+ catStore
84
+ cName
85
+ cState
86
+ cDatCre
87
+ cDatMod
88
+ csDescription
89
+
90
+ }
91
+ }
92
+ }
93
+ `
94
+ export const GET_ONE_STORE_BY_ID = gql`
95
+ query getOneStore($StoreName: String, $idStore: ID){
96
+ getOneStore(idStore: $idStore, StoreName: $StoreName) {
97
+ idStore
98
+ cId
99
+ id
100
+ dId
101
+ ctId
102
+ catStore
103
+ neighborhoodStore
104
+ Viaprincipal
105
+ storeOwner
106
+ storeName
107
+ emailStore
108
+ storePhone
109
+ socialRaz
110
+ Image
111
+ banner
112
+ documentIdentifier
113
+ uPhoNum
114
+ ULocation
115
+ upLat
116
+ upLon
117
+ uState
118
+ siteWeb
119
+ description
120
+ NitStore
121
+ typeRegiments
122
+ typeContribute
123
+ secVia
124
+ addressStore
125
+ createdAt
126
+ pais{
127
+ cId
128
+ cName
129
+ cCalCod
130
+ cState
131
+ cDatCre
132
+ cDatMod
133
+ }
134
+ city {
135
+ ctId
136
+ dId
137
+ cName
138
+ cState
139
+ cDatCre
140
+ cDatMod
141
+ }
142
+ department {
143
+ dId
144
+ cId
145
+ dName
146
+ dState
147
+ dDatCre
148
+ dDatMod
149
+ }
150
+ cateStore {
151
+ catStore
152
+ idUser
153
+ cName
154
+ cState
155
+ cDatCre
156
+ cDatMod
157
+ csDescription
158
+
159
+ }
160
+ }
161
+ }
162
+ `
@@ -1,7 +1,5 @@
1
-
2
- export const useStoreCalendar = () => {
3
- return {
4
- true: true,
5
- }
6
- }
7
-
1
+ export const useStoreCalendar = () => {
2
+ return {
3
+ true: true
4
+ }
5
+ }
@@ -1,46 +1,46 @@
1
1
  import { useQuery, useMutation, useLazyQuery } from '@apollo/client'
2
2
  import { useState } from 'react'
3
- import {
4
- GET_ALL_CONTACTS,
5
- EDIT_ONE_CONTACT,
6
- CREATE_CONTACTS,
3
+ import {
4
+ GET_ALL_CONTACTS,
5
+ EDIT_ONE_CONTACT,
6
+ CREATE_CONTACTS,
7
7
  GET_ONE_CONTACT
8
8
  } from './queries'
9
9
 
10
10
  export const useGetStoreContacts = ({
11
- sendNotification = () => { return },
11
+ sendNotification = () => { },
12
12
  max,
13
13
  search = ''
14
14
  } = {}) => {
15
- const [clientes, setUseStoreContacts] = useState([])
16
- const { loading, error, fetchMore, called } = useQuery(GET_ALL_CONTACTS, {
17
- variables: {
18
- "max": max,
19
- "search": search
20
- },
15
+ const [clientes, setUseStoreContacts] = useState([])
16
+ const { loading, error, fetchMore, called } = useQuery(GET_ALL_CONTACTS, {
17
+ variables: {
18
+ max,
19
+ search
20
+ },
21
21
  onCompleted: (data) => {
22
- setUseStoreContacts(data)
22
+ setUseStoreContacts(data)
23
23
  }
24
24
  })
25
25
  return [clientes?.getAllContacts || [], { loading: called ? false : loading, error, fetchMore }]
26
26
  }
27
27
 
28
- export const useDeleteUseStoreContacts = ({ sendNotification = () => { return } } = {}) => {
28
+ export const useDeleteUseStoreContacts = ({ sendNotification = () => { } } = {}) => {
29
29
  const [getOneContacts, { data, error, loading }] = useLazyQuery(GET_ONE_CONTACT)
30
30
  return [getOneContacts, data?.getOneContacts ?? {}, { loading, error }]
31
31
  }
32
32
 
33
- export const useGetOneUseStoreContacts = ({ sendNotification = () => { return } } = {}) => {
33
+ export const useGetOneUseStoreContacts = ({ sendNotification = () => { } } = {}) => {
34
34
  const [getOneContacts, { data, error, loading }] = useLazyQuery(GET_ONE_CONTACT)
35
35
  return [getOneContacts, { data: data?.getOneContacts, loading, error }]
36
36
  }
37
37
 
38
- export const useEditOneUseStoreContacts = ({ sendNotification = () => { return } } = {}) => {
38
+ export const useEditOneUseStoreContacts = ({ sendNotification = () => { } } = {}) => {
39
39
  const [editOneContacts, { data, error, loading }] = useMutation(EDIT_ONE_CONTACT)
40
40
  return [editOneContacts, { data: data?.editOneContacts, loading, error }]
41
41
  }
42
42
 
43
- export const useCreateContacts = ({ sendNotification = () => { return } } = {}) => {
43
+ export const useCreateContacts = ({ sendNotification = () => { } } = {}) => {
44
44
  const [createUseStoreContacts, { loading, error }] = useMutation(CREATE_CONTACTS)
45
45
 
46
46
  return [createUseStoreContacts, { loading, error }]
@@ -45,4 +45,4 @@ mutation editOneContacts($input: IContacts) {
45
45
  message
46
46
  }
47
47
  }
48
- `
48
+ `
@@ -1,39 +1,39 @@
1
- import { useEffect, useState } from 'react'
2
-
3
- const DATE_UNITS = [
4
- ['day', 86400],
5
- ['hour', 3600],
6
- ['minute', 60],
7
- ['second', 1]
8
- ]
9
-
10
- const getDateDiffs = (timestamp) => {
11
- const now = Date.now()
12
- const elapsed = (timestamp - now) / 1000
13
-
14
- for (const [unit, secondsInUnit] of DATE_UNITS) {
15
- if (Math.abs(elapsed) > secondsInUnit || unit === 'second') {
16
- const value = Math.round(elapsed / secondsInUnit)
17
- return { value, unit }
18
- }
19
- }
20
- }
21
-
22
- export const useTimeAgo = (timestamp) => {
23
- const [timeAgo, setTimeAgo] = useState(() => { return getDateDiffs(timestamp) })
24
-
25
- useEffect(() => {
26
- const interval = setInterval(() => {
27
- const newTimeAgo = getDateDiffs(timestamp)
28
- setTimeAgo(newTimeAgo)
29
- }, 5000)
30
-
31
- return () => { return clearInterval(interval) }
32
- }, [timestamp])
33
-
34
- const rtf = new Intl.RelativeTimeFormat('es', { style: 'short' })
35
-
36
- const { value, unit } = timeAgo
37
-
38
- return rtf && rtf?.format(value, unit)
39
- }
1
+ import { useEffect, useState } from 'react'
2
+
3
+ const DATE_UNITS = [
4
+ ['day', 86400],
5
+ ['hour', 3600],
6
+ ['minute', 60],
7
+ ['second', 1]
8
+ ]
9
+
10
+ const getDateDiffs = (timestamp) => {
11
+ const now = Date.now()
12
+ const elapsed = (timestamp - now) / 1000
13
+
14
+ for (const [unit, secondsInUnit] of DATE_UNITS) {
15
+ if (Math.abs(elapsed) > secondsInUnit || unit === 'second') {
16
+ const value = Math.round(elapsed / secondsInUnit)
17
+ return { value, unit }
18
+ }
19
+ }
20
+ }
21
+
22
+ export const useTimeAgo = (timestamp) => {
23
+ const [timeAgo, setTimeAgo] = useState(() => { return getDateDiffs(timestamp) })
24
+
25
+ useEffect(() => {
26
+ const interval = setInterval(() => {
27
+ const newTimeAgo = getDateDiffs(timestamp)
28
+ setTimeAgo(newTimeAgo)
29
+ }, 5000)
30
+
31
+ return () => { return clearInterval(interval) }
32
+ }, [timestamp])
33
+
34
+ const rtf = new Intl.RelativeTimeFormat('es', { style: 'short' })
35
+
36
+ const { value, unit } = timeAgo
37
+
38
+ return rtf && rtf?.format(value, unit)
39
+ }