npm-pkg-hook 1.12.3 → 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 (315) 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 -146
  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/useProductsFood/index.js +0 -253
  204. package/src/hooks/useProductsFood/queriesStore.js +0 -964
  205. package/src/hooks/useProductsFood/useEditProduct.js +0 -48
  206. package/src/hooks/useProductsFood/usetagsProducts.js +0 -98
  207. package/src/hooks/useProviders/index.js +0 -3
  208. package/src/hooks/useProviders/queries.js +0 -31
  209. package/src/hooks/useProviders/useProvidersCreateStore/index.js +0 -12
  210. package/src/hooks/useProviders/useProvidersDataStore/index.js +0 -24
  211. package/src/hooks/useProvidersStore/index.js +0 -24
  212. package/src/hooks/useProvidersStore/queries.js +0 -31
  213. package/src/hooks/usePushNotificationOrder/index.js +0 -52
  214. package/src/hooks/usePushNotifications/helpers/index.js +0 -114
  215. package/src/hooks/usePushNotifications/index.js +0 -149
  216. package/src/hooks/useQueryLocationsMap/index.js +0 -19
  217. package/src/hooks/useQueryLocationsMap/queries.js +0 -40
  218. package/src/hooks/useRatingArrayData/index.js +0 -54
  219. package/src/hooks/useRatingArrayData/queries.js +0 -19
  220. package/src/hooks/useReactToPrint/index.js +0 -1223
  221. package/src/hooks/useRemoveExtraProductFoodsOptional/index.js +0 -23
  222. package/src/hooks/useRemoveExtraProductFoodsOptional/queries.js +0 -48
  223. package/src/hooks/useReport/index.js +0 -47
  224. package/src/hooks/useReport/queries.js +0 -123
  225. package/src/hooks/useRestaurant/helpers/index.js +0 -24
  226. package/src/hooks/useRestaurant/helpers/manageStatusOpen.js +0 -26
  227. package/src/hooks/useRestaurant/index.js +0 -69
  228. package/src/hooks/useRestaurant/queries.js +0 -81
  229. package/src/hooks/useRoads/index.js +0 -19
  230. package/src/hooks/useRoads/queries.js +0 -13
  231. package/src/hooks/useRoles/index.js +0 -4
  232. package/src/hooks/useRoles/queries.js +0 -70
  233. package/src/hooks/useRoles/useCreateRole.js +0 -37
  234. package/src/hooks/useRoles/useGetRoles.js +0 -36
  235. package/src/hooks/useRoles/useRemoveRoles.js +0 -40
  236. package/src/hooks/useRoles/useUpdateRolesPriority.js +0 -44
  237. package/src/hooks/useSales/helpers/index.js +0 -55
  238. package/src/hooks/useSales/index.js +0 -1381
  239. package/src/hooks/useSales/queries.js +0 -424
  240. package/src/hooks/useSales/useGetAllSales/index.js +0 -25
  241. package/src/hooks/useSales/useGetSale.js +0 -13
  242. package/src/hooks/useSales/useTotalSales.js +0 -23
  243. package/src/hooks/useSaveAvailableProduct/helpers/index.js +0 -38
  244. package/src/hooks/useSaveAvailableProduct/index.js +0 -31
  245. package/src/hooks/useSaveAvailableProduct/queries.js +0 -10
  246. package/src/hooks/useSaveLocation/index.js +0 -16
  247. package/src/hooks/useSaveLocation/queries.js +0 -19
  248. package/src/hooks/useSchedule/index.js +0 -78
  249. package/src/hooks/useSchedule/index.jsx +0 -22
  250. package/src/hooks/useSchedule/queries.js +0 -43
  251. package/src/hooks/useScheduleData/index.js +0 -123
  252. package/src/hooks/useScroll/index.js +0 -56
  253. package/src/hooks/useScrollRotate/index.js +0 -16
  254. package/src/hooks/useSetImageProducts/index.js +0 -57
  255. package/src/hooks/useSetImageProducts/queries.js +0 -18
  256. package/src/hooks/useSetSession/index.js +0 -44
  257. package/src/hooks/useSetState/index.js +0 -24
  258. package/src/hooks/useSetupSchedule/helpers/index.js +0 -85
  259. package/src/hooks/useSetupSchedule/index.js +0 -272
  260. package/src/hooks/useStatusOpenStore/helpers/index.js +0 -101
  261. package/src/hooks/useStatusOpenStore/index.js +0 -179
  262. package/src/hooks/useStatusOrdersClient/helpers/index.js +0 -14
  263. package/src/hooks/useStatusOrdersClient/index.js +0 -17
  264. package/src/hooks/useStatusOrdersClient/queries.js +0 -80
  265. package/src/hooks/useStockMovements/helpers/index.js +0 -16
  266. package/src/hooks/useStockMovements/index.js +0 -38
  267. package/src/hooks/useStore/index.js +0 -80
  268. package/src/hooks/useStore/queries.js +0 -163
  269. package/src/hooks/useStoreCalendar/index.js +0 -5
  270. package/src/hooks/useStoreContacts/index.js +0 -47
  271. package/src/hooks/useStoreContacts/queries.js +0 -48
  272. package/src/hooks/useStoreTable/index.js +0 -2
  273. package/src/hooks/useStoreTable/queries.js +0 -47
  274. package/src/hooks/useStoreTable/useStoreTableCreate.js +0 -76
  275. package/src/hooks/useStoreTable/useStoreTables.js +0 -14
  276. package/src/hooks/useSubscriptionValidation/index.js +0 -41
  277. package/src/hooks/useTagProducts/index.ts +0 -3
  278. package/src/hooks/useTagProducts/useDeleteOneTag.ts +0 -106
  279. package/src/hooks/useTagProducts/useGetAllTags.ts +0 -68
  280. package/src/hooks/useTagProducts/useRegisterMultipleTags.ts +0 -156
  281. package/src/hooks/useTimeAgo/useTimeAgo.js +0 -39
  282. package/src/hooks/useTokenCards/index.js +0 -41
  283. package/src/hooks/useTopProductsMovements/index.js +0 -27
  284. package/src/hooks/useTotalAllSales/index.js +0 -25
  285. package/src/hooks/useTotalProductsInStock/index.js +0 -23
  286. package/src/hooks/useTotalProductsSold/index.js +0 -23
  287. package/src/hooks/useTotalProductsSolded/index.js +0 -20
  288. package/src/hooks/useUpdateCart/index.js +0 -130
  289. package/src/hooks/useUpdateCartCookie/index.js +0 -43
  290. package/src/hooks/useUpdateDashboardComponent/index.ts +0 -91
  291. package/src/hooks/useUpdateExistingOrders/index.js +0 -85
  292. package/src/hooks/useUpdateExtProductFoodsSubOptional/index.js +0 -60
  293. package/src/hooks/useUpdateModuleOrder/index.js +0 -37
  294. package/src/hooks/useUpdateMultipleExtProduct/index.js +0 -33
  295. package/src/hooks/useUpdateMultipleExtProduct/queries.js +0 -33
  296. package/src/hooks/useUpdateMultipleProducts/index.js +0 -80
  297. package/src/hooks/useUpdateMultipleProducts/queries.js +0 -51
  298. package/src/hooks/useUploadProducts/helpers/index.js +0 -1
  299. package/src/hooks/useUploadProducts/helpers/parseNumber.js +0 -37
  300. package/src/hooks/useUploadProducts/helpers/validateProductDataExcel.js +0 -73
  301. package/src/hooks/useUploadProducts/index.js +0 -422
  302. package/src/hooks/useUpsertGoal/index.js +0 -68
  303. package/src/hooks/useUser/index.js +0 -23
  304. package/src/hooks/useUser/queries.js +0 -131
  305. package/src/hooks/useWeeklyStockMovement/helpers/index.js +0 -32
  306. package/src/hooks/useWeeklyStockMovement/index.js +0 -51
  307. package/src/hooks/useWindowSize/index.js +0 -38
  308. package/src/index.jsx +0 -9
  309. package/src/mock/dessert/index.js +0 -16
  310. package/src/mock/index.js +0 -1
  311. package/src/security/index.js +0 -1
  312. package/src/services/index.js +0 -0
  313. package/src/utils/UtilDateRange.js +0 -31
  314. package/src/utils/index.js +0 -306
  315. package/tsconfig.json +0 -5
@@ -1,156 +0,0 @@
1
- import {
2
- getCurrentDayAndTime,
3
- getOpeningKeyFromDay,
4
- getTimeString,
5
- sortOpeningsByDay,
6
- weekDays,
7
- timeToInt,
8
- days
9
- } from './helpers'
10
-
11
- export const statusOpenStores = ({
12
- dataSchedules = []
13
- } = {}) => {
14
- const handleHourPmAM = (hour) => {
15
- const hourPmAm = new Date(`1/1/1999 ${hour}`).toLocaleString('en-US', { hour: 'numeric', minute: 'numeric', hour12: true })
16
- return hour ? hourPmAm : ''
17
- }
18
-
19
- const handleState = (message, open) => {
20
- return {
21
- message,
22
- open
23
- }
24
- }
25
-
26
- function getNextDaySchedule (dataSchedules, currentDayOfWeek) {
27
- const today = new Date()
28
- const tomorrow = new Date(today)
29
- tomorrow.setDate(today.getDate() + 1)
30
- const dayOfWeekTomorrow = tomorrow.getDay()
31
-
32
- const findNextDay = dataSchedules?.length
33
- ? dataSchedules?.some((schedule) => schedule?.schDay === dayOfWeekTomorrow)
34
- : false
35
-
36
- const findDataNextDay = dataSchedules?.length
37
- ? dataSchedules?.find((schedule) => schedule?.schDay === dayOfWeekTomorrow)
38
- : {}
39
-
40
- return { findNextDay, findDataNextDay, dayOfWeekTomorrow }
41
- }
42
-
43
- function getOpeningStatus (openings, currentTime, currentDayOfWeek) {
44
- const weekDayLookup = [
45
- 'Sunday',
46
- 'Monday',
47
- 'Tuesday',
48
- 'Wednesday',
49
- 'Thursday',
50
- 'Friday',
51
- 'Saturday'
52
- ]
53
-
54
- const ceroHours = '00:00 - 00:00'
55
- let dayOfWeek = currentDayOfWeek
56
-
57
- for (let i = 0; i < 7; i++) {
58
- const dayName = weekDayLookup[dayOfWeek % 7]
59
- const opening = openings && openings['opening' + dayName.substring(0, 3)]
60
- const timeSpans = opening?.split(';').map((item) => item.trim())
61
-
62
- for (const span of timeSpans) {
63
- const hours = span.split('-').map((item) => item.trim())
64
- const openTime = timeToInt(hours[0])
65
- const closeTime = timeToInt(hours[1])
66
-
67
- if (currentTime >= openTime && currentTime <= closeTime) {
68
- return handleState(
69
- 'Abierto Ahora - Cierra a las: ' + handleHourPmAM(hours[1]),
70
- true
71
- )
72
- }
73
-
74
- if (currentTime < openTime && dayOfWeek === currentDayOfWeek) {
75
- return handleState(
76
- 'Aun temprano - Abre hoy a las: ' + handleHourPmAM(hours[0]),
77
- false
78
- )
79
- }
80
-
81
- if (currentTime >= closeTime - 30 * 60000 && currentTime < closeTime && dayOfWeek === currentDayOfWeek) {
82
- return handleState(
83
- 'Pronto por cerrar - Cierra hoy a las: ' + handleHourPmAM(hours[1]),
84
- true
85
- )
86
- }
87
-
88
- const { findNextDay, findDataNextDay, dayOfWeekTomorrow } = getNextDaySchedule(
89
- dataSchedules,
90
- currentDayOfWeek
91
- )
92
-
93
- if (findNextDay && findDataNextDay?.schHoSta) {
94
- const nameOfDayTomorrow = weekDays[dayOfWeekTomorrow]
95
- return handleState(
96
- `Cerrado abre - Mañana ${nameOfDayTomorrow} ${!!findDataNextDay?.schHoSta && 'a las'} ${
97
- findDataNextDay?.schHoSta ?? ''
98
- }`,
99
- false
100
- )
101
- }
102
-
103
- const nextDayName = weekDayLookup[(dayOfWeek + 1) % 7]
104
- const nextOpening = openings && openings['opening' + nextDayName.substring(0, 3)]
105
- const nextHours = nextOpening?.split(';')?.map((item) => item?.trim())
106
-
107
- if (nextHours[0] !== ceroHours) {
108
- return handleState(
109
- 'Cerrado - Abre el ' + days[nextDayName] + ' a las ' + nextHours[0],
110
- false
111
- )
112
- }
113
- }
114
-
115
- dayOfWeek++
116
- }
117
-
118
- return handleState('Cerrado', false)
119
- }
120
-
121
- function getIsOpening (openings) {
122
- const { currentTime, currentDayOfWeek } = getCurrentDayAndTime()
123
- return getOpeningStatus(openings, currentTime, currentDayOfWeek)
124
- }
125
-
126
- const createOpeningsObject = (dataSchedules) => {
127
- const openings = {}
128
- const existStoreSchedule = dataSchedules || []
129
-
130
- existStoreSchedule?.forEach((schedule) => {
131
- const day = schedule.schDay
132
- const openingKey = getOpeningKeyFromDay(day)
133
- const schHoSta = getTimeString(schedule?.schHoSta)
134
- const schHoEnd = getTimeString(schedule?.schHoEnd)
135
- openings[openingKey] = `${schHoSta} - ${schHoEnd}`
136
- })
137
-
138
- for (let i = 0; i < 7; i++) {
139
- const openingKey = getOpeningKeyFromDay(i)
140
- // eslint-disable-next-line no-prototype-builtins
141
- if (!(openingKey in openings)) {
142
- openings[openingKey] = '00:00 - 00:00' // Horario vacío para el día faltante
143
- }
144
- }
145
-
146
- return openings
147
- }
148
-
149
- // Luego puedes usar esta función así:
150
- const openings = createOpeningsObject(dataSchedules)
151
- // ...haz lo que necesites con el objeto openings
152
- const sortedOpenings = sortOpeningsByDay(openings)
153
-
154
- // Crear el array completo con objetos de tiempo
155
- return getIsOpening(sortedOpenings)
156
- }
@@ -1,40 +0,0 @@
1
- import { useMutation } from '@apollo/client'
2
- import { updateCacheMod } from '../../utils'
3
- import { GET_EXTRAS_PRODUCT_FOOD_OPTIONAL, UPDATE_EXTRAS_PRODUCT_FOOD_OPTIONAL } from '../useProductsFood/queriesStore'
4
-
5
- export const useUpdateExtProductFoodsOptional = () => {
6
- const [updateExtProductOptional] = useMutation(UPDATE_EXTRAS_PRODUCT_FOOD_OPTIONAL)
7
-
8
- const handleUpdateExtProduct = async ({
9
- pId,
10
- code,
11
- opExPid,
12
- OptionalProName,
13
- required,
14
- numbersOptionalOnly
15
- }) => {
16
- return await updateExtProductOptional({
17
- variables: {
18
- input: {
19
- pId,
20
- code,
21
- opExPid,
22
- OptionalProName,
23
- required,
24
- numbersOptionalOnly: Number(numbersOptionalOnly)
25
- }
26
- },
27
- update: (cache, { data: { ExtProductFoodsOptionalAll } }) => {
28
- return updateCacheMod({
29
- cache,
30
- query: GET_EXTRAS_PRODUCT_FOOD_OPTIONAL,
31
- nameFun: 'ExtProductFoodsOptionalAll',
32
- dataNew: ExtProductFoodsOptionalAll
33
- })
34
- }
35
- })
36
- }
37
- return {
38
- handleUpdateExtProduct
39
- }
40
- }
@@ -1,16 +0,0 @@
1
- const data = [
2
- { x: '2021-10-17T14:38:45.540Z', y: 2 }
3
- ]
4
- export const getDateParts = (isString) => {
5
- const [year, month, day, hr, min, sec] = isString.split(/\D/g)
6
- return { year, month, day, hr, min, sec }
7
- }
8
- export function groupDates (arr) {
9
- const total = arr.reduce((a, b) => {
10
- const { hr } = getDateParts(b.x)
11
- return a + parseInt(hr)
12
- }, 0)
13
- return total
14
- }
15
- // eslint-disable-next-line no-unused-vars
16
- const result = groupDates(data)
@@ -1,34 +0,0 @@
1
- import { gql, useQuery } from '@apollo/client'
2
- import { useEffect, useState } from 'react'
3
-
4
- export const GET_ALL_STORES_PENDING_TO_REGISTER = gql`
5
- query GetAllStoresPendingToRegister {
6
- getAllStoresPendingToRegister {
7
- StorePendingToRegisterId
8
- UserId
9
- UserEmail
10
- StoreNumber
11
- createAt
12
- updateAt
13
- }
14
- }
15
- `
16
-
17
- export function useAllStoresPendingToRegister () {
18
- const { loading, error, data } = useQuery(GET_ALL_STORES_PENDING_TO_REGISTER)
19
-
20
- const [stores, setStores] = useState([])
21
- const [fetchError, setFetchError] = useState(null)
22
-
23
- useEffect(() => {
24
- if (!loading && data) {
25
- setStores(data.getAllStoresPendingToRegister)
26
- }
27
-
28
- if (error) {
29
- setFetchError(error.message)
30
- }
31
- }, [loading, data, error])
32
-
33
- return { loading, stores, fetchError }
34
- }
@@ -1,117 +0,0 @@
1
- import { useState } from 'react'
2
-
3
- const formatCurrency = (
4
- prefix,
5
- amountValue,
6
- number,
7
- groupSeparator,
8
- decimalSeparator,
9
- allowDecimals = false,
10
- decimalsLimit = 0
11
- ) => {
12
- if (isNaN(number)) {
13
- return prefix + '0'
14
- }
15
-
16
- const amountWithoutDecimals = parseInt(number.toString())
17
- const decimalIdx = amountValue.indexOf(decimalSeparator)
18
- const notAllowedChars = new RegExp('[^' + decimalSeparator + '\\d]', 'g')
19
- const decimalsWithSeparator =
20
- decimalIdx >= 0
21
- ? amountValue
22
- .slice(decimalIdx, amountValue.length)
23
- .replace(notAllowedChars, '')
24
- .slice(0, decimalsLimit + 1)
25
- : ''
26
-
27
- return (
28
- prefix +
29
- amountWithoutDecimals
30
- .toString()
31
- .replace(/\B(?=(\d{3}){1,5}(?!\d))/g, groupSeparator) +
32
- decimalsWithSeparator
33
- )
34
- }
35
-
36
- const processInputValue = (input, decimalSeparator) => {
37
- const decimalRegex = new RegExp('[' + decimalSeparator + ']', 'g')
38
- const notAllowedChars = new RegExp('[^' + decimalSeparator + '\\d¬]', 'g')
39
-
40
- return parseFloat(
41
- input
42
- .replace(decimalRegex, '¬')
43
- .replace(notAllowedChars, '')
44
- .replace('¬', '.')
45
- )
46
- }
47
- /**
48
- * Truncate excess decimals from a number based on a limit.
49
- *
50
- * @param {number} number The number to truncate.
51
- * @param {number} decimalsLimit The maximum number of decimal places allowed.
52
- * @returns {number} The number with truncated decimals.
53
- */
54
- const truncateDecimals = (number, decimalsLimit) => {
55
- if (isNaN(number)) {
56
- return 0;
57
- }
58
-
59
- const multiplier = Math.pow(10, decimalsLimit);
60
- return Math.floor(number * multiplier) / multiplier;
61
- };
62
- export const useAmountInput = props => {
63
- const {
64
- onChange = () => {},
65
- prefix = '$',
66
- groupSeparator = '.',
67
- decimalSeparator = ',',
68
- allowDecimals,
69
- decimalsLimit,
70
- defaultValue
71
- } = props
72
-
73
- const inputVal = defaultValue ?? ''
74
- const [inputValue, setInputValue] = useState(inputVal)
75
-
76
- const preProcess = amount => {
77
- const amountValue = amount.trim()
78
- const oldInputValue = inputValue
79
-
80
- if (oldInputValue !== amountValue) {
81
- const amountFloatValue = processInputValue(amount, decimalSeparator)
82
- let inputValue = ''
83
- // This allows for people to use `.` but still input decimals
84
- const isAboutToIntroduceDecimals =
85
- oldInputValue + decimalSeparator === amountValue ||
86
- oldInputValue + '.' === amountValue
87
- if (allowDecimals === true && isAboutToIntroduceDecimals) {
88
- inputValue = oldInputValue + decimalSeparator
89
- } else if (
90
- (allowDecimals === false || allowDecimals === undefined) &&
91
- isAboutToIntroduceDecimals
92
- ) {
93
- inputValue = oldInputValue
94
- } else {
95
- inputValue = formatCurrency(
96
- prefix,
97
- amountValue,
98
- amountFloatValue,
99
- groupSeparator,
100
- decimalSeparator,
101
- allowDecimals,
102
- decimalsLimit
103
- )
104
- }
105
- setInputValue(inputValue)
106
-
107
- const callbackValue = isNaN(amountFloatValue) ? 0 : amountFloatValue
108
- if (typeof onChange === 'function') {
109
- onChange(truncateDecimals(callbackValue, decimalsLimit))
110
- }
111
- }
112
- }
113
- return {
114
- inputValue,
115
- preProcess
116
- }
117
- }
@@ -1,45 +0,0 @@
1
- import { useEffect, useRef } from 'react'
2
-
3
- export const useAnimationFrame = (callback, start, end, duration = 1000) => {
4
- const functionRef = useRef()
5
- const delta = Math.abs(start - end)
6
- const frameCount = Math.ceil(60 * (duration / 1000))
7
- const iteration = useRef(frameCount)
8
- useEffect(() => {
9
- const animate = (rafId) => {
10
- if (iteration.current <= 0) {
11
- cancelAnimationFrame(rafId)
12
- iteration.current = frameCount
13
- }
14
-
15
- callback(Math.max(delta / iteration.current, 1))
16
- iteration.current--
17
- }
18
-
19
- if (delta > 0) functionRef.current = requestAnimationFrame(animate)
20
-
21
- return () => { return cancelAnimationFrame(functionRef.current) }
22
- }, [callback, delta, frameCount, iteration])
23
- }
24
-
25
- // const Counter = ({ numeral = 0 }) => {
26
- // const [currentValue, setCurrentValue] = useState(0)
27
- // const fxOperator = currentValue > numeral ? 'subtraction' : 'addition'
28
-
29
- // useAnimationFrame(
30
- // (diffValue) => {
31
- // // Pass on a function to the setter of the state
32
- // // to make sure we always have the latest state
33
- // setCurrentValue((prevCount) => {
34
- // return fxOperator === 'addition'
35
- // ? prevCount + diffValue
36
- // : prevCount - diffValue
37
- // }
38
- // )
39
- // },
40
- // currentValue,
41
- // numeral,
42
- // 300
43
- // )
44
- // return <>{new Intl.NumberFormat().format(Math.round(currentValue))}</>
45
- // }
@@ -1,31 +0,0 @@
1
- import { useEffect, useRef, useState } from 'react'
2
-
3
- const fullText =
4
- ' this is full text it\'ll be animated again! Writing a really huge senetence here so that I can see the animation happen. I know it\'s fast but that\'s how it goes.'
5
-
6
- export const useAnimatedText = textMessage => {
7
- const fullTextRef = useRef(textMessage)
8
- const [text, setText] = useState('')
9
- const [index, setIndex] = useState(0)
10
-
11
- useEffect(() => {
12
- if (index < fullText.length) {
13
- window.requestAnimationFrame(() => {
14
- // eslint-disable-next-line
15
- setText(text => text + fullTextRef.current[index]);
16
- setIndex(() => {return index + 1})
17
- })
18
- }
19
- }, [index])
20
- useEffect(() => {
21
- fullText.current = textMessage
22
- }, [textMessage])
23
-
24
- return text
25
- }
26
-
27
- // export default function TextHook() {
28
- // const text = useAnimatedText(fullText)
29
-
30
- // return <span>{text} </span>
31
- // }
@@ -1,22 +0,0 @@
1
- export const calculateTotalPrice = (shoppingCardData) => {
2
- if (Array.isArray(shoppingCardData) && shoppingCardData.length) {
3
- return shoppingCardData.reduce((accumulator, currentItem) => {
4
- const { productFood = {}, cantProducts } = currentItem || {}
5
- const { ProPrice = 0, ValueDelivery = 0 } = productFood || {}
6
-
7
- const pricePerProduct = ProPrice * cantProducts
8
- const deliveryCost = ValueDelivery || 0
9
- const ExtProductFoodsAll = currentItem.ExtProductFoodsAll || []
10
-
11
- const extraPriceSum = ExtProductFoodsAll.reduce((extraAccumulator, extraFood) => {
12
- if (Number.isInteger(extraFood.newExtraPrice)) {
13
- return extraAccumulator + extraFood.newExtraPrice
14
- }
15
- return extraAccumulator
16
- }, 0)
17
-
18
- return accumulator + pricePerProduct + deliveryCost + extraPriceSum
19
- }, 0)
20
- }
21
- return 0
22
- }
@@ -1,214 +0,0 @@
1
- import {
2
- useState,
3
- useEffect,
4
- useMemo
5
- } from 'react'
6
- import { useMutation } from '@apollo/client'
7
- import { DELETE_ONE_ITEM_SHOPPING_PRODUCT } from './queries'
8
- import { useCart, useGetCart } from '../useCart'
9
- import { useManageQueryParams } from '../useManageQueryParams'
10
- import { calculateTotalPrice } from './helpers'
11
- import { statusOpenStores } from '../statusOpenStores'
12
-
13
- export const useAsideCart = ({
14
- openModalProduct = false,
15
- location = {
16
- pathname: '',
17
- push: (props, state, { shallow }) => {
18
- return { ...props, state, shallow }
19
- },
20
- query: {
21
- plato: ''
22
- }
23
- },
24
- setCountItemProduct = (number) => { return number },
25
- setAlertBox = (args) => { return args },
26
- setOpenModalProduct = () => { },
27
- handleMenu = (boolean) => { return boolean }
28
- } = {
29
- openModalProduct: false,
30
- location: {
31
- pathname: '',
32
- push: (props, state, { shallow }) => {
33
- return { ...props, state, shallow }
34
- },
35
- query: {
36
- plato: ''
37
- }
38
- },
39
- setCountItemProduct: (number) => { return number },
40
- setAlertBox: () => { },
41
- setOpenModalProduct: () => { },
42
- handleMenu: () => { }
43
- }) => {
44
- const { getOneProduct } = useCart({
45
- handleMenu,
46
- openModalProduct,
47
- location,
48
- setOpenModalProduct
49
- })
50
-
51
- const { handleQuery } = useManageQueryParams({
52
- location
53
- })
54
-
55
- const [totalProductPrice, setTotalProductPrice] = useState(0)
56
-
57
- const [dataShoppingCard, { loading }] = useGetCart({ setCountItemProduct })
58
-
59
- // Lógica de transformación de los datos
60
- const result2 = useMemo(() => {
61
- if (!loading && dataShoppingCard) {
62
- return dataShoppingCard.reduce((r, a) => {
63
- const storeName = a.getStore?.storeName
64
- if (storeName) {
65
- r[storeName] = r[storeName] || []
66
- r[storeName].push(a)
67
- }
68
- return r
69
- }, {})
70
- }
71
- return {}
72
- }, [loading, dataShoppingCard])
73
-
74
- // Obtener dataProduct2 directamente
75
- const key = useMemo(() => {
76
- return Object.keys(result2)
77
- }, [result2])
78
-
79
- useEffect(() => {
80
- const totalPrice = calculateTotalPrice(dataShoppingCard)
81
- setTotalProductPrice(Math.abs(totalPrice))
82
- }, [dataShoppingCard])
83
-
84
- const [deleteOneItem] = useMutation(DELETE_ONE_ITEM_SHOPPING_PRODUCT, {
85
- onCompleted: data => {
86
- setAlertBox({ message: data?.deleteOneItem?.message })
87
-
88
- if (dataShoppingCard?.length === 1 && data?.deleteOneItem?.success) {
89
- setAlertBox({ message: 'Tu carrito está vacío' }) // Ajusta el mensaje en español
90
- handleMenu(false) // Oculta el menú del carrito
91
- }
92
- }
93
- })
94
-
95
- const handleEditProduct = async (item) => {
96
- const pId = item?.pId || null
97
- if (pId) handleQuery('plato', pId)
98
- if (pId) {
99
- const product = { pId, intoCart: true }
100
- getOneProduct(product)
101
- }
102
- }
103
- /**
104
- * Handle the deletion of a shopping cart item.
105
- * @param {Object} item - The item to be deleted from the shopping cart.
106
- */
107
- const handleDeleteItemShopping = async (item) => {
108
- if (!item) {
109
- return setAlertBox({
110
- message: 'Error borrando el producto. Por favor intenta nuevamente.',
111
- color: 'error'
112
- })
113
- }
114
-
115
- try {
116
- const { cState, ShoppingCard } = item
117
- await deleteOneItem({
118
- variables: { cState, ShoppingCard },
119
- update: (cache) => {
120
- cache.modify({
121
- fields: {
122
- getAllShoppingCard (existingCart, { readField }) {
123
- if (!Array.isArray(existingCart)) return []
124
-
125
- const filteredCart = existingCart.filter(product =>
126
- readField('ShoppingCard', product) !== ShoppingCard
127
- )
128
-
129
- // Actualizar el contador de productos
130
- setCountItemProduct(filteredCart.length)
131
-
132
- return filteredCart?.length > 0 ? filteredCart : []
133
- }
134
- }
135
- })
136
- }
137
- })
138
- } catch (error) {
139
- setAlertBox({ message: 'Error borrando el producto. Por favor intenta nuevamente.', color: 'error' })
140
- }
141
- }
142
-
143
- /**
144
- * Calculate the total price of a product.
145
- * @param {number} ProPrice - The price of the product.
146
- * @param {number} ProDelivery - The delivery cost of the product.
147
- * @param {number} cant - The quantity of the product.
148
- * @returns {number} The calculated total price.
149
- */
150
- const sumProduct = (ProPrice, ProDelivery, cant) => {
151
- // Convertir a números, con manejo de posibles errores
152
- const price = ProPrice
153
- const delivery = ProDelivery || 0
154
- const quantity = cant
155
-
156
- // Verificar si las conversiones fueron exitosas
157
- if (isNaN(price) || isNaN(delivery) || isNaN(quantity)) {
158
- throw new Error('Los valores proporcionados no son números válidos.')
159
- }
160
-
161
- // Calcular el precio final
162
- const priceFinal = quantity * price
163
-
164
- // Devolver la suma total, incluyendo el costo de entrega si es aplicable
165
- return delivery ? priceFinal + delivery : priceFinal
166
- }
167
- console.log(dataShoppingCard)
168
-
169
- /**
170
- * Verifica el estado de apertura de la tienda.
171
- *
172
- * @returns {Object|null} Objeto con el estado de apertura de la tienda o null en caso de error.
173
- * @throws {Error} Si ocurre un error durante la verificación del estado de la tienda.
174
- */
175
- const handleVerifyStoreOpenStatus = () => {
176
- /**
177
- * @type {Array} dataShoppingCard - El array de la tarjeta de compras.
178
- */
179
- if (!Array.isArray(dataShoppingCard)) {
180
- return { open: false } // Retorna un objeto indicando que la tienda no está abierta
181
- }
182
-
183
- /**
184
- * @type {Object} store - La primera tienda en el array de la tarjeta de compras.
185
- */
186
- const store = dataShoppingCard[0] || {}
187
- /**
188
- * @type {Object} getStore - El objeto que contiene información de la tienda.
189
- */
190
- const { getStore } = store
191
-
192
- /**
193
- * @type {Array} storeSchedules - El array de horarios de la tienda.
194
- */
195
- const storeSchedules = Array.isArray(getStore?.getStoreSchedules) ? getStore?.getStoreSchedules : []
196
- try {
197
- const status = getStore?.scheduleOpenAll ? { open: true } : statusOpenStores({ dataSchedules: storeSchedules })
198
- return status
199
- } catch (error) {
200
- return null
201
- }
202
- }
203
-
204
- return {
205
- key,
206
- totalProductPrice,
207
- result2,
208
- dataShoppingCard,
209
- handleDeleteItemShopping,
210
- handleEditProduct,
211
- handleVerifyStoreOpenStatus,
212
- sumProduct
213
- }
214
- }
@@ -1,10 +0,0 @@
1
- import { gql } from '@apollo/client'
2
-
3
- export const DELETE_ONE_ITEM_SHOPPING_PRODUCT = gql`
4
- mutation deleteOneItem($cState: Int, $ShoppingCard: ID) {
5
- deleteOneItem(cState: $cState, ShoppingCard: $ShoppingCard){
6
- success
7
- message
8
- }
9
- }
10
- `