npm-pkg-hook 1.12.3 → 1.12.7

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 (315) hide show
  1. package/dist/index.cjs +20089 -0
  2. package/dist/index.js +19854 -0
  3. package/dist/index.mjs +19854 -0
  4. package/package.json +28 -6
  5. package/.babelrc +0 -0
  6. package/.env +0 -5
  7. package/.eslintrc.js +0 -38
  8. package/.eslintrc.json +0 -127
  9. package/.github/pull_request_template.md +0 -18
  10. package/.github/workflows/pepeline.yaml +0 -30
  11. package/expire.json +0 -1
  12. package/jsconfig.json +0 -28
  13. package/script.txt +0 -7
  14. package/src/config/client/errors.js +0 -26
  15. package/src/config/client/index.js +0 -1
  16. package/src/config/content/en.json +0 -5
  17. package/src/config/content/es.json +0 -5
  18. package/src/config/content/index.js +0 -16
  19. package/src/cookies/index.js +0 -3
  20. package/src/hooks/addTenMinutes/index.js +0 -14
  21. package/src/hooks/calculateLogLatHaversine/index.js +0 -30
  22. package/src/hooks/completeSchedules/index.js +0 -22
  23. package/src/hooks/convertToMilitaryTime/index.js +0 -14
  24. package/src/hooks/generateStoreURL/index.js +0 -38
  25. package/src/hooks/generateTemplate/index.js +0 -62
  26. package/src/hooks/getCardType/index.js +0 -24
  27. package/src/hooks/getCategoriesWithProduct/helpers/index.js +0 -7
  28. package/src/hooks/getCategoriesWithProduct/index.js +0 -62
  29. package/src/hooks/getGlobalSession/index.js +0 -49
  30. package/src/hooks/getSession/index.js +0 -18
  31. package/src/hooks/getTodayTimestamps/index.js +0 -64
  32. package/src/hooks/getTotalHours/index.js +0 -48
  33. package/src/hooks/handleLogin/index.js +0 -10
  34. package/src/hooks/index.ts +0 -146
  35. package/src/hooks/isTokenExpired/index.js +0 -17
  36. package/src/hooks/newMessageSubscription/index.js +0 -28
  37. package/src/hooks/newStoreOrderSubscription/index.js +0 -26
  38. package/src/hooks/statusOpenStores/helpers/index.js +0 -101
  39. package/src/hooks/statusOpenStores/index.js +0 -156
  40. package/src/hooks/updateExtProductFoodsOptional/index.js +0 -40
  41. package/src/hooks/useAcumulateDate/index.js +0 -16
  42. package/src/hooks/useAllStoresPendingToRegister/index.js +0 -34
  43. package/src/hooks/useAmountInput/index.ts +0 -117
  44. package/src/hooks/useAnimationFrame/index.js +0 -45
  45. package/src/hooks/useAnimationText/index.jsx +0 -31
  46. package/src/hooks/useAsideCart/helpers/index.js +0 -22
  47. package/src/hooks/useAsideCart/index.js +0 -214
  48. package/src/hooks/useAsideCart/queries.js +0 -10
  49. package/src/hooks/useBanner/index.js +0 -19
  50. package/src/hooks/useCart/index.js +0 -2
  51. package/src/hooks/useCart/queries.js +0 -174
  52. package/src/hooks/useCart/useCart/helpers/index.js +0 -75
  53. package/src/hooks/useCart/useCart/index.js +0 -412
  54. package/src/hooks/useCart/useGetCart/index.js +0 -33
  55. package/src/hooks/useCatWithProduct/index.js +0 -48
  56. package/src/hooks/useCatWithProduct/queries.js +0 -200
  57. package/src/hooks/useCatWithProductClient/index.js +0 -56
  58. package/src/hooks/useCatWithProductClient/queries.js +0 -56
  59. package/src/hooks/useCategoriesProduct/index.js +0 -13
  60. package/src/hooks/useCategoriesProduct/queries.js +0 -16
  61. package/src/hooks/useCategoryInStore/index.js +0 -100
  62. package/src/hooks/useCategoryInStore/queries.js +0 -78
  63. package/src/hooks/useCategoryStore/index.js +0 -7
  64. package/src/hooks/useCategoryStore/queries.js +0 -16
  65. package/src/hooks/useChartData/index.js +0 -170
  66. package/src/hooks/useChartData/useChartData/index.js +0 -199
  67. package/src/hooks/useChartData/useChartDataAllOrders/index.js +0 -94
  68. package/src/hooks/useChatRoomSubscription/index.js +0 -28
  69. package/src/hooks/useCheckbox/index.js +0 -115
  70. package/src/hooks/useCities/index.js +0 -13
  71. package/src/hooks/useCities/queries.js +0 -12
  72. package/src/hooks/useClients/index.js +0 -96
  73. package/src/hooks/useClients/queries.js +0 -212
  74. package/src/hooks/useColorByLetters/helpers/alea.js +0 -54
  75. package/src/hooks/useColorByLetters/helpers/colors.js +0 -45
  76. package/src/hooks/useColorByLetters/helpers/index.js +0 -18
  77. package/src/hooks/useColorByLetters/helpers/mersenne_twister.js +0 -118
  78. package/src/hooks/useColorByLetters/index.js +0 -27
  79. package/src/hooks/useConnection/index.js +0 -24
  80. package/src/hooks/useCountries/index.js +0 -19
  81. package/src/hooks/useCountries/queries.js +0 -12
  82. package/src/hooks/useCreateDeliveryTime/index.js +0 -51
  83. package/src/hooks/useCreateOrderStatusType/index.ts +0 -132
  84. package/src/hooks/useCreateProduct/helpers/index.js +0 -23
  85. package/src/hooks/useCreateProduct/helpers/manageCacheDataCatProduct/index.js +0 -52
  86. package/src/hooks/useCreateProduct/helpers/useEditImageProduct/index.js +0 -176
  87. package/src/hooks/useCreateProduct/index.js +0 -334
  88. package/src/hooks/useCreateStorePendingToRegister/index.js +0 -13
  89. package/src/hooks/useCreateStorePendingToRegister/queries.js +0 -10
  90. package/src/hooks/useDashboardComponents/index.js +0 -50
  91. package/src/hooks/useDeleteExtraProductFoods/index.js +0 -12
  92. package/src/hooks/useDeleteSubProductOptional/index.js +0 -30
  93. package/src/hooks/useDeleteSubProductOptional/queries.js +0 -10
  94. package/src/hooks/useDeliveryTime/index.js +0 -27
  95. package/src/hooks/useDepartments/index.js +0 -13
  96. package/src/hooks/useDepartments/queries.js +0 -13
  97. package/src/hooks/useDessert/helpers/index.js +0 -51
  98. package/src/hooks/useDessert/index.js +0 -525
  99. package/src/hooks/useDessertWithPrice/helpers/index.js +0 -76
  100. package/src/hooks/useDessertWithPrice/index.js +0 -373
  101. package/src/hooks/useDessertWithPrice/queries.js +0 -18
  102. package/src/hooks/useDevWS/index.ts +0 -53
  103. package/src/hooks/useDevices/index.js +0 -2
  104. package/src/hooks/useDevices/queries.js +0 -28
  105. package/src/hooks/useDevices/useGetDevices.js +0 -28
  106. package/src/hooks/useDevices/useRegisterDevices.js +0 -75
  107. package/src/hooks/useDownloadReports/helpers/downloadFileFromResponse.ts +0 -21
  108. package/src/hooks/useDownloadReports/index.ts +0 -2
  109. package/src/hooks/useDownloadReports/useDownloadReportByDay/index.ts +0 -103
  110. package/src/hooks/useDownloadReports/useGetReportByDateRange/index.ts +0 -115
  111. package/src/hooks/useDrag/index.js +0 -63
  112. package/src/hooks/useDropzone/index.js +0 -94
  113. package/src/hooks/useDynamicAuth/index.js +0 -13
  114. package/src/hooks/useDynamicAuth/queries.js +0 -24
  115. package/src/hooks/useEditCategory/index.js +0 -41
  116. package/src/hooks/useEditOneExtProductFoodOptional/index.js +0 -28
  117. package/src/hooks/useEditOneExtProductFoodOptional/queries.js +0 -16
  118. package/src/hooks/useEditSubProductOptional/index.js +0 -11
  119. package/src/hooks/useEditSubProductOptional/queries.js +0 -10
  120. package/src/hooks/useEmployee/index.js +0 -17
  121. package/src/hooks/useEmployee/queries.js +0 -85
  122. package/src/hooks/useEmployee/useCreateEmployee.js +0 -86
  123. package/src/hooks/useEvent/index.js +0 -34
  124. package/src/hooks/useFavoriteStores/index.js +0 -29
  125. package/src/hooks/useFavoriteStores/queries.js +0 -54
  126. package/src/hooks/useFetchJson/index.js +0 -25
  127. package/src/hooks/useFetchMoreInteractions/index.jsx +0 -39
  128. package/src/hooks/useFingerprintjs/index.js +0 -172
  129. package/src/hooks/useFormTools/index.js +0 -116
  130. package/src/hooks/useFormatDate/index.js +0 -86
  131. package/src/hooks/useFormatNumberPhone/index.js +0 -23
  132. package/src/hooks/useFullScreenMode/index.js +0 -65
  133. package/src/hooks/useGenerateNumberArray/index.js +0 -17
  134. package/src/hooks/useGetAllLocationUser/index.js +0 -12
  135. package/src/hooks/useGetAllLocationUser/queries.js +0 -44
  136. package/src/hooks/useGetCookies/index.js +0 -43
  137. package/src/hooks/useGetExtProductFoodsSubOptionalAll/index.js +0 -14
  138. package/src/hooks/useGetFoodRecomended/index.js +0 -32
  139. package/src/hooks/useGetFoodRecomended/queries.js +0 -47
  140. package/src/hooks/useGetMessagesToRoom/index.js +0 -23
  141. package/src/hooks/useGetMinPrice/index.js +0 -12
  142. package/src/hooks/useGetMinPrice/queries.js +0 -7
  143. package/src/hooks/useGetOneStoreRating/index.js +0 -40
  144. package/src/hooks/useGetOneStoreRating/queries.js +0 -18
  145. package/src/hooks/useGetSalesAmountToday/index.js +0 -31
  146. package/src/hooks/useGetStoreCookie/index.js +0 -21
  147. package/src/hooks/useGoogleLogin/index.js +0 -160
  148. package/src/hooks/useGoogleLogin/loadScript.js +0 -15
  149. package/src/hooks/useGoogleLogin/removeScript.js +0 -7
  150. package/src/hooks/useHover/index.js +0 -29
  151. package/src/hooks/useImageOptimization/index.js +0 -28
  152. package/src/hooks/useImageUploaderProduct/helper/canvasUtils.ts +0 -130
  153. package/src/hooks/useImageUploaderProduct/helper/getOrientation.ts +0 -53
  154. package/src/hooks/useImageUploaderProduct/helper/index.ts +0 -5
  155. package/src/hooks/useImageUploaderProduct/index.ts +0 -292
  156. package/src/hooks/useImageWeight/index.js +0 -51
  157. package/src/hooks/useImagesStore/index.js +0 -225
  158. package/src/hooks/useImagesStore/queries.js +0 -193
  159. package/src/hooks/useImagesStore/utils/index.js +0 -4
  160. package/src/hooks/useIncomingOrders/index.js +0 -10
  161. package/src/hooks/useIncomingOrders/queries.js +0 -87
  162. package/src/hooks/useInnerHtml/index.js +0 -39
  163. package/src/hooks/useIntersection/index.js +0 -84
  164. package/src/hooks/useInventory/index.js +0 -2
  165. package/src/hooks/useInventory/queries.js +0 -58
  166. package/src/hooks/useInventory/useGetProductsInStock.js +0 -15
  167. package/src/hooks/useInventory/useUpdateManageStock.js +0 -41
  168. package/src/hooks/useKeypress/index.js +0 -28
  169. package/src/hooks/useLazyScript/index.js +0 -71
  170. package/src/hooks/useLocalBackendIp/index.js +0 -34
  171. package/src/hooks/useLocalSorage/index.js +0 -36
  172. package/src/hooks/useLocationManager/index.js +0 -63
  173. package/src/hooks/useLocationNavigate/index.js +0 -54
  174. package/src/hooks/useLoginEmployeeInStore/index.js +0 -38
  175. package/src/hooks/useLogout/helpers/BroadcastChannel.js +0 -31
  176. package/src/hooks/useLogout/helpers/apiBaseUrl.js +0 -8
  177. package/src/hooks/useLogout/helpers/fetchData.js +0 -28
  178. package/src/hooks/useLogout/helpers/getCsrfToken.js +0 -30
  179. package/src/hooks/useLogout/helpers/index.js +0 -57
  180. package/src/hooks/useLogout/helpers/logger.js +0 -70
  181. package/src/hooks/useLogout/helpers/parseUrl.js +0 -36
  182. package/src/hooks/useLogout/index.js +0 -96
  183. package/src/hooks/useManageNewOrder/helpers/index.js +0 -45
  184. package/src/hooks/useManageNewOrder/helpers/mock.js +0 -0
  185. package/src/hooks/useManageNewOrder/index.js +0 -102
  186. package/src/hooks/useManageQueryParams/index.js +0 -40
  187. package/src/hooks/useMobile/index.js +0 -65
  188. package/src/hooks/useModules/helpers/index.js +0 -1
  189. package/src/hooks/useModules/helpers/validateModules.js +0 -29
  190. package/src/hooks/useModules/index.js +0 -58
  191. package/src/hooks/useMouse/index.ts +0 -50
  192. package/src/hooks/useMutateHeight/index.js +0 -36
  193. package/src/hooks/useOrderClient/index.js +0 -5
  194. package/src/hooks/useOrderStatusTypes/index.ts +0 -2
  195. package/src/hooks/useOrderStatusTypes/useOrderStatusTypes/index.ts +0 -133
  196. package/src/hooks/useOrderStatusTypes/useUpdateOrderStatusPriorities/index.ts +0 -97
  197. package/src/hooks/useOrders/index.js +0 -3
  198. package/src/hooks/useOrders/queries.js +0 -89
  199. package/src/hooks/useOrders/useChangeOrderState/index.ts +0 -125
  200. package/src/hooks/useOrders/useOrdersFromStore/index.ts +0 -77
  201. package/src/hooks/usePWAInstall/index.js +0 -38
  202. package/src/hooks/usePortFetcher/index.ts +0 -33
  203. package/src/hooks/useProductsFood/index.js +0 -253
  204. package/src/hooks/useProductsFood/queriesStore.js +0 -964
  205. package/src/hooks/useProductsFood/useEditProduct.js +0 -48
  206. package/src/hooks/useProductsFood/usetagsProducts.js +0 -98
  207. package/src/hooks/useProviders/index.js +0 -3
  208. package/src/hooks/useProviders/queries.js +0 -31
  209. package/src/hooks/useProviders/useProvidersCreateStore/index.js +0 -12
  210. package/src/hooks/useProviders/useProvidersDataStore/index.js +0 -24
  211. package/src/hooks/useProvidersStore/index.js +0 -24
  212. package/src/hooks/useProvidersStore/queries.js +0 -31
  213. package/src/hooks/usePushNotificationOrder/index.js +0 -52
  214. package/src/hooks/usePushNotifications/helpers/index.js +0 -114
  215. package/src/hooks/usePushNotifications/index.js +0 -149
  216. package/src/hooks/useQueryLocationsMap/index.js +0 -19
  217. package/src/hooks/useQueryLocationsMap/queries.js +0 -40
  218. package/src/hooks/useRatingArrayData/index.js +0 -54
  219. package/src/hooks/useRatingArrayData/queries.js +0 -19
  220. package/src/hooks/useReactToPrint/index.js +0 -1223
  221. package/src/hooks/useRemoveExtraProductFoodsOptional/index.js +0 -23
  222. package/src/hooks/useRemoveExtraProductFoodsOptional/queries.js +0 -48
  223. package/src/hooks/useReport/index.js +0 -47
  224. package/src/hooks/useReport/queries.js +0 -123
  225. package/src/hooks/useRestaurant/helpers/index.js +0 -24
  226. package/src/hooks/useRestaurant/helpers/manageStatusOpen.js +0 -26
  227. package/src/hooks/useRestaurant/index.js +0 -69
  228. package/src/hooks/useRestaurant/queries.js +0 -81
  229. package/src/hooks/useRoads/index.js +0 -19
  230. package/src/hooks/useRoads/queries.js +0 -13
  231. package/src/hooks/useRoles/index.js +0 -4
  232. package/src/hooks/useRoles/queries.js +0 -70
  233. package/src/hooks/useRoles/useCreateRole.js +0 -37
  234. package/src/hooks/useRoles/useGetRoles.js +0 -36
  235. package/src/hooks/useRoles/useRemoveRoles.js +0 -40
  236. package/src/hooks/useRoles/useUpdateRolesPriority.js +0 -44
  237. package/src/hooks/useSales/helpers/index.js +0 -55
  238. package/src/hooks/useSales/index.js +0 -1381
  239. package/src/hooks/useSales/queries.js +0 -424
  240. package/src/hooks/useSales/useGetAllSales/index.js +0 -25
  241. package/src/hooks/useSales/useGetSale.js +0 -13
  242. package/src/hooks/useSales/useTotalSales.js +0 -23
  243. package/src/hooks/useSaveAvailableProduct/helpers/index.js +0 -38
  244. package/src/hooks/useSaveAvailableProduct/index.js +0 -31
  245. package/src/hooks/useSaveAvailableProduct/queries.js +0 -10
  246. package/src/hooks/useSaveLocation/index.js +0 -16
  247. package/src/hooks/useSaveLocation/queries.js +0 -19
  248. package/src/hooks/useSchedule/index.js +0 -78
  249. package/src/hooks/useSchedule/index.jsx +0 -22
  250. package/src/hooks/useSchedule/queries.js +0 -43
  251. package/src/hooks/useScheduleData/index.js +0 -123
  252. package/src/hooks/useScroll/index.js +0 -56
  253. package/src/hooks/useScrollRotate/index.js +0 -16
  254. package/src/hooks/useSetImageProducts/index.js +0 -57
  255. package/src/hooks/useSetImageProducts/queries.js +0 -18
  256. package/src/hooks/useSetSession/index.js +0 -44
  257. package/src/hooks/useSetState/index.js +0 -24
  258. package/src/hooks/useSetupSchedule/helpers/index.js +0 -85
  259. package/src/hooks/useSetupSchedule/index.js +0 -272
  260. package/src/hooks/useStatusOpenStore/helpers/index.js +0 -101
  261. package/src/hooks/useStatusOpenStore/index.js +0 -179
  262. package/src/hooks/useStatusOrdersClient/helpers/index.js +0 -14
  263. package/src/hooks/useStatusOrdersClient/index.js +0 -17
  264. package/src/hooks/useStatusOrdersClient/queries.js +0 -80
  265. package/src/hooks/useStockMovements/helpers/index.js +0 -16
  266. package/src/hooks/useStockMovements/index.js +0 -38
  267. package/src/hooks/useStore/index.js +0 -80
  268. package/src/hooks/useStore/queries.js +0 -163
  269. package/src/hooks/useStoreCalendar/index.js +0 -5
  270. package/src/hooks/useStoreContacts/index.js +0 -47
  271. package/src/hooks/useStoreContacts/queries.js +0 -48
  272. package/src/hooks/useStoreTable/index.js +0 -2
  273. package/src/hooks/useStoreTable/queries.js +0 -47
  274. package/src/hooks/useStoreTable/useStoreTableCreate.js +0 -76
  275. package/src/hooks/useStoreTable/useStoreTables.js +0 -14
  276. package/src/hooks/useSubscriptionValidation/index.js +0 -41
  277. package/src/hooks/useTagProducts/index.ts +0 -3
  278. package/src/hooks/useTagProducts/useDeleteOneTag.ts +0 -106
  279. package/src/hooks/useTagProducts/useGetAllTags.ts +0 -68
  280. package/src/hooks/useTagProducts/useRegisterMultipleTags.ts +0 -156
  281. package/src/hooks/useTimeAgo/useTimeAgo.js +0 -39
  282. package/src/hooks/useTokenCards/index.js +0 -41
  283. package/src/hooks/useTopProductsMovements/index.js +0 -27
  284. package/src/hooks/useTotalAllSales/index.js +0 -25
  285. package/src/hooks/useTotalProductsInStock/index.js +0 -23
  286. package/src/hooks/useTotalProductsSold/index.js +0 -23
  287. package/src/hooks/useTotalProductsSolded/index.js +0 -20
  288. package/src/hooks/useUpdateCart/index.js +0 -130
  289. package/src/hooks/useUpdateCartCookie/index.js +0 -43
  290. package/src/hooks/useUpdateDashboardComponent/index.ts +0 -91
  291. package/src/hooks/useUpdateExistingOrders/index.js +0 -85
  292. package/src/hooks/useUpdateExtProductFoodsSubOptional/index.js +0 -60
  293. package/src/hooks/useUpdateModuleOrder/index.js +0 -37
  294. package/src/hooks/useUpdateMultipleExtProduct/index.js +0 -33
  295. package/src/hooks/useUpdateMultipleExtProduct/queries.js +0 -33
  296. package/src/hooks/useUpdateMultipleProducts/index.js +0 -80
  297. package/src/hooks/useUpdateMultipleProducts/queries.js +0 -51
  298. package/src/hooks/useUploadProducts/helpers/index.js +0 -1
  299. package/src/hooks/useUploadProducts/helpers/parseNumber.js +0 -37
  300. package/src/hooks/useUploadProducts/helpers/validateProductDataExcel.js +0 -73
  301. package/src/hooks/useUploadProducts/index.js +0 -422
  302. package/src/hooks/useUpsertGoal/index.js +0 -68
  303. package/src/hooks/useUser/index.js +0 -23
  304. package/src/hooks/useUser/queries.js +0 -131
  305. package/src/hooks/useWeeklyStockMovement/helpers/index.js +0 -32
  306. package/src/hooks/useWeeklyStockMovement/index.js +0 -51
  307. package/src/hooks/useWindowSize/index.js +0 -38
  308. package/src/index.jsx +0 -9
  309. package/src/mock/dessert/index.js +0 -16
  310. package/src/mock/index.js +0 -1
  311. package/src/security/index.js +0 -1
  312. package/src/services/index.js +0 -0
  313. package/src/utils/UtilDateRange.js +0 -31
  314. package/src/utils/index.js +0 -306
  315. package/tsconfig.json +0 -5
@@ -1,48 +0,0 @@
1
- import { useMutation } from '@apollo/client'
2
- import { EDIT_PRODUCT } from './queriesStore'
3
-
4
- export const useEditProduct = ({
5
- sendNotification = () => {
6
- return null
7
- }
8
- } = {}) => {
9
- const [editProductFoods, { loading, error }] = useMutation(EDIT_PRODUCT, {
10
- onCompleted: (data) => {
11
- const { editProductFoods } = data
12
- const {
13
- success,
14
- message,
15
- errors
16
- } = editProductFoods || {
17
- success: false,
18
- message: '',
19
- errors: []
20
- }
21
- if (errors && errors.length > 0) {
22
- for (const error of errors) {
23
- sendNotification({
24
- title: 'Error',
25
- description: `${error.message}`,
26
- backgroundColor: 'error'
27
- })
28
- }
29
- }
30
- if (success) {
31
- sendNotification({
32
- title: 'Error',
33
- description: `${message}`,
34
- backgroundColor: 'error'
35
- })
36
- }
37
- },
38
- onError: (error) => {
39
- sendNotification({
40
- title: 'Error',
41
- description: error.message,
42
- backgroundColor: 'error'
43
- })
44
- }
45
- })
46
-
47
- return [editProductFoods, { loading, error }]
48
- }
@@ -1,98 +0,0 @@
1
- import { useState } from 'react'
2
- import { useMutation } from '@apollo/client'
3
- import { REGISTER_TAGS_PRODUCT } from './queriesStore'
4
- import { useDeleteOneTag, useGetAllTags } from '../useTagProducts'
5
-
6
- export const useTagsProducts = ({
7
- sendNotification = () => { }
8
- } = {}) => {
9
- const [registerTag] = useMutation(REGISTER_TAGS_PRODUCT)
10
- const [handleDeleteTag, { loading }] = useDeleteOneTag()
11
- const { tags: listTags } = useGetAllTags()
12
- const [newTags, setNewTags] = useState([])
13
-
14
- const [tags, setTags] = useState({
15
- id: '',
16
- tag: ''
17
- })
18
-
19
- const handleAddTag = (id, tag) => {
20
- if (tags.id === id) {
21
- return setTags({
22
- id: '',
23
- tag: ''
24
- })
25
- }
26
- return setTags({
27
- id,
28
- tag
29
- })
30
- }
31
-
32
- const handleRemoveTag = async (tag) => {
33
- try {
34
- if (loading) return
35
- const { id: tgId, tag: nameTag } = tag ?? {
36
- tgId: null,
37
- nameTag: null
38
- }
39
- const response = await handleDeleteTag({ tgId, nameTag })
40
- const {
41
- success = false,
42
- message = '',
43
- data
44
- } = response ?? {}
45
-
46
- const name = data?.nameTag ?? ''
47
- return sendNotification({
48
- title: name ?? 'error',
49
- description: message,
50
- backgroundColor: success ? 'success' : 'error'
51
- })
52
- } catch (e) {
53
- sendNotification({
54
- title: 'Error',
55
- description: 'error',
56
- backgroundColor: 'error'
57
- })
58
- }
59
- }
60
-
61
- const handleRegister = tag => {
62
- const {
63
- pId,
64
- idUser,
65
- idStore,
66
- nameTag
67
- } = tag || {}
68
-
69
- registerTag({
70
- variables: {
71
- input: {
72
- pId,
73
- idUser,
74
- nameTag,
75
- idStore
76
- }
77
- }
78
- }).catch(err => { return console.log({ message: `${err}`, duration: 7000 }) })
79
- }
80
- const data = listTags.map((tag) => {
81
- return {
82
- id: tag?.tgId ?? '',
83
- tag: String(tag?.nameTag ?? '')
84
- }
85
- })
86
-
87
- return {
88
- tags,
89
- error: false,
90
- data,
91
- loading: false,
92
- newTags: newTags ?? [],
93
- setNewTags,
94
- handleRegister,
95
- handleRemoveTag,
96
- handleAddTag
97
- }
98
- }
@@ -1,3 +0,0 @@
1
- export * from './useProvidersCreateStore'
2
- export * from './useProvidersDataStore'
3
- export * from './queries'
@@ -1,31 +0,0 @@
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
- `
@@ -1,12 +0,0 @@
1
- import { useMutation } from '@apollo/client'
2
- import { CREATE_PROVIDERS } from '../queries'
3
-
4
- export const useProvidersCreateStore = ({ setAlertBox = () => { } } = {}) => {
5
- const [registerProviders, { loading, error }] = useMutation(CREATE_PROVIDERS, {
6
- onCompleted: (data) => {
7
- setAlertBox({ message: `${data.registerProviders.message}` })
8
- }
9
- })
10
-
11
- return [registerProviders, { loading, error }]
12
- }
@@ -1,24 +0,0 @@
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
- }
@@ -1,24 +0,0 @@
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
- }
@@ -1,31 +0,0 @@
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
- `
@@ -1,52 +0,0 @@
1
- import { useMutation, gql } from '@apollo/client'
2
-
3
- // Define el mutation GraphQL
4
- const PUSH_NOTIFICATION_ORDER = gql`
5
- mutation PushNotificationOrder($pCodeRef: String!, $idStore: ID!) {
6
- pushNotificationOrder(pCodeRef: $pCodeRef, idStore: $idStore) {
7
- pdpId
8
- id
9
- idStore
10
- pId
11
- ppState
12
- pCodeRef
13
- pPDate
14
- pSState
15
- pPStateP
16
- payMethodPState
17
- pPRecoger
18
- totalProductsPrice
19
- unidProducts
20
- pDatCre
21
- pDatMod
22
- }
23
- }
24
- `
25
-
26
- // Definir el hook personalizado
27
- export const usePushNotificationOrder = ({ client }) => {
28
- // Usar el hook useMutation para ejecutar el mutation
29
- const [pushNotificationOrderMutation] = useMutation(PUSH_NOTIFICATION_ORDER, {
30
- context: { clientName: client }
31
- })
32
-
33
- // Función para ejecutar el mutation
34
- const pushNotificationOrder = async (pCodeRef, idStore) => {
35
- try {
36
- // Ejecutar el mutation con los parámetros proporcionados
37
- const { data } = await pushNotificationOrderMutation({
38
- variables: { pCodeRef, idStore }
39
- })
40
-
41
- // Devolver los datos de la orden recibidos del servidor
42
- return data.pushNotificationOrder
43
- } catch (error) {
44
- // Manejar cualquier error que ocurra durante la ejecución del mutation
45
- console.error('Error al ejecutar el mutation pushNotificationOrder:', error)
46
- throw new Error('Error al publicar la nueva orden de tienda. Por favor, vuelve a intentarlo.')
47
- }
48
- }
49
-
50
- // Devolver la función pushNotificationOrder para ser utilizada por el componente
51
- return pushNotificationOrder
52
- }
@@ -1,114 +0,0 @@
1
- /* eslint-disable consistent-return */
2
- const pushServerPublicKey = 'BIN2Jc5Vmkmy-S3AUrcMlpKxJpLeVRAfu9WBqUbJ70SJOCWGCGXKY-Xzyh7HDr6KbRDGYHjqZ06OcS3BjD7uAm8'
3
-
4
- /**
5
- * checks if Push notification and service workers are supported by your browser
6
- */
7
- function isPushNotificationSupported () {
8
- if (typeof window !== 'undefined' && window.Notification && window.ServiceWorker) {
9
- return 'serviceWorker' in navigator && 'PushManager' in window
10
- }
11
- }
12
-
13
- /**
14
- * asks user consent to receive push notifications and returns the response of the user, one of granted, default, denied
15
- */
16
- async function askUserPermission () {
17
- return await Notification.requestPermission()
18
- }
19
- /**
20
- * shows a notification
21
- */
22
- function sendNotification () {
23
- const img = '/images/jason-leung-HM6TMmevbZQ-unsplash.jpg'
24
- const text = 'Take a look at this brand new t-shirt!'
25
- const title = 'New Product Available'
26
- const options = {
27
- body: text,
28
- icon: '/images/jason-leung-HM6TMmevbZQ-unsplash.jpg',
29
- vibrate: [200, 100, 200],
30
- tag: 'new-product',
31
- image: img,
32
- badge: 'https://spyna.it/icons/android-icon-192x192.png',
33
- actions: [{ action: 'Detail', title: 'View', icon: 'https://via.placeholder.com/128/ff0000' }]
34
- }
35
- navigator.serviceWorker.ready.then(function (serviceWorker) {
36
- serviceWorker.showNotification(title, options)
37
- })
38
- }
39
-
40
- /**
41
- *
42
- */
43
- function registerServiceWorker () {
44
- return navigator.serviceWorker.register('/sw.js')
45
- }
46
-
47
- /**
48
- *
49
- * using the registered service worker creates a push notification subscription and returns it
50
- *
51
- */
52
- async function createNotificationSubscription () {
53
- // wait for service worker installation to be ready
54
- const serviceWorker = await navigator.serviceWorker.ready
55
- // subscribe and return the subscription
56
- return await serviceWorker.pushManager.subscribe({
57
- userVisibleOnly: true,
58
- applicationServerKey: pushServerPublicKey
59
- })
60
- }
61
-
62
- /**
63
- * returns the subscription if present or nothing
64
- */
65
- function getUserSubscription () {
66
- // wait for service worker installation to be ready, and then
67
- return navigator.serviceWorker.ready
68
- .then(function (serviceWorker) {
69
- return serviceWorker.pushManager.getSubscription()
70
- })
71
- .then(function (pushSubscription) {
72
- return pushSubscription
73
- })
74
- }
75
-
76
- const host = process.env.NODE_ENV === 'production' ? 'http://localhost:4000' : 'http://localhost:4000'
77
-
78
- function post (path, body) {
79
- return fetch(`${host}${path}`, {
80
- body: JSON.stringify(body),
81
- method: 'POST',
82
- mode: 'cors'
83
- })
84
- .then(function (response) {
85
- return response.json()
86
- })
87
- .then(function (data) {
88
- return data
89
- })
90
- }
91
-
92
- function get (path) {
93
- return fetch(`${host}${path}`, {
94
- method: 'GET',
95
- mode: 'cors'
96
- })
97
- .then(function (response) {
98
- return response.json()
99
- })
100
- .then(function (data) {
101
- return data
102
- })
103
- }
104
-
105
- export {
106
- isPushNotificationSupported,
107
- askUserPermission,
108
- post,
109
- get,
110
- registerServiceWorker,
111
- sendNotification,
112
- createNotificationSubscription,
113
- getUserSubscription
114
- }
@@ -1,149 +0,0 @@
1
- /* eslint-disable no-console */
2
- import { useState, useEffect } from 'react'
3
- import {
4
- isPushNotificationSupported,
5
- post,
6
- get,
7
- askUserPermission,
8
- registerServiceWorker,
9
- createNotificationSubscription,
10
- getUserSubscription
11
- } from './helpers'
12
- // import all the function created to manage the push notifications
13
-
14
- const pushNotificationSupported = isPushNotificationSupported()
15
- // first thing to do: check if the push notifications are supported by the browser
16
-
17
- export const usePushNotifications = () => {
18
- const [userConsent, setSuserConsent] = useState()
19
- useEffect(() => {
20
- if (typeof Notification !== 'undefined') {
21
- setSuserConsent(Notification.permission)
22
- }
23
- }, [])
24
-
25
- // to manage the user consent: Notification.permission is a JavaScript native function that return the current state of the permission
26
- // We initialize the userConsent with that value
27
- const [userSubscription, setUserSubscription] = useState(null)
28
- // to manage the use push notification subscription
29
- const [pushServerSubscriptionId, setPushServerSubscriptionId] = useState()
30
- // to manage the push server subscription
31
- const [error, setError] = useState(null)
32
- // to manage errors
33
- const [loading, setLoading] = useState(true)
34
- // to manage async actions
35
-
36
- useEffect(() => {
37
- if (pushNotificationSupported) {
38
- setLoading(true)
39
- setError(false)
40
- registerServiceWorker().then(() => {
41
- setLoading(false)
42
- })
43
- }
44
- }, [])
45
- // if the push notifications are supported, registers the service worker
46
- // this effect runs only the first render
47
-
48
- useEffect(() => {
49
- setLoading(true)
50
- setError(false)
51
- const getExixtingSubscription = async () => {
52
- const existingSubscription = await getUserSubscription()
53
- setUserSubscription(existingSubscription)
54
- setLoading(false)
55
- }
56
- getExixtingSubscription()
57
- }, [])
58
- // Retrieve if there is any push notification subscription for the registered service worker
59
- // this use effect runs only in the first render
60
-
61
- /**
62
- * define a click handler that asks the user permission,
63
- * it uses the setSuserConsent state, to set the consent of the user
64
- * If the user denies the consent, an error is created with the setError hook
65
- */
66
- const onClickAskUserPermission = () => {
67
- setLoading(true)
68
- setError(false)
69
- askUserPermission().then(consent => {
70
- setSuserConsent(consent)
71
- if (consent !== 'granted') {
72
- setError({
73
- name: 'consentimiento denegado',
74
- message: 'Negaste el consentimiento para recibir notificaciones',
75
- code: 0
76
- })
77
- }
78
- setLoading(false)
79
- })
80
- }
81
- //
82
-
83
- /**
84
- * define a click handler that creates a push notification subscription.
85
- * Once the subscription is created, it uses the setUserSubscription hook
86
- */
87
- const onClickSusbribeToPushNotification = () => {
88
- setLoading(true)
89
- setError(false)
90
- createNotificationSubscription()
91
- .then(function (subscrition) {
92
- setUserSubscription(subscrition)
93
- setLoading(false)
94
- })
95
- .catch(err => {
96
- console.error("Couldn't create the notification subscription", err, 'name:', err.name, 'message:', err.message, 'code:', err.code)
97
- setError(err)
98
- setLoading(false)
99
- })
100
- }
101
-
102
- /**
103
- * define a click handler that sends the push susbcribtion to the push server.
104
- * Once the subscription ics created on the server, it saves the id using the hook setPushServerSubscriptionId
105
- */
106
- const onClickSendSubscriptionToPushServer = () => {
107
- setLoading(true)
108
- setError(false)
109
- post('/subscription2', userSubscription)
110
- .then(function (response) {
111
- setPushServerSubscriptionId(response.id)
112
- setLoading(false)
113
- })
114
- .catch(err => {
115
- setLoading(false)
116
- setError(err)
117
- })
118
- }
119
-
120
- /**
121
- * define a click handler that request the push server to send a notification, passing the id of the saved subscription
122
- */
123
- const onClickSendNotification = async () => {
124
- setLoading(true)
125
- setError(false)
126
- console.log(pushServerSubscriptionId)
127
- await get(`/subscription/${pushServerSubscriptionId}`).catch(err => {
128
- setLoading(false)
129
- setError(err)
130
- })
131
- setLoading(false)
132
- }
133
-
134
- /**
135
- * returns all the stuff needed by a Component
136
- */
137
- return {
138
- onClickAskUserPermission,
139
- onClickSusbribeToPushNotification,
140
- onClickSendSubscriptionToPushServer,
141
- pushServerSubscriptionId,
142
- onClickSendNotification,
143
- userConsent,
144
- pushNotificationSupported,
145
- userSubscription,
146
- error,
147
- loading
148
- }
149
- }
@@ -1,19 +0,0 @@
1
- import { useLazyQuery } from '@apollo/client'
2
- import { GET_ONE_COUNTRY, GET_ONE_DEPARTMENT, GET_ONE_CITY } from './queries'
3
-
4
- const useGetOneCountry = () => {
5
- const [getOneCountry, { data: dataCountry }] = useLazyQuery(GET_ONE_COUNTRY)
6
- return { getOneCountry, dataCountry }
7
- }
8
-
9
- const useGetOneDepartment = () => {
10
- const [getOneDepartment, { data: dataDepartment }] = useLazyQuery(GET_ONE_DEPARTMENT)
11
- return { getOneDepartment, dataDepartment }
12
- }
13
-
14
- const useGetOneCity = () => {
15
- const [getOneCities, { data: dataGetOneCity }] = useLazyQuery(GET_ONE_CITY)
16
- return { getOneCities, dataGetOneCity }
17
- }
18
-
19
- export { useGetOneCountry, useGetOneDepartment, useGetOneCity }
@@ -1,40 +0,0 @@
1
- import { gql } from '@apollo/client'
2
-
3
- export const GET_ONE_COUNTRY = gql`
4
- query getOneCountry($cId: ID){
5
- getOneCountry(cId: $cId) {
6
- cId
7
- cName
8
- cName
9
- cDatCre
10
- cCalCod
11
- cState
12
- cDatMod
13
-
14
- }
15
- }
16
- `
17
- export const GET_ONE_DEPARTMENT = gql`
18
- query getOneDepartment($dId: ID){
19
- getOneDepartment(dId: $dId) {
20
- dId
21
- cId
22
- dName
23
- dState
24
- dDatCre
25
- dDatMod
26
- }
27
- }
28
- `
29
- export const GET_ONE_CITY = gql`
30
- query getOneCities($ctId: ID){
31
- getOneCities(ctId: $ctId) {
32
- ctId
33
- dId
34
- cName
35
- cState
36
- cDatCre
37
- cDatMod
38
- }
39
- }
40
- `