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
@@ -2,7 +2,8 @@ import { useMutation } from '@apollo/client'
2
2
  import {
3
3
  useRef,
4
4
  useState
5
- } from 'react'
5
+ } from 'react'
6
+
6
7
  import {
7
8
  CREATE_BANNER_STORE,
8
9
  CREATE_LOGO,
@@ -10,7 +11,8 @@ import {
10
11
  DELETE_ONE_LOGO_STORE,
11
12
  GET_ONE_BANNER_STORE
12
13
  } from '../useProductsFood/queriesStore'
13
- import { GET_ONE_STORE } from '../useStore/queries'
14
+ import { GET_ONE_STORE } from '../useStore/queries'
15
+
14
16
  import { color } from './utils'
15
17
  export * from './queries'
16
18
 
@@ -107,9 +109,9 @@ export const useImageStore = ({ idStore, sendNotification = () => { } } = {}) =>
107
109
  setPreviewImg(
108
110
  files.length
109
111
  ? {
110
- src: URL.createObjectURL(files[0]),
111
- alt: files[0].name
112
- }
112
+ src: URL.createObjectURL(files[0]),
113
+ alt: files[0].name
114
+ }
113
115
  : initialState
114
116
  )
115
117
  registerBanner({
@@ -116,7 +116,7 @@ export const GET_MIN_PEDIDO = gql`
116
116
  }
117
117
  `
118
118
 
119
- // eslint-disable-next-line camelcase
119
+
120
120
  export const GET_All_RATING_STORE = gql`
121
121
  query getAllRating($idStore: ID) {
122
122
  getAllRating(idStore: $idStore) {
@@ -1,4 +1,5 @@
1
- import { useQuery } from '@apollo/client'
1
+ import { useQuery } from '@apollo/client'
2
+
2
3
  import { GET_ALL_INCOMING_ORDERS } from './queries' // Asegúrate de importar tu consulta GraphQL
3
4
 
4
5
  export const useIncomingOrders = ({ statusOrder, idStore }) => {
@@ -12,7 +12,7 @@ export const GET_ALL_INCOMING_ORDERS = gql`
12
12
  pDatCre
13
13
  pDatMod
14
14
  pPRecoger
15
- payMethodPState
15
+ payId
16
16
  pdpId
17
17
  totalProductsPrice
18
18
  locationUser
@@ -70,7 +70,7 @@ export const useIntersectionObserver = ({
70
70
  }
71
71
  return () => {
72
72
  if (disconnect) {
73
- // eslint-disable-next-line no-void
73
+
74
74
  observer === null || observer === void 0 ? void 0 : observer.disconnect(refEl)
75
75
  }
76
76
  if (!disconnect) {
@@ -1,4 +1,4 @@
1
- import { useQuery, gql } from "@apollo/client";
1
+ import { gql } from '@apollo/client'
2
2
 
3
3
  export const GET_PRODUCTS_IN_STOCK = gql`
4
4
  query getProductsInStock($limit: Int, $offset: Int) {
@@ -55,4 +55,4 @@ query getProductsInStock($limit: Int, $offset: Int) {
55
55
  }
56
56
  }
57
57
 
58
- `
58
+ `
@@ -1,4 +1,5 @@
1
- import { useQuery } from '@apollo/client'
1
+ import { useQuery } from '@apollo/client'
2
+
2
3
  import { GET_PRODUCTS_IN_STOCK } from './queries'
3
4
 
4
5
  export const useGetProductsInStock = (storeId) => {
@@ -32,6 +32,9 @@ export const useLazyScript = (src, delay = null) => {
32
32
  }
33
33
 
34
34
  // code to inject script
35
+ /**
36
+ *
37
+ */
35
38
  function injectScript () {
36
39
  script = document.createElement('script')
37
40
  script.src = src
@@ -1,6 +1,6 @@
1
1
  import { useState } from 'react'
2
2
 
3
- export const useLocalStorage = (key, initialValue) => {
3
+ export const useLocalStorage = (key: string, initialValue: string | object | any) => {
4
4
  // const { setAlertBox } = useContext(Context)
5
5
  // State to store our value
6
6
  // Pass initial state function to useState so logic is only executed once
@@ -18,7 +18,7 @@ export const useLocalStorage = (key, initialValue) => {
18
18
 
19
19
  // Return a wrapped version of useState's setter function that ...
20
20
  // ... persists the new value to localStorage.
21
- const setValue = value => {
21
+ const setValue = (value: string | object | any) => {
22
22
  try {
23
23
  // Allow value to be a function so we have same API as useState
24
24
  const valueToStore =
@@ -33,4 +33,4 @@ export const useLocalStorage = (key, initialValue) => {
33
33
  }
34
34
 
35
35
  return [storedValue, setValue]
36
- }
36
+ }
@@ -15,11 +15,11 @@ export function useLocationManager (getDepartments, getCities) {
15
15
  const [showLocation, setShowLocation] = useState(true)
16
16
 
17
17
  const handleUpdateValues = (name, value) => {
18
- setValues(prevValues => ({ ...prevValues, [name]: value }))
18
+ setValues(prevValues => {return { ...prevValues, [name]: value }})
19
19
  }
20
20
 
21
21
  const handleUpdateErrors = (name, error) => {
22
- setErrors(prevErrors => ({ ...prevErrors, [name]: error }))
22
+ setErrors(prevErrors => {return { ...prevErrors, [name]: error }})
23
23
  }
24
24
 
25
25
  const handleCountrySearch = (value) => {
@@ -27,7 +27,7 @@ export function useLocationManager (getDepartments, getCities) {
27
27
  }
28
28
 
29
29
  const handleDepartmentSearch = (value) => {
30
- setValues(prevValues => ({ ...prevValues, ctId: '' }))
30
+ setValues(prevValues => {return { ...prevValues, ctId: '' }})
31
31
  getCities({ variables: { dId: value } })
32
32
  }
33
33
 
@@ -14,7 +14,7 @@ const LOGIN_EMPLOYEE_IN_STORE = gql`
14
14
  export const useLoginEmployeeInStore = () => {
15
15
  const [loginEmployeeInStore, { data, loading, error }] = useMutation(LOGIN_EMPLOYEE_IN_STORE)
16
16
 
17
- const loginEmployee = async (idStore, eEmail) => {
17
+ const loginEmployee = async (idStore: string, eEmail: string) => {
18
18
  try {
19
19
  const response = await loginEmployeeInStore({
20
20
  variables: {
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Broadcast message shape
3
+ */
4
+ export interface BroadcastMessage {
5
+ event?: string
6
+ data?: unknown
7
+ [key: string]: unknown
8
+ }
9
+
10
+ /**
11
+ * Receive callback type
12
+ */
13
+ export type BroadcastReceiver = (message: BroadcastMessage) => void
14
+
15
+ /**
16
+ * BroadcastChannel utility based on localStorage events.
17
+ * Keeps original behavior intact.
18
+ *
19
+ * @param {string} name - Channel name
20
+ * @returns {{
21
+ * receive: (onReceive: BroadcastReceiver) => () => void
22
+ * post: (message: BroadcastMessage) => void
23
+ * }}
24
+ */
25
+ function BroadcastChannel(name: string = 'nextauth.message') {
26
+ return {
27
+ /**
28
+ * Listen for broadcast messages
29
+ * @param onReceive
30
+ */
31
+ receive: function (onReceive: BroadcastReceiver): () => void {
32
+ const handler = function (event: StorageEvent): void {
33
+ if (event.key !== name) return
34
+
35
+ const message: BroadcastMessage = JSON.parse(
36
+ event.newValue ?? '{}'
37
+ )
38
+
39
+ if (message?.event !== 'session' || !message?.data) return
40
+
41
+ onReceive(message)
42
+ }
43
+
44
+ window.addEventListener('storage', handler)
45
+
46
+ return function (): void {
47
+ window.removeEventListener('storage', handler)
48
+ }
49
+ },
50
+
51
+ /**
52
+ * Post a broadcast message
53
+ * @param message
54
+ */
55
+ post: function (message: BroadcastMessage): void {
56
+ if (typeof window === 'undefined') return
57
+
58
+ try {
59
+ localStorage.setItem(
60
+ name,
61
+ JSON.stringify({
62
+ ...message,
63
+ timestamp: Date.now()
64
+ })
65
+ )
66
+ } catch {
67
+ // localStorage may be unavailable (private mode, Safari < 11, etc.)
68
+ // Messages are silently dropped to preserve original behavior.
69
+ }
70
+ }
71
+ }
72
+ }
73
+
74
+ export { BroadcastChannel }
@@ -1,3 +1,7 @@
1
+ /**
2
+ *
3
+ * @param __NEXTAUTH
4
+ */
1
5
  export function apiBaseUrl (__NEXTAUTH) {
2
6
  if (typeof window === 'undefined') {
3
7
  // Return absolute path when called server side
@@ -1,6 +1,15 @@
1
1
  import { apiBaseUrl } from './apiBaseUrl'
2
2
 
3
- async function fetchData(path, __NEXTAUTH, logger, { ctx, req } = {}) {
3
+ /**
4
+ *
5
+ * @param path
6
+ * @param __NEXTAUTH
7
+ * @param logger
8
+ * @param root0
9
+ * @param root0.ctx
10
+ * @param root0.req
11
+ */
12
+ async function fetchData (path, __NEXTAUTH, logger, { ctx, req } = {}) {
4
13
  const url = `${apiBaseUrl(__NEXTAUTH)}/${path}`
5
14
  try {
6
15
  const options = {
@@ -19,7 +19,14 @@ const __NEXTAUTH = {
19
19
  }
20
20
  const logger = proxyLogger(_logger, __NEXTAUTH.basePath)
21
21
 
22
- export async function getCsrfToken (params) {
22
+ /**
23
+ *
24
+ * @param params
25
+ * @param params.callbackUrl
26
+ */
27
+ export async function getCsrfToken (params: {
28
+ callbackUrl?: string
29
+ } = {}): Promise<string | undefined> {
23
30
  const response = await fetchData(
24
31
  'csrf',
25
32
  __NEXTAUTH,
@@ -1,7 +1,7 @@
1
1
  import { apiBaseUrl } from './apiBaseUrl'
2
+ import { BroadcastChannel } from './BroadcastChannel'
2
3
  import { getCsrfToken } from './getCsrfToken'
3
4
  import { parseUrl } from './parseUrl'
4
- import { BroadcastChannel } from './BroadcastChannel'
5
5
 
6
6
  const broadcast = BroadcastChannel()
7
7
 
@@ -10,18 +10,27 @@ export const __NEXTAUTH = {
10
10
  basePath: parseUrl(process.env.NEXTAUTH_URL).path,
11
11
  baseUrlServer: parseUrl(
12
12
  process.env.NEXTAUTH_URL_INTERNAL ||
13
- process.env.NEXTAUTH_URL ||
14
- process.env.VERCEL_URL
13
+ process.env.NEXTAUTH_URL ||
14
+ process.env.VERCEL_URL
15
15
  ).origin,
16
16
  basePathServer: parseUrl(
17
17
  process.env.NEXTAUTH_URL_INTERNAL || process.env.NEXTAUTH_URL
18
18
  ).path,
19
19
  _lastSync: 0,
20
20
  _session: undefined,
21
- _getSession: () => {}
21
+ _getSession: ({ ...args }) => { }
22
22
  }
23
23
 
24
- export async function signOutAuth (options) {
24
+ /**
25
+ *
26
+ * @param options
27
+ */
28
+ export async function signOutAuth(options: {
29
+ callbackUrl?: string
30
+ redirect?: boolean
31
+ reload?: boolean
32
+ } | undefined = undefined
33
+ ): Promise<{ url: string } | void> {
25
34
  const { callbackUrl = window.location.href, reload = true } = options ?? {}
26
35
  const baseUrl = apiBaseUrl(__NEXTAUTH)
27
36
  const fetchOptions = {
@@ -49,7 +58,6 @@ export async function signOutAuth (options) {
49
58
  window.location.href = url
50
59
  // If url contains a hash, the browser does not reload the page. We reload manually
51
60
  if (url.includes('#') && !reload) window.location.reload()
52
- // @ts-expect-error
53
61
  return
54
62
  }
55
63
  await __NEXTAUTH._getSession({ event: 'storage' })
@@ -1,4 +1,8 @@
1
- function formatError(o) {
1
+ /**
2
+ *
3
+ * @param o
4
+ */
5
+ function formatError (o) {
2
6
  if (hasErrorProperty(o)) {
3
7
  o.error = formatError(o.error)
4
8
  o.message = o.message ?? o.error.message
@@ -6,12 +10,16 @@ function formatError(o) {
6
10
  return o
7
11
  }
8
12
 
9
- function hasErrorProperty(x) {
10
- return !!(x?.error)
13
+ /**
14
+ *
15
+ * @param x
16
+ */
17
+ function hasErrorProperty (x) {
18
+ return Boolean(x?.error)
11
19
  }
12
20
 
13
21
  const _logger = {
14
- error(code, metadata) {
22
+ error (code, metadata) {
15
23
  metadata = formatError(metadata)
16
24
  console.error(
17
25
  `[next-auth][error][${code}]`,
@@ -20,18 +28,23 @@ const _logger = {
20
28
  metadata
21
29
  )
22
30
  },
23
- warn(code) {
31
+ warn (code) {
24
32
  console.warn(
25
33
  `[next-auth][warn][${code}]`,
26
34
  `\nhttps://next-auth.js.org/warnings#${code.toLowerCase()}`
27
35
  )
28
36
  },
29
- debug(code, metadata) {
37
+ debug (code, metadata) {
30
38
  console.log(`[next-auth][debug][${code}]`, metadata)
31
39
  }
32
40
  }
33
41
 
34
- export function setLogger(newLogger = {}, debug) {
42
+ /**
43
+ *
44
+ * @param newLogger
45
+ * @param debug
46
+ */
47
+ export function setLogger (newLogger = {}, debug) {
35
48
  if (!debug) _logger.debug = () => { }
36
49
 
37
50
  if (newLogger.error) _logger.error = newLogger.error
@@ -39,7 +52,12 @@ export function setLogger(newLogger = {}, debug) {
39
52
  if (newLogger.debug) _logger.debug = newLogger.debug
40
53
  }
41
54
 
42
- export function proxyLogger(logger = _logger, basePath) {
55
+ /**
56
+ *
57
+ * @param logger
58
+ * @param basePath
59
+ */
60
+ export function proxyLogger (logger = _logger, basePath) {
43
61
  try {
44
62
  if (typeof window === 'undefined') {
45
63
  return logger
@@ -9,8 +9,11 @@ const InternalUrl = {
9
9
  }
10
10
  }
11
11
 
12
- /** Function to parse a URL-like object for server-side requests/redirects */
13
- function parseUrl (url) {
12
+ /**
13
+ * Function to parse a URL-like object for server-side requests/redirects
14
+ * @param url
15
+ */
16
+ function parseUrl (url: string | undefined) {
14
17
  const defaultUrl = new URL('http://localhost:3000/api/auth')
15
18
 
16
19
  if (url && !url.startsWith('http')) {
@@ -1,22 +1,26 @@
1
1
  import { useApolloClient } from '@apollo/client'
2
2
  import { useState } from 'react'
3
+
3
4
  import { Cookies } from '../../cookies/index'
4
- import { signOutAuth } from './helpers'
5
5
  import { getCurrentDomain } from '../../utils'
6
- export { signOutAuth } from './helpers'
7
6
 
7
+ import { signOutAuth } from './helpers'
8
+
9
+ interface UseLogoutOptions {
10
+ setAlertBox?: (options: { message: string }) => { message: string }
11
+ }
8
12
  export const useLogout = ({
9
13
  setAlertBox = ({
10
14
  message
11
15
  }) => { return { message } }
12
- } = {}) => {
13
- const [loading, setLoading] = useState(false)
16
+ }: UseLogoutOptions = {}) => {
17
+ const [loading, setLoading] = useState<boolean>(false)
14
18
  const [error, setError] = useState(false)
15
19
  const client = useApolloClient()
16
20
 
17
- const eliminarCookie = async (nombreCookie) => {
21
+ const eliminarCookie = async (nombreCookie: string) => {
18
22
  try {
19
- let domain = getCurrentDomain()
23
+ let domain = getCurrentDomain() as string | undefined
20
24
 
21
25
  // Si estás en entorno local, usa 'localhost' como dominio
22
26
  if (domain === 'localhost') {
@@ -26,9 +30,9 @@ export const useLogout = ({
26
30
  const expirationTime = new Date()
27
31
  expirationTime.setTime(expirationTime.getTime() - 1000) // Establece una fecha de expiración en el pasado
28
32
 
29
- const formattedDomain = domain || getCurrentDomain()
33
+ const formattedDomain: string | undefined = typeof domain === 'string' ? domain : undefined
30
34
 
31
- await Cookies.remove(nombreCookie, { domain: formattedDomain, path: '/', secure: process.env.NODE_ENV === 'production' })
35
+ Cookies.remove(nombreCookie, { domain: formattedDomain, path: '/', secure: process.env.NODE_ENV === 'production' })
32
36
 
33
37
  console.log('Cookie eliminada correctamente.')
34
38
  } catch (error) {
@@ -37,21 +41,24 @@ export const useLogout = ({
37
41
  }
38
42
  }
39
43
  const deleteCookie = async () => {
40
- await eliminarCookie(process.env.NEXT_PUBLIC_SESSION_NAME)
41
- await eliminarCookie(process.env.LOCAL_SALES_STORE)
44
+ await eliminarCookie(String(process.env.NEXT_PUBLIC_SESSION_NAME))
45
+ await eliminarCookie(String(process.env.NEXT_LOCAL_SALES_STORE))
42
46
  await eliminarCookie('restaurant')
43
47
  await eliminarCookie('usuario')
44
48
  await eliminarCookie('session')
45
49
  }
46
- const onClickLogout = async ({ redirect = true } = { redirect: true }) => {
47
- console.log(redirect)
50
+ const onClickLogout = async (params?: { redirect?: boolean }) => {
51
+ const redirect = params?.redirect ?? true
48
52
  try {
49
- if (!redirect) return await deleteCookie()
50
- setLoading(true)
53
+ if (redirect) {
54
+ setLoading(true)
55
+ } else {
56
+ return await deleteCookie()
57
+ }
51
58
  await deleteCookie()
52
59
  // Logout from the server
53
- const port = window.location.port ? `:${window.location.port}` : ''
54
- const baseUrl = `${window.location.protocol}//${window.location.hostname}${port}`
60
+ const port = globalThis.location.port ? `:${globalThis.location.port}` : ''
61
+ const baseUrl = `${globalThis.location.protocol}//${globalThis.location.hostname}${port}`
55
62
  const logoutResponse = await fetch(`${baseUrl}/api/auth/signout/`, {
56
63
  method: 'POST',
57
64
  headers: {
@@ -69,8 +76,8 @@ export const useLogout = ({
69
76
  console.log('Intentando borrar cookies...')
70
77
 
71
78
  // Eliminar la cookie process.env.NEXT_PUBLIC_SESSION_NAME
72
- await eliminarCookie(process.env.NEXT_PUBLIC_SESSION_NAME)
73
- Cookies.remove(process.env.LOCAL_SALES_STORE)
79
+ await eliminarCookie(String(process.env.NEXT_PUBLIC_SESSION_NAME))
80
+ Cookies.remove(String(process.env.NEXT_LOCAL_SALES_STORE))
74
81
  Cookies.remove('restaurant')
75
82
  Cookies.remove('usuario')
76
83
  Cookies.remove('session')
@@ -81,13 +88,15 @@ export const useLogout = ({
81
88
  setLoading(false)
82
89
  console.log('Cookies eliminadas y sesión cerrada con éxito')
83
90
  signOutAuth({ redirect: true, callbackUrl: '/' })
84
- .catch(() => {
91
+ .catch((err) => {
85
92
  setError(true)
93
+ console.error('Error in signOutAuth:', err)
86
94
  setAlertBox({ message: 'Ocurrió un error al cerrar sesión' })
87
95
  })
88
- } catch (error) {
96
+ } catch (err) {
89
97
  setLoading(false)
90
98
  setError(true)
99
+ console.error('Error al cerrar sesión:', err)
91
100
  setAlertBox({ message: 'Ocurrió un error al cerrar sesión' })
92
101
  }
93
102
  }
@@ -21,7 +21,7 @@ export function findOrderByCodeRef (data, pCodeRef) {
21
21
  if (Array.isArray(column)) {
22
22
  // Buscar el objeto por pCodeRef dentro de la columna actual
23
23
  const foundOrder = column.find(
24
- (order) => order && order.pCodeRef === pCodeRef
24
+ (order) => {return order && order.pCodeRef === pCodeRef}
25
25
  )
26
26
  // Si se encuentra el objeto, devolverlo
27
27
  if (foundOrder) {
@@ -1,10 +1,12 @@
1
- import { useEffect, useState } from 'react'
1
+ import { useEffect, useState } from 'react'
2
+
2
3
  import {
3
4
  useGetSale,
4
- updateExistingOrders,
5
+ // updateExistingOrders,
5
6
  convertDateFormat,
6
7
  useOrdersFromStore
7
- } from '../../hooks'
8
+ } from '..'
9
+
8
10
  import { findOrderByCodeRef, isDateInRange } from './helpers'
9
11
 
10
12
  export const useManageNewOrder = ({
@@ -39,7 +41,7 @@ export const useManageNewOrder = ({
39
41
  const dataOrder = data[KEY_STATUS_ORDER]
40
42
  if (Array.isArray(dataOrder) && dataOrder) {
41
43
  const filteredOrders = dataOrder.filter(order =>
42
- isDateInRange(order?.pDatCre) && order?.pSState === 1
44
+ {return isDateInRange(order?.pDatCre) && order?.pSState === 1}
43
45
  ) ?? []
44
46
  setOrders(filteredOrders)
45
47
  setCountOrders(filteredOrders.length)
@@ -0,0 +1,120 @@
1
+ 'use client'
2
+
3
+ import { useRouter, useSearchParams, useParams } from 'next/navigation'
4
+
5
+ /**
6
+ * Generic query params map
7
+ */
8
+ export type QueryParams = Record<string, string>
9
+
10
+ /**
11
+ * Custom location interface (useful for testing or external routers)
12
+ */
13
+ export interface CustomLocation {
14
+ query?: QueryParams
15
+ push?: (url: string) => void
16
+ }
17
+
18
+ /**
19
+ * Hook options
20
+ */
21
+ export interface UseManageQueryParamsOptions {
22
+ location?: CustomLocation
23
+ }
24
+
25
+ /**
26
+ * Params getter options
27
+ */
28
+ export interface GetParamsOptions {
29
+ param: string
30
+ callback?: (value: string) => void
31
+ }
32
+
33
+ /**
34
+ * Hook return type
35
+ */
36
+ export interface UseManageQueryParamsResult {
37
+ getQuery: (name: string) => string
38
+ handleQuery: (name: string, value?: string) => void
39
+ handleCleanQuery: (name: string) => void
40
+ getParams: (options: GetParamsOptions) => string
41
+ }
42
+
43
+ /**
44
+ * Hook to manage query parameters in Next.js 13+ (App Router)
45
+ * Supports dependency injection for router/query (testing-friendly).
46
+ *
47
+ * @param {UseManageQueryParamsOptions} options
48
+ * @returns {UseManageQueryParamsResult}
49
+ */
50
+ export const useManageQueryParams = (
51
+ { location }: UseManageQueryParamsOptions = {}
52
+ ): UseManageQueryParamsResult => {
53
+ const router = useRouter()
54
+ const searchParams = useSearchParams()
55
+ const params = useParams()
56
+
57
+ const activeQuery: QueryParams =
58
+ location?.query ??
59
+ Object.fromEntries(searchParams.entries())
60
+
61
+ const pushFn = location?.push ?? ((url: string) => {return router.push(url)})
62
+
63
+ /**
64
+ * Set or update a query param
65
+ * @param name
66
+ * @param value
67
+ */
68
+ const handleQuery = (name: string, value = ''): void => {
69
+ if (!name) return
70
+
71
+ const query = new URLSearchParams(activeQuery)
72
+ query.set(name, value)
73
+
74
+ pushFn(`?${query.toString()}`)
75
+ }
76
+
77
+ /**
78
+ * Remove a query param
79
+ * @param name
80
+ */
81
+ const handleCleanQuery = (name: string): void => {
82
+ if (!name) return
83
+
84
+ const query = new URLSearchParams(activeQuery)
85
+ query.delete(name)
86
+
87
+ pushFn(`?${query.toString()}`)
88
+ }
89
+
90
+ /**
91
+ * Get a query param value
92
+ * @param name
93
+ */
94
+ const getQuery = (name: string): string => {
95
+ if (!name) return ''
96
+ return activeQuery?.[name] ?? ''
97
+ }
98
+
99
+ /**
100
+ * Get a dynamic route param from Next.js
101
+ * @param root0
102
+ * @param root0.param
103
+ * @param root0.callback
104
+ */
105
+ const getParams = ({ param, callback }: GetParamsOptions): string => {
106
+ if (!param) return ''
107
+
108
+ const value = String(params?.[param] ?? '')
109
+ callback?.(value)
110
+
111
+ return value
112
+ }
113
+
114
+ return {
115
+ getQuery,
116
+ handleQuery,
117
+ handleCleanQuery,
118
+ getParams
119
+ }
120
+ }