npm-pkg-hook 1.3.9 → 1.4.0
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.
- package/.babelrc +2 -10
- package/.env +5 -1
- package/dist/index.js +17953 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +17711 -0
- package/dist/index.mjs.map +1 -0
- package/eslint.config.mjs +154 -0
- package/expire.json +1 -0
- package/index.d.ts +2 -0
- package/jest.config.ts +9 -0
- package/package.json +45 -36
- package/src/config/client/errors.ts +39 -0
- package/src/config/content/en.json +5 -0
- package/src/config/content/es.json +5 -0
- package/src/config/content/index.ts +16 -0
- package/src/hooks/addTenMinutes/index.ts +14 -0
- package/src/hooks/calculateLogLatHaversine/index.ts +41 -0
- package/src/hooks/completeSchedules/index.ts +22 -0
- package/src/hooks/convertToMilitaryTime/index.ts +18 -0
- package/src/hooks/generateStoreURL/index.ts +41 -0
- package/src/hooks/generateTemplate/index.ts +66 -0
- package/src/hooks/getCardType/index.ts +24 -0
- package/src/hooks/getCategoriesWithProduct/{index.js → index.ts} +7 -7
- package/src/hooks/getGlobalSession/index.ts +69 -0
- package/src/hooks/getSession/index.ts +72 -0
- package/src/hooks/getTodayTimestamps/index.ts +70 -0
- package/src/hooks/getTotalHours/index.ts +76 -0
- package/src/hooks/handleLogin/index.ts +14 -0
- package/src/hooks/index.ts +154 -0
- package/src/hooks/isTokenExpired/index.ts +17 -0
- package/src/hooks/newMessageSubscription/index.ts +28 -0
- package/src/hooks/newStoreOrderSubscription/index.ts +26 -0
- package/src/hooks/{useStatusOpenStore/helpers/index.js → statusOpenStores/helpers/index.ts} +24 -1
- package/src/hooks/statusOpenStores/index.ts +221 -0
- package/src/hooks/updateExtProductFoodsOptional/{index.js → index.ts} +15 -6
- package/src/hooks/useAcumulateDate/index.ts +18 -0
- package/src/hooks/useAllStoresPendingToRegister/index.ts +37 -0
- package/src/hooks/useAmountInput/index.ts +127 -0
- package/src/hooks/useAnimationText/{index.jsx → index.ts} +2 -2
- package/src/hooks/useAsideCart/index.ts +217 -0
- package/src/hooks/useBanner/{index.js → index.ts} +2 -1
- package/src/hooks/useCart/{queries.js → queries.ts} +11 -1
- package/src/hooks/useCart/useCart/helpers/{index.js → index.ts} +10 -6
- package/src/hooks/useCart/useCart/{index.js → index.ts} +58 -44
- package/src/hooks/useCart/useGetCart/{index.js → index.ts} +6 -3
- package/src/hooks/useCatWithProduct/{index.js → index.ts} +17 -7
- package/src/hooks/useCatWithProduct/{queries.js → queries.ts} +50 -23
- package/src/hooks/useCatWithProduct/types/index.ts +104 -0
- package/src/hooks/useCatWithProductClient/{index.js → index.ts} +19 -18
- package/src/hooks/useCatWithProductClient/{queries.js → queries.ts} +1 -0
- package/src/hooks/useCategoriesProduct/{index.js → index.ts} +3 -1
- package/src/hooks/useCategoriesProduct/{queries.js → queries.ts} +2 -2
- package/src/hooks/useCategoryInStore/index.ts +167 -0
- package/src/hooks/useCategoryInStore/{queries.js → queries.ts} +2 -2
- package/src/hooks/useCategoryStore/{index.js → index.ts} +4 -3
- package/src/hooks/useCategoryStore/{queries.js → queries.ts} +2 -2
- package/src/hooks/useChartData/{index.js → index.ts} +31 -34
- package/src/hooks/useChartData/useChartData/{index.js → index.ts} +31 -30
- package/src/hooks/useChartData/useChartDataAllOrders/{index.js → index.ts} +4 -4
- package/src/hooks/useChatRoomSubscription/index.ts +28 -0
- package/src/hooks/useCheckbox/{index.js → index.ts} +1 -1
- package/src/hooks/useCities/index.ts +14 -0
- package/src/hooks/useCities/queries.ts +12 -0
- package/src/hooks/useClients/{index.js → index.ts} +36 -10
- package/src/hooks/useClients/queries.ts +215 -0
- package/src/hooks/useColorByLetters/helpers/alea.ts +73 -0
- package/src/hooks/useColorByLetters/helpers/colors.ts +45 -0
- package/src/hooks/useColorByLetters/helpers/index.ts +24 -0
- package/src/hooks/useColorByLetters/helpers/mersenne_twister.ts +118 -0
- package/src/hooks/useColorByLetters/index.ts +24 -0
- package/src/hooks/useConnection/index.ts +24 -0
- package/src/hooks/useCountries/index.ts +20 -0
- package/src/hooks/useCountries/queries.ts +12 -0
- package/src/hooks/useCreateDeliveryTime/index.ts +51 -0
- package/src/hooks/useCreateOrderStatusType/index.ts +134 -0
- package/src/hooks/useCreateProduct/helpers/index.ts +23 -0
- package/src/hooks/useCreateProduct/helpers/manageCacheDataCatProduct/{index.js → index.ts} +1 -1
- package/src/hooks/useCreateProduct/helpers/useEditImageProduct/{index.js → index.ts} +14 -8
- package/src/hooks/useCreateProduct/index.ts +337 -0
- package/src/hooks/useCreateStorePendingToRegister/index.ts +17 -0
- package/src/hooks/useCreateStorePendingToRegister/queries.ts +10 -0
- package/src/hooks/useDashboardComponents/index.ts +50 -0
- package/src/hooks/useDeleteExtraProductFoods/index.ts +13 -0
- package/src/hooks/useDeleteSubProductOptional/{index.js → index.ts} +5 -3
- package/src/hooks/useDeliveryTime/index.ts +29 -0
- package/src/hooks/useDepartments/index.ts +14 -0
- package/src/hooks/useDepartments/queries.ts +13 -0
- package/src/hooks/useDessert/{index.js → index.ts} +162 -114
- package/src/hooks/useDessertWithPrice/helpers/index.ts +76 -0
- package/src/hooks/useDessertWithPrice/index.ts +381 -0
- package/src/hooks/useDessertWithPrice/queries.ts +18 -0
- package/src/hooks/useDevWS/index.ts +53 -0
- package/src/hooks/useDevices/index.ts +2 -0
- package/src/hooks/useDevices/queries.ts +28 -0
- package/src/hooks/useDevices/useGetDevices.ts +28 -0
- package/src/hooks/useDevices/useRegisterDevices.ts +75 -0
- package/src/hooks/useDownloadReports/helpers/downloadFileFromResponse.ts +21 -0
- package/src/hooks/useDownloadReports/index.ts +2 -0
- package/src/hooks/useDownloadReports/useDownloadReportByDay/index.ts +105 -0
- package/src/hooks/useDownloadReports/useGetReportByDateRange/index.ts +116 -0
- package/src/hooks/useDrag/{index.js → index.ts} +16 -0
- package/src/hooks/useDropzone/{index.js → index.ts} +2 -2
- package/src/hooks/useDynamicAuth/{index.js → index.ts} +2 -1
- package/src/hooks/useEditCategory/{index.js → index.ts} +14 -14
- package/src/hooks/useEditOneExtProductFoodOptional/index.ts +28 -0
- package/src/hooks/useEditOneExtProductFoodOptional/{queries.js → queries.ts} +2 -2
- package/src/hooks/useEditSubProductOptional/index.ts +12 -0
- package/src/hooks/useEmployee/index.ts +18 -0
- package/src/hooks/useEmployee/queries.ts +85 -0
- package/src/hooks/useEmployee/useCreateEmployee.ts +90 -0
- package/src/hooks/useEvent/{index.js → index.ts} +1 -0
- package/src/hooks/useFavoriteStores/index.ts +31 -0
- package/src/hooks/useFavoriteStores/queries.ts +54 -0
- package/src/hooks/useFetchMoreInteractions/index.jsx +26 -26
- package/src/hooks/useFilterConfigs/index.ts +173 -0
- package/src/hooks/useFingerprintjs/{index.js → index.ts} +32 -7
- package/src/hooks/useFormTools/index.ts +143 -0
- package/src/hooks/useFormatDate/index.ts +91 -0
- package/src/hooks/useFullScreenMode/{index.js → index.ts} +1 -5
- package/src/hooks/useGetAllLocationUser/index.ts +13 -0
- package/src/hooks/useGetAllLocationUser/queries.ts +44 -0
- package/src/hooks/{useSales/useGetAllSales/index.js → useGetAllSales/index.ts} +3 -2
- package/src/hooks/useGetCookies/index.ts +43 -0
- package/src/hooks/useGetExtProductFoodsSubOptionalAll/{index.js → index.ts} +2 -1
- package/src/hooks/useGetFoodRecomended/{index.js → index.ts} +2 -1
- package/src/hooks/useGetMessagesToRoom/index.ts +23 -0
- package/src/hooks/useGetMinPrice/{index.js → index.ts} +2 -1
- package/src/hooks/useGetOneStoreRating/{index.js → index.ts} +2 -1
- package/src/hooks/useGetSalesAmountToday/index.ts +31 -0
- package/src/hooks/useGetStoreCookie/index.ts +21 -0
- package/src/hooks/useGoogleLogin/{index.js → index.ts} +14 -5
- package/src/hooks/useHover/{index.js → index.ts} +3 -0
- package/src/hooks/useImageOptimization/{index.js → index.ts} +4 -0
- package/src/hooks/useImageUploaderProduct/helper/canvasUtils.ts +146 -0
- package/src/hooks/useImageUploaderProduct/helper/getOrientation.ts +54 -0
- package/src/hooks/useImageUploaderProduct/helper/index.ts +5 -0
- package/src/hooks/useImageUploaderProduct/index.ts +295 -0
- package/src/hooks/useImageWeight/{index.js → index.ts} +4 -0
- package/src/hooks/useImagesStore/index.ts +227 -0
- package/src/hooks/useImagesStore/{queries.js → queries.ts} +4 -68
- package/src/hooks/useImagesStore/utils/index.ts +4 -0
- package/src/hooks/useIncomingOrders/index.ts +11 -0
- package/src/hooks/useIncomingOrders/queries.ts +87 -0
- package/src/hooks/useIntersection/{index.js → index.ts} +1 -1
- package/src/hooks/useInventory/index.ts +2 -0
- package/src/hooks/useInventory/queries.ts +58 -0
- package/src/hooks/useInventory/useGetProductsInStock.ts +16 -0
- package/src/hooks/useInventory/useUpdateManageStock.ts +41 -0
- package/src/hooks/useLazyScript/{index.js → index.ts} +3 -0
- package/src/hooks/useLocalBackendIp/index.ts +34 -0
- package/src/hooks/useLocalSorage/{index.js → index.ts} +3 -3
- package/src/hooks/useLocationManager/index.ts +63 -0
- package/src/hooks/useLoginEmployeeInStore/index.ts +38 -0
- package/src/hooks/useLogout/helpers/BroadcastChannel.ts +74 -0
- package/src/hooks/useLogout/helpers/apiBaseUrl.ts +12 -0
- package/src/hooks/useLogout/helpers/fetchData.ts +37 -0
- package/src/hooks/useLogout/helpers/getCsrfToken.ts +37 -0
- package/src/hooks/useLogout/helpers/index.ts +65 -0
- package/src/hooks/useLogout/helpers/logger.ts +88 -0
- package/src/hooks/useLogout/helpers/parseUrl.ts +39 -0
- package/src/hooks/useLogout/index.ts +105 -0
- package/src/hooks/useManageNewOrder/helpers/index.ts +45 -0
- package/src/hooks/useManageNewOrder/index.ts +104 -0
- package/src/hooks/useManageQueryParams/index.ts +120 -0
- package/src/hooks/useMobile/index.ts +65 -0
- package/src/hooks/useModules/helpers/index.ts +1 -0
- package/src/hooks/useModules/helpers/validateModules.ts +43 -0
- package/src/hooks/useModules/index.ts +124 -0
- package/src/hooks/useMouse/index.ts +55 -0
- package/src/hooks/useOrderStatusTypes/index.ts +2 -0
- package/src/hooks/useOrderStatusTypes/useOrderStatusTypes/index.ts +133 -0
- package/src/hooks/useOrderStatusTypes/useUpdateOrderStatusPriorities/index.ts +99 -0
- package/src/hooks/useOrders/index.ts +3 -0
- package/src/hooks/useOrders/queries.ts +99 -0
- package/src/hooks/useOrders/useChangeOrderState/index.ts +128 -0
- package/src/hooks/useOrders/{index.js → useOrdersFromStore/index.ts} +20 -18
- package/src/hooks/usePWAInstall/index.ts +38 -0
- package/src/hooks/usePaymentMethod/index.ts +3 -0
- package/src/hooks/usePaymentMethod/paymentMethod.gql.ts +62 -0
- package/src/hooks/usePaymentMethod/paymentMethod.types.ts +28 -0
- package/src/hooks/usePaymentMethod/useCreatePaymentMethod/index.ts +25 -0
- package/src/hooks/usePaymentMethod/useGetAllPaymentMethods/index.ts +19 -0
- package/src/hooks/usePaymentMethod/useGetPaymentMethod/index.ts +26 -0
- package/src/hooks/usePortFetcher/index.ts +33 -0
- package/src/hooks/usePrintSaleTicket/index.ts +68 -0
- package/src/hooks/useProductsFood/index.ts +341 -0
- package/src/hooks/useProductsFood/{queriesStore.js → queriesStore.ts} +151 -84
- package/src/hooks/useProductsFood/types/index.ts +0 -0
- package/src/hooks/useProductsFood/useEditProduct.ts +49 -0
- package/src/hooks/useProductsFood/usetagsProducts.ts +101 -0
- package/src/hooks/useProviders/useProvidersCreateStore/{index.js → index.ts} +2 -1
- package/src/hooks/useProviders/useProvidersDataStore/{index.js → index.ts} +2 -1
- package/src/hooks/useProvidersStore/{index.js → index.ts} +2 -1
- package/src/hooks/usePushNotificationOrder/index.ts +52 -0
- package/src/hooks/usePushNotifications/helpers/index.ts +123 -0
- package/src/hooks/usePushNotifications/index.ts +150 -0
- package/src/hooks/useQueryLocationsMap/index.ts +20 -0
- package/src/hooks/useQueryLocationsMap/queries.ts +40 -0
- package/src/hooks/useRatingArrayData/{index.js → index.ts} +4 -4
- package/src/hooks/useRatingArrayData/{queries.js → queries.ts} +1 -1
- package/src/hooks/useReactToPrint/index.ts +4 -0
- package/src/hooks/useRemoveExtraProductFoodsOptional/{index.js → index.ts} +2 -1
- package/src/hooks/useRemoveExtraProductFoodsOptional/{queries.js → queries.ts} +4 -4
- package/src/hooks/useReport/{index.js → index.ts} +5 -5
- package/src/hooks/useReport/{queries.js → queries.ts} +4 -55
- package/src/hooks/useRestaurant/helpers/index.ts +28 -0
- package/src/hooks/useRestaurant/helpers/manageStatusOpen.ts +26 -0
- package/src/hooks/useRestaurant/index.ts +71 -0
- package/src/hooks/useRestaurant/{queries.js → queries.ts} +2 -1
- package/src/hooks/useRoads/index.ts +20 -0
- package/src/hooks/useRoads/queries.ts +13 -0
- package/src/hooks/useRoles/index.ts +4 -0
- package/src/hooks/useRoles/queries.ts +70 -0
- package/src/hooks/useRoles/useCreateRole.ts +40 -0
- package/src/hooks/useRoles/useGetRoles.ts +37 -0
- package/src/hooks/useRoles/useRemoveRoles.ts +40 -0
- package/src/hooks/useRoles/useUpdateRolesPriority.ts +44 -0
- package/src/hooks/useSales/helpers/add-product.utils.ts +120 -0
- package/src/hooks/useSales/helpers/apply-discount-to-cart.utils.ts +292 -0
- package/src/hooks/useSales/helpers/comment-product.utils.ts +41 -0
- package/src/hooks/useSales/helpers/constants/index.ts +38 -0
- package/src/hooks/useSales/helpers/extras.utils.ts +42 -0
- package/src/hooks/useSales/helpers/filterProductsByCarProId.utils.ts +17 -0
- package/src/hooks/useSales/helpers/increment-product-quantity.utils.ts +76 -0
- package/src/hooks/useSales/helpers/index.ts +3 -0
- package/src/hooks/useSales/helpers/initializer.utils.ts +22 -0
- package/src/hooks/useSales/helpers/isStockInsufficient.ts +3 -0
- package/src/hooks/useSales/helpers/remove-product.utils.test.ts +49 -0
- package/src/hooks/useSales/helpers/remove-product.utils.ts +34 -0
- package/src/hooks/useSales/helpers/resolveProduct.ts +29 -0
- package/src/hooks/useSales/helpers/useAddToCart.ts +64 -0
- package/src/hooks/useSales/index.ts +1418 -0
- package/src/hooks/useSales/{queries.js → queries.ts} +256 -166
- package/src/hooks/useSales/types/index.ts +206 -0
- package/src/hooks/useSales/types/use-sales.types.ts +8 -0
- package/src/hooks/useSales/useGetSale.ts +21 -0
- package/src/hooks/useSales/useTotalSales.ts +24 -0
- package/src/hooks/useSaveAvailableProduct/helpers/{index.js → index.ts} +4 -4
- package/src/hooks/useSaveAvailableProduct/{index.js → index.ts} +7 -1
- package/src/hooks/useSaveLocation/index.ts +17 -0
- package/src/hooks/useSaveLocation/queries.ts +19 -0
- package/src/hooks/useSchedule/{index.jsx → index.ts} +16 -4
- package/src/hooks/useSchedule/{index.js → schedule.ts} +22 -15
- package/src/hooks/useScheduleData/{index.js → index.ts} +21 -9
- package/src/hooks/useSetImageProducts/index.ts +59 -0
- package/src/hooks/useSetImageProducts/queries.ts +18 -0
- package/src/hooks/useSetSession/{index.js → index.ts} +16 -17
- package/src/hooks/useSetupSchedule/helpers/index.ts +85 -0
- package/src/hooks/useSetupSchedule/index.ts +284 -0
- package/src/hooks/useStatusOpenStore/helpers/index.ts +124 -0
- package/src/hooks/useStatusOpenStore/{index.js → index.ts} +39 -16
- package/src/hooks/useStatusOrdersClient/{index.js → index.ts} +3 -2
- package/src/hooks/useStatusOrdersClient/{queries.js → queries.ts} +2 -2
- package/src/hooks/useStock/index.ts +1 -0
- package/src/hooks/useStock/useStockUpdatedAllSubscription.ts +40 -0
- package/src/hooks/useStockMovements/helpers/index.ts +16 -0
- package/src/hooks/useStockMovements/index.ts +39 -0
- package/src/hooks/useStore/index.ts +83 -0
- package/src/hooks/useStore/{queries.js → queries.ts} +71 -71
- package/src/hooks/useStoreContacts/{index.js → index.ts} +11 -5
- package/src/hooks/useStoreTable/index.ts +2 -0
- package/src/hooks/useStoreTable/queries.ts +47 -0
- package/src/hooks/useStoreTable/useStoreTableCreate.ts +77 -0
- package/src/hooks/useStoreTable/useStoreTables.ts +15 -0
- package/src/hooks/useSubscriptionValidation/index.ts +112 -0
- package/src/hooks/useTagProducts/index.ts +3 -0
- package/src/hooks/useTagProducts/useDeleteOneTag.ts +106 -0
- package/src/hooks/useTagProducts/useGetAllTags.ts +68 -0
- package/src/hooks/useTagProducts/useRegisterMultipleTags.ts +157 -0
- package/src/hooks/useTheme/index.ts +65 -0
- package/src/hooks/useTimeAgo/{useTimeAgo.js → useTimeAgo.ts} +7 -7
- package/src/hooks/useTokenCards/index.ts +45 -0
- package/src/hooks/useTopProductsMovements/index.ts +27 -0
- package/src/hooks/useTotalAllSales/index.ts +25 -0
- package/src/hooks/useTotalProductsInStock/index.ts +23 -0
- package/src/hooks/useTotalProductsSold/index.ts +23 -0
- package/src/hooks/useTotalProductsSolded/index.ts +20 -0
- package/src/hooks/useUpdateCart/{index.js → index.ts} +3 -2
- package/src/hooks/useUpdateCartCookie/index.ts +60 -0
- package/src/hooks/useUpdateDashboardComponent/index.ts +91 -0
- package/src/hooks/useUpdateExistingOrders/{index.js → index.ts} +5 -11
- package/src/hooks/useUpdateExtProductFoodsSubOptional/index.ts +61 -0
- package/src/hooks/useUpdateModuleOrder/index.ts +37 -0
- package/src/hooks/useUpdateMultipleExtProduct/index.ts +34 -0
- package/src/hooks/useUpdateMultipleExtProduct/queries.ts +33 -0
- package/src/hooks/useUpdateMultipleProducts/index.ts +117 -0
- package/src/hooks/useUpdateMultipleProducts/queries.ts +51 -0
- package/src/hooks/useUploadProducts/helpers/index.ts +1 -0
- package/src/hooks/useUploadProducts/helpers/parseNumber.ts +37 -0
- package/src/hooks/useUploadProducts/helpers/validateProductDataExcel.ts +73 -0
- package/src/hooks/useUploadProducts/index.ts +442 -0
- package/src/hooks/useUpsertGoal/index.ts +68 -0
- package/src/hooks/useUser/{index.js → index.ts} +11 -4
- package/src/hooks/useUser/{queries.js → queries.ts} +9 -4
- package/src/hooks/useWeeklyStockMovement/helpers/index.ts +32 -0
- package/src/hooks/useWeeklyStockMovement/index.ts +52 -0
- package/src/hooks/useWindowSize/{index.js → index.ts} +9 -2
- package/src/index.ts +12 -0
- package/src/security/index.ts +1 -0
- package/src/services/index.ts +1 -0
- package/src/utils/UtilDateRange.ts +56 -0
- package/src/utils/generateCode.ts +222 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/utils.ts +344 -0
- package/tsconfig.eslint.json +17 -0
- package/tsconfig.json +21 -0
- package/tsup.config.ts +24 -0
- package/.eslintrc.js +0 -38
- package/.eslintrc.json +0 -127
- package/next.config.js +0 -126
- package/src/config/client/errors.js +0 -26
- package/src/hooks/getGlobalSession/index.js +0 -49
- package/src/hooks/getSession/index.js +0 -18
- package/src/hooks/handleLogin/index.js +0 -10
- package/src/hooks/index.js +0 -77
- package/src/hooks/useAcumulateDate/index.js +0 -16
- package/src/hooks/useAsideCart/index.js +0 -155
- package/src/hooks/useCategoryInStore/index.js +0 -98
- package/src/hooks/useClients/queries.js +0 -127
- package/src/hooks/useConnection/index.js +0 -22
- package/src/hooks/useCreateProduct/index.js +0 -291
- package/src/hooks/useDevices/index.js +0 -35
- package/src/hooks/useDevices/queries.js +0 -19
- package/src/hooks/useEditOneExtProductFoodOptional/index.js +0 -28
- package/src/hooks/useEditSubProductOptional/index.js +0 -11
- package/src/hooks/useEmployee/index.js +0 -13
- package/src/hooks/useEmployee/queries.js +0 -17
- package/src/hooks/useFavoriteStores/index.js +0 -19
- package/src/hooks/useFavoriteStores/queries.js +0 -47
- package/src/hooks/useFormTools/index.js +0 -100
- package/src/hooks/useFormatDate/index.js +0 -33
- package/src/hooks/useGetStoreCookie/index.js +0 -22
- package/src/hooks/useImagesStore/index.js +0 -183
- package/src/hooks/useLogout/helpers/BroadcastChannel.js +0 -32
- package/src/hooks/useLogout/helpers/apiBaseUrl.js +0 -8
- package/src/hooks/useLogout/helpers/fetchData.js +0 -29
- package/src/hooks/useLogout/helpers/getCsrfToken.js +0 -30
- package/src/hooks/useLogout/helpers/index.js +0 -54
- package/src/hooks/useLogout/helpers/logger.js +0 -72
- package/src/hooks/useLogout/helpers/parseUrl.js +0 -36
- package/src/hooks/useLogout/index.js +0 -46
- package/src/hooks/useManageQueryParams/index.js +0 -37
- package/src/hooks/useMobile/index.js +0 -39
- package/src/hooks/useOrders/queries.js +0 -328
- package/src/hooks/useProductsFood/index.js +0 -234
- package/src/hooks/useProductsFood/useEditProduct.js +0 -8
- package/src/hooks/useProductsFood/usetagsProducts.js +0 -94
- package/src/hooks/useRestaurant/index.js +0 -19
- package/src/hooks/useSales/helpers/index.js +0 -8
- package/src/hooks/useSales/index.js +0 -1102
- package/src/hooks/useSales/useGetSale.js +0 -13
- package/src/hooks/useSales/useTotalSales.js +0 -24
- package/src/hooks/useStore/index.js +0 -70
- package/src/hooks/useUpdateExtProductFoodsSubOptional/index.js +0 -38
- package/src/index.jsx +0 -4
- package/src/utils/index.js +0 -141
- /package/src/config/client/{index.js → index.ts} +0 -0
- /package/src/hooks/getCategoriesWithProduct/helpers/{index.js → index.ts} +0 -0
- /package/src/hooks/useAnimationFrame/{index.js → index.ts} +0 -0
- /package/src/hooks/useAsideCart/helpers/{index.js → index.ts} +0 -0
- /package/src/hooks/useAsideCart/{queries.js → queries.ts} +0 -0
- /package/src/hooks/useCart/{index.js → index.ts} +0 -0
- /package/src/hooks/useDeleteSubProductOptional/{queries.js → queries.ts} +0 -0
- /package/src/hooks/useDessert/helpers/{index.js → index.ts} +0 -0
- /package/src/hooks/useDynamicAuth/{queries.js → queries.ts} +0 -0
- /package/src/hooks/useEditSubProductOptional/{queries.js → queries.ts} +0 -0
- /package/src/hooks/useFetchJson/{index.js → index.ts} +0 -0
- /package/src/hooks/useFormatNumberPhone/{index.js → index.ts} +0 -0
- /package/src/hooks/useGenerateNumberArray/{index.js → index.ts} +0 -0
- /package/src/hooks/useGetFoodRecomended/{queries.js → queries.ts} +0 -0
- /package/src/hooks/useGetMinPrice/{queries.js → queries.ts} +0 -0
- /package/src/hooks/useGetOneStoreRating/{queries.js → queries.ts} +0 -0
- /package/src/hooks/useGoogleLogin/{loadScript.js → loadScript.ts} +0 -0
- /package/src/hooks/useGoogleLogin/{removeScript.js → removeScript.ts} +0 -0
- /package/src/hooks/useInnerHtml/{index.js → index.ts} +0 -0
- /package/src/hooks/useKeypress/{index.js → index.ts} +0 -0
- /package/src/hooks/useLocationNavigate/{index.js → index.ts} +0 -0
- /package/src/{security/index.js → hooks/useManageNewOrder/helpers/mock.ts} +0 -0
- /package/src/hooks/useMutateHeight/{index.js → index.ts} +0 -0
- /package/src/hooks/useOrderClient/{index.js → index.ts} +0 -0
- /package/src/hooks/useProviders/{index.js → index.ts} +0 -0
- /package/src/hooks/useProviders/{queries.js → queries.ts} +0 -0
- /package/src/hooks/useProvidersStore/{queries.js → queries.ts} +0 -0
- /package/src/hooks/useReactToPrint/{index.js → index.txt} +0 -0
- /package/src/hooks/useSaveAvailableProduct/{queries.js → queries.ts} +0 -0
- /package/src/hooks/useSchedule/{queries.js → queries.ts} +0 -0
- /package/src/hooks/useScroll/{index.js → index.ts} +0 -0
- /package/src/hooks/useScrollRotate/{index.js → index.ts} +0 -0
- /package/src/hooks/useSetState/{index.js → index.ts} +0 -0
- /package/src/hooks/useStatusOrdersClient/helpers/{index.js → index.ts} +0 -0
- /package/src/hooks/useStoreCalendar/{index.js → index.ts} +0 -0
- /package/src/hooks/useStoreContacts/{queries.js → queries.ts} +0 -0
- /package/src/mock/dessert/{index.js → index.ts} +0 -0
- /package/src/mock/{index.js → index.ts} +0 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Cookies } from '../../cookies'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Decodes a JWT safely without verifying signature.
|
|
5
|
+
* Use ONLY for reading payload data.
|
|
6
|
+
*
|
|
7
|
+
* @param {string} token - JWT string
|
|
8
|
+
* @returns {Record<string, any> | null}
|
|
9
|
+
*/
|
|
10
|
+
const decodeJwtPayload = (token: string): Record<string, any> | null => {
|
|
11
|
+
try {
|
|
12
|
+
const [, payload] = token.split('.')
|
|
13
|
+
if (!payload) return null
|
|
14
|
+
|
|
15
|
+
const decoded = Buffer.from(payload, 'base64').toString('utf-8')
|
|
16
|
+
return JSON.parse(decoded)
|
|
17
|
+
} catch {
|
|
18
|
+
return null
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Gets session data from cookie "session".
|
|
24
|
+
* Designed for Next.js 15 App Router (server-side).
|
|
25
|
+
*
|
|
26
|
+
* @returns {Promise<{
|
|
27
|
+
* isSession: boolean
|
|
28
|
+
* token?: string
|
|
29
|
+
* user?: Record<string, any>
|
|
30
|
+
* deviceid?: string
|
|
31
|
+
* error?: string
|
|
32
|
+
* }>}
|
|
33
|
+
*/
|
|
34
|
+
export const getSession = async () => {
|
|
35
|
+
try {
|
|
36
|
+
const token = Cookies.get('session')
|
|
37
|
+
return new Promise((resolve) => {
|
|
38
|
+
if (!token) {
|
|
39
|
+
resolve({ isSession: false })
|
|
40
|
+
return
|
|
41
|
+
}
|
|
42
|
+
const payload = decodeJwtPayload(token)
|
|
43
|
+
if (!payload) {
|
|
44
|
+
resolve({ isSession: false })
|
|
45
|
+
return
|
|
46
|
+
}
|
|
47
|
+
const { user, deviceid, exp } = payload
|
|
48
|
+
const currentTime = Math.floor(Date.now() / 1000)
|
|
49
|
+
if (exp && currentTime >= exp) {
|
|
50
|
+
resolve({ isSession: false })
|
|
51
|
+
return
|
|
52
|
+
}
|
|
53
|
+
resolve({
|
|
54
|
+
isSession: true,
|
|
55
|
+
token,
|
|
56
|
+
user,
|
|
57
|
+
deviceid
|
|
58
|
+
})
|
|
59
|
+
})
|
|
60
|
+
} catch (error) {
|
|
61
|
+
if (error instanceof Error) {
|
|
62
|
+
return {
|
|
63
|
+
isSession: false,
|
|
64
|
+
error: String(error.message)
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
isSession: false,
|
|
69
|
+
error: 'Unexpected session error'
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the start timestamp for the current day.
|
|
3
|
+
* @returns {string} The start timestamp for the current day.
|
|
4
|
+
*/
|
|
5
|
+
export const getStartOfDayTimestamp = () => {
|
|
6
|
+
const start = new Date()
|
|
7
|
+
start.setHours(0, 0, 0, 0)
|
|
8
|
+
return start.toISOString()
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Get the end timestamp for the current day.
|
|
13
|
+
* @returns {string} The end timestamp for the current day.
|
|
14
|
+
*/
|
|
15
|
+
export const getEndOfDayTimestamp = () => {
|
|
16
|
+
const end = new Date()
|
|
17
|
+
end.setHours(23, 59, 59, 999)
|
|
18
|
+
return end.toISOString()
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Get start and end timestamps for the current day.
|
|
23
|
+
* @returns {Object} An object containing start and end timestamps.
|
|
24
|
+
*/
|
|
25
|
+
export const getTodayTimestamps = () => {
|
|
26
|
+
return {
|
|
27
|
+
startTimestamp: getStartOfDayTimestamp(),
|
|
28
|
+
endTimestamp: getEndOfDayTimestamp()
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Get start timestamp for a specific number of days ago.
|
|
34
|
+
* @param {number} daysAgo - The number of days ago.
|
|
35
|
+
* @returns {string} The start timestamp for the specified number of days ago.
|
|
36
|
+
*/
|
|
37
|
+
export const getStartTimestampDaysAgo = (daysAgo) => {
|
|
38
|
+
if (isNaN(daysAgo) || daysAgo < 0) {
|
|
39
|
+
throw new Error('Invalid input. Provide a valid number of days.')
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const start = new Date()
|
|
43
|
+
start.setDate(start.getDate() - daysAgo)
|
|
44
|
+
start.setHours(0, 0, 0, 0)
|
|
45
|
+
|
|
46
|
+
return start.toISOString()
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
*
|
|
51
|
+
* @param root0
|
|
52
|
+
* @param root0.dateString
|
|
53
|
+
* @param root0.start
|
|
54
|
+
*/
|
|
55
|
+
export function convertDateFormat ({ dateString, start }) {
|
|
56
|
+
const parsedDate = dateString ? new Date(dateString) : new Date()
|
|
57
|
+
const year = parsedDate.getFullYear()
|
|
58
|
+
const month = `0${parsedDate.getMonth() + 1}`.slice(-2)
|
|
59
|
+
const day = `0${parsedDate.getDate()}`.slice(-2)
|
|
60
|
+
|
|
61
|
+
if (start) {
|
|
62
|
+
// Inicio del día (00:00:00)
|
|
63
|
+
return `${year}-${month}-${day}T00:00:00.000Z`
|
|
64
|
+
}
|
|
65
|
+
// Final del día (23:59:59.999)
|
|
66
|
+
const endOfDay = new Date(parsedDate)
|
|
67
|
+
endOfDay.setHours(23, 59, 59, 999)
|
|
68
|
+
return endOfDay.toISOString()
|
|
69
|
+
|
|
70
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schedule day structure
|
|
3
|
+
*/
|
|
4
|
+
export interface ScheduleDay {
|
|
5
|
+
schHoSta?: string
|
|
6
|
+
schHoEnd?: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Calculate total worked hours from a list of days.
|
|
11
|
+
* Keeps original behavior and edge cases intact.
|
|
12
|
+
*
|
|
13
|
+
* @param {ScheduleDay[]} days - Array of days with start and end times
|
|
14
|
+
* @returns {string} Total time formatted as HH:MM
|
|
15
|
+
*/
|
|
16
|
+
export const getTotalHours = (days: ScheduleDay[] = []): string => {
|
|
17
|
+
const totalMinutesArray: number[] = days.map((day) => {
|
|
18
|
+
const { schHoSta, schHoEnd } = day
|
|
19
|
+
|
|
20
|
+
// Handle potential invalid time strings
|
|
21
|
+
if (!isValidTimeString(schHoSta) || !isValidTimeString(schHoEnd)) {
|
|
22
|
+
return 0
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const [startHours, startMinutes] = schHoSta.split(':')
|
|
26
|
+
const [endHours, endMinutes] = schHoEnd.split(':')
|
|
27
|
+
|
|
28
|
+
// Convert hours and minutes to integers for calculations
|
|
29
|
+
let totalHoursInt =
|
|
30
|
+
parseInt(endHours, 10) - parseInt(startHours, 10)
|
|
31
|
+
|
|
32
|
+
const totalMinutesInt =
|
|
33
|
+
parseInt(endMinutes, 10) - parseInt(startMinutes, 10)
|
|
34
|
+
|
|
35
|
+
// Handle negative total minutes
|
|
36
|
+
let totalMinutes = totalMinutesInt
|
|
37
|
+
if (totalMinutes < 0) {
|
|
38
|
+
totalHoursInt--
|
|
39
|
+
totalMinutes += 60
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Calculate total time in minutes
|
|
43
|
+
return totalHoursInt * 60 + totalMinutes
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
// Sum all minutes
|
|
47
|
+
const totalMinutes: number = totalMinutesArray.reduce(
|
|
48
|
+
(acc, curr) => {return acc + curr},
|
|
49
|
+
0
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
// Convert to hours and minutes
|
|
53
|
+
const totalHours: number = Math.floor(totalMinutes / 60)
|
|
54
|
+
const remainingMinutes: number = totalMinutes % 60
|
|
55
|
+
|
|
56
|
+
// Format HH:MM
|
|
57
|
+
const formattedHours = totalHours.toString().padStart(2, '0')
|
|
58
|
+
const formattedMinutes = remainingMinutes.toString().padStart(2, '0')
|
|
59
|
+
|
|
60
|
+
return `${formattedHours}:${formattedMinutes}`
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Validate time string format (HH:MM)
|
|
65
|
+
*
|
|
66
|
+
* @param {string | undefined} timeString
|
|
67
|
+
* @returns {boolean}
|
|
68
|
+
*/
|
|
69
|
+
export const isValidTimeString = (
|
|
70
|
+
timeString?: string
|
|
71
|
+
): timeString is string => {
|
|
72
|
+
if (!timeString) return false
|
|
73
|
+
|
|
74
|
+
const timeRegex = /^([0-1][0-9]|2[0-3]):([0-5][0-9])$/
|
|
75
|
+
return timeRegex.test(timeString)
|
|
76
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param body
|
|
4
|
+
*/
|
|
5
|
+
export async function handleLogin (body) {
|
|
6
|
+
const response = await fetch(`${process.env.URL_BASE}/api/auth/login`, {
|
|
7
|
+
method: 'POST',
|
|
8
|
+
headers: { 'Content-Type': 'application/json' },
|
|
9
|
+
body: JSON.stringify(body),
|
|
10
|
+
credentials: 'include'
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
return response.json()
|
|
14
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
export * from './updateExtProductFoodsOptional'
|
|
2
|
+
export * from './useAcumulateDate'
|
|
3
|
+
export * from './useBanner'
|
|
4
|
+
export * from './useCategoryInStore'
|
|
5
|
+
export * from './useCategoryStore'
|
|
6
|
+
export * from './useCatWithProduct'
|
|
7
|
+
export * from './useManageQueryParams'
|
|
8
|
+
export * from './useDeliveryTime'
|
|
9
|
+
export * from './useModules'
|
|
10
|
+
export * from './getTotalHours'
|
|
11
|
+
export * from './useUpdateMultipleProducts'
|
|
12
|
+
export * from './useTokenCards'
|
|
13
|
+
export * from './useStoreTable/index'
|
|
14
|
+
export * from './useSubscriptionValidation'
|
|
15
|
+
export * from './convertToMilitaryTime'
|
|
16
|
+
export * from './useRoles'
|
|
17
|
+
export * from './useLocalBackendIp'
|
|
18
|
+
export * from './statusOpenStores'
|
|
19
|
+
export * from './completeSchedules'
|
|
20
|
+
export * from './useLogout/helpers/BroadcastChannel'
|
|
21
|
+
export * from './useLogout/helpers/index'
|
|
22
|
+
export * from './getCardType'
|
|
23
|
+
export * from './useLoginEmployeeInStore'
|
|
24
|
+
export * from './useUploadProducts'
|
|
25
|
+
export * from './useAmountInput'
|
|
26
|
+
export * from './useColorByLetters'
|
|
27
|
+
export * from './newMessageSubscription'
|
|
28
|
+
export * from './usePWAInstall'
|
|
29
|
+
export * from './useGetCookies'
|
|
30
|
+
export * from './generateTemplate'
|
|
31
|
+
export * from './isTokenExpired'
|
|
32
|
+
export * from './useCreateDeliveryTime'
|
|
33
|
+
export * from './addTenMinutes'
|
|
34
|
+
export * from './useUpdateCartCookie'
|
|
35
|
+
export * from './useCategoriesProduct'
|
|
36
|
+
export * from './useLogout'
|
|
37
|
+
export * from './useSetupSchedule'
|
|
38
|
+
export * from './useMouse'
|
|
39
|
+
export * from './useStatusOpenStore'
|
|
40
|
+
export * from './usePushNotificationOrder'
|
|
41
|
+
export * from './newStoreOrderSubscription'
|
|
42
|
+
export * from './useChatRoomSubscription'
|
|
43
|
+
export * from './useScheduleData'
|
|
44
|
+
export * from './useGetMessagesToRoom'
|
|
45
|
+
export * from './useOrders'
|
|
46
|
+
export * from './usePushNotifications'
|
|
47
|
+
export * from './useLocationManager'
|
|
48
|
+
export * from './useQueryLocationsMap'
|
|
49
|
+
export * from './useGetAllLocationUser'
|
|
50
|
+
export * from './useFingerprintjs'
|
|
51
|
+
export * from './useCountries'
|
|
52
|
+
export * from './useDessertWithPrice'
|
|
53
|
+
export * from './generateStoreURL'
|
|
54
|
+
export * from './useCreateStorePendingToRegister'
|
|
55
|
+
export * from './useDepartments'
|
|
56
|
+
export * from './useSaveLocation'
|
|
57
|
+
export * from './useRoads'
|
|
58
|
+
export * from './useCities'
|
|
59
|
+
export * from './useEditCategory'
|
|
60
|
+
export * from './useEmployee'
|
|
61
|
+
export * from './useEmployee/useCreateEmployee'
|
|
62
|
+
export * from './useCheckbox'
|
|
63
|
+
export * from './useRemoveExtraProductFoodsOptional'
|
|
64
|
+
export * from './useDeleteSubProductOptional'
|
|
65
|
+
export * from './useGetOneStoreRating'
|
|
66
|
+
export * from './useFavoriteStores'
|
|
67
|
+
export * from './useAsideCart'
|
|
68
|
+
export * from './useRatingArrayData'
|
|
69
|
+
export * from './useChartData'
|
|
70
|
+
export * from './useDevices'
|
|
71
|
+
export * from './useClients'
|
|
72
|
+
export * from './useScroll'
|
|
73
|
+
export * from './useStatusOrdersClient'
|
|
74
|
+
export * from './useUpdateExistingOrders'
|
|
75
|
+
export * from './useConnection'
|
|
76
|
+
export * from './useManageNewOrder'
|
|
77
|
+
export * from './useCreateProduct'
|
|
78
|
+
export * from './useCreateProduct/helpers/useEditImageProduct'
|
|
79
|
+
export * from './useDessert'
|
|
80
|
+
export * from './useDrag'
|
|
81
|
+
export * from './useEvent'
|
|
82
|
+
export * from './useFetchJson'
|
|
83
|
+
export * from './useFormatDate'
|
|
84
|
+
export * from './getTodayTimestamps'
|
|
85
|
+
export * from './useFormatNumberPhone'
|
|
86
|
+
export * from './useFormTools/index'
|
|
87
|
+
export * from './useHover'
|
|
88
|
+
export * from './useImageOptimization'
|
|
89
|
+
export * from './useImagesStore'
|
|
90
|
+
export * from './useImageWeight'
|
|
91
|
+
export * from './useIntersection'
|
|
92
|
+
export * from './useKeypress'
|
|
93
|
+
export * from './useLazyScript'
|
|
94
|
+
export * from './useLocalSorage'
|
|
95
|
+
export * from './useLocationNavigate'
|
|
96
|
+
export * from './useSetSession'
|
|
97
|
+
export * from './useMobile'
|
|
98
|
+
export * from './useMutateHeight'
|
|
99
|
+
export * from './useProductsFood'
|
|
100
|
+
export * from './useProductsFood/usetagsProducts'
|
|
101
|
+
// export * from './useReactToPrint'
|
|
102
|
+
export * from './useReport'
|
|
103
|
+
export * from './useSales/useTotalSales'
|
|
104
|
+
export * from './useOrderClient'
|
|
105
|
+
export * from './useStoreContacts'
|
|
106
|
+
export * from './useRestaurant'
|
|
107
|
+
export * from './useSales/index'
|
|
108
|
+
export * from './useSales/useGetSale'
|
|
109
|
+
export * from './useGetMinPrice'
|
|
110
|
+
export * from './useCatWithProductClient'
|
|
111
|
+
export * from './useGetFoodRecomended'
|
|
112
|
+
export * from './useSaveAvailableProduct'
|
|
113
|
+
export * from './useSchedule'
|
|
114
|
+
export * from './useSetState'
|
|
115
|
+
export * from './useStore'
|
|
116
|
+
export * from './useStoreCalendar'
|
|
117
|
+
export * from './getCategoriesWithProduct'
|
|
118
|
+
export * from './useIncomingOrders'
|
|
119
|
+
export * from './useTimeAgo/useTimeAgo'
|
|
120
|
+
export * from './useUpdateCart'
|
|
121
|
+
export * from './useUpdateExtProductFoodsSubOptional'
|
|
122
|
+
export * from './useUser'
|
|
123
|
+
export * from './useCart'
|
|
124
|
+
export * from './useGetStoreCookie'
|
|
125
|
+
export * from './getGlobalSession'
|
|
126
|
+
export * from './handleLogin'
|
|
127
|
+
export * from './useInventory'
|
|
128
|
+
export * from './useStockMovements'
|
|
129
|
+
export * from './useTopProductsMovements'
|
|
130
|
+
export * from './useTotalProductsSold'
|
|
131
|
+
export * from './useTotalProductsInStock/index'
|
|
132
|
+
export * from './useTotalAllSales/index'
|
|
133
|
+
export * from './useTotalProductsSolded'
|
|
134
|
+
export * from './useWeeklyStockMovement'
|
|
135
|
+
export * from './useSetImageProducts'
|
|
136
|
+
export * from './useGetSalesAmountToday'
|
|
137
|
+
export * from './useUpsertGoal'
|
|
138
|
+
export * from './useDashboardComponents'
|
|
139
|
+
export * from './useUpdateDashboardComponent'
|
|
140
|
+
export * from './useUpdateModuleOrder'
|
|
141
|
+
export * from './useDownloadReports'
|
|
142
|
+
export * from './usePortFetcher'
|
|
143
|
+
export * from './useImageUploaderProduct'
|
|
144
|
+
export * from './useTagProducts'
|
|
145
|
+
export * from './useOrderStatusTypes'
|
|
146
|
+
export * from './useCreateOrderStatusType'
|
|
147
|
+
export * from './useDevWS'
|
|
148
|
+
export * from './usePrintSaleTicket'
|
|
149
|
+
export * from './usePaymentMethod'
|
|
150
|
+
export * from './useGetAllSales'
|
|
151
|
+
export * from './useTheme'
|
|
152
|
+
export * from './useFilterConfigs'
|
|
153
|
+
export * from './useStock'
|
|
154
|
+
export * from './getSession'
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Verifica si un token JWT ha expirado.
|
|
3
|
+
* @param {string} token El token JWT a verificar.
|
|
4
|
+
* @param {string} [expField='exp'] El nombre del campo que contiene la fecha de expiración en el token.
|
|
5
|
+
* @returns {boolean} True si el token ha expirado, false de lo contrario.
|
|
6
|
+
*/
|
|
7
|
+
export const isTokenExpired = (token, expField = 'exp') => {
|
|
8
|
+
try {
|
|
9
|
+
const [, payloadBase64] = token.split('.')
|
|
10
|
+
const decodedJson = Buffer.from(payloadBase64, 'base64').toString()
|
|
11
|
+
const decoded = JSON.parse(decodedJson)
|
|
12
|
+
const exp = decoded[expField] * 1000 // Convertir segundos a milisegundos
|
|
13
|
+
return Date.now() >= exp
|
|
14
|
+
} catch (error) {
|
|
15
|
+
return true
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { useSubscription, gql } from '@apollo/client'
|
|
2
|
+
|
|
3
|
+
const NEW_MESSAGE_SUBSCRIPTION = gql`
|
|
4
|
+
subscription NewMessage($idStore: String!) {
|
|
5
|
+
newMessage(idStore: $idStore) {
|
|
6
|
+
uuid
|
|
7
|
+
content
|
|
8
|
+
aDatCre
|
|
9
|
+
from
|
|
10
|
+
to
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
`
|
|
14
|
+
|
|
15
|
+
export const newMessageSubscription = (idStore, onMessageReceived) => {
|
|
16
|
+
const subscription = useSubscription(NEW_MESSAGE_SUBSCRIPTION, {
|
|
17
|
+
variables: { idStore },
|
|
18
|
+
onSubscriptionData: ({ client, subscriptionData }) => {
|
|
19
|
+
if (subscriptionData.data && subscriptionData.data.newMessage) {
|
|
20
|
+
// Llama a la función proporcionada cuando se recibe un nuevo mensaje
|
|
21
|
+
onMessageReceived(subscriptionData.data.newMessage)
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
// Puedes ajustar lo que devuelve el hook según tus necesidades
|
|
27
|
+
return subscription
|
|
28
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useSubscription, gql } from '@apollo/client'
|
|
2
|
+
|
|
3
|
+
const NEW_STORE_ORDER_SUBSCRIPTION = gql`
|
|
4
|
+
subscription NewStoreOrder($idStore: String!) {
|
|
5
|
+
newStoreOrder(idStore: $idStore) {
|
|
6
|
+
id
|
|
7
|
+
idStore
|
|
8
|
+
pCodeRef
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
`
|
|
12
|
+
|
|
13
|
+
export const newStoreOrderSubscription = (idStore, onOrderReceived) => {
|
|
14
|
+
const subscription = useSubscription(NEW_STORE_ORDER_SUBSCRIPTION, {
|
|
15
|
+
variables: { idStore },
|
|
16
|
+
onSubscriptionData: ({ client, subscriptionData }) => {
|
|
17
|
+
if (subscriptionData.data && subscriptionData.data.newStoreOrder) {
|
|
18
|
+
// Llama a la función proporcionada cuando se recibe una nueva orden
|
|
19
|
+
onOrderReceived(subscriptionData.data.newStoreOrder)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
// Puedes ajustar lo que devuelve el hook según tus necesidades
|
|
25
|
+
return subscription
|
|
26
|
+
}
|
|
@@ -12,10 +12,17 @@ export const getDayFromOpeningKey = (key) => {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
// Función para convertir el objeto de tiempo en una cadena de tiempo
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
* @param timeStr
|
|
18
|
+
*/
|
|
15
19
|
export function getTimeString (timeStr) {
|
|
16
20
|
return timeStr || '00:00' // Return '00:00' for empty time strings
|
|
17
21
|
}
|
|
18
22
|
|
|
23
|
+
/**
|
|
24
|
+
*
|
|
25
|
+
*/
|
|
19
26
|
export function getCurrentDayAndTime () {
|
|
20
27
|
try {
|
|
21
28
|
const date = new Date()
|
|
@@ -29,18 +36,26 @@ export function getCurrentDayAndTime () {
|
|
|
29
36
|
}
|
|
30
37
|
}
|
|
31
38
|
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
* @param timeStr
|
|
42
|
+
*/
|
|
32
43
|
export function getTimeObject (timeStr) {
|
|
33
44
|
try {
|
|
34
45
|
if (!timeStr || !/\d{2}:\d{2}/.test(timeStr)) {
|
|
35
46
|
return { hours: 0, minutes: 0 } // Return default values for invalid input
|
|
36
47
|
}
|
|
37
|
-
const [hours, minutes] = timeStr.split(':').map(str => parseInt(str))
|
|
48
|
+
const [hours, minutes] = timeStr.split(':').map(str => {return parseInt(str)})
|
|
38
49
|
return { hours, minutes }
|
|
39
50
|
} catch (e) {
|
|
40
51
|
return { hours: 0, minutes: 0 } // Return default values on error
|
|
41
52
|
}
|
|
42
53
|
}
|
|
43
54
|
|
|
55
|
+
/**
|
|
56
|
+
*
|
|
57
|
+
* @param openings
|
|
58
|
+
*/
|
|
44
59
|
export function sortOpeningsByDay (openings) {
|
|
45
60
|
const days = [
|
|
46
61
|
'openingSun',
|
|
@@ -61,6 +76,10 @@ export function sortOpeningsByDay (openings) {
|
|
|
61
76
|
}
|
|
62
77
|
|
|
63
78
|
// Función para obtener la clave de openings a partir del día de la semana
|
|
79
|
+
/**
|
|
80
|
+
*
|
|
81
|
+
* @param day
|
|
82
|
+
*/
|
|
64
83
|
export function getOpeningKeyFromDay (day) {
|
|
65
84
|
const days = {
|
|
66
85
|
0: 'openingSun',
|
|
@@ -84,6 +103,10 @@ export const weekDays = [
|
|
|
84
103
|
'Sábado'
|
|
85
104
|
]
|
|
86
105
|
|
|
106
|
+
/**
|
|
107
|
+
*
|
|
108
|
+
* @param text
|
|
109
|
+
*/
|
|
87
110
|
export function timeToInt (text) {
|
|
88
111
|
const hour = parseInt(text.substring(0, 2))
|
|
89
112
|
const minute = parseInt(text.substring(3))
|