npm-pkg-hook 1.12.4 → 1.12.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +57529 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +57315 -0
- package/dist/index.mjs.map +1 -0
- package/eslint.config.mts +153 -0
- package/package.json +30 -45
- package/src/config/client/errors.ts +39 -0
- package/src/hooks/addTenMinutes/{index.js → index.ts} +4 -4
- package/src/hooks/calculateLogLatHaversine/{index.js → index.ts} +15 -4
- package/src/hooks/completeSchedules/{index.js → index.ts} +4 -4
- package/src/hooks/convertToMilitaryTime/index.ts +18 -0
- package/src/hooks/generateStoreURL/index.ts +41 -0
- package/src/hooks/generateTemplate/{index.js → index.ts} +15 -11
- package/src/hooks/getCardType/{index.js → index.ts} +1 -1
- 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.js → index.ts} +18 -12
- package/src/hooks/getTotalHours/index.ts +76 -0
- package/src/hooks/handleLogin/{index.js → index.ts} +4 -0
- package/src/hooks/index.ts +8 -2
- package/src/hooks/statusOpenStores/helpers/{index.js → index.ts} +24 -1
- package/src/hooks/statusOpenStores/index.ts +221 -0
- package/src/hooks/updateExtProductFoodsOptional/{index.js → index.ts} +12 -3
- package/src/hooks/useAcumulateDate/index.ts +18 -0
- package/src/hooks/useAllStoresPendingToRegister/{index.js → index.ts} +3 -0
- package/src/hooks/useAmountInput/index.ts +42 -32
- package/src/hooks/useAnimationText/{index.jsx → index.ts} +2 -2
- package/src/hooks/useAsideCart/{index.js → index.ts} +22 -19
- package/src/hooks/useBanner/{index.js → index.ts} +2 -1
- package/src/hooks/useCart/useCart/helpers/{index.js → index.ts} +10 -6
- package/src/hooks/useCart/useCart/{index.js → index.ts} +29 -17
- package/src/hooks/useCart/useGetCart/{index.js → index.ts} +2 -1
- package/src/hooks/useCatWithProduct/{index.js → index.ts} +11 -5
- package/src/hooks/useCatWithProduct/types/index.ts +104 -0
- package/src/hooks/useCatWithProductClient/{index.js → index.ts} +3 -2
- package/src/hooks/useCategoriesProduct/{index.js → index.ts} +2 -1
- package/src/hooks/useCategoryInStore/index.ts +167 -0
- package/src/hooks/useCategoryStore/{index.js → index.ts} +2 -1
- package/src/hooks/useCategoryStore/{queries.js → queries.ts} +2 -2
- package/src/hooks/useChartData/{index.js → index.ts} +9 -8
- package/src/hooks/useChartData/useChartData/{index.js → index.ts} +31 -30
- package/src/hooks/useChartData/useChartDataAllOrders/{index.js → index.ts} +2 -2
- package/src/hooks/useCheckbox/{index.js → index.ts} +1 -1
- package/src/hooks/useCities/{index.js → index.ts} +2 -1
- package/src/hooks/useClients/{index.js → index.ts} +2 -1
- package/src/hooks/useClients/{queries.js → queries.ts} +7 -4
- package/src/hooks/useColorByLetters/helpers/{alea.js → alea.ts} +19 -0
- package/src/hooks/useColorByLetters/helpers/{index.js → index.ts} +5 -1
- package/src/hooks/useColorByLetters/helpers/{mersenne_twister.js → mersenne_twister.ts} +1 -1
- package/src/hooks/useColorByLetters/{index.js → index.ts} +3 -6
- package/src/hooks/useConnection/{index.js → index.ts} +3 -3
- package/src/hooks/useCountries/{index.js → index.ts} +2 -1
- package/src/hooks/useCreateOrderStatusType/index.ts +8 -6
- package/src/hooks/useCreateProduct/helpers/{index.js → index.ts} +1 -1
- 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.js → index.ts} +22 -19
- package/src/hooks/useCreateStorePendingToRegister/{index.js → index.ts} +5 -1
- package/src/hooks/useDeleteExtraProductFoods/{index.js → index.ts} +2 -1
- package/src/hooks/useDeleteSubProductOptional/{index.js → index.ts} +5 -3
- package/src/hooks/useDeliveryTime/{index.js → index.ts} +3 -1
- package/src/hooks/useDepartments/{index.js → index.ts} +2 -1
- package/src/hooks/useDessert/{index.js → index.ts} +56 -52
- package/src/hooks/useDessertWithPrice/helpers/{index.js → index.ts} +4 -4
- package/src/hooks/useDessertWithPrice/{index.js → index.ts} +34 -26
- package/src/hooks/useDevWS/index.ts +43 -43
- package/src/hooks/useDevices/{useGetDevices.js → useGetDevices.ts} +3 -3
- package/src/hooks/useDevices/{useRegisterDevices.js → useRegisterDevices.ts} +5 -5
- package/src/hooks/useDownloadReports/helpers/downloadFileFromResponse.ts +17 -17
- package/src/hooks/useDownloadReports/useDownloadReportByDay/index.ts +4 -2
- package/src/hooks/useDownloadReports/useGetReportByDateRange/index.ts +3 -2
- 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} +5 -5
- 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.js → index.ts} +2 -1
- package/src/hooks/useEmployee/{queries.js → queries.ts} +1 -1
- package/src/hooks/useEmployee/{useCreateEmployee.js → useCreateEmployee.ts} +6 -2
- package/src/hooks/useFavoriteStores/{index.js → index.ts} +5 -3
- package/src/hooks/useFetchMoreInteractions/index.jsx +26 -26
- package/src/hooks/useFilterConfigs/index.ts +173 -0
- package/src/hooks/useFingerprintjs/{index.js → index.ts} +29 -4
- package/src/hooks/useFormTools/{index.js → index.ts} +38 -11
- package/src/hooks/useFormatDate/{index.js → index.ts} +10 -5
- package/src/hooks/useFullScreenMode/{index.js → index.ts} +1 -5
- package/src/hooks/useGetAllLocationUser/{index.js → index.ts} +2 -1
- package/src/hooks/useGetAllLocationUser/{queries.js → queries.ts} +2 -2
- package/src/hooks/{useSales/useGetAllSales/index.js → useGetAllSales/index.ts} +3 -2
- package/src/hooks/useGetExtProductFoodsSubOptionalAll/{index.js → index.ts} +2 -1
- package/src/hooks/useGetFoodRecomended/{index.js → index.ts} +2 -1
- package/src/hooks/useGetMinPrice/{index.js → index.ts} +2 -1
- package/src/hooks/useGetOneStoreRating/{index.js → index.ts} +2 -1
- package/src/hooks/useGetStoreCookie/{index.js → index.ts} +1 -1
- 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 +25 -9
- package/src/hooks/useImageUploaderProduct/helper/getOrientation.ts +5 -4
- package/src/hooks/useImageUploaderProduct/index.ts +227 -224
- package/src/hooks/useImageWeight/{index.js → index.ts} +4 -0
- package/src/hooks/useImagesStore/{index.js → index.ts} +7 -5
- package/src/hooks/useImagesStore/{queries.js → queries.ts} +1 -1
- package/src/hooks/useIncomingOrders/{index.js → index.ts} +2 -1
- package/src/hooks/useIncomingOrders/{queries.js → queries.ts} +1 -1
- package/src/hooks/useIntersection/{index.js → index.ts} +1 -1
- package/src/hooks/useInventory/{queries.js → queries.ts} +2 -2
- package/src/hooks/useInventory/{useGetProductsInStock.js → useGetProductsInStock.ts} +2 -1
- package/src/hooks/useLazyScript/{index.js → index.ts} +3 -0
- package/src/hooks/useLocalSorage/{index.js → index.ts} +3 -3
- package/src/hooks/useLocationManager/{index.js → index.ts} +3 -3
- package/src/hooks/useLoginEmployeeInStore/{index.js → index.ts} +1 -1
- package/src/hooks/useLogout/helpers/BroadcastChannel.ts +74 -0
- package/src/hooks/useLogout/helpers/{apiBaseUrl.js → apiBaseUrl.ts} +4 -0
- package/src/hooks/useLogout/helpers/{fetchData.js → fetchData.ts} +10 -1
- package/src/hooks/useLogout/helpers/{getCsrfToken.js → getCsrfToken.ts} +8 -1
- package/src/hooks/useLogout/helpers/{index.js → index.ts} +14 -6
- package/src/hooks/useLogout/helpers/{logger.js → logger.ts} +26 -8
- package/src/hooks/useLogout/helpers/{parseUrl.js → parseUrl.ts} +5 -2
- package/src/hooks/useLogout/{index.js → index.ts} +29 -20
- package/src/hooks/useManageNewOrder/helpers/{index.js → index.ts} +1 -1
- package/src/hooks/useManageNewOrder/{index.js → index.ts} +6 -4
- package/src/hooks/useManageQueryParams/index.ts +120 -0
- package/src/hooks/useModules/helpers/{validateModules.js → validateModules.ts} +1 -1
- package/src/hooks/useModules/index.ts +124 -0
- package/src/hooks/useMouse/index.ts +23 -18
- package/src/hooks/useOrderStatusTypes/useOrderStatusTypes/index.ts +1 -1
- package/src/hooks/useOrderStatusTypes/useUpdateOrderStatusPriorities/index.ts +7 -5
- package/src/hooks/useOrders/{queries.js → queries.ts} +30 -20
- package/src/hooks/useOrders/useChangeOrderState/index.ts +79 -76
- package/src/hooks/useOrders/useOrdersFromStore/index.ts +4 -3
- 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/usePrintSaleTicket/index.ts +4 -0
- package/src/hooks/useProductsFood/{index.js → index.ts} +115 -27
- package/src/hooks/useProductsFood/{queriesStore.js → queriesStore.ts} +1 -1
- package/src/hooks/useProductsFood/{useEditProduct.js → useEditProduct.ts} +2 -1
- package/src/hooks/useProductsFood/{usetagsProducts.js → usetagsProducts.ts} +6 -3
- 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.js → index.ts} +1 -1
- package/src/hooks/usePushNotifications/helpers/{index.js → index.ts} +9 -0
- package/src/hooks/usePushNotifications/{index.js → index.ts} +2 -1
- package/src/hooks/useQueryLocationsMap/{index.js → index.ts} +2 -1
- package/src/hooks/useRatingArrayData/{index.js → index.ts} +4 -4
- package/src/hooks/useRatingArrayData/{queries.js → queries.ts} +1 -1
- package/src/hooks/useRemoveExtraProductFoodsOptional/{index.js → index.ts} +2 -1
- package/src/hooks/useReport/{index.js → index.ts} +2 -1
- package/src/hooks/useReport/{queries.js → queries.ts} +2 -53
- package/src/hooks/useRestaurant/helpers/{index.js → index.ts} +4 -0
- package/src/hooks/useRestaurant/helpers/{manageStatusOpen.js → manageStatusOpen.ts} +1 -1
- package/src/hooks/useRestaurant/{index.js → index.ts} +5 -3
- package/src/hooks/useRoads/{index.js → index.ts} +2 -1
- package/src/hooks/useRoles/{queries.js → queries.ts} +1 -1
- package/src/hooks/useRoles/{useCreateRole.js → useCreateRole.ts} +4 -1
- package/src/hooks/useRoles/{useGetRoles.js → useGetRoles.ts} +2 -1
- 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.js → index.ts} +559 -522
- package/src/hooks/useSales/{queries.js → queries.ts} +187 -79
- 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.js → useGetSale.ts} +10 -2
- package/src/hooks/useSales/{useTotalSales.js → useTotalSales.ts} +2 -1
- package/src/hooks/useSaveAvailableProduct/helpers/{index.js → index.ts} +4 -4
- package/src/hooks/useSaveAvailableProduct/{index.js → index.ts} +2 -1
- package/src/hooks/useSaveLocation/{index.js → index.ts} +2 -1
- package/src/hooks/useSaveLocation/{queries.js → queries.ts} +1 -1
- package/src/hooks/useSchedule/{index.jsx → index.ts} +14 -1
- package/src/hooks/useSchedule/{index.js → schedule.ts} +2 -1
- package/src/hooks/useScheduleData/{index.js → index.ts} +21 -9
- package/src/hooks/useSetImageProducts/{index.js → index.ts} +4 -2
- package/src/hooks/useSetupSchedule/{index.js → index.ts} +40 -28
- package/src/hooks/useStatusOpenStore/helpers/{index.js → index.ts} +24 -1
- package/src/hooks/useStatusOpenStore/{index.js → index.ts} +30 -14
- 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.js → index.ts} +1 -1
- package/src/hooks/useStockMovements/{index.js → index.ts} +4 -3
- package/src/hooks/useStore/{index.js → index.ts} +30 -27
- package/src/hooks/useStoreContacts/{index.js → index.ts} +11 -5
- package/src/hooks/useStoreTable/{useStoreTableCreate.js → useStoreTableCreate.ts} +3 -2
- package/src/hooks/useStoreTable/{useStoreTables.js → useStoreTables.ts} +2 -1
- package/src/hooks/useSubscriptionValidation/index.ts +112 -0
- package/src/hooks/useTagProducts/useDeleteOneTag.ts +66 -66
- package/src/hooks/useTagProducts/useGetAllTags.ts +2 -2
- package/src/hooks/useTagProducts/useRegisterMultipleTags.ts +27 -26
- package/src/hooks/useTheme/index.ts +65 -0
- package/src/hooks/useTimeAgo/{useTimeAgo.js → useTimeAgo.ts} +7 -7
- package/src/hooks/useTokenCards/{index.js → index.ts} +7 -3
- package/src/hooks/useUpdateCart/{index.js → index.ts} +3 -2
- package/src/hooks/useUpdateCartCookie/{index.js → index.ts} +23 -6
- package/src/hooks/useUpdateDashboardComponent/index.ts +11 -11
- package/src/hooks/useUpdateExtProductFoodsSubOptional/{index.js → index.ts} +2 -1
- package/src/hooks/useUpdateModuleOrder/{index.js → index.ts} +2 -2
- package/src/hooks/useUpdateMultipleExtProduct/{index.js → index.ts} +2 -1
- package/src/hooks/useUpdateMultipleProducts/{index.js → index.ts} +57 -20
- package/src/hooks/useUploadProducts/helpers/{parseNumber.js → parseNumber.ts} +3 -3
- package/src/hooks/useUploadProducts/{index.js → index.ts} +89 -69
- package/src/hooks/useUpsertGoal/{index.js → index.ts} +1 -1
- package/src/hooks/useUser/{index.js → index.ts} +5 -4
- package/src/hooks/useWeeklyStockMovement/helpers/{index.js → index.ts} +3 -3
- package/src/hooks/useWeeklyStockMovement/{index.js → index.ts} +4 -3
- package/src/hooks/useWindowSize/{index.js → index.ts} +9 -2
- package/src/index.ts +13 -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/{index.js → utils.ts} +69 -31
- package/tsconfig.eslint.json +16 -0
- package/tsconfig.json +18 -2
- package/tsup.config.ts +24 -0
- package/.eslintrc.js +0 -38
- package/.eslintrc.json +0 -127
- package/src/config/client/errors.js +0 -26
- package/src/hooks/convertToMilitaryTime/index.js +0 -14
- package/src/hooks/generateStoreURL/index.js +0 -38
- package/src/hooks/getGlobalSession/index.js +0 -49
- package/src/hooks/getSession/index.js +0 -18
- package/src/hooks/getTotalHours/index.js +0 -48
- package/src/hooks/statusOpenStores/index.js +0 -156
- package/src/hooks/useAcumulateDate/index.js +0 -16
- package/src/hooks/useCategoryInStore/index.js +0 -100
- package/src/hooks/useEditOneExtProductFoodOptional/index.js +0 -28
- package/src/hooks/useEditSubProductOptional/index.js +0 -11
- package/src/hooks/useLogout/helpers/BroadcastChannel.js +0 -31
- package/src/hooks/useManageQueryParams/index.js +0 -40
- package/src/hooks/useModules/index.js +0 -58
- package/src/hooks/useSales/helpers/index.js +0 -55
- package/src/hooks/useSubscriptionValidation/index.js +0 -41
- package/src/index.jsx +0 -9
- package/src/security/index.js +0 -1
- package/src/utils/UtilDateRange.js +0 -31
- /package/src/config/client/{index.js → index.ts} +0 -0
- /package/src/config/content/{index.js → index.ts} +0 -0
- /package/src/cookies/{index.js → index.ts} +0 -0
- /package/src/hooks/getCategoriesWithProduct/helpers/{index.js → index.ts} +0 -0
- /package/src/hooks/isTokenExpired/{index.js → index.ts} +0 -0
- /package/src/hooks/newMessageSubscription/{index.js → index.ts} +0 -0
- /package/src/hooks/newStoreOrderSubscription/{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/useCart/{queries.js → queries.ts} +0 -0
- /package/src/hooks/useCatWithProduct/{queries.js → queries.ts} +0 -0
- /package/src/hooks/useCatWithProductClient/{queries.js → queries.ts} +0 -0
- /package/src/hooks/useCategoriesProduct/{queries.js → queries.ts} +0 -0
- /package/src/hooks/useCategoryInStore/{queries.js → queries.ts} +0 -0
- /package/src/hooks/useChatRoomSubscription/{index.js → index.ts} +0 -0
- /package/src/hooks/useCities/{queries.js → queries.ts} +0 -0
- /package/src/hooks/useColorByLetters/helpers/{colors.js → colors.ts} +0 -0
- /package/src/hooks/useCountries/{queries.js → queries.ts} +0 -0
- /package/src/hooks/useCreateDeliveryTime/{index.js → index.ts} +0 -0
- /package/src/hooks/useCreateStorePendingToRegister/{queries.js → queries.ts} +0 -0
- /package/src/hooks/useDashboardComponents/{index.js → index.ts} +0 -0
- /package/src/hooks/useDeleteSubProductOptional/{queries.js → queries.ts} +0 -0
- /package/src/hooks/useDepartments/{queries.js → queries.ts} +0 -0
- /package/src/hooks/useDessert/helpers/{index.js → index.ts} +0 -0
- /package/src/hooks/useDessertWithPrice/{queries.js → queries.ts} +0 -0
- /package/src/hooks/useDevices/{index.js → index.ts} +0 -0
- /package/src/hooks/useDevices/{queries.js → queries.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/useEvent/{index.js → index.ts} +0 -0
- /package/src/hooks/useFavoriteStores/{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/useGetCookies/{index.js → index.ts} +0 -0
- /package/src/hooks/useGetFoodRecomended/{queries.js → queries.ts} +0 -0
- /package/src/hooks/useGetMessagesToRoom/{index.js → index.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/useGetSalesAmountToday/{index.js → index.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/useImagesStore/utils/{index.js → index.ts} +0 -0
- /package/src/hooks/useInnerHtml/{index.js → index.ts} +0 -0
- /package/src/hooks/useInventory/{index.js → index.ts} +0 -0
- /package/src/hooks/useInventory/{useUpdateManageStock.js → useUpdateManageStock.ts} +0 -0
- /package/src/hooks/useKeypress/{index.js → index.ts} +0 -0
- /package/src/hooks/useLocalBackendIp/{index.js → index.ts} +0 -0
- /package/src/hooks/useLocationNavigate/{index.js → index.ts} +0 -0
- /package/src/hooks/useManageNewOrder/helpers/{mock.js → mock.ts} +0 -0
- /package/src/hooks/useMobile/{index.js → index.ts} +0 -0
- /package/src/hooks/useModules/helpers/{index.js → index.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/useOrders/{index.js → index.ts} +0 -0
- /package/src/hooks/usePWAInstall/{index.js → index.ts} +0 -0
- /package/src/{services/index.js → hooks/useProductsFood/types/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/useQueryLocationsMap/{queries.js → queries.ts} +0 -0
- /package/src/hooks/useReactToPrint/{index.js → index.txt} +0 -0
- /package/src/hooks/useRemoveExtraProductFoodsOptional/{queries.js → queries.ts} +0 -0
- /package/src/hooks/useRestaurant/{queries.js → queries.ts} +0 -0
- /package/src/hooks/useRoads/{queries.js → queries.ts} +0 -0
- /package/src/hooks/useRoles/{index.js → index.ts} +0 -0
- /package/src/hooks/useRoles/{useRemoveRoles.js → useRemoveRoles.ts} +0 -0
- /package/src/hooks/useRoles/{useUpdateRolesPriority.js → useUpdateRolesPriority.ts} +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/useSetImageProducts/{queries.js → queries.ts} +0 -0
- /package/src/hooks/useSetSession/{index.js → index.ts} +0 -0
- /package/src/hooks/useSetState/{index.js → index.ts} +0 -0
- /package/src/hooks/useSetupSchedule/helpers/{index.js → index.ts} +0 -0
- /package/src/hooks/useStatusOrdersClient/helpers/{index.js → index.ts} +0 -0
- /package/src/hooks/useStore/{queries.js → queries.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/hooks/useStoreTable/{index.js → index.ts} +0 -0
- /package/src/hooks/useStoreTable/{queries.js → queries.ts} +0 -0
- /package/src/hooks/useTopProductsMovements/{index.js → index.ts} +0 -0
- /package/src/hooks/useTotalAllSales/{index.js → index.ts} +0 -0
- /package/src/hooks/useTotalProductsInStock/{index.js → index.ts} +0 -0
- /package/src/hooks/useTotalProductsSold/{index.js → index.ts} +0 -0
- /package/src/hooks/useTotalProductsSolded/{index.js → index.ts} +0 -0
- /package/src/hooks/useUpdateExistingOrders/{index.js → index.ts} +0 -0
- /package/src/hooks/useUpdateMultipleExtProduct/{queries.js → queries.ts} +0 -0
- /package/src/hooks/useUpdateMultipleProducts/{queries.js → queries.ts} +0 -0
- /package/src/hooks/useUploadProducts/helpers/{index.js → index.ts} +0 -0
- /package/src/hooks/useUploadProducts/helpers/{validateProductDataExcel.js → validateProductDataExcel.ts} +0 -0
- /package/src/hooks/useUser/{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
|
@@ -1,11 +1,39 @@
|
|
|
1
|
-
import { useMutation } from '@apollo/client'
|
|
2
|
-
|
|
1
|
+
import { useMutation } from '@apollo/client'
|
|
2
|
+
|
|
3
3
|
import { CATEGORY_EMPTY } from '../../utils/index'
|
|
4
|
-
import { useCategoriesProduct } from '../useCategoriesProduct'
|
|
4
|
+
import { useCategoriesProduct } from '../useCategoriesProduct'
|
|
5
|
+
|
|
6
|
+
import { UPDATE_MULTIPLE_PRODUCTS } from './queries'
|
|
7
|
+
|
|
8
|
+
interface UpdateMultipleProductsProps {
|
|
9
|
+
sendNotification?: (notification: Notification) => void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface Product {
|
|
13
|
+
PRECIO_AL_PUBLICO: number;
|
|
14
|
+
DESCRIPCION: string;
|
|
15
|
+
NOMBRE: string;
|
|
16
|
+
pCode: string;
|
|
17
|
+
CANTIDAD?: number;
|
|
18
|
+
'IMPUESTO (%)': number;
|
|
19
|
+
CODIGO_DE_BARRAS: string | null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface Notification {
|
|
23
|
+
backgroundColor: string;
|
|
24
|
+
description: string;
|
|
25
|
+
title: string;
|
|
26
|
+
}
|
|
5
27
|
|
|
6
28
|
export const useUpdateMultipleProducts = ({
|
|
7
|
-
sendNotification = () => {
|
|
8
|
-
})
|
|
29
|
+
sendNotification = () => {}
|
|
30
|
+
}: UpdateMultipleProductsProps): {
|
|
31
|
+
updateProducts: (products: Product[]) => Promise<any[]>;
|
|
32
|
+
data: any;
|
|
33
|
+
loading: boolean;
|
|
34
|
+
error: any;
|
|
35
|
+
} => {
|
|
36
|
+
|
|
9
37
|
const [updateMultipleProducts, {
|
|
10
38
|
data,
|
|
11
39
|
loading,
|
|
@@ -13,8 +41,11 @@ export const useUpdateMultipleProducts = ({
|
|
|
13
41
|
}] = useMutation(UPDATE_MULTIPLE_PRODUCTS)
|
|
14
42
|
|
|
15
43
|
const [dataCategoriesProducts] = useCategoriesProduct()
|
|
16
|
-
|
|
17
|
-
const
|
|
44
|
+
|
|
45
|
+
const findEmptyCategory = dataCategoriesProducts?.find(({ pName }: { pName: string }) => {return pName === CATEGORY_EMPTY})
|
|
46
|
+
|
|
47
|
+
const updateProducts = async (products: Product[]): Promise<any[]> => {
|
|
48
|
+
|
|
18
49
|
const newProducts = products.map(product => {
|
|
19
50
|
const {
|
|
20
51
|
PRECIO_AL_PUBLICO: ProPrice,
|
|
@@ -25,6 +56,7 @@ export const useUpdateMultipleProducts = ({
|
|
|
25
56
|
'IMPUESTO (%)': vat,
|
|
26
57
|
CODIGO_DE_BARRAS: ProBarCode
|
|
27
58
|
} = product
|
|
59
|
+
|
|
28
60
|
return {
|
|
29
61
|
idStore: '',
|
|
30
62
|
ProPrice,
|
|
@@ -46,35 +78,40 @@ export const useUpdateMultipleProducts = ({
|
|
|
46
78
|
ProOutstanding: 0,
|
|
47
79
|
ProDelivery: 0
|
|
48
80
|
}
|
|
49
|
-
}
|
|
50
|
-
|
|
81
|
+
})
|
|
82
|
+
|
|
51
83
|
try {
|
|
52
84
|
const response = await updateMultipleProducts({ variables: { input: newProducts } })
|
|
53
|
-
|
|
85
|
+
|
|
54
86
|
for (const { errors } of response.data.updateMultipleProducts) {
|
|
87
|
+
|
|
55
88
|
if (errors) {
|
|
56
89
|
sendNotification({
|
|
57
|
-
backgroundColor:
|
|
58
|
-
description: errors[0].message,
|
|
59
|
-
title: 'Error'
|
|
90
|
+
backgroundColor:'error',
|
|
91
|
+
description : errors[0].message ,
|
|
92
|
+
title : 'Error'
|
|
60
93
|
})
|
|
61
94
|
}
|
|
62
95
|
}
|
|
96
|
+
|
|
63
97
|
return response.data.updateMultipleProducts
|
|
98
|
+
|
|
64
99
|
} catch (e) {
|
|
65
100
|
sendNotification({
|
|
66
|
-
backgroundColor:
|
|
67
|
-
description:
|
|
68
|
-
title:
|
|
101
|
+
backgroundColor:'error',
|
|
102
|
+
description :'Ocurrió un error al actualizar los productos',
|
|
103
|
+
title :'Error'
|
|
69
104
|
})
|
|
105
|
+
|
|
70
106
|
return []
|
|
71
107
|
}
|
|
108
|
+
|
|
72
109
|
}
|
|
73
110
|
|
|
74
111
|
return {
|
|
75
|
-
updateProducts,
|
|
76
|
-
data,
|
|
77
|
-
loading,
|
|
112
|
+
updateProducts,
|
|
113
|
+
data,
|
|
114
|
+
loading,
|
|
78
115
|
error
|
|
79
116
|
}
|
|
80
|
-
}
|
|
117
|
+
}
|
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
* @returns {string} Parsed number as a string in the format "1500.00".
|
|
5
5
|
* @throws Will throw an error if the input is not a valid formatted number.
|
|
6
6
|
*/
|
|
7
|
-
export const parseNumber = (value) => {
|
|
7
|
+
export const parseNumber = (value: string | number) => {
|
|
8
8
|
// Convert value to string if it's a number
|
|
9
9
|
const stringValue = typeof value === 'number' ? value.toString() : value
|
|
10
10
|
|
|
11
11
|
if (typeof stringValue !== 'string') {
|
|
12
|
-
throw new
|
|
12
|
+
throw new TypeError('Input must be a string or number')
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
// Remove thousands separators and adjust decimal separator
|
|
@@ -20,7 +20,7 @@ export const parseNumber = (value) => {
|
|
|
20
20
|
// Parse the sanitized value as a float
|
|
21
21
|
const parsedNumber = parseFloat(sanitizedValue)
|
|
22
22
|
if (isNaN(parsedNumber)) {
|
|
23
|
-
throw new
|
|
23
|
+
throw new TypeError('Invalid number format')
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
// Format the number with two decimal places
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { useState } from 'react'
|
|
2
2
|
import * as XLSX from 'xlsx'
|
|
3
|
+
|
|
3
4
|
import { RandomCode } from '../../utils'
|
|
5
|
+
|
|
4
6
|
import { validateProductDataExcel } from './helpers/validateProductDataExcel'
|
|
5
7
|
|
|
6
8
|
const STEPS = {
|
|
@@ -8,23 +10,31 @@ const STEPS = {
|
|
|
8
10
|
UPLOAD_PRODUCTS: 1
|
|
9
11
|
}
|
|
10
12
|
|
|
13
|
+
interface UseUploadProductsProps {
|
|
14
|
+
sendNotification?: (notification: {
|
|
15
|
+
title: string
|
|
16
|
+
description: string
|
|
17
|
+
backgroundColor: 'success' | 'error' | 'info' | 'warning'
|
|
18
|
+
}) => void
|
|
19
|
+
}
|
|
11
20
|
export const useUploadProducts = ({
|
|
12
21
|
sendNotification = () => { return null }
|
|
13
|
-
}
|
|
14
|
-
sendNotification: () => { return null }
|
|
15
|
-
}) => {
|
|
22
|
+
}: UseUploadProductsProps) => {
|
|
16
23
|
const [data, setData] = useState([])
|
|
17
24
|
const [isLoading, setIsLoading] = useState(false)
|
|
18
25
|
const [active, setActive] = useState(STEPS.UPLOAD_FILE)
|
|
19
26
|
const [overActive, setOverActive] = useState(STEPS.UPLOAD_FILE)
|
|
20
27
|
|
|
21
|
-
const handleOverActive = (index) => {
|
|
28
|
+
const handleOverActive = (index: number) => {
|
|
22
29
|
setOverActive(index)
|
|
23
30
|
}
|
|
24
|
-
const readExcelFile = (file) => {
|
|
31
|
+
const readExcelFile = (file: File) => {
|
|
25
32
|
return new Promise((resolve, reject) => {
|
|
26
33
|
const reader = new FileReader()
|
|
27
34
|
reader.onload = (e) => {
|
|
35
|
+
if (!e.target || !(e.target.result instanceof ArrayBuffer)) {
|
|
36
|
+
return reject(new Error('Failed to read file as ArrayBuffer.'))
|
|
37
|
+
}
|
|
28
38
|
const data = new Uint8Array(e.target.result)
|
|
29
39
|
const workbook = XLSX.read(data, { type: 'array' })
|
|
30
40
|
const sheetName = workbook.SheetNames[0]
|
|
@@ -32,29 +42,31 @@ export const useUploadProducts = ({
|
|
|
32
42
|
const json = XLSX.utils.sheet_to_json(worksheet)
|
|
33
43
|
resolve(json)
|
|
34
44
|
}
|
|
35
|
-
reader.onerror = (error) => reject(error)
|
|
45
|
+
reader.onerror = (error) => {return reject(error)}
|
|
36
46
|
reader.readAsArrayBuffer(file)
|
|
37
47
|
})
|
|
38
48
|
}
|
|
39
49
|
|
|
40
|
-
const onChangeFiles = async (files) => {
|
|
50
|
+
const onChangeFiles = async (files: FileList) => {
|
|
41
51
|
setIsLoading(true) // Activa el loader al inicio
|
|
42
52
|
try {
|
|
43
|
-
const filePromises = Array.from(files).map(file => readExcelFile(file))
|
|
53
|
+
const filePromises = Array.from(files).map(file => {return readExcelFile(file)})
|
|
44
54
|
const newData = await Promise.all(filePromises)
|
|
45
55
|
|
|
46
56
|
const newProducts = newData.flat().map((product, index) => {
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
const
|
|
57
|
+
// Assert product as a record to access its properties
|
|
58
|
+
const prod = product as Record<string, any>
|
|
59
|
+
const PRECIO_AL_PUBLICO = Number.isNaN(prod.PRECIO_AL_PUBLICO) ? 0 : prod.PRECIO_AL_PUBLICO
|
|
60
|
+
const VALOR_DE_COMPRA = Number.isNaN(prod.VALOR_DE_COMPRA) ? 0 : prod.VALOR_DE_COMPRA
|
|
61
|
+
const validationErrors = validateProductDataExcel(prod, index)
|
|
50
62
|
|
|
51
63
|
const code = RandomCode(9)
|
|
52
64
|
return {
|
|
53
|
-
...
|
|
54
|
-
CANTIDAD: isNaN(
|
|
55
|
-
ORIGINAL_CANTIDAD: isNaN(
|
|
65
|
+
...prod,
|
|
66
|
+
CANTIDAD: Number.isNaN(prod.CANTIDAD) ? 1 : prod.CANTIDAD,
|
|
67
|
+
ORIGINAL_CANTIDAD: Number.isNaN(prod.CANTIDAD) ? 1 : prod.CANTIDAD,
|
|
56
68
|
free: false,
|
|
57
|
-
product:
|
|
69
|
+
product: prod?.DESCRIPCION,
|
|
58
70
|
pCode: code,
|
|
59
71
|
editing: false,
|
|
60
72
|
PRECIO_AL_PUBLICO,
|
|
@@ -95,12 +107,20 @@ export const useUploadProducts = ({
|
|
|
95
107
|
const remainingSlots = 100 - currentLength
|
|
96
108
|
const productsToAdd = newProducts.slice(0, remainingSlots)
|
|
97
109
|
return [...prevData, ...productsToAdd]
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
110
|
+
}
|
|
111
|
+
// Agregar todos los nuevos productos si no se excede el límite
|
|
112
|
+
return [...prevData, ...newProducts]
|
|
113
|
+
|
|
102
114
|
})
|
|
103
115
|
} catch (error) {
|
|
116
|
+
if (error instanceof Error) {
|
|
117
|
+
sendNotification({
|
|
118
|
+
description: error.message,
|
|
119
|
+
title: 'Error',
|
|
120
|
+
backgroundColor: 'error'
|
|
121
|
+
})
|
|
122
|
+
return
|
|
123
|
+
}
|
|
104
124
|
sendNotification({
|
|
105
125
|
description: 'Un error ha ocurrido mientras se cargaba el archivo de productos.',
|
|
106
126
|
title: 'Error',
|
|
@@ -157,12 +177,12 @@ export const useUploadProducts = ({
|
|
|
157
177
|
setData(newData)
|
|
158
178
|
}
|
|
159
179
|
/**
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
const handleCheckFree = (productIndex) => {
|
|
180
|
+
* Toggle the 'free' status of a specific product in the data array.
|
|
181
|
+
* Performs validation to ensure the product index is valid.
|
|
182
|
+
*
|
|
183
|
+
* @param {number} productIndex - The index of the product to update.
|
|
184
|
+
*/
|
|
185
|
+
const handleCheckFree = (productIndex: number) => {
|
|
166
186
|
setData((prevData) => {
|
|
167
187
|
// Validar que el índice es un número válido
|
|
168
188
|
if (typeof productIndex !== 'number' || productIndex < 0 || productIndex >= prevData.length) {
|
|
@@ -186,14 +206,14 @@ export const useUploadProducts = ({
|
|
|
186
206
|
|
|
187
207
|
// Crear una nueva copia de los datos actualizando solo el producto específico
|
|
188
208
|
return prevData.map((product, index) =>
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
209
|
+
{return index === productIndex
|
|
210
|
+
? {
|
|
211
|
+
...product,
|
|
212
|
+
free: updatedFreeStatus,
|
|
213
|
+
PRECIO_AL_PUBLICO: updatedFreeStatus ? 0 : product.oldPrice,
|
|
214
|
+
oldPrice: product.PRECIO_AL_PUBLICO
|
|
215
|
+
}
|
|
216
|
+
: product}
|
|
197
217
|
)
|
|
198
218
|
})
|
|
199
219
|
}
|
|
@@ -202,11 +222,11 @@ export const useUploadProducts = ({
|
|
|
202
222
|
setActive(STEPS.UPLOAD_FILE)
|
|
203
223
|
}
|
|
204
224
|
/**
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
225
|
+
* Toggle the 'editing' status of a specific product in the data array.
|
|
226
|
+
* Validates the product index and only updates if necessary.
|
|
227
|
+
*
|
|
228
|
+
* @param {number} productIndex - The index of the product to update.
|
|
229
|
+
*/
|
|
210
230
|
const handleToggleEditingStatus = (productIndex) => {
|
|
211
231
|
setData((prevData) => {
|
|
212
232
|
// Validar que el índice es un número válido
|
|
@@ -245,9 +265,9 @@ export const useUploadProducts = ({
|
|
|
245
265
|
return prevData.map((product, index) => {
|
|
246
266
|
return index === productIndex
|
|
247
267
|
? {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
268
|
+
...product,
|
|
269
|
+
editing: updatedEditingStatus
|
|
270
|
+
}
|
|
251
271
|
: product
|
|
252
272
|
}
|
|
253
273
|
)
|
|
@@ -276,13 +296,13 @@ export const useUploadProducts = ({
|
|
|
276
296
|
|
|
277
297
|
// Crear una copia actualizada de prevData donde se actualiza `CANTIDAD` si es necesario
|
|
278
298
|
const updatedData = prevData.map((product, index) =>
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
299
|
+
{return index === productIndex
|
|
300
|
+
? { ...product, editing: false, ORIGINAL_CANTIDAD: product.CANTIDAD } // Actualización o cambio de estado
|
|
301
|
+
: product}
|
|
282
302
|
)
|
|
283
303
|
|
|
284
304
|
// Filtrar productos con CANTIDAD mayor a 0
|
|
285
|
-
const filteredData = updatedData.filter(product => product.CANTIDAD > 0)
|
|
305
|
+
const filteredData = updatedData.filter(product => {return product.CANTIDAD > 0})
|
|
286
306
|
|
|
287
307
|
// Cambiar el estado a `STEPS.UPLOAD_FILE` si no quedan productos
|
|
288
308
|
if (filteredData.length === 0) {
|
|
@@ -317,18 +337,18 @@ export const useUploadProducts = ({
|
|
|
317
337
|
|
|
318
338
|
// Actualiza el array `data` con la nueva cantidad
|
|
319
339
|
return prevData.map((product, index) =>
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
340
|
+
{return index === productIndex
|
|
341
|
+
? { ...product, CANTIDAD: newQuantity }
|
|
342
|
+
: product}
|
|
323
343
|
)
|
|
324
344
|
})
|
|
325
345
|
}
|
|
326
346
|
/**
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
347
|
+
* Restore the 'CANTIDAD' value to 'ORIGINAL_CANTIDAD' for a specific product.
|
|
348
|
+
* Validates the product index and only updates if necessary.
|
|
349
|
+
*
|
|
350
|
+
* @param {number} productIndex - The index of the product to restore quantity for.
|
|
351
|
+
*/
|
|
332
352
|
const handleCancelUpdateQuantity = (productIndex) => {
|
|
333
353
|
setData((prevData) => {
|
|
334
354
|
// Validar que el índice es un número válido
|
|
@@ -346,20 +366,20 @@ export const useUploadProducts = ({
|
|
|
346
366
|
|
|
347
367
|
// Crear una nueva copia de los datos actualizando solo el producto específico
|
|
348
368
|
return prevData.map((product, index) =>
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
369
|
+
{return index === productIndex
|
|
370
|
+
? { ...product, CANTIDAD: product.ORIGINAL_CANTIDAD, editing: false }
|
|
371
|
+
: product}
|
|
352
372
|
)
|
|
353
373
|
})
|
|
354
374
|
}
|
|
355
375
|
/**
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
376
|
+
* Filters products with a quantity of 0 or less from the data array.
|
|
377
|
+
* Sends a notification if any products are found with invalid quantities.
|
|
378
|
+
*/
|
|
359
379
|
const filterInvalidQuantityProducts = () => {
|
|
360
380
|
setData((prevData) => {
|
|
361
381
|
// Filtrar productos con `CANTIDAD` mayor a 0
|
|
362
|
-
const validProducts = prevData.filter(product => product.CANTIDAD > 0)
|
|
382
|
+
const validProducts = prevData.filter(product => {return product.CANTIDAD > 0})
|
|
363
383
|
|
|
364
384
|
// Notificar si hubo productos con cantidad no válida
|
|
365
385
|
if (validProducts.length < prevData.length) {
|
|
@@ -375,24 +395,24 @@ export const useUploadProducts = ({
|
|
|
375
395
|
}
|
|
376
396
|
|
|
377
397
|
/**
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
398
|
+
* Compares uploaded products against response data to determine which were successfully uploaded.
|
|
399
|
+
* @param {Array} data - Original array of products with their details.
|
|
400
|
+
* @param {Array} response - Array of response objects from the `updateProducts` function.
|
|
401
|
+
* @returns {Object} Object containing arrays of successfully and unsuccessfully uploaded products.
|
|
402
|
+
*/
|
|
383
403
|
const getUploadResults = (data, response) => {
|
|
384
404
|
const uploadedCodes = new Set(
|
|
385
405
|
response
|
|
386
|
-
.filter((product) => product.success)
|
|
387
|
-
.map((product) => product.data.pCode)
|
|
406
|
+
.filter((product) => {return product.success})
|
|
407
|
+
.map((product) => {return product.data.pCode})
|
|
388
408
|
)
|
|
389
409
|
|
|
390
410
|
const successfullyUploaded = data.filter((product) =>
|
|
391
|
-
|
|
411
|
+
{return uploadedCodes.has(product.pCode)}
|
|
392
412
|
)
|
|
393
413
|
|
|
394
414
|
const failedUploads = data.filter(
|
|
395
|
-
(product) => !uploadedCodes.has(product.pCode)
|
|
415
|
+
(product) => {return !uploadedCodes.has(product.pCode)}
|
|
396
416
|
)
|
|
397
417
|
|
|
398
418
|
return {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { gql, useMutation } from '@apollo/client'
|
|
2
|
-
import { GET_ONE_STORE } from '../useStore/queries'
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* GraphQL mutation to upsert (create or update) the daily goal.
|
|
@@ -20,6 +19,7 @@ const UPSERT_GOAL = gql`
|
|
|
20
19
|
/**
|
|
21
20
|
* Custom hook to handle the upsert of the daily goal.
|
|
22
21
|
* @param {Object} input - The goal data (e.g. dailyGoal).
|
|
22
|
+
* @param input.sendNotification
|
|
23
23
|
* @returns {{
|
|
24
24
|
* upsertGoal: (input: { dailyGoal: number }) => void,
|
|
25
25
|
* data: { success: boolean, message: string, dailyGoal: number } | undefined,
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { useMutation, useQuery } from '@apollo/client'
|
|
1
|
+
import { useMutation, useQuery } from '@apollo/client'
|
|
2
|
+
|
|
2
3
|
import { GET_USER, GET_USER_PROFILE, SET_USER_PROFILE } from './queries'
|
|
3
4
|
|
|
4
5
|
export const useUser = (email) => {
|
|
5
6
|
const { data, loading, error } = useQuery(GET_USER, email !== ''
|
|
6
7
|
? {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
8
|
+
variables: {
|
|
9
|
+
email
|
|
10
10
|
}
|
|
11
|
+
}
|
|
11
12
|
: {})
|
|
12
13
|
return [data?.getUser, { loading, error }]
|
|
13
14
|
}
|
|
@@ -18,15 +18,15 @@ export const fillLast7Weeks = (data) => {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
// Mapear los datos existentes para acceso rápido
|
|
21
|
-
const dataMap = new Map(data.map(item => [item.weekStart, item]))
|
|
21
|
+
const dataMap = new Map(data.map(item => {return [item.weekStart, item]}))
|
|
22
22
|
|
|
23
23
|
// Construir la nueva lista asegurando que todas las semanas estén presentes
|
|
24
|
-
return last7Weeks.map(weekStart => (
|
|
24
|
+
return last7Weeks.map(weekStart => {return (
|
|
25
25
|
dataMap.get(weekStart) || {
|
|
26
26
|
weekStart,
|
|
27
27
|
totalOut: 0,
|
|
28
28
|
prevTotalOut: null,
|
|
29
29
|
percentageChange: 'N/A'
|
|
30
30
|
}
|
|
31
|
-
))
|
|
31
|
+
)})
|
|
32
32
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { gql, useQuery } from '@apollo/client'
|
|
1
|
+
import { gql, useQuery } from '@apollo/client'
|
|
2
|
+
|
|
2
3
|
import { fillLast7Weeks } from './helpers' // Asegúrate de importar el helper
|
|
3
4
|
|
|
4
5
|
const GET_WEEKLY_STOCK_MOVEMENT = gql`
|
|
@@ -22,10 +23,10 @@ export const useWeeklyStockMovement = () => {
|
|
|
22
23
|
// Transform data and fill missing weeks
|
|
23
24
|
const rawData = data?.getStockMovementWeeklyComparison || []
|
|
24
25
|
const formattedData = fillLast7Weeks(
|
|
25
|
-
rawData.map(item =>
|
|
26
|
+
rawData.map(item => {return {
|
|
26
27
|
...item,
|
|
27
28
|
percentageChange: formatPercentageChange(item.percentageChange)
|
|
28
|
-
})
|
|
29
|
+
}})
|
|
29
30
|
)
|
|
30
31
|
|
|
31
32
|
return [formattedData, { loading, error }]
|
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
import { useState, useEffect } from 'react'
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* A custom React hook that provides the current window size.
|
|
5
|
+
* @returns An object containing the current window width and height
|
|
6
|
+
*/
|
|
3
7
|
export function useWindowSize () {
|
|
4
8
|
// Initialize state with undefined width/height so server and client renders match
|
|
5
9
|
// Learn more here: https://joshwcomeau.com/react/the-perils-of-rehydration/
|
|
6
|
-
const [windowSize, setWindowSize] = useState({
|
|
10
|
+
const [windowSize, setWindowSize] = useState<{ width: number | undefined; height: number | undefined }>({
|
|
7
11
|
width: undefined,
|
|
8
12
|
height: undefined
|
|
9
13
|
})
|
|
10
14
|
|
|
11
15
|
useEffect(() => {
|
|
12
16
|
// Handler to call on window resize
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
13
20
|
function handleResize () {
|
|
14
21
|
// Set window width/height to state
|
|
15
22
|
setWindowSize({
|
|
@@ -25,7 +32,7 @@ export function useWindowSize () {
|
|
|
25
32
|
handleResize()
|
|
26
33
|
|
|
27
34
|
// Remove event listener on cleanup
|
|
28
|
-
return () => window.removeEventListener('resize', handleResize)
|
|
35
|
+
return () => {return window.removeEventListener('resize', handleResize)}
|
|
29
36
|
}, []) // Empty array ensures that effect is only run on mount
|
|
30
37
|
|
|
31
38
|
return windowSize
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs'
|
|
2
|
+
import { join } from 'node:path'
|
|
3
|
+
|
|
4
|
+
const packageJson = JSON.parse(readFileSync(join(__dirname, '..', 'package.json'), 'utf8')) as { version: string }
|
|
5
|
+
|
|
6
|
+
export * from './hooks/index'
|
|
7
|
+
export * from './utils'
|
|
8
|
+
export * from './utils/generateCode'
|
|
9
|
+
export * from './cookies'
|
|
10
|
+
export * from './security'
|
|
11
|
+
|
|
12
|
+
// version
|
|
13
|
+
export const version = packageJson.version
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const future = null
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const serviceName = 'dummy'
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns an object containing the start and end of the day in local time (UTC-5 by default) for the given date.
|
|
3
|
+
* @returns {{ start: Date; end: Date }} An object with `start` and `end` Date properties.
|
|
4
|
+
*/
|
|
5
|
+
export class UtilDateRange {
|
|
6
|
+
private readonly date: Date
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @param date
|
|
11
|
+
* @returns UtilDateRange instance
|
|
12
|
+
*/
|
|
13
|
+
constructor(date: Date | string | number = new Date()) {
|
|
14
|
+
this.date = new Date(date) // Asegura que sea un objeto Date
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
* @param date
|
|
20
|
+
* @returns Date ajustada a la zona horaria local (UTC-5)
|
|
21
|
+
*/
|
|
22
|
+
private toLocalTime(date: Date | string | number): Date {
|
|
23
|
+
const offset = -5 // UTC-5 (ajustar si es necesario)
|
|
24
|
+
const localDate = new Date(date)
|
|
25
|
+
localDate.setHours(localDate.getHours() + offset)
|
|
26
|
+
return localDate
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @returns Date al inicio del día (00:00:00.000) en hora local
|
|
31
|
+
*/
|
|
32
|
+
getStartOfDay(): Date {
|
|
33
|
+
const localDate = this.toLocalTime(this.date)
|
|
34
|
+
localDate.setHours(0, 0, 0, 0)
|
|
35
|
+
return localDate
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @returns Date al final del día (23:59:59.999) en hora local
|
|
40
|
+
*/
|
|
41
|
+
getEndOfDay(): Date {
|
|
42
|
+
const localDate = this.toLocalTime(this.date)
|
|
43
|
+
localDate.setHours(23, 59, 59, 999)
|
|
44
|
+
return localDate
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @returns {{ start: Date; end: Date }} Objeto con las fechas de inicio y fin del día en hora local
|
|
49
|
+
*/
|
|
50
|
+
getRange(): { start: Date; end: Date } {
|
|
51
|
+
return {
|
|
52
|
+
start: this.getStartOfDay(),
|
|
53
|
+
end: this.getEndOfDay()
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|