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,4 +1,5 @@
1
- import { useQuery } from '@apollo/client'
1
+ import { useQuery } from '@apollo/client'
2
+
2
3
  import { GET_MIN_PEDIDO } from './queries'
3
4
 
4
5
  export const useGetMinPrice = ({ idStore = '' } = {}) => {
@@ -1,5 +1,6 @@
1
- import { useState } from 'react'
2
1
  import { useLazyQuery } from '@apollo/client'
2
+ import { useState } from 'react'
3
+
3
4
  import { GET_ONE_RATING_STORE } from './queries'
4
5
 
5
6
  export const useGetOneStoreRating = () => {
@@ -1,5 +1,5 @@
1
- import { useState, useEffect } from 'react'
2
1
  import Cookies from 'js-cookie'
2
+ import { useState, useEffect } from 'react'
3
3
 
4
4
  export const useGetStoreCookie = () => {
5
5
  const [vpStoreCookie, setVpStoreCookie] = useState(null)
@@ -1,4 +1,5 @@
1
- import { useState, useEffect } from 'react'
1
+ import { useState, useEffect } from 'react'
2
+
2
3
  import loadScript from './loadScript'
3
4
  import removeScript from './removeScript'
4
5
 
@@ -26,6 +27,10 @@ export const useGoogleLogin = ({
26
27
  }) => {
27
28
  const [loaded, setLoaded] = useState(false)
28
29
 
30
+ /**
31
+ *
32
+ * @param res
33
+ */
29
34
  function handleSigninSuccess (res) {
30
35
  /*
31
36
  offer renamed response keys to names that match use
@@ -47,6 +52,10 @@ export const useGoogleLogin = ({
47
52
  onSuccess(res)
48
53
  }
49
54
 
55
+ /**
56
+ *
57
+ * @param e
58
+ */
50
59
  function signIn (e) {
51
60
  if (e) {
52
61
  e.preventDefault() // to prevent submit if used within form
@@ -59,13 +68,13 @@ export const useGoogleLogin = ({
59
68
  onRequest()
60
69
  if (responseType === 'code') {
61
70
  GoogleAuth.grantOfflineAccess(options).then(
62
- res => onSuccess(res),
63
- err => onFailure(err)
71
+ res => {return onSuccess(res)},
72
+ err => {return onFailure(err)}
64
73
  )
65
74
  } else {
66
75
  GoogleAuth.signIn(options).then(
67
- res => handleSigninSuccess(res),
68
- err => onFailure(err)
76
+ res => {return handleSigninSuccess(res)},
77
+ err => {return onFailure(err)}
69
78
  )
70
79
  }
71
80
  }
@@ -1,5 +1,8 @@
1
1
  import { useRef, useState, useEffect } from 'react'
2
2
 
3
+ /**
4
+ *
5
+ */
3
6
  export function useHover () {
4
7
  const [value, setValue] = useState(false)
5
8
 
@@ -3,6 +3,10 @@ import { useEffect, useState } from 'react'
3
3
  // const imageUrl = 'https://example.com/image.jpg';
4
4
  // const optimizedUrl = useImageOptimization(imageUrl);
5
5
 
6
+ /**
7
+ *
8
+ * @param imageUrl
9
+ */
6
10
  export function useImageOptimization (imageUrl) {
7
11
  const [optimizedUrl, setOptimizedUrl] = useState(null)
8
12
 
@@ -1,18 +1,25 @@
1
1
  export const createImage = (url) =>
2
- new Promise((resolve, reject) => {
3
- const image = new Image()
4
- image.addEventListener('load', () => resolve(image))
5
- image.addEventListener('error', (error) => reject(error))
6
- image.setAttribute('crossOrigin', 'anonymous') // needed to avoid cross-origin issues on CodeSandbox
7
- image.src = url
8
- })
9
-
2
+ {return new Promise((resolve, reject) => {
3
+ const image = new Image()
4
+ image.addEventListener('load', () => {return resolve(image)})
5
+ image.addEventListener('error', (error) => {return reject(error)})
6
+ image.setAttribute('crossOrigin', 'anonymous') // needed to avoid cross-origin issues on CodeSandbox
7
+ image.src = url
8
+ })}
9
+
10
+ /**
11
+ *
12
+ * @param degreeValue
13
+ */
10
14
  export function getRadianAngle(degreeValue) {
11
15
  return (degreeValue * Math.PI) / 180
12
16
  }
13
17
 
14
18
  /**
15
19
  * Returns the new bounding area of a rotated rectangle.
20
+ * @param width
21
+ * @param height
22
+ * @param rotation
16
23
  */
17
24
  export function rotateSize(width, height, rotation) {
18
25
  const rotRad = getRadianAngle(rotation)
@@ -21,7 +28,7 @@ export function rotateSize(width, height, rotation) {
21
28
  width:
22
29
  Math.abs(Math.cos(rotRad) * width) + Math.abs(Math.sin(rotRad) * height),
23
30
  height:
24
- Math.abs(Math.sin(rotRad) * width) + Math.abs(Math.cos(rotRad) * height),
31
+ Math.abs(Math.sin(rotRad) * width) + Math.abs(Math.cos(rotRad) * height)
25
32
  }
26
33
  }
27
34
 
@@ -30,6 +37,10 @@ export function rotateSize(width, height, rotation) {
30
37
  */
31
38
  /**
32
39
  * This function was adapted from the one in the ReadMe of https://github.com/DominicTobias/react-image-crop
40
+ * @param imageSrc
41
+ * @param pixelCrop
42
+ * @param rotation
43
+ * @param flip
33
44
  */
34
45
  export async function getCroppedImg(
35
46
  imageSrc,
@@ -103,6 +114,11 @@ export async function getCroppedImg(
103
114
  })
104
115
  }
105
116
 
117
+ /**
118
+ *
119
+ * @param imageSrc
120
+ * @param rotation
121
+ */
106
122
  export async function getRotatedImage(imageSrc, rotation = 0) {
107
123
  const image = await createImage(imageSrc)
108
124
  const canvas = document.createElement('canvas')
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Reads EXIF orientation from a JPEG file (native, no dependencies)
3
3
  * @param {File} file
4
+ * @param validTypes
4
5
  * @returns {Promise<number>} Orientation value from 1 to 8
5
6
  */
6
7
  export const getOrientation = (file: File, validTypes: string[]): Promise<number> => {
@@ -9,9 +10,9 @@ export const getOrientation = (file: File, validTypes: string[]): Promise<number
9
10
  reader.onload = (event) => {
10
11
  const view = new DataView(event.target?.result as ArrayBuffer)
11
12
 
12
- if (!validTypes.includes(file.type)) {
13
- return reject(new Error(`Archivo no soportado: ${file.type}`))
14
- }
13
+ if (!validTypes.includes(file.type)) {
14
+ return reject(new Error(`Archivo no soportado: ${file.type}`))
15
+ }
15
16
 
16
17
  let offset = 2
17
18
  const length = view.byteLength
@@ -47,7 +48,7 @@ export const getOrientation = (file: File, validTypes: string[]): Promise<number
47
48
  resolve(1) // por defecto
48
49
  }
49
50
 
50
- reader.onerror = () => reject(new Error('Error leyendo archivo'))
51
+ reader.onerror = () => {return reject(new Error('Error leyendo archivo'))}
51
52
  reader.readAsArrayBuffer(file)
52
53
  })
53
54
  }
@@ -1,14 +1,19 @@
1
- import { useRef, useState } from 'react'
1
+ import { useRef, useState } from 'react'
2
+
2
3
  import { ORIENTATION_TO_ANGLE } from './helper'
3
4
  import { getCroppedImg, getRotatedImage } from './helper/canvasUtils'
4
5
  import { getOrientation } from './helper/getOrientation'
5
6
 
7
+ /**
8
+ *
9
+ * @param file
10
+ */
6
11
  function readFile(file: File): Promise<string> {
7
- return new Promise((resolve) => {
8
- const reader = new FileReader()
9
- reader.addEventListener('load', () => resolve(reader.result as string), false)
10
- reader.readAsDataURL(file)
11
- })
12
+ return new Promise((resolve) => {
13
+ const reader = new FileReader()
14
+ reader.addEventListener('load', () => {return resolve(reader.result as string)}, false)
15
+ reader.readAsDataURL(file)
16
+ })
12
17
  }
13
18
 
14
19
  export type SendNotificationFn = (params: {
@@ -56,237 +61,235 @@ interface UseImageUploaderResult {
56
61
  * @returns {UseImageUploaderResult}
57
62
  */
58
63
  export const useImageUploaderProduct = (
59
- options?: UseImageUploaderOptions
64
+ options?: UseImageUploaderOptions
60
65
  ): UseImageUploaderResult => {
61
- const {
62
- validTypes = ['image/jpeg', 'image/jpg', 'image/png'],
63
- maxSizeMB = 20,
64
- minWidth = 300,
65
- minHeight = 275,
66
- sendNotification
67
- } = options ?? {
68
-
66
+ const {
67
+ validTypes = ['image/jpeg', 'image/jpg', 'image/png'],
68
+ maxSizeMB = 20,
69
+ minWidth = 300,
70
+ minHeight = 275,
71
+ sendNotification
72
+ } = options ?? {
73
+
74
+ }
75
+ const readableFormats = validTypes
76
+ .map((type) => {return type.split('/')[1].toUpperCase()})
77
+
78
+ const formatter = new Intl.ListFormat('es', {
79
+ style: 'long',
80
+ type: 'conjunction'
81
+ })
82
+
83
+ const formattedList = formatter.format(readableFormats)
84
+
85
+ const [loading, setLoading] = useState(false)
86
+ const inputRef = useRef<HTMLInputElement>(null)
87
+ const [open, setOpen] = useState(false)
88
+ const [preview, setPreview] = useState<string | null>(null)
89
+ const [imageSrc, setImageSrc] = useState<string | null>(null)
90
+ const [croppedImage, setCroppedImage] = useState<string | null>(null)
91
+ const [crop, setCrop] = useState({ x: 0, y: 0 })
92
+ const [zoom, setZoom] = useState(1)
93
+ const [rotation, setRotation] = useState(0)
94
+ const [croppedAreaPixels, setCroppedAreaPixels] = useState(null)
95
+ const [error, setError] = useState('')
96
+ const [image, setImage] = useState<File | null>(null)
97
+
98
+
99
+ const onCropComplete = (_: any, croppedPixels: any) => {
100
+ setCroppedAreaPixels(croppedPixels)
101
+ }
102
+
103
+ const showCroppedImage = async () => {
104
+ if (!imageSrc || !croppedAreaPixels) return
105
+ try {
106
+ setLoading(true)
107
+ const base64Image = await getCroppedImg(imageSrc, croppedAreaPixels, rotation) as string
108
+
109
+ setCroppedImage(base64Image)
110
+ setPreview(base64Image)
111
+
112
+ // ✅ Convert base64 to blob and file
113
+ const blob = await (await fetch(base64Image)).blob()
114
+ const file = new File([blob], image?.name ?? 'cropped.jpeg', { type: blob.type })
115
+ setImage(file)
116
+ setLoading(false)
117
+ } catch (e) {
118
+ setLoading(false)
119
+ return sendNotification({
120
+ description: e ?? 'Ocurrió un error',
121
+ title: 'Error',
122
+ backgroundColor: 'error'
123
+ })
69
124
  }
70
- const readableFormats = validTypes
71
- .map((type) => type.split('/')[1].toUpperCase())
72
-
73
- const formatter = new Intl.ListFormat('es', {
74
- style: 'long',
75
- type: 'conjunction'
76
- })
77
-
78
- const formattedList = formatter.format(readableFormats)
79
-
80
- const [loading, setLoading] = useState(false)
81
- const inputRef = useRef<HTMLInputElement>(null)
82
- const [open, setOpen] = useState(false)
83
- const [preview, setPreview] = useState<string | null>(null)
84
- const [imageSrc, setImageSrc] = useState<string | null>(null)
85
- const [croppedImage, setCroppedImage] = useState<string | null>(null)
86
- const [crop, setCrop] = useState({ x: 0, y: 0 })
87
- const [zoom, setZoom] = useState(1)
88
- const [rotation, setRotation] = useState(0)
89
- const [croppedAreaPixels, setCroppedAreaPixels] = useState(null)
90
- const [error, setError] = useState('')
91
- const [image, setImage] = useState<File | null>(null)
92
-
93
-
94
- const onCropComplete = (_: any, croppedPixels: any) => {
95
- setCroppedAreaPixels(croppedPixels)
125
+ }
126
+
127
+ /**
128
+ * Removes the selected image and resets relevant states
129
+ */
130
+ const handleRemoveImage = () => {
131
+ setImage(null)
132
+ setPreview(null)
133
+ setImageSrc(null)
134
+ setCroppedImage(null)
135
+ setZoom(1)
136
+ setCrop({ x: 0, y: 0 })
137
+ setRotation(0)
138
+ setError('')
139
+ if (inputRef.current) inputRef.current.value = ''
140
+ }
141
+
142
+ const onFileChange = async (e: React.ChangeEvent<HTMLInputElement>) => {
143
+ const file = e.target.files?.[0]
144
+ handleRemoveImage()
145
+ if (!file) return
146
+
147
+ if (!validTypes.includes(file.type)) {
148
+
149
+
150
+ const error = `Formato inválido. Solo se permiten: ${formattedList}.`
151
+ sendNotification({
152
+ description: error,
153
+ title: 'Error',
154
+ backgroundColor: 'error'
155
+ })
156
+ return setError(error)
96
157
  }
97
158
 
98
- const showCroppedImage = async () => {
99
- if (!imageSrc || !croppedAreaPixels) return
100
- try {
101
- setLoading(true)
102
- const base64Image = await getCroppedImg(imageSrc, croppedAreaPixels, rotation) as string
103
-
104
- setCroppedImage(base64Image)
105
- setPreview(base64Image)
106
-
107
- // ✅ Convert base64 to blob and file
108
- const blob = await (await fetch(base64Image)).blob()
109
- const file = new File([blob], image?.name ?? 'cropped.jpeg', { type: blob.type })
110
- setImage(file)
111
- setLoading(false)
112
- } catch (e) {
113
- setLoading(false)
114
- return sendNotification({
115
- description: e ?? 'Ocurrió un error',
116
- title: 'Error',
117
- backgroundColor: 'error'
118
- })
119
- }
159
+ if (file.size > maxSizeMB * 1024 * 1024) {
160
+ const error = `El archivo supera los ${maxSizeMB} MB.`
161
+ sendNotification({
162
+ description: error,
163
+ title: 'Error',
164
+ backgroundColor: 'error'
165
+ })
166
+ return setError(`El archivo supera los ${maxSizeMB} MB.`)
120
167
  }
121
168
 
122
- /**
123
- * Removes the selected image and resets relevant states
124
- */
125
- const handleRemoveImage = () => {
126
- setImage(null)
127
- setPreview(null)
128
- setImageSrc(null)
129
- setCroppedImage(null)
130
- setZoom(1)
131
- setCrop({ x: 0, y: 0 })
132
- setRotation(0)
133
- setError('')
134
- if (inputRef.current) inputRef.current.value = ''
169
+ let imageDataUrl = await readFile(file)
170
+
171
+ try {
172
+ const orientation = await getOrientation(file, validTypes)
173
+ const rotation = ORIENTATION_TO_ANGLE[orientation]
174
+ if (rotation) {
175
+ imageDataUrl = await getRotatedImage(imageDataUrl, rotation) as string
176
+ setRotation(rotation)
177
+ }
178
+ } catch (e) {
179
+ return sendNotification({
180
+ description: 'Error desconocido',
181
+ title: 'Error',
182
+ backgroundColor: 'error'
183
+ })
135
184
  }
136
185
 
137
- const onFileChange = async (e: React.ChangeEvent<HTMLInputElement>) => {
138
- const file = e.target.files?.[0]
139
- handleRemoveImage()
140
- if (!file) return
141
-
142
- if (!validTypes.includes(file.type)) {
143
-
144
-
145
- const error = `Formato inválido. Solo se permiten: ${formattedList}.`
146
- sendNotification({
147
- description: error,
148
- title: 'Error',
149
- backgroundColor: 'error'
150
- })
151
- return setError(error)
152
- }
153
-
154
- if (file.size > maxSizeMB * 1024 * 1024) {
155
- const error = `El archivo supera los ${maxSizeMB} MB.`
156
- sendNotification({
157
- description: error,
158
- title: 'Error',
159
- backgroundColor: 'error'
160
- })
161
- return setError(`El archivo supera los ${maxSizeMB} MB.`)
162
- }
163
-
164
- let imageDataUrl = await readFile(file)
165
-
166
- try {
167
- const orientation = await getOrientation(file, validTypes)
168
- const rotation = ORIENTATION_TO_ANGLE[orientation]
169
- if (rotation) {
170
- imageDataUrl = await getRotatedImage(imageDataUrl, rotation) as string
171
- setRotation(rotation)
172
- }
173
- } catch (e) {
174
- return sendNotification({
175
- description: 'Error desconocido',
176
- title: 'Error',
177
- backgroundColor: 'error'
178
- })
179
- }
180
-
181
- const image = new Image()
182
- image.src = imageDataUrl
183
- image.onload = () => {
184
- if (image.width < minWidth || image.height < minHeight) {
185
- const error = `Resolución mínima: ${minWidth}x${minHeight}px.`
186
- sendNotification({
187
- description: error,
188
- title: 'Error',
189
- backgroundColor: 'error'
190
- })
191
- setError(error)
192
- return
193
- }
194
- setImageSrc(imageDataUrl)
195
- setOpen(true)
196
- }
186
+ const image = new Image()
187
+ image.src = imageDataUrl
188
+ image.onload = () => {
189
+ if (image.width < minWidth || image.height < minHeight) {
190
+ const error = `Resolución mínima: ${minWidth}x${minHeight}px.`
191
+ sendNotification({
192
+ description: error,
193
+ title: 'Error',
194
+ backgroundColor: 'error'
195
+ })
196
+ setError(error)
197
+ return
198
+ }
199
+ setImageSrc(imageDataUrl)
200
+ setOpen(true)
197
201
  }
198
-
199
- const handleClose = () => {
200
- setOpen(!open)
202
+ }
203
+
204
+ const handleClose = () => {
205
+ setOpen(!open)
206
+ }
207
+
208
+ const handleDrop = async (event: React.DragEvent<HTMLDivElement>): Promise<void> => {
209
+ event.preventDefault()
210
+ handleRemoveImage()
211
+ const file = event.dataTransfer.files?.[0]
212
+ if (!file) return
213
+
214
+ if (!validTypes.includes(file.type)) {
215
+ const error = `Formato inválido. Solo se permiten: ${formattedList}.`
216
+ sendNotification({
217
+ description: error,
218
+ title: 'Error',
219
+ backgroundColor: 'error'
220
+ })
221
+ return setError(error)
201
222
  }
202
223
 
203
- const handleDrop = async (event: React.DragEvent<HTMLDivElement>): Promise<void> => {
204
- event.preventDefault()
205
- handleRemoveImage()
206
- const file = event.dataTransfer.files?.[0]
207
- if (!file) return
208
-
209
- if (!validTypes.includes(file.type)) {
210
- const error = `Formato inválido. Solo se permiten: ${formattedList}.`
211
- sendNotification({
212
- description: error,
213
- title: 'Error',
214
- backgroundColor: 'error'
215
- })
216
- return setError(error)
217
- }
218
-
219
- if (file.size > maxSizeMB * 1024 * 1024) {
220
- const error = `El archivo supera los ${maxSizeMB} MB.`
221
- sendNotification({
222
- description: error,
223
- title: 'Error',
224
- backgroundColor: 'error'
225
- })
226
- return setError(error)
227
- }
228
-
229
- let imageDataUrl = await readFile(file)
230
-
231
- try {
232
- const orientation = await getOrientation(file, validTypes)
233
- const rotation = ORIENTATION_TO_ANGLE[orientation]
234
- if (rotation) {
235
- imageDataUrl = await getRotatedImage(imageDataUrl, rotation) as string
236
- setRotation(rotation)
237
- }
238
- } catch (e) {
239
- return sendNotification({
240
- description: 'Error al procesar la orientación de la imagen',
241
- title: 'Error',
242
- backgroundColor: 'error'
243
- })
244
- }
245
-
246
- const image = new Image()
247
- image.src = imageDataUrl
248
- image.onload = () => {
249
- if (image.width < minWidth || image.height < minHeight) {
250
- const error = `Resolución mínima: ${minWidth}x${minHeight}px.`
251
- sendNotification({
252
- description: error,
253
- title: 'Error',
254
- backgroundColor: 'error'
255
- })
256
- setError(error)
257
- return
258
- }
259
- setImageSrc(imageDataUrl)
260
- setImage(file)
261
- setOpen(true)
262
- }
224
+ if (file.size > maxSizeMB * 1024 * 1024) {
225
+ const error = `El archivo supera los ${maxSizeMB} MB.`
226
+ sendNotification({
227
+ description: error,
228
+ title: 'Error',
229
+ backgroundColor: 'error'
230
+ })
231
+ return setError(error)
263
232
  }
264
233
 
234
+ let imageDataUrl = await readFile(file)
235
+
236
+ try {
237
+ const orientation = await getOrientation(file, validTypes)
238
+ const rotation = ORIENTATION_TO_ANGLE[orientation]
239
+ if (rotation) {
240
+ imageDataUrl = await getRotatedImage(imageDataUrl, rotation) as string
241
+ setRotation(rotation)
242
+ }
243
+ } catch (e) {
244
+ return sendNotification({
245
+ description: 'Error al procesar la orientación de la imagen',
246
+ title: 'Error',
247
+ backgroundColor: 'error'
248
+ })
249
+ }
265
250
 
266
-
267
-
268
- return {
269
- inputRef,
270
- open,
271
- imageSrc,
272
- preview,
273
- croppedImage,
274
- crop,
275
- zoom,
276
- image,
277
- rotation,
278
- error,
279
- formattedList,
280
- loading,
281
- validTypes,
282
- onCropComplete,
283
- showCroppedImage,
284
- handleRemoveImage,
285
- handleDrop,
286
- onFileChange,
287
- handleClose,
288
- setCrop,
289
- setZoom,
290
- setRotation,
251
+ const image = new Image()
252
+ image.src = imageDataUrl
253
+ image.onload = () => {
254
+ if (image.width < minWidth || image.height < minHeight) {
255
+ const error = `Resolución mínima: ${minWidth}x${minHeight}px.`
256
+ sendNotification({
257
+ description: error,
258
+ title: 'Error',
259
+ backgroundColor: 'error'
260
+ })
261
+ setError(error)
262
+ return
263
+ }
264
+ setImageSrc(imageDataUrl)
265
+ setImage(file)
266
+ setOpen(true)
291
267
  }
268
+ }
269
+
270
+
271
+ return {
272
+ inputRef,
273
+ open,
274
+ imageSrc,
275
+ preview,
276
+ croppedImage,
277
+ crop,
278
+ zoom,
279
+ image,
280
+ rotation,
281
+ error,
282
+ formattedList,
283
+ loading,
284
+ validTypes,
285
+ onCropComplete,
286
+ showCroppedImage,
287
+ handleRemoveImage,
288
+ handleDrop,
289
+ onFileChange,
290
+ handleClose,
291
+ setCrop,
292
+ setZoom,
293
+ setRotation
294
+ }
292
295
  }
@@ -1,5 +1,9 @@
1
1
  import { useEffect, useState } from 'react'
2
2
 
3
+ /**
4
+ *
5
+ * @param imageUrl
6
+ */
3
7
  export function useImageWeight (imageUrl) {
4
8
  const [weight, setWeight] = useState(null)
5
9