npm-pkg-hook 1.12.4 → 1.12.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 (354) hide show
  1. package/dist/index.js +57529 -0
  2. package/dist/index.js.map +1 -0
  3. package/dist/index.mjs +57315 -0
  4. package/dist/index.mjs.map +1 -0
  5. package/eslint.config.mts +153 -0
  6. package/package.json +30 -45
  7. package/src/config/client/errors.ts +39 -0
  8. package/src/hooks/addTenMinutes/{index.js → index.ts} +4 -4
  9. package/src/hooks/calculateLogLatHaversine/{index.js → index.ts} +15 -4
  10. package/src/hooks/completeSchedules/{index.js → index.ts} +4 -4
  11. package/src/hooks/convertToMilitaryTime/index.ts +18 -0
  12. package/src/hooks/generateStoreURL/index.ts +41 -0
  13. package/src/hooks/generateTemplate/{index.js → index.ts} +15 -11
  14. package/src/hooks/getCardType/{index.js → index.ts} +1 -1
  15. package/src/hooks/getCategoriesWithProduct/{index.js → index.ts} +7 -7
  16. package/src/hooks/getGlobalSession/index.ts +69 -0
  17. package/src/hooks/getSession/index.ts +72 -0
  18. package/src/hooks/getTodayTimestamps/{index.js → index.ts} +18 -12
  19. package/src/hooks/getTotalHours/index.ts +76 -0
  20. package/src/hooks/handleLogin/{index.js → index.ts} +4 -0
  21. package/src/hooks/index.ts +8 -2
  22. package/src/hooks/statusOpenStores/helpers/{index.js → index.ts} +24 -1
  23. package/src/hooks/statusOpenStores/index.ts +221 -0
  24. package/src/hooks/updateExtProductFoodsOptional/{index.js → index.ts} +12 -3
  25. package/src/hooks/useAcumulateDate/index.ts +18 -0
  26. package/src/hooks/useAllStoresPendingToRegister/{index.js → index.ts} +3 -0
  27. package/src/hooks/useAmountInput/index.ts +42 -32
  28. package/src/hooks/useAnimationText/{index.jsx → index.ts} +2 -2
  29. package/src/hooks/useAsideCart/{index.js → index.ts} +22 -19
  30. package/src/hooks/useBanner/{index.js → index.ts} +2 -1
  31. package/src/hooks/useCart/useCart/helpers/{index.js → index.ts} +10 -6
  32. package/src/hooks/useCart/useCart/{index.js → index.ts} +29 -17
  33. package/src/hooks/useCart/useGetCart/{index.js → index.ts} +2 -1
  34. package/src/hooks/useCatWithProduct/{index.js → index.ts} +11 -5
  35. package/src/hooks/useCatWithProduct/types/index.ts +104 -0
  36. package/src/hooks/useCatWithProductClient/{index.js → index.ts} +3 -2
  37. package/src/hooks/useCategoriesProduct/{index.js → index.ts} +2 -1
  38. package/src/hooks/useCategoryInStore/index.ts +167 -0
  39. package/src/hooks/useCategoryStore/{index.js → index.ts} +2 -1
  40. package/src/hooks/useCategoryStore/{queries.js → queries.ts} +2 -2
  41. package/src/hooks/useChartData/{index.js → index.ts} +9 -8
  42. package/src/hooks/useChartData/useChartData/{index.js → index.ts} +31 -30
  43. package/src/hooks/useChartData/useChartDataAllOrders/{index.js → index.ts} +2 -2
  44. package/src/hooks/useCheckbox/{index.js → index.ts} +1 -1
  45. package/src/hooks/useCities/{index.js → index.ts} +2 -1
  46. package/src/hooks/useClients/{index.js → index.ts} +2 -1
  47. package/src/hooks/useClients/{queries.js → queries.ts} +7 -4
  48. package/src/hooks/useColorByLetters/helpers/{alea.js → alea.ts} +19 -0
  49. package/src/hooks/useColorByLetters/helpers/{index.js → index.ts} +5 -1
  50. package/src/hooks/useColorByLetters/helpers/{mersenne_twister.js → mersenne_twister.ts} +1 -1
  51. package/src/hooks/useColorByLetters/{index.js → index.ts} +3 -6
  52. package/src/hooks/useConnection/{index.js → index.ts} +3 -3
  53. package/src/hooks/useCountries/{index.js → index.ts} +2 -1
  54. package/src/hooks/useCreateOrderStatusType/index.ts +8 -6
  55. package/src/hooks/useCreateProduct/helpers/{index.js → index.ts} +1 -1
  56. package/src/hooks/useCreateProduct/helpers/manageCacheDataCatProduct/{index.js → index.ts} +1 -1
  57. package/src/hooks/useCreateProduct/helpers/useEditImageProduct/{index.js → index.ts} +14 -8
  58. package/src/hooks/useCreateProduct/{index.js → index.ts} +22 -19
  59. package/src/hooks/useCreateStorePendingToRegister/{index.js → index.ts} +5 -1
  60. package/src/hooks/useDeleteExtraProductFoods/{index.js → index.ts} +2 -1
  61. package/src/hooks/useDeleteSubProductOptional/{index.js → index.ts} +5 -3
  62. package/src/hooks/useDeliveryTime/{index.js → index.ts} +3 -1
  63. package/src/hooks/useDepartments/{index.js → index.ts} +2 -1
  64. package/src/hooks/useDessert/{index.js → index.ts} +56 -52
  65. package/src/hooks/useDessertWithPrice/helpers/{index.js → index.ts} +4 -4
  66. package/src/hooks/useDessertWithPrice/{index.js → index.ts} +34 -26
  67. package/src/hooks/useDevWS/index.ts +43 -43
  68. package/src/hooks/useDevices/{useGetDevices.js → useGetDevices.ts} +3 -3
  69. package/src/hooks/useDevices/{useRegisterDevices.js → useRegisterDevices.ts} +5 -5
  70. package/src/hooks/useDownloadReports/helpers/downloadFileFromResponse.ts +17 -17
  71. package/src/hooks/useDownloadReports/useDownloadReportByDay/index.ts +4 -2
  72. package/src/hooks/useDownloadReports/useGetReportByDateRange/index.ts +3 -2
  73. package/src/hooks/useDrag/{index.js → index.ts} +16 -0
  74. package/src/hooks/useDropzone/{index.js → index.ts} +2 -2
  75. package/src/hooks/useDynamicAuth/{index.js → index.ts} +2 -1
  76. package/src/hooks/useEditCategory/{index.js → index.ts} +5 -5
  77. package/src/hooks/useEditOneExtProductFoodOptional/index.ts +28 -0
  78. package/src/hooks/useEditOneExtProductFoodOptional/{queries.js → queries.ts} +2 -2
  79. package/src/hooks/useEditSubProductOptional/index.ts +12 -0
  80. package/src/hooks/useEmployee/{index.js → index.ts} +2 -1
  81. package/src/hooks/useEmployee/{queries.js → queries.ts} +1 -1
  82. package/src/hooks/useEmployee/{useCreateEmployee.js → useCreateEmployee.ts} +6 -2
  83. package/src/hooks/useFavoriteStores/{index.js → index.ts} +5 -3
  84. package/src/hooks/useFetchMoreInteractions/index.jsx +26 -26
  85. package/src/hooks/useFilterConfigs/index.ts +173 -0
  86. package/src/hooks/useFingerprintjs/{index.js → index.ts} +29 -4
  87. package/src/hooks/useFormTools/{index.js → index.ts} +38 -11
  88. package/src/hooks/useFormatDate/{index.js → index.ts} +10 -5
  89. package/src/hooks/useFullScreenMode/{index.js → index.ts} +1 -5
  90. package/src/hooks/useGetAllLocationUser/{index.js → index.ts} +2 -1
  91. package/src/hooks/useGetAllLocationUser/{queries.js → queries.ts} +2 -2
  92. package/src/hooks/{useSales/useGetAllSales/index.js → useGetAllSales/index.ts} +3 -2
  93. package/src/hooks/useGetExtProductFoodsSubOptionalAll/{index.js → index.ts} +2 -1
  94. package/src/hooks/useGetFoodRecomended/{index.js → index.ts} +2 -1
  95. package/src/hooks/useGetMinPrice/{index.js → index.ts} +2 -1
  96. package/src/hooks/useGetOneStoreRating/{index.js → index.ts} +2 -1
  97. package/src/hooks/useGetStoreCookie/{index.js → index.ts} +1 -1
  98. package/src/hooks/useGoogleLogin/{index.js → index.ts} +14 -5
  99. package/src/hooks/useHover/{index.js → index.ts} +3 -0
  100. package/src/hooks/useImageOptimization/{index.js → index.ts} +4 -0
  101. package/src/hooks/useImageUploaderProduct/helper/canvasUtils.ts +25 -9
  102. package/src/hooks/useImageUploaderProduct/helper/getOrientation.ts +5 -4
  103. package/src/hooks/useImageUploaderProduct/index.ts +227 -224
  104. package/src/hooks/useImageWeight/{index.js → index.ts} +4 -0
  105. package/src/hooks/useImagesStore/{index.js → index.ts} +7 -5
  106. package/src/hooks/useImagesStore/{queries.js → queries.ts} +1 -1
  107. package/src/hooks/useIncomingOrders/{index.js → index.ts} +2 -1
  108. package/src/hooks/useIncomingOrders/{queries.js → queries.ts} +1 -1
  109. package/src/hooks/useIntersection/{index.js → index.ts} +1 -1
  110. package/src/hooks/useInventory/{queries.js → queries.ts} +2 -2
  111. package/src/hooks/useInventory/{useGetProductsInStock.js → useGetProductsInStock.ts} +2 -1
  112. package/src/hooks/useLazyScript/{index.js → index.ts} +3 -0
  113. package/src/hooks/useLocalSorage/{index.js → index.ts} +3 -3
  114. package/src/hooks/useLocationManager/{index.js → index.ts} +3 -3
  115. package/src/hooks/useLoginEmployeeInStore/{index.js → index.ts} +1 -1
  116. package/src/hooks/useLogout/helpers/BroadcastChannel.ts +74 -0
  117. package/src/hooks/useLogout/helpers/{apiBaseUrl.js → apiBaseUrl.ts} +4 -0
  118. package/src/hooks/useLogout/helpers/{fetchData.js → fetchData.ts} +10 -1
  119. package/src/hooks/useLogout/helpers/{getCsrfToken.js → getCsrfToken.ts} +8 -1
  120. package/src/hooks/useLogout/helpers/{index.js → index.ts} +14 -6
  121. package/src/hooks/useLogout/helpers/{logger.js → logger.ts} +26 -8
  122. package/src/hooks/useLogout/helpers/{parseUrl.js → parseUrl.ts} +5 -2
  123. package/src/hooks/useLogout/{index.js → index.ts} +29 -20
  124. package/src/hooks/useManageNewOrder/helpers/{index.js → index.ts} +1 -1
  125. package/src/hooks/useManageNewOrder/{index.js → index.ts} +6 -4
  126. package/src/hooks/useManageQueryParams/index.ts +120 -0
  127. package/src/hooks/useModules/helpers/{validateModules.js → validateModules.ts} +1 -1
  128. package/src/hooks/useModules/index.ts +124 -0
  129. package/src/hooks/useMouse/index.ts +23 -18
  130. package/src/hooks/useOrderStatusTypes/useOrderStatusTypes/index.ts +1 -1
  131. package/src/hooks/useOrderStatusTypes/useUpdateOrderStatusPriorities/index.ts +7 -5
  132. package/src/hooks/useOrders/{queries.js → queries.ts} +30 -20
  133. package/src/hooks/useOrders/useChangeOrderState/index.ts +79 -76
  134. package/src/hooks/useOrders/useOrdersFromStore/index.ts +4 -3
  135. package/src/hooks/usePaymentMethod/index.ts +3 -0
  136. package/src/hooks/usePaymentMethod/paymentMethod.gql.ts +62 -0
  137. package/src/hooks/usePaymentMethod/paymentMethod.types.ts +28 -0
  138. package/src/hooks/usePaymentMethod/useCreatePaymentMethod/index.ts +25 -0
  139. package/src/hooks/usePaymentMethod/useGetAllPaymentMethods/index.ts +19 -0
  140. package/src/hooks/usePaymentMethod/useGetPaymentMethod/index.ts +26 -0
  141. package/src/hooks/usePrintSaleTicket/index.ts +4 -0
  142. package/src/hooks/useProductsFood/{index.js → index.ts} +115 -27
  143. package/src/hooks/useProductsFood/{queriesStore.js → queriesStore.ts} +1 -1
  144. package/src/hooks/useProductsFood/{useEditProduct.js → useEditProduct.ts} +2 -1
  145. package/src/hooks/useProductsFood/{usetagsProducts.js → usetagsProducts.ts} +6 -3
  146. package/src/hooks/useProviders/useProvidersCreateStore/{index.js → index.ts} +2 -1
  147. package/src/hooks/useProviders/useProvidersDataStore/{index.js → index.ts} +2 -1
  148. package/src/hooks/useProvidersStore/{index.js → index.ts} +2 -1
  149. package/src/hooks/usePushNotificationOrder/{index.js → index.ts} +1 -1
  150. package/src/hooks/usePushNotifications/helpers/{index.js → index.ts} +9 -0
  151. package/src/hooks/usePushNotifications/{index.js → index.ts} +2 -1
  152. package/src/hooks/useQueryLocationsMap/{index.js → index.ts} +2 -1
  153. package/src/hooks/useRatingArrayData/{index.js → index.ts} +4 -4
  154. package/src/hooks/useRatingArrayData/{queries.js → queries.ts} +1 -1
  155. package/src/hooks/useRemoveExtraProductFoodsOptional/{index.js → index.ts} +2 -1
  156. package/src/hooks/useReport/{index.js → index.ts} +2 -1
  157. package/src/hooks/useReport/{queries.js → queries.ts} +2 -53
  158. package/src/hooks/useRestaurant/helpers/{index.js → index.ts} +4 -0
  159. package/src/hooks/useRestaurant/helpers/{manageStatusOpen.js → manageStatusOpen.ts} +1 -1
  160. package/src/hooks/useRestaurant/{index.js → index.ts} +5 -3
  161. package/src/hooks/useRoads/{index.js → index.ts} +2 -1
  162. package/src/hooks/useRoles/{queries.js → queries.ts} +1 -1
  163. package/src/hooks/useRoles/{useCreateRole.js → useCreateRole.ts} +4 -1
  164. package/src/hooks/useRoles/{useGetRoles.js → useGetRoles.ts} +2 -1
  165. package/src/hooks/useSales/helpers/add-product.utils.ts +120 -0
  166. package/src/hooks/useSales/helpers/apply-discount-to-cart.utils.ts +292 -0
  167. package/src/hooks/useSales/helpers/comment-product.utils.ts +41 -0
  168. package/src/hooks/useSales/helpers/constants/index.ts +38 -0
  169. package/src/hooks/useSales/helpers/extras.utils.ts +42 -0
  170. package/src/hooks/useSales/helpers/filterProductsByCarProId.utils.ts +17 -0
  171. package/src/hooks/useSales/helpers/increment-product-quantity.utils.ts +76 -0
  172. package/src/hooks/useSales/helpers/index.ts +3 -0
  173. package/src/hooks/useSales/helpers/initializer.utils.ts +22 -0
  174. package/src/hooks/useSales/helpers/isStockInsufficient.ts +3 -0
  175. package/src/hooks/useSales/helpers/remove-product.utils.test.ts +49 -0
  176. package/src/hooks/useSales/helpers/remove-product.utils.ts +34 -0
  177. package/src/hooks/useSales/helpers/resolveProduct.ts +29 -0
  178. package/src/hooks/useSales/helpers/useAddToCart.ts +64 -0
  179. package/src/hooks/useSales/{index.js → index.ts} +559 -522
  180. package/src/hooks/useSales/{queries.js → queries.ts} +187 -79
  181. package/src/hooks/useSales/types/index.ts +206 -0
  182. package/src/hooks/useSales/types/use-sales.types.ts +8 -0
  183. package/src/hooks/useSales/{useGetSale.js → useGetSale.ts} +10 -2
  184. package/src/hooks/useSales/{useTotalSales.js → useTotalSales.ts} +2 -1
  185. package/src/hooks/useSaveAvailableProduct/helpers/{index.js → index.ts} +4 -4
  186. package/src/hooks/useSaveAvailableProduct/{index.js → index.ts} +2 -1
  187. package/src/hooks/useSaveLocation/{index.js → index.ts} +2 -1
  188. package/src/hooks/useSaveLocation/{queries.js → queries.ts} +1 -1
  189. package/src/hooks/useSchedule/{index.jsx → index.ts} +14 -1
  190. package/src/hooks/useSchedule/{index.js → schedule.ts} +2 -1
  191. package/src/hooks/useScheduleData/{index.js → index.ts} +21 -9
  192. package/src/hooks/useSetImageProducts/{index.js → index.ts} +4 -2
  193. package/src/hooks/useSetupSchedule/{index.js → index.ts} +40 -28
  194. package/src/hooks/useStatusOpenStore/helpers/{index.js → index.ts} +24 -1
  195. package/src/hooks/useStatusOpenStore/{index.js → index.ts} +30 -14
  196. package/src/hooks/useStatusOrdersClient/{index.js → index.ts} +3 -2
  197. package/src/hooks/useStatusOrdersClient/{queries.js → queries.ts} +2 -2
  198. package/src/hooks/useStock/index.ts +1 -0
  199. package/src/hooks/useStock/useStockUpdatedAllSubscription.ts +40 -0
  200. package/src/hooks/useStockMovements/helpers/{index.js → index.ts} +1 -1
  201. package/src/hooks/useStockMovements/{index.js → index.ts} +4 -3
  202. package/src/hooks/useStore/{index.js → index.ts} +30 -27
  203. package/src/hooks/useStoreContacts/{index.js → index.ts} +11 -5
  204. package/src/hooks/useStoreTable/{useStoreTableCreate.js → useStoreTableCreate.ts} +3 -2
  205. package/src/hooks/useStoreTable/{useStoreTables.js → useStoreTables.ts} +2 -1
  206. package/src/hooks/useSubscriptionValidation/index.ts +112 -0
  207. package/src/hooks/useTagProducts/useDeleteOneTag.ts +66 -66
  208. package/src/hooks/useTagProducts/useGetAllTags.ts +2 -2
  209. package/src/hooks/useTagProducts/useRegisterMultipleTags.ts +27 -26
  210. package/src/hooks/useTheme/index.ts +65 -0
  211. package/src/hooks/useTimeAgo/{useTimeAgo.js → useTimeAgo.ts} +7 -7
  212. package/src/hooks/useTokenCards/{index.js → index.ts} +7 -3
  213. package/src/hooks/useUpdateCart/{index.js → index.ts} +3 -2
  214. package/src/hooks/useUpdateCartCookie/{index.js → index.ts} +23 -6
  215. package/src/hooks/useUpdateDashboardComponent/index.ts +11 -11
  216. package/src/hooks/useUpdateExtProductFoodsSubOptional/{index.js → index.ts} +2 -1
  217. package/src/hooks/useUpdateModuleOrder/{index.js → index.ts} +2 -2
  218. package/src/hooks/useUpdateMultipleExtProduct/{index.js → index.ts} +2 -1
  219. package/src/hooks/useUpdateMultipleProducts/{index.js → index.ts} +57 -20
  220. package/src/hooks/useUploadProducts/helpers/{parseNumber.js → parseNumber.ts} +3 -3
  221. package/src/hooks/useUploadProducts/{index.js → index.ts} +89 -69
  222. package/src/hooks/useUpsertGoal/{index.js → index.ts} +1 -1
  223. package/src/hooks/useUser/{index.js → index.ts} +5 -4
  224. package/src/hooks/useWeeklyStockMovement/helpers/{index.js → index.ts} +3 -3
  225. package/src/hooks/useWeeklyStockMovement/{index.js → index.ts} +4 -3
  226. package/src/hooks/useWindowSize/{index.js → index.ts} +9 -2
  227. package/src/index.ts +13 -0
  228. package/src/security/index.ts +1 -0
  229. package/src/services/index.ts +1 -0
  230. package/src/utils/UtilDateRange.ts +56 -0
  231. package/src/utils/generateCode.ts +222 -0
  232. package/src/utils/index.ts +2 -0
  233. package/src/utils/{index.js → utils.ts} +69 -31
  234. package/tsconfig.eslint.json +16 -0
  235. package/tsconfig.json +18 -2
  236. package/tsup.config.ts +24 -0
  237. package/.eslintrc.js +0 -38
  238. package/.eslintrc.json +0 -127
  239. package/src/config/client/errors.js +0 -26
  240. package/src/hooks/convertToMilitaryTime/index.js +0 -14
  241. package/src/hooks/generateStoreURL/index.js +0 -38
  242. package/src/hooks/getGlobalSession/index.js +0 -49
  243. package/src/hooks/getSession/index.js +0 -18
  244. package/src/hooks/getTotalHours/index.js +0 -48
  245. package/src/hooks/statusOpenStores/index.js +0 -156
  246. package/src/hooks/useAcumulateDate/index.js +0 -16
  247. package/src/hooks/useCategoryInStore/index.js +0 -100
  248. package/src/hooks/useEditOneExtProductFoodOptional/index.js +0 -28
  249. package/src/hooks/useEditSubProductOptional/index.js +0 -11
  250. package/src/hooks/useLogout/helpers/BroadcastChannel.js +0 -31
  251. package/src/hooks/useManageQueryParams/index.js +0 -40
  252. package/src/hooks/useModules/index.js +0 -58
  253. package/src/hooks/useSales/helpers/index.js +0 -55
  254. package/src/hooks/useSubscriptionValidation/index.js +0 -41
  255. package/src/index.jsx +0 -9
  256. package/src/security/index.js +0 -1
  257. package/src/utils/UtilDateRange.js +0 -31
  258. /package/src/config/client/{index.js → index.ts} +0 -0
  259. /package/src/config/content/{index.js → index.ts} +0 -0
  260. /package/src/cookies/{index.js → index.ts} +0 -0
  261. /package/src/hooks/getCategoriesWithProduct/helpers/{index.js → index.ts} +0 -0
  262. /package/src/hooks/isTokenExpired/{index.js → index.ts} +0 -0
  263. /package/src/hooks/newMessageSubscription/{index.js → index.ts} +0 -0
  264. /package/src/hooks/newStoreOrderSubscription/{index.js → index.ts} +0 -0
  265. /package/src/hooks/useAnimationFrame/{index.js → index.ts} +0 -0
  266. /package/src/hooks/useAsideCart/helpers/{index.js → index.ts} +0 -0
  267. /package/src/hooks/useAsideCart/{queries.js → queries.ts} +0 -0
  268. /package/src/hooks/useCart/{index.js → index.ts} +0 -0
  269. /package/src/hooks/useCart/{queries.js → queries.ts} +0 -0
  270. /package/src/hooks/useCatWithProduct/{queries.js → queries.ts} +0 -0
  271. /package/src/hooks/useCatWithProductClient/{queries.js → queries.ts} +0 -0
  272. /package/src/hooks/useCategoriesProduct/{queries.js → queries.ts} +0 -0
  273. /package/src/hooks/useCategoryInStore/{queries.js → queries.ts} +0 -0
  274. /package/src/hooks/useChatRoomSubscription/{index.js → index.ts} +0 -0
  275. /package/src/hooks/useCities/{queries.js → queries.ts} +0 -0
  276. /package/src/hooks/useColorByLetters/helpers/{colors.js → colors.ts} +0 -0
  277. /package/src/hooks/useCountries/{queries.js → queries.ts} +0 -0
  278. /package/src/hooks/useCreateDeliveryTime/{index.js → index.ts} +0 -0
  279. /package/src/hooks/useCreateStorePendingToRegister/{queries.js → queries.ts} +0 -0
  280. /package/src/hooks/useDashboardComponents/{index.js → index.ts} +0 -0
  281. /package/src/hooks/useDeleteSubProductOptional/{queries.js → queries.ts} +0 -0
  282. /package/src/hooks/useDepartments/{queries.js → queries.ts} +0 -0
  283. /package/src/hooks/useDessert/helpers/{index.js → index.ts} +0 -0
  284. /package/src/hooks/useDessertWithPrice/{queries.js → queries.ts} +0 -0
  285. /package/src/hooks/useDevices/{index.js → index.ts} +0 -0
  286. /package/src/hooks/useDevices/{queries.js → queries.ts} +0 -0
  287. /package/src/hooks/useDynamicAuth/{queries.js → queries.ts} +0 -0
  288. /package/src/hooks/useEditSubProductOptional/{queries.js → queries.ts} +0 -0
  289. /package/src/hooks/useEvent/{index.js → index.ts} +0 -0
  290. /package/src/hooks/useFavoriteStores/{queries.js → queries.ts} +0 -0
  291. /package/src/hooks/useFetchJson/{index.js → index.ts} +0 -0
  292. /package/src/hooks/useFormatNumberPhone/{index.js → index.ts} +0 -0
  293. /package/src/hooks/useGenerateNumberArray/{index.js → index.ts} +0 -0
  294. /package/src/hooks/useGetCookies/{index.js → index.ts} +0 -0
  295. /package/src/hooks/useGetFoodRecomended/{queries.js → queries.ts} +0 -0
  296. /package/src/hooks/useGetMessagesToRoom/{index.js → index.ts} +0 -0
  297. /package/src/hooks/useGetMinPrice/{queries.js → queries.ts} +0 -0
  298. /package/src/hooks/useGetOneStoreRating/{queries.js → queries.ts} +0 -0
  299. /package/src/hooks/useGetSalesAmountToday/{index.js → index.ts} +0 -0
  300. /package/src/hooks/useGoogleLogin/{loadScript.js → loadScript.ts} +0 -0
  301. /package/src/hooks/useGoogleLogin/{removeScript.js → removeScript.ts} +0 -0
  302. /package/src/hooks/useImagesStore/utils/{index.js → index.ts} +0 -0
  303. /package/src/hooks/useInnerHtml/{index.js → index.ts} +0 -0
  304. /package/src/hooks/useInventory/{index.js → index.ts} +0 -0
  305. /package/src/hooks/useInventory/{useUpdateManageStock.js → useUpdateManageStock.ts} +0 -0
  306. /package/src/hooks/useKeypress/{index.js → index.ts} +0 -0
  307. /package/src/hooks/useLocalBackendIp/{index.js → index.ts} +0 -0
  308. /package/src/hooks/useLocationNavigate/{index.js → index.ts} +0 -0
  309. /package/src/hooks/useManageNewOrder/helpers/{mock.js → mock.ts} +0 -0
  310. /package/src/hooks/useMobile/{index.js → index.ts} +0 -0
  311. /package/src/hooks/useModules/helpers/{index.js → index.ts} +0 -0
  312. /package/src/hooks/useMutateHeight/{index.js → index.ts} +0 -0
  313. /package/src/hooks/useOrderClient/{index.js → index.ts} +0 -0
  314. /package/src/hooks/useOrders/{index.js → index.ts} +0 -0
  315. /package/src/hooks/usePWAInstall/{index.js → index.ts} +0 -0
  316. /package/src/{services/index.js → hooks/useProductsFood/types/index.ts} +0 -0
  317. /package/src/hooks/useProviders/{index.js → index.ts} +0 -0
  318. /package/src/hooks/useProviders/{queries.js → queries.ts} +0 -0
  319. /package/src/hooks/useProvidersStore/{queries.js → queries.ts} +0 -0
  320. /package/src/hooks/useQueryLocationsMap/{queries.js → queries.ts} +0 -0
  321. /package/src/hooks/useReactToPrint/{index.js → index.txt} +0 -0
  322. /package/src/hooks/useRemoveExtraProductFoodsOptional/{queries.js → queries.ts} +0 -0
  323. /package/src/hooks/useRestaurant/{queries.js → queries.ts} +0 -0
  324. /package/src/hooks/useRoads/{queries.js → queries.ts} +0 -0
  325. /package/src/hooks/useRoles/{index.js → index.ts} +0 -0
  326. /package/src/hooks/useRoles/{useRemoveRoles.js → useRemoveRoles.ts} +0 -0
  327. /package/src/hooks/useRoles/{useUpdateRolesPriority.js → useUpdateRolesPriority.ts} +0 -0
  328. /package/src/hooks/useSaveAvailableProduct/{queries.js → queries.ts} +0 -0
  329. /package/src/hooks/useSchedule/{queries.js → queries.ts} +0 -0
  330. /package/src/hooks/useScroll/{index.js → index.ts} +0 -0
  331. /package/src/hooks/useScrollRotate/{index.js → index.ts} +0 -0
  332. /package/src/hooks/useSetImageProducts/{queries.js → queries.ts} +0 -0
  333. /package/src/hooks/useSetSession/{index.js → index.ts} +0 -0
  334. /package/src/hooks/useSetState/{index.js → index.ts} +0 -0
  335. /package/src/hooks/useSetupSchedule/helpers/{index.js → index.ts} +0 -0
  336. /package/src/hooks/useStatusOrdersClient/helpers/{index.js → index.ts} +0 -0
  337. /package/src/hooks/useStore/{queries.js → queries.ts} +0 -0
  338. /package/src/hooks/useStoreCalendar/{index.js → index.ts} +0 -0
  339. /package/src/hooks/useStoreContacts/{queries.js → queries.ts} +0 -0
  340. /package/src/hooks/useStoreTable/{index.js → index.ts} +0 -0
  341. /package/src/hooks/useStoreTable/{queries.js → queries.ts} +0 -0
  342. /package/src/hooks/useTopProductsMovements/{index.js → index.ts} +0 -0
  343. /package/src/hooks/useTotalAllSales/{index.js → index.ts} +0 -0
  344. /package/src/hooks/useTotalProductsInStock/{index.js → index.ts} +0 -0
  345. /package/src/hooks/useTotalProductsSold/{index.js → index.ts} +0 -0
  346. /package/src/hooks/useTotalProductsSolded/{index.js → index.ts} +0 -0
  347. /package/src/hooks/useUpdateExistingOrders/{index.js → index.ts} +0 -0
  348. /package/src/hooks/useUpdateMultipleExtProduct/{queries.js → queries.ts} +0 -0
  349. /package/src/hooks/useUpdateMultipleProducts/{queries.js → queries.ts} +0 -0
  350. /package/src/hooks/useUploadProducts/helpers/{index.js → index.ts} +0 -0
  351. /package/src/hooks/useUploadProducts/helpers/{validateProductDataExcel.js → validateProductDataExcel.ts} +0 -0
  352. /package/src/hooks/useUser/{queries.js → queries.ts} +0 -0
  353. /package/src/mock/dessert/{index.js → index.ts} +0 -0
  354. /package/src/mock/{index.js → index.ts} +0 -0
@@ -1,16 +1,19 @@
1
1
  import {
2
2
  useState,
3
3
  useEffect
4
- } from 'react'
4
+ } from 'react'
5
+
5
6
  import { MockData } from '../../mock'
6
7
  import { RandomCode, updateCacheMod } from '../../utils'
7
8
  import { useUpdateExtProductFoodsOptional } from '../updateExtProductFoodsOptional'
8
- import { useUpdateExtProductFoodsSubOptional } from '../useUpdateExtProductFoodsSubOptional'
9
- import { useRemoveExtraProductFoodsOptional } from '../useRemoveExtraProductFoodsOptional'
10
- import { GET_EXTRAS_PRODUCT_FOOD_OPTIONAL } from '../useRemoveExtraProductFoodsOptional/queries'
11
- import { transformDataToDessert } from './helpers'
12
9
  import { useDeleteSubProductOptional } from '../useDeleteSubProductOptional'
13
10
  import { useEditSubProductOptional } from '../useEditSubProductOptional'
11
+ import { useRemoveExtraProductFoodsOptional } from '../useRemoveExtraProductFoodsOptional'
12
+ import { GET_EXTRAS_PRODUCT_FOOD_OPTIONAL } from '../useRemoveExtraProductFoodsOptional/queries'
13
+ import { useUpdateExtProductFoodsSubOptional } from '../useUpdateExtProductFoodsSubOptional'
14
+
15
+ import { transformDataToDessert } from './helpers'
16
+
14
17
 
15
18
  export const useDessert = ({
16
19
  pId = null,
@@ -32,13 +35,13 @@ export const useDessert = ({
32
35
  const handleCleanData = () => {
33
36
  setData(MockData)
34
37
  }
35
- const dataListIds = data?.listIds?.filter(x => x !== '01list')
38
+ const dataListIds = data?.listIds?.filter(x => {return x !== '01list'})
36
39
 
37
40
  /**
38
- * Checks if all required lists have the maximum number of cards.
39
- *
40
- * @return {boolean} Returns true if all required lists have the maximum number of cards, otherwise false.
41
- */
41
+ * Checks if all required lists have the maximum number of cards.
42
+ *
43
+ * @return {boolean} Returns true if all required lists have the maximum number of cards, otherwise false.
44
+ */
42
45
  const isCompleteRequired = dataListIds?.every(listID => {
43
46
  try {
44
47
  if (!Array.isArray(dataListIds) || data === null) {
@@ -95,13 +98,13 @@ export const useDessert = ({
95
98
  }
96
99
 
97
100
  /**
98
- * Handles the removal of a list from the data state and performs additional operations if needed.
99
- * @param {number} i - The index of the list to be removed.
100
- * @param {string} listID - The ID of the list to be removed (optional).
101
- * @throws {Error} Will throw an error if the provided index (i) is not a non-negative number.
102
- * @throws {Error} Will throw an error if the provided index (i) is out of range.
103
- * @throws {Error} Will throw an error if the provided listID is invalid (optional validation).
104
- */
101
+ * Handles the removal of a list from the data state and performs additional operations if needed.
102
+ * @param {number} i - The index of the list to be removed.
103
+ * @param {string} listID - The ID of the list to be removed (optional).
104
+ * @throws {Error} Will throw an error if the provided index (i) is not a non-negative number.
105
+ * @throws {Error} Will throw an error if the provided index (i) is out of range.
106
+ * @throws {Error} Will throw an error if the provided listID is invalid (optional validation).
107
+ */
105
108
  const handleRemoveList = (i, listID) => {
106
109
  // Validate that the provided index (i) is a non-negative number
107
110
  if (typeof i !== 'number' || i < 0) {
@@ -117,7 +120,7 @@ export const useDessert = ({
117
120
  }
118
121
 
119
122
  // Remove the list with the specified index from the listIdsCopy array
120
- const Lines = data?.listIds.filter((_, index) => index !== i)?.filter(x => x !== '01list')
123
+ const Lines = data?.listIds.filter((_, index) => {return index !== i})?.filter(x => {return x !== '01list'})
121
124
  // Update the data state with the modified listIdsCopy array
122
125
  setData({
123
126
  listIds: listID ? Lines.filter((subItem) => { return subItem !== listID }) : Lines,
@@ -158,6 +161,7 @@ export const useDessert = ({
158
161
  * @param {Object} params - The parameters for removing the item.
159
162
  * @param {string} params.listID - The ID of the list from which the item will be removed.
160
163
  * @param {string} params.id - The ID of the item to be removed.
164
+ * @param params.isCustomSubOpExPid
161
165
  * @throws {Error} Will throw an error if the provided listID does not exist in the data state.
162
166
  * @throws {Error} Will throw an error if the provided listID exists but the corresponding list does not have a cards array.
163
167
  */
@@ -191,7 +195,7 @@ export const useDessert = ({
191
195
  const currentList = data.lists[listID]
192
196
 
193
197
  // Filter out the item with the specified ID from the current list's cards array
194
- const filteredCart = currentList?.cards?.filter((cart) => cart.id !== id)
198
+ const filteredCart = currentList?.cards?.filter((cart) => {return cart.id !== id})
195
199
 
196
200
  // Update the current list's cards with the filtered array to remove the specified item
197
201
  setData({
@@ -210,22 +214,22 @@ export const useDessert = ({
210
214
  }
211
215
 
212
216
  /**
213
- * Edits a single item within a list.
214
- *
215
- * The `editOneItem` function is responsible for editing the title of a specific item in a list.
216
- * It first updates the state of the selected item, then searches for the item in the current list
217
- * using its ID, and compares the existing title with the new title provided. If the title is
218
- * different and not null, it makes an API call (`editExtFoodSubsOptional`) to update the
219
- * title in the database. If the update is successful, a success notification is sent, and
220
- * the local state is updated to reflect the changes in the item. The function handles errors
221
- * internally and logs them to the console.
222
- *
223
- * @param {Object} params - Parameters for editing an item.
224
- * @param {string} params.listID - The ID of the list containing the item to be edited.
225
- * @param {string} params.id - The ID of the specific item to be edited.
226
- * @param {string|null} [params.title=null] - The new title for the item. If null, no
227
- * update is performed.
228
- */
217
+ * Edits a single item within a list.
218
+ *
219
+ * The `editOneItem` function is responsible for editing the title of a specific item in a list.
220
+ * It first updates the state of the selected item, then searches for the item in the current list
221
+ * using its ID, and compares the existing title with the new title provided. If the title is
222
+ * different and not null, it makes an API call (`editExtFoodSubsOptional`) to update the
223
+ * title in the database. If the update is successful, a success notification is sent, and
224
+ * the local state is updated to reflect the changes in the item. The function handles errors
225
+ * internally and logs them to the console.
226
+ *
227
+ * @param {Object} params - Parameters for editing an item.
228
+ * @param {string} params.listID - The ID of the list containing the item to be edited.
229
+ * @param {string} params.id - The ID of the specific item to be edited.
230
+ * @param {string|null} [params.title=null] - The new title for the item. If null, no
231
+ * update is performed.
232
+ */
229
233
  const editOneItem = ({
230
234
  listID = '',
231
235
  id = '',
@@ -299,16 +303,16 @@ export const useDessert = ({
299
303
  })
300
304
  }
301
305
  /**
302
- * Edit a extra.
303
- * @async
304
- * @param {Object} options - Opciones para la edición del extra.
305
- * @param {string} options.id - ID del extra.
306
- * @param {number|null} options.numberLimit - Límite de número para el extra.
307
- * @param {string} options.title - Título del extra.
308
- * @param {boolean} options.required - Indica si el extra es requerido.
309
- * @throws {Error} Se lanza un error si no se proporciona un ID válido.
310
- * @returns {Promise<void>}
311
- */
306
+ * Edit a extra.
307
+ * @async
308
+ * @param {Object} options - Opciones para la edición del extra.
309
+ * @param {string} options.id - ID del extra.
310
+ * @param {number|null} options.numberLimit - Límite de número para el extra.
311
+ * @param {string} options.title - Título del extra.
312
+ * @param {boolean} options.required - Indica si el extra es requerido.
313
+ * @throws {Error} Se lanza un error si no se proporciona un ID válido.
314
+ * @returns {Promise<void>}
315
+ */
312
316
  const editOneExtra = async ({
313
317
  id = '',
314
318
  numberLimit = null,
@@ -440,7 +444,7 @@ export const useDessert = ({
440
444
  const required = setCheck.exState ? 1 : 0
441
445
 
442
446
  // Add the new list to the beginning of the data state
443
- setData(prevData => ({
447
+ setData(prevData => {return {
444
448
  listIds: [newListId, ...prevData.listIds], // Agrega el nuevo ID al principio del array
445
449
  lists: {
446
450
  ...prevData.lists,
@@ -453,7 +457,7 @@ export const useDessert = ({
453
457
  cards: []
454
458
  }
455
459
  }
456
- }))
460
+ }})
457
461
 
458
462
  // Update the external product with the information of the new list
459
463
  handleUpdateExtProduct({
@@ -469,11 +473,11 @@ export const useDessert = ({
469
473
  }
470
474
 
471
475
  /**
472
- * Handles the change of items in a specific list.
473
- * @param {Object} params - The parameters for handling the change.
474
- * @param {string} params.listID - The ID of the list where the change is happening.
475
- * @param {Object} params.value - The event object containing the new value for the list items.
476
- */
476
+ * Handles the change of items in a specific list.
477
+ * @param {Object} params - The parameters for handling the change.
478
+ * @param {string} params.listID - The ID of the list where the change is happening.
479
+ * @param {Object} params.value - The event object containing the new value for the list items.
480
+ */
477
481
  const handleChangeItems = ({ listID, value: e }) => {
478
482
  const value = e.target.value
479
483
  setValueItems(value)
@@ -1,11 +1,11 @@
1
1
  export const transformData = (dataExtra) => {
2
- const transformedData = dataExtra?.map(item => ({
2
+ const transformedData = dataExtra?.map(item => {return {
3
3
  extraName: item.extraName || '',
4
4
  extraPrice: item?.extraPrice?.toString() || '',
5
- exState: !!item.exState,
5
+ exState: Boolean(item.exState),
6
6
  forEdit: true,
7
7
  ...item
8
- }))
8
+ }})
9
9
 
10
10
  return transformedData
11
11
  }
@@ -54,7 +54,7 @@ export const updateErrorFieldByIndex = ({
54
54
  // Utiliza map para iterar sobre cada elemento en checkNumberRange
55
55
  const updatedLines = updatedLineItems.Lines.map((line, index) => {
56
56
  // Verifica si el índice está dentro del rango de LineItems.Lines
57
- if (checkNumberRange.some(item => item.index === index)) {
57
+ if (checkNumberRange.some(item => {return item.index === index})) {
58
58
  // Crea una copia del elemento actual
59
59
  const updatedLine = { ...line }
60
60
 
@@ -1,3 +1,4 @@
1
+ import { useMutation } from '@apollo/client'
1
2
  import {
2
3
  useCallback,
3
4
  useEffect,
@@ -5,12 +6,14 @@ import {
5
6
  useRef,
6
7
  useState,
7
8
  createRef
8
- } from 'react'
9
- import { useUpdateMultipleExtProduct } from '../useUpdateMultipleExtProduct'
10
- import { useMutation } from '@apollo/client'
11
- import { EDIT_EXTRA_PRODUCT_FOODS } from './queries'
12
- import { findNumbersExceedingRange, transformData, updateErrorFieldByIndex } from './helpers'
9
+ } from 'react'
10
+
13
11
  import { useDeleteExtraProductFoods } from '../useDeleteExtraProductFoods'
12
+ import { useUpdateMultipleExtProduct } from '../useUpdateMultipleExtProduct'
13
+
14
+ import { findNumbersExceedingRange, transformData, updateErrorFieldByIndex } from './helpers'
15
+ import { EDIT_EXTRA_PRODUCT_FOODS } from './queries'
16
+
14
17
 
15
18
  export const useDessertWithPrice = ({
16
19
  dataExtra = [],
@@ -59,7 +62,7 @@ export const useDessertWithPrice = ({
59
62
  Array.isArray(dataExtra) && dataExtra.length > 0 ? { Lines: transformedData } : initialLineItems
60
63
  )
61
64
 
62
- const inputRefs = useRef(LineItems.Lines.map(() => createRef()))
65
+ const inputRefs = useRef(LineItems.Lines.map(() => {return createRef()}))
63
66
 
64
67
  const handleSelect = (item, index) => {
65
68
  try {
@@ -75,7 +78,7 @@ export const useDessertWithPrice = ({
75
78
 
76
79
  useEffect(() => {
77
80
  // Asegurándote de que las referencias se actualicen si LineItems cambia
78
- inputRefs.current = LineItems.Lines.map((_, i) => inputRefs.current[i] || createRef())
81
+ inputRefs.current = LineItems.Lines.map((_, i) => {return inputRefs.current[i] || createRef()})
79
82
  }, [LineItems])
80
83
 
81
84
  const handleCleanLines = useCallback(() => {
@@ -123,11 +126,11 @@ export const useDessertWithPrice = ({
123
126
  }
124
127
 
125
128
  /**
126
- * Handles changes in line items, updating the state accordingly.
127
- * @param {number} index - The index of the line item being updated.
128
- * @param {string} name - The name of the attribute being changed.
129
- * @param {any} value - The new value of the attribute.
130
- */
129
+ * Handles changes in line items, updating the state accordingly.
130
+ * @param {number} index - The index of the line item being updated.
131
+ * @param {string} name - The name of the attribute being changed.
132
+ * @param {any} value - The new value of the attribute.
133
+ */
131
134
  const handleLineChange = (index, name, value) => {
132
135
  const newLines = LineItems.Lines.map((line, i) => {
133
136
  if (i !== index) return { ...line }
@@ -150,9 +153,9 @@ export const useDessertWithPrice = ({
150
153
  const { deleteExtraProductFoods } = useDeleteExtraProductFoods()
151
154
 
152
155
  /**
153
- * Filter out a specific line from the LineItems array.
154
- * @param {number} index - Index of the line to be filtered out.
155
- */
156
+ * Filter out a specific line from the LineItems array.
157
+ * @param {number} index - Index of the line to be filtered out.
158
+ */
156
159
  const filterOneLine = (index) => {
157
160
  // Use optional chaining to safely access nested properties.
158
161
  const Lines = LineItems?.Lines?.filter((_, i) => { return i !== index })
@@ -173,7 +176,7 @@ export const useDessertWithPrice = ({
173
176
  return filterOneLine(i)
174
177
  }
175
178
 
176
- const findDataExtra = dataExtra?.find(x => x?.exPid === exPid)
179
+ const findDataExtra = dataExtra?.find(x => {return x?.exPid === exPid})
177
180
  if (!findDataExtra) return
178
181
 
179
182
  await deleteExtraProductFoods({
@@ -206,13 +209,13 @@ export const useDessertWithPrice = ({
206
209
  if (!Array.isArray(dataOld)) return dataOld
207
210
 
208
211
  const transformedData = transformData(dataOld)
209
- const Lines = transformedData.filter((_, index) => index !== i)
210
- const newCache = dataOld.filter((_, index) => index !== i)
212
+ const Lines = transformedData.filter((_, index) => {return index !== i})
213
+ const newCache = dataOld.filter((_, index) => {return index !== i})
211
214
 
212
- setLine(prev => ({
215
+ setLine(prev => {return {
213
216
  ...prev,
214
217
  Lines
215
- }))
218
+ }})
216
219
 
217
220
  return newCache
218
221
  }
@@ -235,16 +238,16 @@ export const useDessertWithPrice = ({
235
238
  }, [dataExtra.length])
236
239
 
237
240
  const prepareAndValidateData = useCallback((pId) => {
238
- const dataArr = LineItems?.Lines?.map(({ extraPrice, exState, extraName }) => ({
241
+ const dataArr = LineItems?.Lines?.map(({ extraPrice, exState, extraName }) => {return {
239
242
  extraPrice,
240
243
  exState: exState === true ? 1 : 0,
241
244
  extraName,
242
245
  pId
243
- }))
246
+ }})
244
247
  console.log(dataArr)
245
248
  const message = 'Complete los campos vacíos'
246
- const findInputEmpty = dataArr?.find(({ extraName }) => extraName === '')
247
- const findInputEmptyPrice = dataArr?.find(({ extraPrice }) => isNaN(extraPrice) || extraPrice === '')
249
+ const findInputEmpty = dataArr?.find(({ extraName }) => {return extraName === ''})
250
+ const findInputEmptyPrice = dataArr?.find(({ extraPrice }) => {return isNaN(extraPrice) || extraPrice === ''})
248
251
 
249
252
  if (findInputEmpty || findInputEmptyPrice) {
250
253
  setAlertBox({ message })
@@ -291,6 +294,11 @@ export const useDessertWithPrice = ({
291
294
  }
292
295
  }
293
296
 
297
+ /**
298
+ *
299
+ * @param items
300
+ * @param pId
301
+ */
294
302
  function filterItemsWithValidExPid (items, pId) {
295
303
  // Primero, filtrar los elementos basados en exPid
296
304
  const filteredItems = items.filter(({ exPid }) => {
@@ -299,13 +307,13 @@ export const useDessertWithPrice = ({
299
307
  })
300
308
 
301
309
  // Luego, transformar los elementos filtrados
302
- return filteredItems.map(({ exPid, extraPrice, exState, extraName }) => ({
310
+ return filteredItems.map(({ exPid, extraPrice, exState, extraName }) => {return {
303
311
  exPid,
304
312
  extraPrice,
305
313
  exState: exState === true ? 1 : 0,
306
314
  extraName,
307
315
  pId
308
- }))
316
+ }})
309
317
  }
310
318
 
311
319
  const handleSubmit = ({ pId }) => {
@@ -2,52 +2,52 @@
2
2
  import { useEffect, useRef, useState } from 'react'
3
3
 
4
4
  export const useDevWS = () => {
5
- const [status, setStatus] = useState("loading")
6
- const wsRef = useRef<WebSocket | null>(null)
7
-
8
- useEffect(() => {
9
- let reconnectTimer: any
10
-
11
- const connect = async () => {
12
- try {
13
- const r = await fetch('/api/ws-port')
14
- const { port } = await r.json()
15
-
16
- if (!port) {
17
- setStatus("down")
18
- reconnectTimer = setTimeout(connect, 2000)
19
- return
20
- }
21
-
22
- const ws = new WebSocket(`ws://localhost:${port}`)
23
- wsRef.current = ws
24
-
25
- ws.onopen = () => {
26
- setStatus("up")
27
- }
28
-
29
- ws.onerror = () => {
30
- setStatus("down")
31
- ws.close()
32
- }
33
-
34
- ws.onclose = () => {
35
- setStatus("down")
36
- reconnectTimer = setTimeout(connect, 2000)
37
- }
38
- } catch {
39
- setStatus("down")
40
- reconnectTimer = setTimeout(connect, 2000)
41
- }
5
+ const [status, setStatus] = useState('loading')
6
+ const wsRef = useRef<WebSocket | null>(null)
7
+
8
+ useEffect(() => {
9
+ let reconnectTimer: any
10
+
11
+ const connect = async () => {
12
+ try {
13
+ const r = await fetch('/api/ws-port')
14
+ const { port } = await r.json()
15
+
16
+ if (!port) {
17
+ setStatus('down')
18
+ reconnectTimer = setTimeout(connect, 2000)
19
+ return
42
20
  }
43
21
 
44
- connect()
22
+ const ws = new WebSocket(`ws://localhost:${port}`)
23
+ wsRef.current = ws
24
+
25
+ ws.onopen = () => {
26
+ setStatus('up')
27
+ }
45
28
 
46
- return () => {
47
- wsRef.current?.close()
48
- clearTimeout(reconnectTimer)
29
+ ws.onerror = () => {
30
+ setStatus('down')
31
+ ws.close()
49
32
  }
50
- }, [])
51
33
 
52
- return status
34
+ ws.onclose = () => {
35
+ setStatus('down')
36
+ reconnectTimer = setTimeout(connect, 2000)
37
+ }
38
+ } catch {
39
+ setStatus('down')
40
+ reconnectTimer = setTimeout(connect, 2000)
41
+ }
42
+ }
43
+
44
+ connect()
45
+
46
+ return () => {
47
+ wsRef.current?.close()
48
+ clearTimeout(reconnectTimer)
49
+ }
50
+ }, [])
51
+
52
+ return status
53
53
  }
@@ -1,6 +1,6 @@
1
- import { useQuery } from '@apollo/client'
1
+ import { useQuery } from '@apollo/client'
2
+
2
3
  import { GET_ALL_DEVICES } from './queries'
3
- import { useFormatDate } from '../useFormatDate'
4
4
 
5
5
  export const useDevices = () => {
6
6
  const { data, loading } = useQuery(GET_ALL_DEVICES, {
@@ -10,7 +10,7 @@ export const useDevices = () => {
10
10
  })
11
11
 
12
12
  // Función para formatear la fecha
13
- const { formatDateInTimeZone } = useFormatDate({})
13
+ // const { formatDateInTimeZone } = useFormatDate({})
14
14
 
15
15
  const listDevices = Array.isArray(data?.getDeviceUsers)
16
16
  ? data?.getDeviceUsers.map((device) => {
@@ -55,12 +55,12 @@ export const useRegisterDeviceUser = () => {
55
55
 
56
56
  if (result.data?.newRegisterDeviceUser?.success) {
57
57
  return { success: true, data: result.data.newRegisterDeviceUser.data }
58
- } else {
59
- return {
60
- success: false,
61
- errors: result.data?.newRegisterDeviceUser?.errors || []
62
- }
58
+ }
59
+ return {
60
+ success: false,
61
+ errors: result.data?.newRegisterDeviceUser?.errors || []
63
62
  }
63
+
64
64
  } catch (err) {
65
65
  console.error('Error while registering device user:', err)
66
66
  return { success: false, errors: [{ message: err.message }] }
@@ -1,21 +1,21 @@
1
1
  export const downloadFileFromResponse = async (response, fileName) => {
2
- try {
3
- if (!response.ok) {
4
- throw new Error(`Failed to download file: ${response.statusText}`)
5
- }
6
-
7
- const blob = await response.blob()
8
- const url = window.URL.createObjectURL(blob)
9
- const link = document.createElement('a')
10
- link.href = url
11
- link.setAttribute('download', fileName)
12
- document.body.appendChild(link)
13
- link.click()
14
- document.body.removeChild(link)
15
- window.URL.revokeObjectURL(url)
16
- } catch (error) {
17
- console.error('Error downloading file:', error)
18
- throw error
2
+ try {
3
+ if (!response.ok) {
4
+ throw new Error(`Failed to download file: ${response.statusText}`)
19
5
  }
20
6
 
7
+ const blob = await response.blob()
8
+ const url = window.URL.createObjectURL(blob)
9
+ const link = document.createElement('a')
10
+ link.href = url
11
+ link.setAttribute('download', fileName)
12
+ document.body.appendChild(link)
13
+ link.click()
14
+ document.body.removeChild(link)
15
+ window.URL.revokeObjectURL(url)
16
+ } catch (error) {
17
+ console.error('Error downloading file:', error)
18
+ throw error
19
+ }
20
+
21
21
  }
@@ -1,8 +1,8 @@
1
1
  import { useLazyQuery } from '@apollo/client'
2
2
  import { gql } from '@apollo/client'
3
- import { useState } from 'react'
4
- import { downloadFileFromResponse } from '../helpers/downloadFileFromResponse'
3
+ import { useState } from 'react'
5
4
 
5
+ import { downloadFileFromResponse } from '../helpers/downloadFileFromResponse'
6
6
 
7
7
 
8
8
  /**
@@ -32,6 +32,8 @@ const GET_REPORT_DAY_NUMBER = gql`
32
32
  /**
33
33
  * Custom hook to trigger the report download when the GraphQL query resolves.
34
34
  *
35
+ * @param root0
36
+ * @param root0.sendNotification
35
37
  * @returns {{
36
38
  * downloadReport: (day: number) => void,
37
39
  * loading: boolean,
@@ -1,7 +1,8 @@
1
1
  import { useLazyQuery } from '@apollo/client'
2
- import { gql } from '@apollo/client'
2
+ import { gql } from '@apollo/client'
3
+ import { useState } from 'react'
4
+
3
5
  import { downloadFileFromResponse } from '../helpers/downloadFileFromResponse'
4
- import { useState } from 'react'
5
6
 
6
7
  /**
7
8
  * GraphQL query to get report by date range
@@ -1,5 +1,9 @@
1
1
  import { useEffect, useState } from 'react'
2
2
 
3
+ /**
4
+ *
5
+ * @param ref
6
+ */
3
7
  export function useDrag2 (ref) {
4
8
  useEffect(() => {
5
9
  if (!ref || !ref?.current) return null
@@ -8,18 +12,30 @@ export function useDrag2 (ref) {
8
12
  const previousOffset = { x: 0, y: 0 }
9
13
  let originMouseX
10
14
  let originMouseY
15
+ /**
16
+ *
17
+ * @param e
18
+ */
11
19
  function onMousemove (e) {
12
20
  const { pageX, pageY } = e
13
21
  const x = pageX - originMouseX + previousOffset.x
14
22
  const y = pageY - originMouseY + previousOffset.y
15
23
  target.style.transform = `translate(${x}px, ${y}px)`
16
24
  }
25
+ /**
26
+ *
27
+ * @param e
28
+ */
17
29
  function onMouseup (e) {
18
30
  previousOffset.x += e.pageX - originMouseX
19
31
  previousOffset.y += e.pageY - originMouseY
20
32
  window.removeEventListener('mousemove', onMousemove)
21
33
  window.removeEventListener('mouseup', onMouseup)
22
34
  }
35
+ /**
36
+ *
37
+ * @param e
38
+ */
23
39
  function onMousedown (e) {
24
40
  originMouseX = e.pageX
25
41
  originMouseY = e.pageY
@@ -43,12 +43,12 @@ export const useDropzone = (
43
43
  },
44
44
  dragleave: e => {
45
45
  return handle.body.dragLeave(e, () => {
46
- // eslint-disable-next-line
46
+
47
47
  if (isDragging) setDragging(false)
48
48
  })
49
49
  },
50
50
  dragend: () => {
51
- // eslint-disable-next-line
51
+
52
52
  },
53
53
  drop: e => {
54
54
  return handle.body.drop(e, () => {
@@ -1,5 +1,6 @@
1
1
  import { useQuery } from '@apollo/client'
2
- import { useState } from 'react'
2
+ import { useState } from 'react'
3
+
3
4
  import { GET_ONE_DYNAMIC_PASS } from './queries'
4
5
 
5
6
  export const useDynamicAuth = () => {
@@ -23,12 +23,12 @@ export const useEditCategoryProduct = ({ sendNotification = () => { } } = {}) =>
23
23
  success: true,
24
24
  message: 'Categoría de producto editada correctamente'
25
25
  }
26
- } else {
27
- return {
28
- success: false,
29
- message: data.editOneCategoryProduct.message || 'Error al editar la categoría de producto'
30
- }
26
+ }
27
+ return {
28
+ success: false,
29
+ message: data.editOneCategoryProduct.message || 'Error al editar la categoría de producto'
31
30
  }
31
+
32
32
  } catch (error) {
33
33
  return {
34
34
  success: false,