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
@@ -14,7 +14,7 @@ export const validateModules = (modules = [], permissions = {}) => {
14
14
 
15
15
  // Validate and filter subModules if they exist
16
16
  const validSubModules = module.subModules?.filter(subModule =>
17
- permissions[subModule.view]?.includes('read')
17
+ {return permissions[subModule.view]?.includes('read')}
18
18
  ) || []
19
19
 
20
20
  // If the module or its subModules don't have read permission, exclude it
@@ -0,0 +1,124 @@
1
+ import { gql, useQuery } from '@apollo/client'
2
+
3
+ import { validateModules } from './helpers/validateModules'
4
+
5
+ /**
6
+ * GraphQL query to get modules and submodules
7
+ */
8
+ const GET_MODULES = gql`
9
+ query GetModules {
10
+ modules {
11
+ mName
12
+ mId
13
+ mPath
14
+ mPriority
15
+ mIcon
16
+ view
17
+ subModules {
18
+ smId
19
+ smName
20
+ smPath
21
+ view
22
+ smIcon
23
+ smState
24
+ }
25
+ }
26
+ }
27
+ `
28
+
29
+ /**
30
+ * SubModule entity
31
+ */
32
+ export interface SubModule {
33
+ smId: string
34
+ smName: string
35
+ smPath: string
36
+ smIcon?: string | null
37
+ smState?: boolean | null
38
+ view?: boolean | null
39
+ }
40
+
41
+ /**
42
+ * Module entity
43
+ */
44
+ export interface Module {
45
+ mId: string
46
+ mName: string
47
+ mPath: string
48
+ mPriority?: number | null
49
+ mIcon?: string | null
50
+ view?: boolean | null
51
+ subModules?: SubModule[]
52
+ }
53
+
54
+ /**
55
+ * Permissions map
56
+ */
57
+ export type Permissions = Record<string, boolean>
58
+
59
+ /**
60
+ * User role structure
61
+ */
62
+ export interface Role {
63
+ permissions?: Permissions
64
+ }
65
+
66
+ /**
67
+ * User data structure
68
+ */
69
+ export interface UserData {
70
+ role?: Role
71
+ }
72
+
73
+ /**
74
+ * Hook params
75
+ */
76
+ export interface UseModulesParams {
77
+ dataUser?: UserData
78
+ callback?: (modules: Module[]) => void
79
+ }
80
+
81
+ /**
82
+ * Hook return type
83
+ */
84
+ export interface UseModulesResult {
85
+ loading: boolean
86
+ error?: Error
87
+ modules: Module[]
88
+ }
89
+
90
+ /**
91
+ * Custom hook to fetch and validate modules based on user permissions
92
+ *
93
+ * @param {UseModulesParams} params - Hook parameters
94
+ * @returns {UseModulesResult}
95
+ */
96
+ export const useModules = ({
97
+ dataUser = {},
98
+ callback = () => {}
99
+ }: UseModulesParams = {}): UseModulesResult => {
100
+ const permissions: Permissions = dataUser?.role?.permissions ?? {}
101
+
102
+ const { loading, error, data } = useQuery<{ modules: Module[] }>(GET_MODULES, {
103
+ fetchPolicy: 'cache-and-network',
104
+ onCompleted: (response) => {
105
+ if (Array.isArray(response?.modules)) {
106
+ callback(response.modules)
107
+ }
108
+ },
109
+ onError: (err) => {
110
+ console.error('Error fetching modules:', err)
111
+ }
112
+ })
113
+
114
+ const safeModules: Module[] = Array.isArray(data?.modules) ? data.modules : []
115
+
116
+ // cast to any to work around a too-narrow parameter type in the helper
117
+ const filteredModules: Module[] = validateModules(safeModules as any, permissions)
118
+
119
+ return {
120
+ loading,
121
+ error: error ?? undefined,
122
+ modules: filteredModules
123
+ }
124
+ }
@@ -1,50 +1,55 @@
1
- import { useEffect, useRef, useState } from "react";
1
+ import { useEffect, useRef, useState } from 'react'
2
2
 
3
+ /**
4
+ *
5
+ * @param options
6
+ * @param options.resetOnExit
7
+ */
3
8
  export function useMouse(
4
9
  options: { resetOnExit } = { resetOnExit: false }
5
10
  ) {
6
- const [position, setPosition] = useState({ x: 0, y: 0 });
11
+ const [position, setPosition] = useState({ x: 0, y: 0 })
7
12
 
8
- const ref = useRef();
13
+ const ref = useRef()
9
14
 
10
15
  const setMousePosition = (event) => {
11
16
  if (ref.current) {
12
- const rect = event.currentTarget.getBoundingClientRect();
17
+ const rect = event.currentTarget.getBoundingClientRect()
13
18
 
14
19
  const x = Math.max(
15
20
  0,
16
21
  Math.round(
17
22
  event.pageX - rect.left - (window.pageXOffset || window.scrollX)
18
23
  )
19
- );
24
+ )
20
25
 
21
26
  const y = Math.max(
22
27
  0,
23
28
  Math.round(
24
29
  event.pageY - rect.top - (window.pageYOffset || window.scrollY)
25
30
  )
26
- );
31
+ )
27
32
 
28
- setPosition({ x, y });
33
+ setPosition({ x, y })
29
34
  } else {
30
- setPosition({ x: event.clientX, y: event.clientY });
35
+ setPosition({ x: event.clientX, y: event.clientY })
31
36
  }
32
- };
37
+ }
33
38
 
34
- const resetMousePosition = () => setPosition({ x: 0, y: 0 });
39
+ const resetMousePosition = () => {return setPosition({ x: 0, y: 0 })}
35
40
 
36
41
  useEffect(() => {
37
- const element = ref?.current ? ref.current : document;
38
- element.addEventListener("mousemove", setMousePosition);
42
+ const element = ref?.current ? ref.current : document
43
+ element.addEventListener('mousemove', setMousePosition)
39
44
  if (options.resetOnExit)
40
- element.addEventListener("mouseleave", resetMousePosition);
45
+ {element.addEventListener('mouseleave', resetMousePosition)}
41
46
 
42
47
  return () => {
43
- element.removeEventListener("mousemove", setMousePosition);
48
+ element.removeEventListener('mousemove', setMousePosition)
44
49
  if (options.resetOnExit)
45
- element.removeEventListener("mouseleave", resetMousePosition);
46
- };
47
- }, [ref.current]);
50
+ {element.removeEventListener('mouseleave', resetMousePosition)}
51
+ }
52
+ }, [ref.current])
48
53
 
49
- return { ref, ...position };
54
+ return { ref, ...position }
50
55
  }
@@ -110,7 +110,7 @@ export interface UseOrderStatusTypesOptions {
110
110
  }
111
111
 
112
112
  export const useOrderStatusTypes = ({
113
- callback = () => undefined
113
+ callback = () => {return undefined}
114
114
  }: UseOrderStatusTypesOptions = {}) => {
115
115
  const {
116
116
  data,
@@ -24,6 +24,8 @@ const UPDATE_ORDER_STATUS_PRIORITIES = gql`
24
24
  /**
25
25
  * Custom hook to update the priority of order statuses.
26
26
  *
27
+ * @param root0
28
+ * @param root0.sendNotification
27
29
  * @returns {{
28
30
  * updatePriorities: (input: OrderStatusPriorityInput[]) => Promise<UpdateStatusPriorityResponse>,
29
31
  * loading: boolean,
@@ -47,16 +49,16 @@ export const useUpdateOrderStatusPriorities = ({
47
49
  success: false,
48
50
  message: 'Input must be a non-empty array.',
49
51
  data: [],
50
- errors: [{ path: 'input', message: 'Invalid or empty input array.' }],
52
+ errors: [{ path: 'input', message: 'Invalid or empty input array.' }]
51
53
  }
52
54
  }
53
55
 
54
56
  const isValid = input.every(
55
57
  ({ idStatus, priority }) =>
56
- typeof idStatus === 'string' &&
58
+ {return typeof idStatus === 'string' &&
57
59
  idStatus.length > 0 &&
58
60
  typeof priority === 'number' &&
59
- priority >= 0
61
+ priority >= 0}
60
62
  )
61
63
 
62
64
  if (!isValid) {
@@ -64,7 +66,7 @@ export const useUpdateOrderStatusPriorities = ({
64
66
  success: false,
65
67
  message: 'Validation failed for one or more input items.',
66
68
  data: [],
67
- errors: [{ path: 'input', message: 'Each item must have a valid idStatus and priority.' }],
69
+ errors: [{ path: 'input', message: 'Each item must have a valid idStatus and priority.' }]
68
70
  }
69
71
  }
70
72
 
@@ -88,7 +90,7 @@ export const useUpdateOrderStatusPriorities = ({
88
90
  success: false,
89
91
  message: 'Unexpected error while updating priorities.',
90
92
  data: [],
91
- errors: [{ path: 'mutation', message: err.message }],
93
+ errors: [{ path: 'mutation', message: err.message }]
92
94
  }
93
95
  }
94
96
  }
@@ -15,7 +15,7 @@ query getAllOrderStoreFinal($idStore: ID, $search: String, $min: Int, $max: Int,
15
15
  pdpId
16
16
  idStore
17
17
  pCodeRef
18
- payMethodPState
18
+ payId
19
19
  pPRecoger
20
20
  totalProductsPrice
21
21
  pSState
@@ -30,7 +30,7 @@ query getAllOrderStoreFinal($idStore: ID, $search: String, $min: Int, $max: Int,
30
30
  ShoppingCard
31
31
  pCodeRef
32
32
  pPStateP
33
- payMethodPState
33
+ payId
34
34
  pPRecoger
35
35
  pDatCre
36
36
  pDatMod
@@ -64,26 +64,36 @@ query getAllOrderStoreFinal($idStore: ID, $search: String, $min: Int, $max: Int,
64
64
  export const GET_ALL_ORDER_FROM_STORE = gql`
65
65
  query getAllSalesStore {
66
66
  getAllSalesStore {
67
- change
68
- channel
69
- status
67
+ change
68
+ channel
69
+ status
70
+ createdAt
71
+ pCodeRef
72
+ idStore
73
+ pdpId
74
+ locationUser
75
+ shoppingCartRefCode
76
+ statusOrder {
77
+ idStatus
78
+ name
79
+ description
80
+ color
81
+ backgroundColor
82
+ priority
83
+ state
70
84
  createdAt
71
- pCodeRef
72
- idStore
73
- pdpId
74
- locationUser
75
- shoppingCartRefCode
76
- payMethodPState
77
85
  updatedAt
78
- totalProductsPrice
79
- unidProducts
80
- getUser {
81
- associateStore
82
- avatar
83
- createdAt
84
- id
85
- email
86
- }
86
+ }
87
+ updatedAt
88
+ totalProductsPrice
89
+ unidProducts
90
+ getUser {
91
+ associateStore
92
+ avatar
93
+ createdAt
94
+ id
95
+ email
96
+ }
87
97
  }
88
98
  }
89
99
  `
@@ -1,4 +1,5 @@
1
- import { gql, useApolloClient, useMutation } from '@apollo/client'
1
+ import { gql, useApolloClient, useMutation } from '@apollo/client'
2
+
2
3
  import { SendNotificationFn } from '../../useImageUploaderProduct'
3
4
  import { updateExistingOrders } from '../../useUpdateExistingOrders'
4
5
  /**
@@ -33,93 +34,95 @@ interface IUseChangeStateOrder {
33
34
  }
34
35
  /**
35
36
  * Hook to trigger the `changePPStateOrder` mutation.
37
+ * @param root0
38
+ * @param root0.sendNotification
36
39
  * @returns {Object} Contains the mutation function, loading and error state.
37
40
  */
38
41
  export const useChangeStateOrder = ({
39
- sendNotification
42
+ sendNotification
40
43
  }: IUseChangeStateOrder) => {
41
- const client = useApolloClient()
44
+ const client = useApolloClient()
42
45
 
43
- const [changeState, { loading, error, data }] = useMutation(CHANGE_STATE_STORE_ORDER, {
44
- onCompleted: (res) => {
45
- if (!res || !res.changePPStateOrder) {
46
- return
47
- }
48
- const { success, data } = res?.changePPStateOrder || {}
49
- if (success) {
50
- const { pCodeRef, pSState } = data ?? {
51
- pCodeRef: null,
52
- pSState: null
53
- }
54
- if (!pCodeRef || !pSState) {
55
- return
56
- }
57
- // client.cache.modify({
58
- // fields: {
59
- // getAllOrdersFromStore(existingOrders = []) {
60
- // try {
61
- // // return
62
- // console.log({ cache: updateExistingOrders(existingOrders, pCodeRef, pSState) })
63
- // } catch (e) {
64
- // return existingOrders
65
- // }
66
- // }
67
- // }
68
- // })
69
- }
46
+ const [changeState, { loading, error, data }] = useMutation(CHANGE_STATE_STORE_ORDER, {
47
+ onCompleted: (res) => {
48
+ if (!res || !res.changePPStateOrder) {
49
+ return
50
+ }
51
+ const { success, data } = res?.changePPStateOrder || {}
52
+ if (success) {
53
+ const { pCodeRef, pSState } = data ?? {
54
+ pCodeRef: null,
55
+ pSState: null
70
56
  }
71
- })
57
+ if (!pCodeRef || !pSState) {
58
+ return
59
+ }
60
+ // client.cache.modify({
61
+ // fields: {
62
+ // getAllOrdersFromStore(existingOrders = []) {
63
+ // try {
64
+ // // return
65
+ // console.log({ cache: updateExistingOrders(existingOrders, pCodeRef, pSState) })
66
+ // } catch (e) {
67
+ // return existingOrders
68
+ // }
69
+ // }
70
+ // }
71
+ // })
72
+ }
73
+ }
74
+ })
72
75
 
73
- /**
74
- * Triggers the mutation to update the pedido state.
75
- * @param {Object} params
76
- * @param {number} params.idStatus - New state of the pedido (required).
77
- * @param {string} params.pCodeRef - Reference code for the pedido (required).
78
- * @param {string} params.pDatMod - Modification date in ISO format (required).
79
- * @returns {Promise<Object>} Response from the mutation.
80
- */
81
- const changeStateOrder = async ({
82
- idStatus,
83
- pCodeRef,
84
- pDatMod,
85
- }: {
76
+ /**
77
+ * Triggers the mutation to update the pedido state.
78
+ * @param {Object} params
79
+ * @param {number} params.idStatus - New state of the pedido (required).
80
+ * @param {string} params.pCodeRef - Reference code for the pedido (required).
81
+ * @param {string} params.pDatMod - Modification date in ISO format (required).
82
+ * @returns {Promise<Object>} Response from the mutation.
83
+ */
84
+ const changeStateOrder = async ({
85
+ idStatus,
86
+ pCodeRef,
87
+ pDatMod
88
+ }: {
86
89
  idStatus: string
87
90
  pCodeRef: string
88
91
  pDatMod: string
89
92
  }) => {
90
- try {
91
- const response = await changeState({
92
- variables:
93
+ try {
94
+ const response = await changeState({
95
+ variables:
93
96
  {
94
- idStatus,
95
- pCodeRef,
96
- pDatMod
97
- },
98
- })
99
- const { success, message } = response?.data?.changePPStateOrder ?? {
100
- success: false,
101
- message: ''
102
- }
103
- sendNotification({
104
- title: success ? 'Exitoso' : 'Error',
105
- description: message,
106
- backgroundColor: success ? 'success' : 'error'
107
- })
108
- return response?.data?.changePPStateOrder ?? {
109
- success: false,
110
- message,
111
- }
112
- } catch (err) {
113
- return {
114
- success: false,
115
- message: err.message || 'Unexpected error occurred',
116
- }
117
- }
97
+ idStatus,
98
+ pCodeRef,
99
+ pDatMod
100
+ }
101
+ })
102
+ const { success, message } = response?.data?.changePPStateOrder ?? {
103
+ success: false,
104
+ message: ''
105
+ }
106
+ sendNotification({
107
+ title: success ? 'Exitoso' : 'Error',
108
+ description: message,
109
+ backgroundColor: success ? 'success' : 'error'
110
+ })
111
+ return response?.data?.changePPStateOrder ?? {
112
+ success: false,
113
+ message
114
+ }
115
+ } catch (err) {
116
+ return {
117
+ success: false,
118
+ message: err.message || 'Unexpected error occurred'
119
+ }
118
120
  }
121
+ }
119
122
 
120
- return [changeStateOrder, {
121
- loading,
122
- error,
123
- data,
124
- }]
123
+ return [changeStateOrder, {
124
+ loading,
125
+ error,
126
+ data
127
+ }]
125
128
  }
@@ -1,6 +1,7 @@
1
- import { useQuery } from '@apollo/client'
1
+ import { useQuery } from '@apollo/client'
2
+ import groupBy from 'lodash/groupBy'
3
+
2
4
  import { GET_ALL_ORDER, GET_ALL_ORDER_FROM_STORE } from '../queries.js'
3
- import groupBy from 'lodash/groupBy'
4
5
 
5
6
  export const useOrders = ({
6
7
  refetchWritePolicy = 'merge',
@@ -53,7 +54,7 @@ export const useOrdersFromStore = ({
53
54
  return data
54
55
  }
55
56
  }) => {
56
- const key = 'status'
57
+ const key = 'status'
57
58
  const {
58
59
  data,
59
60
  loading,
@@ -0,0 +1,3 @@
1
+ export * from './useCreatePaymentMethod'
2
+ export * from './useGetAllPaymentMethods'
3
+ export * from './useGetPaymentMethod'
@@ -0,0 +1,62 @@
1
+ import { gql } from '@apollo/client'
2
+
3
+ export const GET_PAYMENT_METHOD = gql`
4
+ query getPaymentMethod($payId: ID!) {
5
+ getPaymentMethod(payId: $payId) {
6
+ payId
7
+ name
8
+ icon
9
+ state
10
+ paymentPriority
11
+ createdAt
12
+ updatedAt
13
+ }
14
+ }
15
+ `
16
+
17
+ export const GET_ALL_PAYMENT_METHODS = gql`
18
+ query getAllPaymentMethods {
19
+ getAllPaymentMethods {
20
+ payId
21
+ name
22
+ icon
23
+ state
24
+ paymentPriority
25
+ createdAt
26
+ updatedAt
27
+ }
28
+ }
29
+ `
30
+
31
+ export const CREATE_PAYMENT_METHOD = gql`
32
+ mutation createPaymentMethod($input: CreatePaymentMethodInput!) {
33
+ createPaymentMethod(input: $input) {
34
+ payId
35
+ name
36
+ icon
37
+ state
38
+ paymentPriority
39
+ createdAt
40
+ updatedAt
41
+ }
42
+ }
43
+ `
44
+
45
+ export const UPDATE_PAYMENT_METHOD = gql`
46
+ mutation updatePaymentMethod($payId: ID!, $input: UpdatePaymentMethodInput!) {
47
+ updatePaymentMethod(payId: $payId, input: $input) {
48
+ payId
49
+ name
50
+ icon
51
+ state
52
+ paymentPriority
53
+ updatedAt
54
+ }
55
+ }
56
+ `
57
+
58
+ export const DELETE_PAYMENT_METHOD = gql`
59
+ mutation deletePaymentMethod($payId: ID!) {
60
+ deletePaymentMethod(payId: $payId)
61
+ }
62
+ `
@@ -0,0 +1,28 @@
1
+ export interface PaymentMethod {
2
+ payId: string
3
+ name: string
4
+ icon: string
5
+ state: string
6
+ paymentPriority: number
7
+ createdAt?: string
8
+ updatedAt?: string
9
+ }
10
+
11
+ export interface CreatePaymentMethodInput {
12
+ payId: string
13
+ name: string
14
+ icon: string
15
+ state: string
16
+ paymentPriority: number
17
+ mIcon?: number
18
+ mState?: number
19
+ }
20
+
21
+ export interface UpdatePaymentMethodInput {
22
+ name?: string
23
+ icon?: string
24
+ state?: string
25
+ paymentPriority?: number
26
+ mIcon?: number
27
+ mState?: number
28
+ }
@@ -0,0 +1,25 @@
1
+ 'use client'
2
+
3
+ import { useMutation } from '@apollo/client'
4
+
5
+ import { CREATE_PAYMENT_METHOD, GET_ALL_PAYMENT_METHODS } from '../paymentMethod.gql'
6
+ import { CreatePaymentMethodInput, PaymentMethod } from '../paymentMethod.types'
7
+
8
+
9
+ export const useCreatePaymentMethod = () => {
10
+ const [createPaymentMethod, { loading, error }] = useMutation<
11
+ { createPaymentMethod: PaymentMethod },
12
+ { input: CreatePaymentMethodInput }
13
+ >(CREATE_PAYMENT_METHOD, {
14
+ refetchQueries: [{ query: GET_ALL_PAYMENT_METHODS }]
15
+ })
16
+
17
+ const handleCreate = async (input: CreatePaymentMethodInput) => {
18
+ const res = await createPaymentMethod({ variables: { input } })
19
+ return res.data?.createPaymentMethod
20
+ }
21
+ return [handleCreate, {
22
+ loading,
23
+ error
24
+ }]
25
+ }
@@ -0,0 +1,19 @@
1
+ 'use client'
2
+
3
+ import { useQuery } from '@apollo/client'
4
+
5
+ import { GET_ALL_PAYMENT_METHODS } from '../paymentMethod.gql'
6
+ import { PaymentMethod } from '../paymentMethod.types'
7
+
8
+ export const useGetAllPaymentMethods = () => {
9
+ const { data, loading, error, refetch } = useQuery<{
10
+ getAllPaymentMethods: PaymentMethod[]
11
+ }>(GET_ALL_PAYMENT_METHODS)
12
+
13
+ return {
14
+ data: data?.getAllPaymentMethods ?? [],
15
+ loading,
16
+ error,
17
+ refetch
18
+ }
19
+ }