npm-pkg-hook 1.12.4 → 1.12.7

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 (316) hide show
  1. package/dist/index.cjs +20089 -0
  2. package/dist/index.js +19854 -0
  3. package/dist/index.mjs +19854 -0
  4. package/package.json +28 -6
  5. package/.babelrc +0 -0
  6. package/.env +0 -5
  7. package/.eslintrc.js +0 -38
  8. package/.eslintrc.json +0 -127
  9. package/.github/pull_request_template.md +0 -18
  10. package/.github/workflows/pepeline.yaml +0 -30
  11. package/expire.json +0 -1
  12. package/jsconfig.json +0 -28
  13. package/script.txt +0 -7
  14. package/src/config/client/errors.js +0 -26
  15. package/src/config/client/index.js +0 -1
  16. package/src/config/content/en.json +0 -5
  17. package/src/config/content/es.json +0 -5
  18. package/src/config/content/index.js +0 -16
  19. package/src/cookies/index.js +0 -3
  20. package/src/hooks/addTenMinutes/index.js +0 -14
  21. package/src/hooks/calculateLogLatHaversine/index.js +0 -30
  22. package/src/hooks/completeSchedules/index.js +0 -22
  23. package/src/hooks/convertToMilitaryTime/index.js +0 -14
  24. package/src/hooks/generateStoreURL/index.js +0 -38
  25. package/src/hooks/generateTemplate/index.js +0 -62
  26. package/src/hooks/getCardType/index.js +0 -24
  27. package/src/hooks/getCategoriesWithProduct/helpers/index.js +0 -7
  28. package/src/hooks/getCategoriesWithProduct/index.js +0 -62
  29. package/src/hooks/getGlobalSession/index.js +0 -49
  30. package/src/hooks/getSession/index.js +0 -18
  31. package/src/hooks/getTodayTimestamps/index.js +0 -64
  32. package/src/hooks/getTotalHours/index.js +0 -48
  33. package/src/hooks/handleLogin/index.js +0 -10
  34. package/src/hooks/index.ts +0 -147
  35. package/src/hooks/isTokenExpired/index.js +0 -17
  36. package/src/hooks/newMessageSubscription/index.js +0 -28
  37. package/src/hooks/newStoreOrderSubscription/index.js +0 -26
  38. package/src/hooks/statusOpenStores/helpers/index.js +0 -101
  39. package/src/hooks/statusOpenStores/index.js +0 -156
  40. package/src/hooks/updateExtProductFoodsOptional/index.js +0 -40
  41. package/src/hooks/useAcumulateDate/index.js +0 -16
  42. package/src/hooks/useAllStoresPendingToRegister/index.js +0 -34
  43. package/src/hooks/useAmountInput/index.ts +0 -117
  44. package/src/hooks/useAnimationFrame/index.js +0 -45
  45. package/src/hooks/useAnimationText/index.jsx +0 -31
  46. package/src/hooks/useAsideCart/helpers/index.js +0 -22
  47. package/src/hooks/useAsideCart/index.js +0 -214
  48. package/src/hooks/useAsideCart/queries.js +0 -10
  49. package/src/hooks/useBanner/index.js +0 -19
  50. package/src/hooks/useCart/index.js +0 -2
  51. package/src/hooks/useCart/queries.js +0 -174
  52. package/src/hooks/useCart/useCart/helpers/index.js +0 -75
  53. package/src/hooks/useCart/useCart/index.js +0 -412
  54. package/src/hooks/useCart/useGetCart/index.js +0 -33
  55. package/src/hooks/useCatWithProduct/index.js +0 -48
  56. package/src/hooks/useCatWithProduct/queries.js +0 -200
  57. package/src/hooks/useCatWithProductClient/index.js +0 -56
  58. package/src/hooks/useCatWithProductClient/queries.js +0 -56
  59. package/src/hooks/useCategoriesProduct/index.js +0 -13
  60. package/src/hooks/useCategoriesProduct/queries.js +0 -16
  61. package/src/hooks/useCategoryInStore/index.js +0 -100
  62. package/src/hooks/useCategoryInStore/queries.js +0 -78
  63. package/src/hooks/useCategoryStore/index.js +0 -7
  64. package/src/hooks/useCategoryStore/queries.js +0 -16
  65. package/src/hooks/useChartData/index.js +0 -170
  66. package/src/hooks/useChartData/useChartData/index.js +0 -199
  67. package/src/hooks/useChartData/useChartDataAllOrders/index.js +0 -94
  68. package/src/hooks/useChatRoomSubscription/index.js +0 -28
  69. package/src/hooks/useCheckbox/index.js +0 -115
  70. package/src/hooks/useCities/index.js +0 -13
  71. package/src/hooks/useCities/queries.js +0 -12
  72. package/src/hooks/useClients/index.js +0 -96
  73. package/src/hooks/useClients/queries.js +0 -212
  74. package/src/hooks/useColorByLetters/helpers/alea.js +0 -54
  75. package/src/hooks/useColorByLetters/helpers/colors.js +0 -45
  76. package/src/hooks/useColorByLetters/helpers/index.js +0 -18
  77. package/src/hooks/useColorByLetters/helpers/mersenne_twister.js +0 -118
  78. package/src/hooks/useColorByLetters/index.js +0 -27
  79. package/src/hooks/useConnection/index.js +0 -24
  80. package/src/hooks/useCountries/index.js +0 -19
  81. package/src/hooks/useCountries/queries.js +0 -12
  82. package/src/hooks/useCreateDeliveryTime/index.js +0 -51
  83. package/src/hooks/useCreateOrderStatusType/index.ts +0 -132
  84. package/src/hooks/useCreateProduct/helpers/index.js +0 -23
  85. package/src/hooks/useCreateProduct/helpers/manageCacheDataCatProduct/index.js +0 -52
  86. package/src/hooks/useCreateProduct/helpers/useEditImageProduct/index.js +0 -176
  87. package/src/hooks/useCreateProduct/index.js +0 -334
  88. package/src/hooks/useCreateStorePendingToRegister/index.js +0 -13
  89. package/src/hooks/useCreateStorePendingToRegister/queries.js +0 -10
  90. package/src/hooks/useDashboardComponents/index.js +0 -50
  91. package/src/hooks/useDeleteExtraProductFoods/index.js +0 -12
  92. package/src/hooks/useDeleteSubProductOptional/index.js +0 -30
  93. package/src/hooks/useDeleteSubProductOptional/queries.js +0 -10
  94. package/src/hooks/useDeliveryTime/index.js +0 -27
  95. package/src/hooks/useDepartments/index.js +0 -13
  96. package/src/hooks/useDepartments/queries.js +0 -13
  97. package/src/hooks/useDessert/helpers/index.js +0 -51
  98. package/src/hooks/useDessert/index.js +0 -525
  99. package/src/hooks/useDessertWithPrice/helpers/index.js +0 -76
  100. package/src/hooks/useDessertWithPrice/index.js +0 -373
  101. package/src/hooks/useDessertWithPrice/queries.js +0 -18
  102. package/src/hooks/useDevWS/index.ts +0 -53
  103. package/src/hooks/useDevices/index.js +0 -2
  104. package/src/hooks/useDevices/queries.js +0 -28
  105. package/src/hooks/useDevices/useGetDevices.js +0 -28
  106. package/src/hooks/useDevices/useRegisterDevices.js +0 -75
  107. package/src/hooks/useDownloadReports/helpers/downloadFileFromResponse.ts +0 -21
  108. package/src/hooks/useDownloadReports/index.ts +0 -2
  109. package/src/hooks/useDownloadReports/useDownloadReportByDay/index.ts +0 -103
  110. package/src/hooks/useDownloadReports/useGetReportByDateRange/index.ts +0 -115
  111. package/src/hooks/useDrag/index.js +0 -63
  112. package/src/hooks/useDropzone/index.js +0 -94
  113. package/src/hooks/useDynamicAuth/index.js +0 -13
  114. package/src/hooks/useDynamicAuth/queries.js +0 -24
  115. package/src/hooks/useEditCategory/index.js +0 -41
  116. package/src/hooks/useEditOneExtProductFoodOptional/index.js +0 -28
  117. package/src/hooks/useEditOneExtProductFoodOptional/queries.js +0 -16
  118. package/src/hooks/useEditSubProductOptional/index.js +0 -11
  119. package/src/hooks/useEditSubProductOptional/queries.js +0 -10
  120. package/src/hooks/useEmployee/index.js +0 -17
  121. package/src/hooks/useEmployee/queries.js +0 -85
  122. package/src/hooks/useEmployee/useCreateEmployee.js +0 -86
  123. package/src/hooks/useEvent/index.js +0 -34
  124. package/src/hooks/useFavoriteStores/index.js +0 -29
  125. package/src/hooks/useFavoriteStores/queries.js +0 -54
  126. package/src/hooks/useFetchJson/index.js +0 -25
  127. package/src/hooks/useFetchMoreInteractions/index.jsx +0 -39
  128. package/src/hooks/useFingerprintjs/index.js +0 -172
  129. package/src/hooks/useFormTools/index.js +0 -116
  130. package/src/hooks/useFormatDate/index.js +0 -86
  131. package/src/hooks/useFormatNumberPhone/index.js +0 -23
  132. package/src/hooks/useFullScreenMode/index.js +0 -65
  133. package/src/hooks/useGenerateNumberArray/index.js +0 -17
  134. package/src/hooks/useGetAllLocationUser/index.js +0 -12
  135. package/src/hooks/useGetAllLocationUser/queries.js +0 -44
  136. package/src/hooks/useGetCookies/index.js +0 -43
  137. package/src/hooks/useGetExtProductFoodsSubOptionalAll/index.js +0 -14
  138. package/src/hooks/useGetFoodRecomended/index.js +0 -32
  139. package/src/hooks/useGetFoodRecomended/queries.js +0 -47
  140. package/src/hooks/useGetMessagesToRoom/index.js +0 -23
  141. package/src/hooks/useGetMinPrice/index.js +0 -12
  142. package/src/hooks/useGetMinPrice/queries.js +0 -7
  143. package/src/hooks/useGetOneStoreRating/index.js +0 -40
  144. package/src/hooks/useGetOneStoreRating/queries.js +0 -18
  145. package/src/hooks/useGetSalesAmountToday/index.js +0 -31
  146. package/src/hooks/useGetStoreCookie/index.js +0 -21
  147. package/src/hooks/useGoogleLogin/index.js +0 -160
  148. package/src/hooks/useGoogleLogin/loadScript.js +0 -15
  149. package/src/hooks/useGoogleLogin/removeScript.js +0 -7
  150. package/src/hooks/useHover/index.js +0 -29
  151. package/src/hooks/useImageOptimization/index.js +0 -28
  152. package/src/hooks/useImageUploaderProduct/helper/canvasUtils.ts +0 -130
  153. package/src/hooks/useImageUploaderProduct/helper/getOrientation.ts +0 -53
  154. package/src/hooks/useImageUploaderProduct/helper/index.ts +0 -5
  155. package/src/hooks/useImageUploaderProduct/index.ts +0 -292
  156. package/src/hooks/useImageWeight/index.js +0 -51
  157. package/src/hooks/useImagesStore/index.js +0 -225
  158. package/src/hooks/useImagesStore/queries.js +0 -193
  159. package/src/hooks/useImagesStore/utils/index.js +0 -4
  160. package/src/hooks/useIncomingOrders/index.js +0 -10
  161. package/src/hooks/useIncomingOrders/queries.js +0 -87
  162. package/src/hooks/useInnerHtml/index.js +0 -39
  163. package/src/hooks/useIntersection/index.js +0 -84
  164. package/src/hooks/useInventory/index.js +0 -2
  165. package/src/hooks/useInventory/queries.js +0 -58
  166. package/src/hooks/useInventory/useGetProductsInStock.js +0 -15
  167. package/src/hooks/useInventory/useUpdateManageStock.js +0 -41
  168. package/src/hooks/useKeypress/index.js +0 -28
  169. package/src/hooks/useLazyScript/index.js +0 -71
  170. package/src/hooks/useLocalBackendIp/index.js +0 -34
  171. package/src/hooks/useLocalSorage/index.js +0 -36
  172. package/src/hooks/useLocationManager/index.js +0 -63
  173. package/src/hooks/useLocationNavigate/index.js +0 -54
  174. package/src/hooks/useLoginEmployeeInStore/index.js +0 -38
  175. package/src/hooks/useLogout/helpers/BroadcastChannel.js +0 -31
  176. package/src/hooks/useLogout/helpers/apiBaseUrl.js +0 -8
  177. package/src/hooks/useLogout/helpers/fetchData.js +0 -28
  178. package/src/hooks/useLogout/helpers/getCsrfToken.js +0 -30
  179. package/src/hooks/useLogout/helpers/index.js +0 -57
  180. package/src/hooks/useLogout/helpers/logger.js +0 -70
  181. package/src/hooks/useLogout/helpers/parseUrl.js +0 -36
  182. package/src/hooks/useLogout/index.js +0 -96
  183. package/src/hooks/useManageNewOrder/helpers/index.js +0 -45
  184. package/src/hooks/useManageNewOrder/helpers/mock.js +0 -0
  185. package/src/hooks/useManageNewOrder/index.js +0 -102
  186. package/src/hooks/useManageQueryParams/index.js +0 -40
  187. package/src/hooks/useMobile/index.js +0 -65
  188. package/src/hooks/useModules/helpers/index.js +0 -1
  189. package/src/hooks/useModules/helpers/validateModules.js +0 -29
  190. package/src/hooks/useModules/index.js +0 -58
  191. package/src/hooks/useMouse/index.ts +0 -50
  192. package/src/hooks/useMutateHeight/index.js +0 -36
  193. package/src/hooks/useOrderClient/index.js +0 -5
  194. package/src/hooks/useOrderStatusTypes/index.ts +0 -2
  195. package/src/hooks/useOrderStatusTypes/useOrderStatusTypes/index.ts +0 -133
  196. package/src/hooks/useOrderStatusTypes/useUpdateOrderStatusPriorities/index.ts +0 -97
  197. package/src/hooks/useOrders/index.js +0 -3
  198. package/src/hooks/useOrders/queries.js +0 -89
  199. package/src/hooks/useOrders/useChangeOrderState/index.ts +0 -125
  200. package/src/hooks/useOrders/useOrdersFromStore/index.ts +0 -77
  201. package/src/hooks/usePWAInstall/index.js +0 -38
  202. package/src/hooks/usePortFetcher/index.ts +0 -33
  203. package/src/hooks/usePrintSaleTicket/index.ts +0 -64
  204. package/src/hooks/useProductsFood/index.js +0 -253
  205. package/src/hooks/useProductsFood/queriesStore.js +0 -964
  206. package/src/hooks/useProductsFood/useEditProduct.js +0 -48
  207. package/src/hooks/useProductsFood/usetagsProducts.js +0 -98
  208. package/src/hooks/useProviders/index.js +0 -3
  209. package/src/hooks/useProviders/queries.js +0 -31
  210. package/src/hooks/useProviders/useProvidersCreateStore/index.js +0 -12
  211. package/src/hooks/useProviders/useProvidersDataStore/index.js +0 -24
  212. package/src/hooks/useProvidersStore/index.js +0 -24
  213. package/src/hooks/useProvidersStore/queries.js +0 -31
  214. package/src/hooks/usePushNotificationOrder/index.js +0 -52
  215. package/src/hooks/usePushNotifications/helpers/index.js +0 -114
  216. package/src/hooks/usePushNotifications/index.js +0 -149
  217. package/src/hooks/useQueryLocationsMap/index.js +0 -19
  218. package/src/hooks/useQueryLocationsMap/queries.js +0 -40
  219. package/src/hooks/useRatingArrayData/index.js +0 -54
  220. package/src/hooks/useRatingArrayData/queries.js +0 -19
  221. package/src/hooks/useReactToPrint/index.js +0 -1223
  222. package/src/hooks/useRemoveExtraProductFoodsOptional/index.js +0 -23
  223. package/src/hooks/useRemoveExtraProductFoodsOptional/queries.js +0 -48
  224. package/src/hooks/useReport/index.js +0 -47
  225. package/src/hooks/useReport/queries.js +0 -123
  226. package/src/hooks/useRestaurant/helpers/index.js +0 -24
  227. package/src/hooks/useRestaurant/helpers/manageStatusOpen.js +0 -26
  228. package/src/hooks/useRestaurant/index.js +0 -69
  229. package/src/hooks/useRestaurant/queries.js +0 -81
  230. package/src/hooks/useRoads/index.js +0 -19
  231. package/src/hooks/useRoads/queries.js +0 -13
  232. package/src/hooks/useRoles/index.js +0 -4
  233. package/src/hooks/useRoles/queries.js +0 -70
  234. package/src/hooks/useRoles/useCreateRole.js +0 -37
  235. package/src/hooks/useRoles/useGetRoles.js +0 -36
  236. package/src/hooks/useRoles/useRemoveRoles.js +0 -40
  237. package/src/hooks/useRoles/useUpdateRolesPriority.js +0 -44
  238. package/src/hooks/useSales/helpers/index.js +0 -55
  239. package/src/hooks/useSales/index.js +0 -1381
  240. package/src/hooks/useSales/queries.js +0 -424
  241. package/src/hooks/useSales/useGetAllSales/index.js +0 -25
  242. package/src/hooks/useSales/useGetSale.js +0 -13
  243. package/src/hooks/useSales/useTotalSales.js +0 -23
  244. package/src/hooks/useSaveAvailableProduct/helpers/index.js +0 -38
  245. package/src/hooks/useSaveAvailableProduct/index.js +0 -31
  246. package/src/hooks/useSaveAvailableProduct/queries.js +0 -10
  247. package/src/hooks/useSaveLocation/index.js +0 -16
  248. package/src/hooks/useSaveLocation/queries.js +0 -19
  249. package/src/hooks/useSchedule/index.js +0 -78
  250. package/src/hooks/useSchedule/index.jsx +0 -22
  251. package/src/hooks/useSchedule/queries.js +0 -43
  252. package/src/hooks/useScheduleData/index.js +0 -123
  253. package/src/hooks/useScroll/index.js +0 -56
  254. package/src/hooks/useScrollRotate/index.js +0 -16
  255. package/src/hooks/useSetImageProducts/index.js +0 -57
  256. package/src/hooks/useSetImageProducts/queries.js +0 -18
  257. package/src/hooks/useSetSession/index.js +0 -44
  258. package/src/hooks/useSetState/index.js +0 -24
  259. package/src/hooks/useSetupSchedule/helpers/index.js +0 -85
  260. package/src/hooks/useSetupSchedule/index.js +0 -272
  261. package/src/hooks/useStatusOpenStore/helpers/index.js +0 -101
  262. package/src/hooks/useStatusOpenStore/index.js +0 -179
  263. package/src/hooks/useStatusOrdersClient/helpers/index.js +0 -14
  264. package/src/hooks/useStatusOrdersClient/index.js +0 -17
  265. package/src/hooks/useStatusOrdersClient/queries.js +0 -80
  266. package/src/hooks/useStockMovements/helpers/index.js +0 -16
  267. package/src/hooks/useStockMovements/index.js +0 -38
  268. package/src/hooks/useStore/index.js +0 -80
  269. package/src/hooks/useStore/queries.js +0 -163
  270. package/src/hooks/useStoreCalendar/index.js +0 -5
  271. package/src/hooks/useStoreContacts/index.js +0 -47
  272. package/src/hooks/useStoreContacts/queries.js +0 -48
  273. package/src/hooks/useStoreTable/index.js +0 -2
  274. package/src/hooks/useStoreTable/queries.js +0 -47
  275. package/src/hooks/useStoreTable/useStoreTableCreate.js +0 -76
  276. package/src/hooks/useStoreTable/useStoreTables.js +0 -14
  277. package/src/hooks/useSubscriptionValidation/index.js +0 -41
  278. package/src/hooks/useTagProducts/index.ts +0 -3
  279. package/src/hooks/useTagProducts/useDeleteOneTag.ts +0 -106
  280. package/src/hooks/useTagProducts/useGetAllTags.ts +0 -68
  281. package/src/hooks/useTagProducts/useRegisterMultipleTags.ts +0 -156
  282. package/src/hooks/useTimeAgo/useTimeAgo.js +0 -39
  283. package/src/hooks/useTokenCards/index.js +0 -41
  284. package/src/hooks/useTopProductsMovements/index.js +0 -27
  285. package/src/hooks/useTotalAllSales/index.js +0 -25
  286. package/src/hooks/useTotalProductsInStock/index.js +0 -23
  287. package/src/hooks/useTotalProductsSold/index.js +0 -23
  288. package/src/hooks/useTotalProductsSolded/index.js +0 -20
  289. package/src/hooks/useUpdateCart/index.js +0 -130
  290. package/src/hooks/useUpdateCartCookie/index.js +0 -43
  291. package/src/hooks/useUpdateDashboardComponent/index.ts +0 -91
  292. package/src/hooks/useUpdateExistingOrders/index.js +0 -85
  293. package/src/hooks/useUpdateExtProductFoodsSubOptional/index.js +0 -60
  294. package/src/hooks/useUpdateModuleOrder/index.js +0 -37
  295. package/src/hooks/useUpdateMultipleExtProduct/index.js +0 -33
  296. package/src/hooks/useUpdateMultipleExtProduct/queries.js +0 -33
  297. package/src/hooks/useUpdateMultipleProducts/index.js +0 -80
  298. package/src/hooks/useUpdateMultipleProducts/queries.js +0 -51
  299. package/src/hooks/useUploadProducts/helpers/index.js +0 -1
  300. package/src/hooks/useUploadProducts/helpers/parseNumber.js +0 -37
  301. package/src/hooks/useUploadProducts/helpers/validateProductDataExcel.js +0 -73
  302. package/src/hooks/useUploadProducts/index.js +0 -422
  303. package/src/hooks/useUpsertGoal/index.js +0 -68
  304. package/src/hooks/useUser/index.js +0 -23
  305. package/src/hooks/useUser/queries.js +0 -131
  306. package/src/hooks/useWeeklyStockMovement/helpers/index.js +0 -32
  307. package/src/hooks/useWeeklyStockMovement/index.js +0 -51
  308. package/src/hooks/useWindowSize/index.js +0 -38
  309. package/src/index.jsx +0 -9
  310. package/src/mock/dessert/index.js +0 -16
  311. package/src/mock/index.js +0 -1
  312. package/src/security/index.js +0 -1
  313. package/src/services/index.js +0 -0
  314. package/src/utils/UtilDateRange.js +0 -31
  315. package/src/utils/index.js +0 -306
  316. package/tsconfig.json +0 -5
@@ -1,115 +0,0 @@
1
- import { useLazyQuery } from '@apollo/client'
2
- import { gql } from '@apollo/client'
3
- import { downloadFileFromResponse } from '../helpers/downloadFileFromResponse'
4
- import { useState } from 'react'
5
-
6
- /**
7
- * GraphQL query to get report by date range
8
- */
9
- const GET_REPORT_BY_DATE_RANGE = gql`
10
- query getReportByDateRange($startDate: DateTime!, $endDate: DateTime!) {
11
- getReportBydateRange(startDate: $startDate, endDate: $endDate) {
12
- success
13
- message
14
- errors {
15
- path
16
- message
17
- type
18
- }
19
- data {
20
- id
21
- name
22
- description
23
- url
24
- createdAt
25
- }
26
- }
27
- }
28
- `
29
-
30
- /**
31
- * Custom hook to fetch report by a date range
32
- * @param {Object} options
33
- * @param {Function} options.sendNotification - Function to notify user
34
- * @returns {[Function, { loading: boolean, error: any, data: any }]}
35
- */
36
- export const useGetReportByDateRange = ({
37
- sendNotification = ({ description = '', title = '', backgroundColor = 'info' } = {}) => {
38
- return { description, title, backgroundColor }
39
- }
40
- } = {}) => {
41
- const [loading, setLoading] = useState(false)
42
- const [finished, setFinished] = useState(false)
43
-
44
- const [getReportQuery, { data, error }] = useLazyQuery(GET_REPORT_BY_DATE_RANGE, {
45
- onCompleted: () => {
46
- setFinished(true)
47
- }
48
- })
49
-
50
- /**
51
- * Triggers the report generation and handles download
52
- * @param {string} startDate - Start date in YYYY-MM-DD format
53
- * @param {string} endDate - End date in YYYY-MM-DD format
54
- * @returns {Promise<any>}
55
- */
56
- const getReport = async (startDate, endDate) => {
57
- try {
58
- setLoading(true)
59
- const response = await getReportQuery({
60
- variables: { startDate, endDate },
61
- fetchPolicy: 'network-only'
62
- })
63
-
64
- const reportResult = response?.data?.getReportBydateRange ?? {
65
- success: false,
66
- message: 'No report data found',
67
- data: null
68
- }
69
-
70
- if (!reportResult) {
71
- setLoading(false)
72
- return {
73
- success: false,
74
- message: 'No report data found',
75
- data: null
76
- }
77
- }
78
-
79
- const {
80
- success,
81
- message,
82
- data
83
- } = reportResult
84
-
85
- sendNotification({
86
- description: message,
87
- title: success ? 'Success' : 'Error',
88
- backgroundColor: success ? 'success' : 'error'
89
- })
90
-
91
- if (success && data?.url && data?.name) {
92
- setLoading(true)
93
- const res = await fetch(`/api/files/${encodeURIComponent(data.url)}`)
94
- await downloadFileFromResponse(res, data.name)
95
- setLoading(false)
96
- }
97
- return reportResult
98
- } catch (err) {
99
- setLoading(false)
100
- sendNotification({
101
- description: err.message || 'Unexpected error',
102
- title: 'Error',
103
- backgroundColor: 'error'
104
- })
105
- return { success: false, message: err.message, data: null }
106
- }
107
- }
108
-
109
- return [getReport, {
110
- loading,
111
- error,
112
- finished,
113
- data: data?.getReportBydateRange
114
- }]
115
- }
@@ -1,63 +0,0 @@
1
- import { useEffect, useState } from 'react'
2
-
3
- export function useDrag2 (ref) {
4
- useEffect(() => {
5
- if (!ref || !ref?.current) return null
6
- const target = ref?.current
7
- if (!target) return
8
- const previousOffset = { x: 0, y: 0 }
9
- let originMouseX
10
- let originMouseY
11
- function onMousemove (e) {
12
- const { pageX, pageY } = e
13
- const x = pageX - originMouseX + previousOffset.x
14
- const y = pageY - originMouseY + previousOffset.y
15
- target.style.transform = `translate(${x}px, ${y}px)`
16
- }
17
- function onMouseup (e) {
18
- previousOffset.x += e.pageX - originMouseX
19
- previousOffset.y += e.pageY - originMouseY
20
- window.removeEventListener('mousemove', onMousemove)
21
- window.removeEventListener('mouseup', onMouseup)
22
- }
23
- function onMousedown (e) {
24
- originMouseX = e.pageX
25
- originMouseY = e.pageY
26
- window.addEventListener('mousemove', onMousemove)
27
- window.addEventListener('mouseup', onMouseup)
28
- }
29
- target.addEventListener('mousedown', onMousedown)
30
- return () => {
31
- target?.removeEventListener('mousedown', onMousedown)
32
- window?.removeEventListener('mouseup', onMouseup)
33
- window?.removeEventListener('mousemove', onMousemove)
34
- }
35
- }, [ref])
36
- }
37
-
38
- export const useDrag = (x, y) => {
39
- const [move, setMove] = useState(false)
40
- const [moveTo, setMoveTo] = useState([x, y])
41
- const moveIcon = e => {
42
- const xcoord = moveTo[0] + e.movementX
43
- const ycoord = moveTo[1] + e.movementY
44
- setMoveTo([xcoord, ycoord])
45
- }
46
- const handleMove = e => {
47
- move && moveIcon(e)
48
- }
49
- const handelDown = () => {
50
- setMove(true)
51
- }
52
- const handelUp = () => {
53
- setMove(false)
54
- }
55
-
56
- return {
57
- move,
58
- moveTo,
59
- handelDown,
60
- handelUp,
61
- handleMove
62
- }
63
- }
@@ -1,94 +0,0 @@
1
- import { useEffect, useMemo, useRef, useState } from 'react'
2
-
3
- export const useDropzone = (
4
- onDrop,
5
- dragHandler = {},
6
- draggingStyle = { border: 'dashed grey 3px' },
7
- dragOverStyle = {
8
- border: 'dashed grey 3px'
9
- }
10
- ) => {
11
- const ref = useRef(null)
12
- const [cleanup, setCleanup] = useState(false)
13
- const [isDragging, setDragging] = useState(false)
14
- const [dragOver, setDragOver] = useState(false)
15
- const handle = useMemo(dragHandler, [])
16
-
17
- const eventListeners = {
18
- dragenter: e => {
19
- return handle.dragEnter(e, () => {
20
- if (!dragOver) setDragOver(true)
21
- })
22
- },
23
- dragleave: e => {
24
- return handle.dragLeave(e, () => {
25
- setDragOver(false)
26
- })
27
- },
28
- dragover: handle.dragBegin,
29
- drop: e => {
30
- return handle.drop(e, files => {
31
- if (typeof onDrop === 'function') onDrop(files, e)
32
- setDragOver(false)
33
- setDragging(false)
34
- })
35
- }
36
- }
37
-
38
- const windowListeners = {
39
- dragenter: e => {
40
- return handle.body.dragEnter(e, () => {
41
- if (!isDragging) setDragging(true)
42
- })
43
- },
44
- dragleave: e => {
45
- return handle.body.dragLeave(e, () => {
46
- // eslint-disable-next-line
47
- if (isDragging) setDragging(false)
48
- })
49
- },
50
- dragend: () => {
51
- // eslint-disable-next-line
52
- },
53
- drop: e => {
54
- return handle.body.drop(e, () => {
55
- setDragging(false)
56
- setDragOver(false)
57
- })
58
- }
59
- }
60
-
61
- useEffect(() => {
62
- if (ref.current) {
63
- const { current } = ref
64
- Object.keys(eventListeners).forEach(key => { return current.addEventListener(key, eventListeners[key]) }
65
- )
66
- Object.keys(windowListeners).forEach(key => { return window.addEventListener(key, windowListeners[key]) }
67
- )
68
- setCleanup(true)
69
- }
70
-
71
- return () => {
72
- if (cleanup) {
73
- const { current } = ref
74
- if (current) {
75
- Object.keys(eventListeners).forEach(key => { return current.removeEventListener(key, eventListeners[key]) }
76
- )
77
- }
78
- Object.keys(windowListeners).forEach(key => { return window.removeEventListener(key, windowListeners[key]) }
79
- )
80
- }
81
- }
82
- }, [ref, windowListeners, cleanup, eventListeners, isDragging, dragOver])
83
-
84
- const dropProps = {
85
- ref,
86
- style:
87
- isDragging || dragOver
88
- ? dragOver
89
- ? dragOverStyle
90
- : draggingStyle
91
- : undefined
92
- }
93
- return { isDragging, dragOver, dropProps }
94
- }
@@ -1,13 +0,0 @@
1
- import { useQuery } from '@apollo/client'
2
- import { useState } from 'react'
3
- import { GET_ONE_DYNAMIC_PASS } from './queries'
4
-
5
- export const useDynamicAuth = () => {
6
- const [dynamicPass, setDynamicPass] = useState({})
7
- const { loading, error } = useQuery(GET_ONE_DYNAMIC_PASS, {
8
- onCompleted: (res) => {
9
- setDynamicPass(res.getAOneDynamicPassword)
10
- }
11
- })
12
- return [dynamicPass, { loading, error }]
13
- }
@@ -1,24 +0,0 @@
1
- import { gql } from '@apollo/client'
2
-
3
- export const CREATE_ONE_DYNAMIC_PASS = gql`
4
- mutation registerDynamicPassword($input: IDynamicPassword) {
5
- registerDynamicPassword(input: $input) {
6
- success
7
- message
8
- }
9
- }
10
- `
11
- export const GET_ONE_DYNAMIC_PASS = gql`
12
- query getAOneDynamicPassword {
13
- getAOneDynamicPassword {
14
- dPassId
15
- id
16
- idStore
17
- keyPassDynamic
18
- deviceName
19
- dState
20
- DatCre
21
- DatMod
22
- }
23
- }
24
- `
@@ -1,41 +0,0 @@
1
- import { gql, useMutation } from '@apollo/client'
2
-
3
- const EDIT_CATEGORY_PRODUCT = gql`
4
- mutation EditOneCategoryProduct($pName: String!, $ProDescription: String, $carProId: ID!) {
5
- editOneCategoryProduct(pName: $pName, ProDescription: $ProDescription, carProId: $carProId) {
6
- success
7
- message
8
- }
9
- }
10
- `
11
-
12
- export const useEditCategoryProduct = ({ sendNotification = () => { } } = {}) => {
13
- const [editCategoryProductMutation] = useMutation(EDIT_CATEGORY_PRODUCT)
14
-
15
- const editCategoryProduct = async (pName, ProDescription, carProId) => {
16
- try {
17
- const { data } = await editCategoryProductMutation({
18
- variables: { pName, ProDescription, carProId }
19
- })
20
-
21
- if (data.editOneCategoryProduct.success) {
22
- return {
23
- success: true,
24
- message: 'Categoría de producto editada correctamente'
25
- }
26
- } else {
27
- return {
28
- success: false,
29
- message: data.editOneCategoryProduct.message || 'Error al editar la categoría de producto'
30
- }
31
- }
32
- } catch (error) {
33
- return {
34
- success: false,
35
- message: error.message || 'Error al editar la categoría de producto'
36
- }
37
- }
38
- }
39
-
40
- return { editCategoryProduct }
41
- }
@@ -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,16 +0,0 @@
1
- import { gql } from "@apollo/client"
2
-
3
- export const UPDATE_EXT_PRODUCT_FOOD_OPTIONAL = gql`
4
- mutation editExtProductFoodOptional($input: EditExtProductFoodOptionalInput!) {
5
- editExtProductFoodOptional(input: $input) {
6
- pId
7
- opExPid
8
- OptionalProName
9
- state
10
- code
11
- required
12
- numbersOptionalOnly
13
- pDatMod
14
- }
15
- }
16
- `
@@ -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,10 +0,0 @@
1
- import { gql } from '@apollo/client'
2
-
3
- export const EDIT_EXTRA_SUB_OPTIONAL_PRODUCTS = gql`
4
- mutation editExtFoodSubsOptional($opSubExPid: ID, $state: Int, $isCustomSubOpExPid: Boolean, $OptionalSubProName: String){
5
- editExtFoodSubsOptional(opSubExPid: $opSubExPid, state: $state, isCustomSubOpExPid: $isCustomSubOpExPid, OptionalSubProName: $OptionalSubProName){
6
- success,
7
- message
8
- }
9
- }
10
- `
@@ -1,17 +0,0 @@
1
- import { useQuery } from '@apollo/client'
2
- import { GET_EMPLOYEES } from './queries'
3
-
4
- export const useEmployee = () => {
5
- const {
6
- data,
7
- loading,
8
- error,
9
- fetchMore
10
- } = useQuery(GET_EMPLOYEES)
11
- return [data?.employees?.data ?? [], {
12
- loading,
13
- error,
14
- fetchMore,
15
- pagination: data?.employees?.pagination ?? {}
16
- }]
17
- }
@@ -1,85 +0,0 @@
1
- import { gql } from '@apollo/client'
2
-
3
- export const GET_EMPLOYEES = gql`
4
- query employees {
5
- employees {
6
- data {
7
- eId
8
- idStore
9
- idRole
10
- eEmail
11
- eState
12
- status
13
- user {
14
- id
15
- name
16
- username
17
- lastName
18
- email
19
- avatar
20
- uToken
21
- uPhoNum
22
- ULocation
23
- upLat
24
- uState
25
- upLon
26
- upIdeDoc
27
- siteWeb
28
- description
29
- createAt
30
- associateStore
31
- }
32
- roles {
33
- idRole
34
- name
35
- priority
36
- description
37
- permissions
38
- createdAt
39
- updatedAt
40
- }
41
- }
42
- success
43
- message
44
- pagination {
45
- totalRecords
46
- totalPages
47
- currentPage
48
- }
49
- errors {
50
- path
51
- message
52
- type
53
- context {
54
- limit
55
- value
56
- label
57
- key
58
- }
59
- }
60
-
61
- }
62
- }
63
- `
64
- /**
65
- * GraphQL mutation for creating an employee, store, and user.
66
- */
67
- export const CREATE_ONE_EMPLOYEE_STORE_AND_USER = gql`
68
- mutation createOneEmployeeStoreAndUser($input: IEmployeeStore!) {
69
- createOneEmployeeStoreAndUser(input: $input) {
70
- success
71
- message
72
- errors {
73
- path
74
- message
75
- type
76
- context {
77
- limit
78
- value
79
- label
80
- key
81
- }
82
- }
83
- }
84
- }
85
- `
@@ -1,86 +0,0 @@
1
- import { useMutation } from '@apollo/client'
2
- import { useState } from 'react'
3
- import { CREATE_ONE_EMPLOYEE_STORE_AND_USER } from './queries'
4
-
5
- /**
6
- * Custom hook to handle the createOneEmployeeStoreAndUser mutation.
7
- *
8
- * @param
9
- * @param {Object}
10
- * @returns {{
11
- * createEmployeeStoreAndUser: (input: IEmployeeStore) => Promise<void>,
12
- * loading: boolean,
13
- * error: Error | null,
14
- * data: Object | null
15
- * }} An object containing the mutation function, loading status, error, and data.
16
- */
17
- export const useCreateEmployeeStoreAndUser = ({
18
- sendNotification = () => {
19
- return {
20
- description: '',
21
- title: '',
22
- backgroundColor: ''
23
- }
24
- },
25
- onCompleted = () => {
26
- return {
27
- }
28
- },
29
- onError = () => {
30
- return {
31
- }
32
- }
33
- } = {}) => {
34
- const [createEmployeeStoreAndUserMutation, { loading, error, data }] = useMutation(CREATE_ONE_EMPLOYEE_STORE_AND_USER, {
35
- onError: () => {
36
- sendNotification({
37
- description: 'Error creando empleado',
38
- title: 'Error',
39
- backgroundColor: 'error'
40
- })
41
- },
42
- onCompleted: (response) => {
43
- console.log(response)
44
- const { createOneEmployeeStoreAndUser } = response ?? {}
45
- const { message, success } = createOneEmployeeStoreAndUser ?? {}
46
- if (success === false) {
47
- onError(response)
48
- }
49
- if (success) {
50
- onCompleted(response)
51
- }
52
- sendNotification({
53
- description: message,
54
- title: success ? 'Exito' : 'Error',
55
- backgroundColor: success ? 'success' : 'error'
56
- })
57
- }
58
- })
59
- const [errors, setErrors] = useState([])
60
-
61
- /**
62
- * Calls the createOneEmployeeStoreAndUser mutation.
63
- *
64
- * @param {Object} input - The input data for the mutation.
65
- * @returns {Promise<void>}
66
- */
67
- const createEmployeeStoreAndUser = async (input) => {
68
- try {
69
- const response = await createEmployeeStoreAndUserMutation({ variables: { input } })
70
- if (response.data.createOneEmployeeStoreAndUser.errors) {
71
- setErrors(response.data.createOneEmployeeStoreAndUser.errors)
72
- } else {
73
- setErrors([])
74
- }
75
- } catch (err) {
76
- setErrors([{ message: err.message }])
77
- }
78
- }
79
-
80
- return [createEmployeeStoreAndUser, {
81
- loading,
82
- error,
83
- data,
84
- errors
85
- }]
86
- }
@@ -1,34 +0,0 @@
1
- import { useEffect } from 'react'
2
-
3
- export const on = ({ eventType, callBack }) => {
4
- document.addEventListener(eventType, callBack)
5
- }
6
- export const off = ({ eventType, callBack }) => {
7
- document.removeEventListener(eventType, callBack)
8
- }
9
- export const once = ({ eventType, callBack }) => {
10
- const handleEventOnce = (event) => {
11
- callBack(event)
12
- off({ eventType, callBack: handleEventOnce })
13
- }
14
- on({ eventType, callBack: handleEventOnce })
15
- }
16
- export const trigger = ({ eventType, data }) => {
17
- const event = new CustomEvent(eventType, { detail: data })
18
- document.dispatchEvent(event)
19
- }
20
- // This function is used to subscribe components an any event
21
- export const useEvents = ({ eventType, callBack }) => {
22
- useEffect(() => {
23
- on({ eventType, callBack })
24
- return () => {
25
- off({ eventType, callBack })
26
- }
27
- }, [eventType, callBack])
28
- }
29
- // This function create and dispatch event
30
- export const useTrigerEvent = () => {
31
- return {
32
- trigger
33
- }
34
- }
@@ -1,29 +0,0 @@
1
- import { useQuery } from '@apollo/client'
2
- import { GET_ALL_FAV_STORE } from './queries'
3
- import { filterAndSortByDate } from '../useRestaurant/helpers'
4
- import { getStatusForStores } from '../useRestaurant/helpers/manageStatusOpen'
5
-
6
- export const useFavoriteStores = () => {
7
- const {
8
- data,
9
- loading,
10
- error
11
- } = useQuery(GET_ALL_FAV_STORE, {
12
- fetchPolicy: 'cache-and-network',
13
- onError: () => {
14
- console.log('')
15
- }
16
- })
17
- const newArray = data?.getFavorite?.map(store => {
18
- return {
19
- ...store.getOneStore
20
- }
21
- }) || []
22
- const dataSort = filterAndSortByDate(newArray)
23
-
24
- const statuses = getStatusForStores(dataSort)
25
-
26
- const favoriteStores = statuses || []
27
-
28
- return [loading ? [] : favoriteStores, { loading, error }]
29
- }