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,26 +0,0 @@
1
- import { onError } from '@apollo/client/link/error'
2
-
3
- export const errorHandler = (error) => {
4
- let logout = null
5
- if (error && Array.isArray(error?.errors)) {
6
- error.errors?.length && error?.errors?.forEach(err => {
7
- if (err?.extensions) {
8
- const { code, message } = err?.extensions || {}
9
- if (code === 'UNAUTHENTICATED' || code === 'FORBIDDEN') {
10
- logout = true
11
- return {
12
- status: 'FORBIDDEN',
13
- message
14
- }
15
- }
16
- }
17
- })
18
- }
19
- return logout
20
- }
21
-
22
- export const errorLink = onError(({ graphQLErrors, networkError }) => {
23
- if (graphQLErrors)graphQLErrors.map(({ message, location, path }) => { return console.log(`[GraphQL error]: Message: ${message}, Location: ${location}, Path: ${path}`) })
24
-
25
- if (networkError) console.log(`[Network error]: ${networkError}`)
26
- })
@@ -1,14 +0,0 @@
1
- export function convertToMilitaryTime (time12Hour) {
2
- const [time, period] = time12Hour.split(' ')
3
- let [hours, minutes] = time.split(':')
4
-
5
- if (period === 'PM' && hours !== '12') {
6
- hours = String(Number(hours) + 12)
7
- }
8
-
9
- if (period === 'AM' && hours === '12') {
10
- hours = '00'
11
- }
12
-
13
- return `${hours}:${minutes}`
14
- }
@@ -1,38 +0,0 @@
1
- /**
2
- * Generate the store URL based on given parameters
3
- * @param {Object} city - The city object with name
4
- * @param {Object} department - The department object with name
5
- * @param {string} storeName - The name of the store
6
- * @param {string} idStore - The ID of the store
7
- * @returns {string} - The generated URL or null if any field is missing
8
- */
9
- export const generateStoreURL = ({
10
- city,
11
- department,
12
- storeName,
13
- idStore,
14
- rootMainPath = 'delivery'
15
- }) => {
16
- try {
17
- // Validate all necessary fields
18
- if (
19
- !process.env.MAIN_URL_BASE ||
20
- !city?.cName ||
21
- !department?.dName ||
22
- !storeName ||
23
- !idStore
24
- ) {
25
- return '/' // Return null or any default case you'd prefer
26
- }
27
-
28
- const cityName = city.cName.toLocaleLowerCase()
29
- const departmentName = department.dName.toLocaleLowerCase()
30
-
31
- // Replace spaces in storeName with hyphens
32
- const formattedStoreName = storeName.replace(/\s+/g, '-')
33
-
34
- return `${process.env.MAIN_URL_BASE}/${rootMainPath}/${cityName}-${departmentName}/${formattedStoreName}/${idStore}`
35
- } catch (_) {
36
- return '/'
37
- }
38
- }
@@ -1,49 +0,0 @@
1
- import crypto from 'crypto'
2
-
3
- function generateEncryptionKey (password, salt) {
4
- return crypto
5
- .pbkdf2Sync(password, salt, 100000, 32, 'sha256')
6
- .toString('hex')
7
- .slice(0, 32)
8
- }
9
-
10
- const ENCRYPTION_KEY = generateEncryptionKey(
11
- 'tu-contraseña',
12
- 'alguna-sal-segura'
13
- )
14
- const IV_LENGTH = 16 // Para AES, este siempre debe ser 16
15
-
16
- export const encryptSession = (text) => {
17
- try {
18
- const iv = crypto.randomBytes(IV_LENGTH)
19
- const cipher = crypto.createCipheriv(
20
- 'aes-256-cbc',
21
- Buffer.from(ENCRYPTION_KEY),
22
- iv
23
- )
24
- let encrypted = cipher.update(text)
25
- encrypted = Buffer.concat([encrypted, cipher.final()])
26
- return iv.toString('hex') + ':' + encrypted.toString('hex')
27
- } catch (error) {
28
- return null
29
- }
30
- }
31
-
32
- export const decryptSession = (text) => {
33
- try {
34
- if (!text) return
35
- const textParts = text.split(':')
36
- const iv = Buffer.from(textParts.shift(), 'hex')
37
- const encryptedText = Buffer.from(textParts.join(':'), 'hex')
38
- const decipher = crypto.createDecipheriv(
39
- 'aes-256-cbc',
40
- Buffer.from(ENCRYPTION_KEY),
41
- iv
42
- )
43
- let decrypted = decipher.update(encryptedText)
44
- decrypted = Buffer.concat([decrypted, decipher.final()])
45
- return decrypted.toString()
46
- } catch (error) {
47
- return null
48
- }
49
- }
@@ -1,18 +0,0 @@
1
- export const getSession = async () => {
2
- try {
3
- const res = await fetch(`${process.env.URL_BASE}/api/auth/getAuth`,
4
- { method: 'GET', headers: { 'Content-Type': 'application/json' } })
5
- const data = await res.json()
6
- const { ok, ok: { user }, isSession } = data || {}
7
- const { deviceid, token } = user || {}
8
- return {
9
- user,
10
- ok,
11
- isSession,
12
- deviceid,
13
- token
14
- }
15
- } catch (e) {
16
- return e
17
- }
18
- }
@@ -1,48 +0,0 @@
1
- export const getTotalHours = (days = []) => {
2
- const totalMinutesArray = days?.map((day) => {
3
- const { schHoSta, schHoEnd } = day
4
-
5
- // Handle potential invalid time strings
6
- if (!isValidTimeString(schHoSta) || !isValidTimeString(schHoEnd)) {
7
- return 0 // Ignore invalid time strings and return 0
8
- }
9
-
10
- const [startHours, startMinutes] = schHoSta.split(':')
11
- const [endHours, endMinutes] = schHoEnd.split(':')
12
-
13
- // Convert hours and minutes to integers for calculations
14
- let totalHoursInt = parseInt(endHours, 10) - parseInt(startHours, 10)
15
- const totalMinutesInt = parseInt(endMinutes, 10) - parseInt(startMinutes, 10)
16
-
17
- // Handle negative total minutes (occurs when endMinutes < startMinutes)
18
- let totalMinutes = totalMinutesInt
19
- if (totalMinutes < 0) {
20
- totalHoursInt-- // Decrement total hours for negative minutes
21
- totalMinutes += 60 // Add 60 minutes to account for borrowing from previous hour
22
- }
23
-
24
- // Calculate total time in minutes
25
- const totalTimeMinutes = totalHoursInt * 60 + totalMinutes
26
-
27
- return totalTimeMinutes
28
- })
29
-
30
- // Calculate the sum of total minutes for all days
31
- const totalMinutes = totalMinutesArray.reduce((acc, curr) => acc + curr, 0)
32
-
33
- // Convert total minutes to hours and minutes format
34
- const totalHours = Math.floor(totalMinutes / 60)
35
- const remainingMinutes = totalMinutes % 60
36
-
37
- // Format the total time as "00:00"
38
- const formattedHours = totalHours.toString().padStart(2, '0')
39
- const formattedMinutes = remainingMinutes.toString().padStart(2, '0')
40
-
41
- return `${formattedHours}:${formattedMinutes}`
42
- }
43
-
44
- // Function to validate time string format (HH:MM)
45
- export const isValidTimeString = (timeString) => {
46
- const timeRegex = /^([0-1][0-9]|2[0-3]):([0-5][0-9])$/
47
- return timeRegex.test(timeString)
48
- }
@@ -1,156 +0,0 @@
1
- import {
2
- getCurrentDayAndTime,
3
- getOpeningKeyFromDay,
4
- getTimeString,
5
- sortOpeningsByDay,
6
- weekDays,
7
- timeToInt,
8
- days
9
- } from './helpers'
10
-
11
- export const statusOpenStores = ({
12
- dataSchedules = []
13
- } = {}) => {
14
- const handleHourPmAM = (hour) => {
15
- const hourPmAm = new Date(`1/1/1999 ${hour}`).toLocaleString('en-US', { hour: 'numeric', minute: 'numeric', hour12: true })
16
- return hour ? hourPmAm : ''
17
- }
18
-
19
- const handleState = (message, open) => {
20
- return {
21
- message,
22
- open
23
- }
24
- }
25
-
26
- function getNextDaySchedule (dataSchedules, currentDayOfWeek) {
27
- const today = new Date()
28
- const tomorrow = new Date(today)
29
- tomorrow.setDate(today.getDate() + 1)
30
- const dayOfWeekTomorrow = tomorrow.getDay()
31
-
32
- const findNextDay = dataSchedules?.length
33
- ? dataSchedules?.some((schedule) => schedule?.schDay === dayOfWeekTomorrow)
34
- : false
35
-
36
- const findDataNextDay = dataSchedules?.length
37
- ? dataSchedules?.find((schedule) => schedule?.schDay === dayOfWeekTomorrow)
38
- : {}
39
-
40
- return { findNextDay, findDataNextDay, dayOfWeekTomorrow }
41
- }
42
-
43
- function getOpeningStatus (openings, currentTime, currentDayOfWeek) {
44
- const weekDayLookup = [
45
- 'Sunday',
46
- 'Monday',
47
- 'Tuesday',
48
- 'Wednesday',
49
- 'Thursday',
50
- 'Friday',
51
- 'Saturday'
52
- ]
53
-
54
- const ceroHours = '00:00 - 00:00'
55
- let dayOfWeek = currentDayOfWeek
56
-
57
- for (let i = 0; i < 7; i++) {
58
- const dayName = weekDayLookup[dayOfWeek % 7]
59
- const opening = openings && openings['opening' + dayName.substring(0, 3)]
60
- const timeSpans = opening?.split(';').map((item) => item.trim())
61
-
62
- for (const span of timeSpans) {
63
- const hours = span.split('-').map((item) => item.trim())
64
- const openTime = timeToInt(hours[0])
65
- const closeTime = timeToInt(hours[1])
66
-
67
- if (currentTime >= openTime && currentTime <= closeTime) {
68
- return handleState(
69
- 'Abierto Ahora - Cierra a las: ' + handleHourPmAM(hours[1]),
70
- true
71
- )
72
- }
73
-
74
- if (currentTime < openTime && dayOfWeek === currentDayOfWeek) {
75
- return handleState(
76
- 'Aun temprano - Abre hoy a las: ' + handleHourPmAM(hours[0]),
77
- false
78
- )
79
- }
80
-
81
- if (currentTime >= closeTime - 30 * 60000 && currentTime < closeTime && dayOfWeek === currentDayOfWeek) {
82
- return handleState(
83
- 'Pronto por cerrar - Cierra hoy a las: ' + handleHourPmAM(hours[1]),
84
- true
85
- )
86
- }
87
-
88
- const { findNextDay, findDataNextDay, dayOfWeekTomorrow } = getNextDaySchedule(
89
- dataSchedules,
90
- currentDayOfWeek
91
- )
92
-
93
- if (findNextDay && findDataNextDay?.schHoSta) {
94
- const nameOfDayTomorrow = weekDays[dayOfWeekTomorrow]
95
- return handleState(
96
- `Cerrado abre - Mañana ${nameOfDayTomorrow} ${!!findDataNextDay?.schHoSta && 'a las'} ${
97
- findDataNextDay?.schHoSta ?? ''
98
- }`,
99
- false
100
- )
101
- }
102
-
103
- const nextDayName = weekDayLookup[(dayOfWeek + 1) % 7]
104
- const nextOpening = openings && openings['opening' + nextDayName.substring(0, 3)]
105
- const nextHours = nextOpening?.split(';')?.map((item) => item?.trim())
106
-
107
- if (nextHours[0] !== ceroHours) {
108
- return handleState(
109
- 'Cerrado - Abre el ' + days[nextDayName] + ' a las ' + nextHours[0],
110
- false
111
- )
112
- }
113
- }
114
-
115
- dayOfWeek++
116
- }
117
-
118
- return handleState('Cerrado', false)
119
- }
120
-
121
- function getIsOpening (openings) {
122
- const { currentTime, currentDayOfWeek } = getCurrentDayAndTime()
123
- return getOpeningStatus(openings, currentTime, currentDayOfWeek)
124
- }
125
-
126
- const createOpeningsObject = (dataSchedules) => {
127
- const openings = {}
128
- const existStoreSchedule = dataSchedules || []
129
-
130
- existStoreSchedule?.forEach((schedule) => {
131
- const day = schedule.schDay
132
- const openingKey = getOpeningKeyFromDay(day)
133
- const schHoSta = getTimeString(schedule?.schHoSta)
134
- const schHoEnd = getTimeString(schedule?.schHoEnd)
135
- openings[openingKey] = `${schHoSta} - ${schHoEnd}`
136
- })
137
-
138
- for (let i = 0; i < 7; i++) {
139
- const openingKey = getOpeningKeyFromDay(i)
140
- // eslint-disable-next-line no-prototype-builtins
141
- if (!(openingKey in openings)) {
142
- openings[openingKey] = '00:00 - 00:00' // Horario vacío para el día faltante
143
- }
144
- }
145
-
146
- return openings
147
- }
148
-
149
- // Luego puedes usar esta función así:
150
- const openings = createOpeningsObject(dataSchedules)
151
- // ...haz lo que necesites con el objeto openings
152
- const sortedOpenings = sortOpeningsByDay(openings)
153
-
154
- // Crear el array completo con objetos de tiempo
155
- return getIsOpening(sortedOpenings)
156
- }
@@ -1,16 +0,0 @@
1
- const data = [
2
- { x: '2021-10-17T14:38:45.540Z', y: 2 }
3
- ]
4
- export const getDateParts = (isString) => {
5
- const [year, month, day, hr, min, sec] = isString.split(/\D/g)
6
- return { year, month, day, hr, min, sec }
7
- }
8
- export function groupDates (arr) {
9
- const total = arr.reduce((a, b) => {
10
- const { hr } = getDateParts(b.x)
11
- return a + parseInt(hr)
12
- }, 0)
13
- return total
14
- }
15
- // eslint-disable-next-line no-unused-vars
16
- const result = groupDates(data)
@@ -1,100 +0,0 @@
1
- import { useMutation, useQuery } from '@apollo/client'
2
- import { useState } from 'react'
3
- import {
4
- DELETE_ONE_CAT_PRODUCTS,
5
- GET_ULTIMATE_CATEGORY_PRODUCTS,
6
- UPDATE_CAT_IN_PRODUCT
7
- } from '../useProductsFood/queriesStore'
8
- import { GET_ONE_STORE_IN_CATEGORY } from './queries'
9
-
10
- export const useCategoryInStore = ({ catStoreId, setAlertBox = () => {} } = {}) => {
11
- // STATES
12
- const [categories, setOneCategoryInStore] = useState([])
13
- const [deleteCatOfProducts] = useMutation(DELETE_ONE_CAT_PRODUCTS, {
14
- onError: (e) => {
15
- setAlertBox({
16
- message: e.graphQLErrors[0].message,
17
- color: 'error'
18
- })
19
- },
20
- update (cache) {
21
- cache.modify({
22
- fields: {
23
- catProductsAll (dataOld = []) {
24
- return cache.writeQuery({ query: GET_ULTIMATE_CATEGORY_PRODUCTS, data: dataOld })
25
- }
26
- }
27
- })
28
- }
29
- })
30
- const [updatedCatWithProducts] = useMutation(UPDATE_CAT_IN_PRODUCT, {
31
- onError: (e) => {
32
- console.log({
33
- message: e.graphQLErrors[0].message,
34
- color: 'error'
35
- })
36
- },
37
- update (cache) {
38
- cache.modify({
39
- fields: {
40
- catProductsAll (dataOld = []) {
41
- return cache.writeQuery({ query: GET_ULTIMATE_CATEGORY_PRODUCTS, data: dataOld })
42
- }
43
- }
44
- })
45
- }
46
- })
47
- // QUERIES
48
- const { data } = useQuery(GET_ULTIMATE_CATEGORY_PRODUCTS)
49
- const {
50
- loading,
51
- error
52
- } = useQuery(GET_ONE_STORE_IN_CATEGORY, {
53
- variables: {
54
- catStore: catStoreId
55
- },
56
- onError: () => {
57
- console.log({ message: '', duration: 5000 })
58
- },
59
- onCompleted: () => {
60
- if (data?.getOneCatStore) {
61
- setOneCategoryInStore(data?.getOneCatStore)
62
- }
63
- }
64
- })
65
- // HANDLESS
66
- const handlerDeleteCategoryInStore = (category) => {
67
- const { pState, idPc } = category || {}
68
- if (!idPc || !pState) return
69
- return deleteCatOfProducts({
70
- variables: { idPc, pState },
71
- update (cache) {
72
- cache.modify({
73
- fields: {
74
- catProductsAll (dataOld = []) {
75
- return cache.writeQuery({ query: GET_ULTIMATE_CATEGORY_PRODUCTS, data: dataOld })
76
- }
77
- }
78
- })
79
- }
80
- })
81
- }
82
- const handleUpdateCatInProduct = async ({ data }) => {
83
- await updatedCatWithProducts({
84
- variables: {
85
- input: {
86
- setData: data?.map(x => { return { idProduct: x.pId } }),
87
- idCat: ''
88
- }
89
- }
90
- })
91
- }
92
- return {
93
- categories,
94
- data: data?.catProductsAll || [],
95
- loading,
96
- error,
97
- handlerDeleteCategoryInStore,
98
- handleUpdateCatInProduct
99
- }
100
- }
@@ -1,28 +0,0 @@
1
- import React from 'react'
2
- import { useState } from 'react';
3
- import { useMutation } from '@apollo/client'
4
- import { UPDATE_EXT_PRODUCT_FOOD_OPTIONAL } from './queries';
5
- export const useEditOneExtProductFoodOptional = () => {
6
- const [updateExtProductFood] = useMutation(UPDATE_EXT_PRODUCT_FOOD_OPTIONAL);
7
- const [loading, setLoading] = useState(false);
8
-
9
- const updateOneExtraProductFood = async (input) => {
10
- setLoading(true);
11
-
12
- try {
13
- const { data } = await updateExtProductFood({
14
- variables: { input }
15
- });
16
- console.log('Product food updated:', data.editExtProductFoodOptional);
17
- setLoading(false);
18
- } catch (error) {
19
- console.error('Error updating product food:', error.message);
20
- setLoading(false);
21
- throw new Error('Error updating product food');
22
- }
23
- };
24
- return {
25
- loading,
26
- updateOneExtraProductFood
27
- }
28
- }
@@ -1,11 +0,0 @@
1
- import { EDIT_EXTRA_SUB_OPTIONAL_PRODUCTS } from "./queries"
2
- import { useMutation } from '@apollo/client'
3
-
4
- export const useEditSubProductOptional = () => {
5
- const [editExtFoodSubsOptional, {
6
- loading,
7
- error,
8
- called
9
- }] = useMutation(EDIT_EXTRA_SUB_OPTIONAL_PRODUCTS)
10
- return [editExtFoodSubsOptional, { loading, error, called }]
11
- }
@@ -1,31 +0,0 @@
1
- function BroadcastChannel (name = 'nextauth.message') {
2
- return {
3
- receive: function (onReceive) {
4
- const handler = function (event) {
5
- if (event.key !== name) return
6
- const message = JSON.parse(event.newValue ?? '{}')
7
- if (message?.event !== 'session' || !message?.data) return
8
- onReceive(message)
9
- }
10
- window.addEventListener('storage', handler)
11
- return function () {
12
- window.removeEventListener('storage', handler)
13
- }
14
- },
15
- post: function (message) {
16
- if (typeof window === 'undefined') return
17
- try {
18
- localStorage.setItem(
19
- name,
20
- JSON.stringify({ ...message, timestamp: Date.now() })
21
- )
22
- } catch {
23
- // The localStorage API isn't always available.
24
- // It won't work in private mode prior to Safari 11 for example.
25
- // Notifications are simply dropped if an error is encountered.
26
- }
27
- }
28
- }
29
- }
30
-
31
- export { BroadcastChannel }
@@ -1,40 +0,0 @@
1
- 'use client'
2
- import { useRouter, useSearchParams } from 'next/navigation'
3
-
4
- /**
5
- * Hook to manage query parameters in Next.js 13+ (App Router),
6
- * with support for custom router/query injection.
7
- * @param {Object} [options] - Optional parameters.
8
- * @param {Object} [options.location] - Custom location object with query and push method
9
- */
10
- export const useManageQueryParams = ({
11
- location
12
- } = {}) => {
13
- const router = useRouter()
14
- const searchParams = useSearchParams()
15
-
16
- const activeQuery = location?.query || Object.fromEntries(searchParams.entries())
17
- const pushFn = location?.push || ((url) => router.push(url))
18
-
19
- const handleQuery = (name, value = '') => {
20
- const params = new URLSearchParams(activeQuery)
21
- params.set(name, value)
22
- pushFn(`?${params.toString()}`)
23
- }
24
-
25
- const handleCleanQuery = (name) => {
26
- const params = new URLSearchParams(activeQuery)
27
- params.delete(name)
28
- pushFn(`?${params.toString()}`)
29
- }
30
-
31
- const getQuery = (name) => {
32
- return activeQuery?.[name] || ''
33
- }
34
-
35
- return {
36
- getQuery,
37
- handleQuery,
38
- handleCleanQuery
39
- }
40
- }
@@ -1,58 +0,0 @@
1
- import { gql, useQuery } from '@apollo/client'
2
- import { validateModules } from './helpers/validateModules'
3
-
4
- const GET_MODULES = gql`
5
- query GetModules {
6
- modules {
7
- mName
8
- mId
9
- mPath
10
- mPriority
11
- mIcon
12
- view
13
- subModules {
14
- smId
15
- smName
16
- smPath
17
- view
18
- smState
19
- }
20
- }
21
- }
22
- `
23
-
24
- export const useModules = ({
25
- dataUser = {},
26
- callback = () => {}
27
- }) => {
28
- const { role } = dataUser ?? {
29
- role: {
30
- permissions: {}
31
- }
32
- }
33
- const {
34
- loading,
35
- error,
36
- data
37
- } = useQuery(GET_MODULES, {
38
- fetchPolicy: 'cache-and-network',
39
- onCompleted: (data) => {
40
- if (Array.isArray(data?.modules)) {
41
- callback(data.modules)
42
- }
43
- },
44
- onError: (error) => {
45
- console.error('Error fetching modules:', error)
46
- }
47
- })
48
-
49
- const permissions = role?.permissions ?? {}
50
-
51
- const filteredModules = validateModules(data ? data.modules : [], permissions)
52
-
53
- return {
54
- loading,
55
- error,
56
- modules: data ? filteredModules : []
57
- }
58
- }