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,14 +1,17 @@
|
|
|
1
|
+
import { useMutation } from '@apollo/client'
|
|
1
2
|
import {
|
|
2
3
|
useState,
|
|
3
4
|
useEffect,
|
|
4
5
|
useMemo
|
|
5
|
-
} from 'react'
|
|
6
|
-
|
|
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'
|
|
6
|
+
} from 'react'
|
|
7
|
+
|
|
11
8
|
import { statusOpenStores } from '../statusOpenStores'
|
|
9
|
+
import { useCart, useGetCart } from '../useCart'
|
|
10
|
+
import { useManageQueryParams } from '../useManageQueryParams'
|
|
11
|
+
|
|
12
|
+
import { calculateTotalPrice } from './helpers'
|
|
13
|
+
import { DELETE_ONE_ITEM_SHOPPING_PRODUCT } from './queries'
|
|
14
|
+
|
|
12
15
|
|
|
13
16
|
export const useAsideCart = ({
|
|
14
17
|
openModalProduct = false,
|
|
@@ -101,9 +104,9 @@ export const useAsideCart = ({
|
|
|
101
104
|
}
|
|
102
105
|
}
|
|
103
106
|
/**
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
+
* Handle the deletion of a shopping cart item.
|
|
108
|
+
* @param {Object} item - The item to be deleted from the shopping cart.
|
|
109
|
+
*/
|
|
107
110
|
const handleDeleteItemShopping = async (item) => {
|
|
108
111
|
if (!item) {
|
|
109
112
|
return setAlertBox({
|
|
@@ -123,7 +126,7 @@ export const useAsideCart = ({
|
|
|
123
126
|
if (!Array.isArray(existingCart)) return []
|
|
124
127
|
|
|
125
128
|
const filteredCart = existingCart.filter(product =>
|
|
126
|
-
|
|
129
|
+
{return readField('ShoppingCard', product) !== ShoppingCard}
|
|
127
130
|
)
|
|
128
131
|
|
|
129
132
|
// Actualizar el contador de productos
|
|
@@ -167,11 +170,11 @@ export const useAsideCart = ({
|
|
|
167
170
|
console.log(dataShoppingCard)
|
|
168
171
|
|
|
169
172
|
/**
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
173
|
+
* Verifica el estado de apertura de la tienda.
|
|
174
|
+
*
|
|
175
|
+
* @returns {Object|null} Objeto con el estado de apertura de la tienda o null en caso de error.
|
|
176
|
+
* @throws {Error} Si ocurre un error durante la verificación del estado de la tienda.
|
|
177
|
+
*/
|
|
175
178
|
const handleVerifyStoreOpenStatus = () => {
|
|
176
179
|
/**
|
|
177
180
|
* @type {Array} dataShoppingCard - El array de la tarjeta de compras.
|
|
@@ -181,17 +184,17 @@ export const useAsideCart = ({
|
|
|
181
184
|
}
|
|
182
185
|
|
|
183
186
|
/**
|
|
184
|
-
|
|
185
|
-
|
|
187
|
+
* @type {Object} store - La primera tienda en el array de la tarjeta de compras.
|
|
188
|
+
*/
|
|
186
189
|
const store = dataShoppingCard[0] || {}
|
|
187
190
|
/**
|
|
188
191
|
* @type {Object} getStore - El objeto que contiene información de la tienda.
|
|
189
|
-
|
|
192
|
+
*/
|
|
190
193
|
const { getStore } = store
|
|
191
194
|
|
|
192
195
|
/**
|
|
193
196
|
* @type {Array} storeSchedules - El array de horarios de la tienda.
|
|
194
|
-
|
|
197
|
+
*/
|
|
195
198
|
const storeSchedules = Array.isArray(getStore?.getStoreSchedules) ? getStore?.getStoreSchedules : []
|
|
196
199
|
try {
|
|
197
200
|
const status = getStore?.scheduleOpenAll ? { open: true } : statusOpenStores({ dataSchedules: storeSchedules })
|
|
@@ -9,7 +9,7 @@ export const filterDataOptional = (dataOptional) => {
|
|
|
9
9
|
|
|
10
10
|
try {
|
|
11
11
|
const filteredDataOptional = dataOptional.map(item => {
|
|
12
|
-
const checkedSubOptions = item?.ExtProductFoodsSubOptionalAll?.filter(subItem => subItem.check === true)
|
|
12
|
+
const checkedSubOptions = item?.ExtProductFoodsSubOptionalAll?.filter(subItem => {return subItem.check === true})
|
|
13
13
|
const ExtProductFoodsSubOptionalAll = checkedSubOptions?.map(subItemsOptional => {
|
|
14
14
|
return {
|
|
15
15
|
...filterKeyObject(subItemsOptional, filters)
|
|
@@ -19,7 +19,7 @@ export const filterDataOptional = (dataOptional) => {
|
|
|
19
19
|
...filterKeyObject(item, filters),
|
|
20
20
|
ExtProductFoodsSubOptionalAll
|
|
21
21
|
}
|
|
22
|
-
}).filter(item => item?.ExtProductFoodsSubOptionalAll.length > 0)
|
|
22
|
+
}).filter(item => {return item?.ExtProductFoodsSubOptionalAll.length > 0})
|
|
23
23
|
return filteredDataOptional
|
|
24
24
|
} catch (error) {
|
|
25
25
|
console.error('An error occurred while filtering data:', error.message)
|
|
@@ -36,7 +36,7 @@ export function validateRequirements (filteredDataOptional) {
|
|
|
36
36
|
if (Array.isArray(filteredDataOptional)) {
|
|
37
37
|
for (const item of filteredDataOptional) {
|
|
38
38
|
if (item.required === 1) {
|
|
39
|
-
const checkedSubOptions = item?.ExtProductFoodsSubOptionalAll.filter(subItem => subItem.check === true)
|
|
39
|
+
const checkedSubOptions = item?.ExtProductFoodsSubOptionalAll.filter(subItem => {return subItem.check === true})
|
|
40
40
|
if (checkedSubOptions.length !== item.numbersOptionalOnly) {
|
|
41
41
|
return true
|
|
42
42
|
}
|
|
@@ -46,11 +46,15 @@ export function validateRequirements (filteredDataOptional) {
|
|
|
46
46
|
return false
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
+
/**
|
|
50
|
+
*
|
|
51
|
+
* @param dataExtra
|
|
52
|
+
*/
|
|
49
53
|
export function validateExtraProducts (dataExtra) {
|
|
50
|
-
const requiredItems = dataExtra.filter(item => item.exState === 1)
|
|
54
|
+
const requiredItems = dataExtra.filter(item => {return item.exState === 1})
|
|
51
55
|
|
|
52
56
|
if (requiredItems.length > 0) {
|
|
53
|
-
const hasSelectedRequiredProduct = requiredItems.some(item => item.quantity > 0)
|
|
57
|
+
const hasSelectedRequiredProduct = requiredItems.some(item => {return item.quantity > 0})
|
|
54
58
|
return hasSelectedRequiredProduct
|
|
55
59
|
}
|
|
56
60
|
|
|
@@ -62,7 +66,7 @@ export const filterExtra = (dataExtra) => {
|
|
|
62
66
|
throw new Error('Input data is not an array')
|
|
63
67
|
}
|
|
64
68
|
try {
|
|
65
|
-
const dataExtraFiltered = dataExtra.filter(extra => extra.quantity !== 0)
|
|
69
|
+
const dataExtraFiltered = dataExtra.filter(extra => {return extra.quantity !== 0})
|
|
66
70
|
.map(extra => {
|
|
67
71
|
return {
|
|
68
72
|
...filterKeyObject(extra, filters)
|
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
import { useState, useCallback, useEffect } from 'react'
|
|
2
1
|
import { useMutation } from '@apollo/client'
|
|
3
|
-
import {
|
|
2
|
+
import { useState, useCallback, useEffect } from 'react'
|
|
3
|
+
|
|
4
4
|
import { RandomCode, updateCacheMod, numberFormat } from '../../../utils'
|
|
5
|
-
import { useExtProductFoodsAll, useGetOneProductsFood } from '../../useProductsFood'
|
|
6
5
|
import { useGetExtProductFoodsSubOptionalAll } from '../../useGetExtProductFoodsSubOptionalAll'
|
|
7
|
-
import {
|
|
6
|
+
import { useManageQueryParams } from '../../useManageQueryParams'
|
|
7
|
+
import { useExtProductFoodsAll, useGetOneProductsFood } from '../../useProductsFood'
|
|
8
|
+
import { CREATE_SHOPPING_CARD, GET_ALL_SHOPPING_CARD } from '../queries'
|
|
9
|
+
import { useGetCart } from '../useGetCart'
|
|
10
|
+
|
|
8
11
|
import {
|
|
9
12
|
filterDataOptional,
|
|
10
13
|
filterExtra,
|
|
11
14
|
validateExtraProducts,
|
|
12
15
|
validateRequirements
|
|
13
|
-
} from './helpers'
|
|
14
|
-
|
|
16
|
+
} from './helpers'
|
|
17
|
+
|
|
15
18
|
|
|
16
19
|
export const useCart = ({
|
|
17
20
|
location = {
|
|
@@ -91,7 +94,7 @@ export const useCart = ({
|
|
|
91
94
|
const filteredDataOptional = optionalFetch
|
|
92
95
|
.map((obj) => {
|
|
93
96
|
const filteredSubOptions = (obj.ExtProductFoodsSubOptionalAll || []).filter(
|
|
94
|
-
(subObj) => subObj.check !== false
|
|
97
|
+
(subObj) => {return subObj.check !== false}
|
|
95
98
|
)
|
|
96
99
|
|
|
97
100
|
if (filteredSubOptions.length === 0) {
|
|
@@ -103,7 +106,7 @@ export const useCart = ({
|
|
|
103
106
|
ExtProductFoodsSubOptionalAll: filteredSubOptions
|
|
104
107
|
}
|
|
105
108
|
})
|
|
106
|
-
.filter((obj) => obj !== null)
|
|
109
|
+
.filter((obj) => {return obj !== null})
|
|
107
110
|
|
|
108
111
|
if (matchingItemInShoppingCartOptional?.length === 0) {
|
|
109
112
|
setDataOptional(filteredDataOptional || [])
|
|
@@ -113,7 +116,7 @@ export const useCart = ({
|
|
|
113
116
|
// Actualiza los objetos de filteredDataOptional con información de matchingItemInShoppingCartOptional
|
|
114
117
|
const updateOption = filteredDataOptional?.map((obj) => {
|
|
115
118
|
const matchingArray = matchingItemInShoppingCartOptional?.find(
|
|
116
|
-
(o) => o && o.opExPid === obj.opExPid
|
|
119
|
+
(o) => {return o && o.opExPid === obj.opExPid}
|
|
117
120
|
)
|
|
118
121
|
|
|
119
122
|
if (!matchingArray) {
|
|
@@ -122,7 +125,7 @@ export const useCart = ({
|
|
|
122
125
|
|
|
123
126
|
// Actualiza las propiedades específicas
|
|
124
127
|
const updatedExtProductFoodsSubOptionalAll = (obj.ExtProductFoodsSubOptionalAll || []).map((subObj) => {
|
|
125
|
-
const newItem = matchingArray.saleExtProductFoodsSubOptionalAll?.find((newItem) => newItem && newItem.opSubExPid === subObj.opSubExPid)
|
|
128
|
+
const newItem = matchingArray.saleExtProductFoodsSubOptionalAll?.find((newItem) => {return newItem && newItem.opSubExPid === subObj.opSubExPid})
|
|
126
129
|
|
|
127
130
|
if (newItem) {
|
|
128
131
|
return {
|
|
@@ -138,7 +141,7 @@ export const useCart = ({
|
|
|
138
141
|
...obj,
|
|
139
142
|
ExtProductFoodsSubOptionalAll: updatedExtProductFoodsSubOptionalAll
|
|
140
143
|
}
|
|
141
|
-
}).filter((obj) => obj)
|
|
144
|
+
}).filter((obj) => {return obj})
|
|
142
145
|
|
|
143
146
|
setDataOptional(updateOption || [])
|
|
144
147
|
}
|
|
@@ -149,7 +152,7 @@ export const useCart = ({
|
|
|
149
152
|
|
|
150
153
|
if (Array.isArray(originalArray) && originalArray?.length) {
|
|
151
154
|
const fetchedDataExtra = originalArray?.map(extra => {
|
|
152
|
-
const updatedExtra = shoppingCartOptionalAll?.find(updatedItem => updatedItem.exPid === extra.exPid)
|
|
155
|
+
const updatedExtra = shoppingCartOptionalAll?.find(updatedItem => {return updatedItem.exPid === extra.exPid})
|
|
153
156
|
if (updatedExtra) {
|
|
154
157
|
return {
|
|
155
158
|
...extra,
|
|
@@ -170,6 +173,9 @@ export const useCart = ({
|
|
|
170
173
|
/**
|
|
171
174
|
* The function `handleIncrementExtra` updates the quantity and price of a specific extra product in
|
|
172
175
|
* an array based on the provided index and product ID.
|
|
176
|
+
* @param root0
|
|
177
|
+
* @param root0.extra
|
|
178
|
+
* @param root0.index
|
|
173
179
|
*/
|
|
174
180
|
function handleIncrementExtra ({ extra, index }) {
|
|
175
181
|
// Desestructura las propiedades necesarias de dataOneProduct
|
|
@@ -202,6 +208,12 @@ export const useCart = ({
|
|
|
202
208
|
}
|
|
203
209
|
}
|
|
204
210
|
|
|
211
|
+
/**
|
|
212
|
+
*
|
|
213
|
+
* @param root0
|
|
214
|
+
* @param root0.extra
|
|
215
|
+
* @param root0.index
|
|
216
|
+
*/
|
|
205
217
|
function handleDecrementExtra ({ extra, index }) {
|
|
206
218
|
// Desestructura las propiedades necesarias de dataOneProduct
|
|
207
219
|
const { pId } = dataOneProduct || {}
|
|
@@ -210,7 +222,7 @@ export const useCart = ({
|
|
|
210
222
|
const { exPid = null } = extra
|
|
211
223
|
|
|
212
224
|
// Encuentra el índice del objeto extra en dataExtra
|
|
213
|
-
const extraIndex = dataExtra.findIndex((item) => item.exPid === exPid)
|
|
225
|
+
const extraIndex = dataExtra.findIndex((item) => {return item.exPid === exPid})
|
|
214
226
|
|
|
215
227
|
if (pId && exPid && extraIndex !== -1) {
|
|
216
228
|
const newExtra = dataExtra.map((producto, i) => {
|
|
@@ -268,10 +280,10 @@ export const useCart = ({
|
|
|
268
280
|
|
|
269
281
|
const handleAddOptional = ({ exOptional = null, codeCategory = null }) => {
|
|
270
282
|
if (!exOptional || !codeCategory) return
|
|
271
|
-
const item = dataOptional.find((item) => item.code === codeCategory)
|
|
283
|
+
const item = dataOptional.find((item) => {return item.code === codeCategory})
|
|
272
284
|
if (!item) return
|
|
273
285
|
const idx = item.ExtProductFoodsSubOptionalAll.findIndex(
|
|
274
|
-
(el) => el.opSubExPid === exOptional
|
|
286
|
+
(el) => {return el.opSubExPid === exOptional}
|
|
275
287
|
)
|
|
276
288
|
if (item && idx !== -1) {
|
|
277
289
|
const updatedItem = {
|
|
@@ -286,9 +298,9 @@ export const useCart = ({
|
|
|
286
298
|
]
|
|
287
299
|
}
|
|
288
300
|
const newData = dataOptional.map((el) =>
|
|
289
|
-
|
|
301
|
+
{return el.code === codeCategory ? updatedItem : el}
|
|
290
302
|
)
|
|
291
|
-
setDataOptional((prevData) => [...newData])
|
|
303
|
+
setDataOptional((prevData) => {return [...newData]})
|
|
292
304
|
}
|
|
293
305
|
}
|
|
294
306
|
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { useQuery } from '@apollo/client'
|
|
1
|
+
import { useQuery } from '@apollo/client'
|
|
2
|
+
|
|
2
3
|
import { GET_ALL_CATEGORIES_WITH_PRODUCT } from './queries'
|
|
4
|
+
import { GetCatProductsWithProductResponse, ICatWithProduct } from './types'
|
|
3
5
|
|
|
4
6
|
export const useCatWithProduct = ({
|
|
5
|
-
max =
|
|
7
|
+
max = 400,
|
|
6
8
|
min = 0,
|
|
7
9
|
search = null,
|
|
8
10
|
productName = null,
|
|
9
|
-
searchFilter = {}
|
|
10
|
-
|
|
11
|
+
searchFilter = {},
|
|
12
|
+
callback = () => {}
|
|
13
|
+
}: ICatWithProduct) => {
|
|
11
14
|
const {
|
|
12
15
|
gender,
|
|
13
16
|
desc,
|
|
@@ -23,6 +26,9 @@ export const useCatWithProduct = ({
|
|
|
23
26
|
error,
|
|
24
27
|
fetchMore
|
|
25
28
|
} = useQuery(GET_ALL_CATEGORIES_WITH_PRODUCT, {
|
|
29
|
+
onCompleted: (data) => {
|
|
30
|
+
callback(data as GetCatProductsWithProductResponse)
|
|
31
|
+
},
|
|
26
32
|
fetchPolicy: 'network-only',
|
|
27
33
|
variables:
|
|
28
34
|
{
|
|
@@ -30,7 +36,7 @@ export const useCatWithProduct = ({
|
|
|
30
36
|
productName,
|
|
31
37
|
gender,
|
|
32
38
|
min,
|
|
33
|
-
max
|
|
39
|
+
max,
|
|
34
40
|
desc,
|
|
35
41
|
categories: speciality
|
|
36
42
|
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
export interface ICatWithProduct {
|
|
2
|
+
max?: number
|
|
3
|
+
min?: number
|
|
4
|
+
search?: string | null
|
|
5
|
+
productName?: string | null
|
|
6
|
+
searchFilter?: {
|
|
7
|
+
gender?: string[]
|
|
8
|
+
desc?: string | null
|
|
9
|
+
speciality?: string[]
|
|
10
|
+
}
|
|
11
|
+
callback?: Function
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
// =====================
|
|
16
|
+
// Query Variables
|
|
17
|
+
// =====================
|
|
18
|
+
|
|
19
|
+
export interface GetCatProductsWithProductVariables {
|
|
20
|
+
search?: string
|
|
21
|
+
productName?: string
|
|
22
|
+
min?: number
|
|
23
|
+
max?: number
|
|
24
|
+
gender?: string[]
|
|
25
|
+
desc?: string[]
|
|
26
|
+
categories?: string[]
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// =====================
|
|
30
|
+
// Response Types
|
|
31
|
+
// =====================
|
|
32
|
+
|
|
33
|
+
export interface GetCatProductsWithProductResponse {
|
|
34
|
+
getCatProductsWithProduct: {
|
|
35
|
+
totalCount: number
|
|
36
|
+
catProductsWithProduct: CatProductWithProduct[]
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// =====================
|
|
41
|
+
// Main Entities
|
|
42
|
+
// =====================
|
|
43
|
+
|
|
44
|
+
export interface CatProductWithProduct {
|
|
45
|
+
carProId: string
|
|
46
|
+
pState: number
|
|
47
|
+
ProImage: string | null
|
|
48
|
+
idStore: string
|
|
49
|
+
pName: string
|
|
50
|
+
totalCount: number
|
|
51
|
+
checked?: boolean
|
|
52
|
+
ProDescription?: string | null
|
|
53
|
+
createdAt: string
|
|
54
|
+
updatedAt: string
|
|
55
|
+
productFoodsAll: ProductFood[]
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface ProductFood {
|
|
59
|
+
pId: string
|
|
60
|
+
stock: number
|
|
61
|
+
manageStock: boolean
|
|
62
|
+
sizeId?: string | null
|
|
63
|
+
colorId?: string | null
|
|
64
|
+
carProId: string
|
|
65
|
+
cId?: string | null
|
|
66
|
+
dId?: string | null
|
|
67
|
+
ctId?: string | null
|
|
68
|
+
idStore: string
|
|
69
|
+
caId?: string | null
|
|
70
|
+
fId?: string | null
|
|
71
|
+
pName: string
|
|
72
|
+
ProPrice: number
|
|
73
|
+
ProDescuento?: number | null
|
|
74
|
+
ProUniDisponibles?: number | null
|
|
75
|
+
ProDescription?: string | null
|
|
76
|
+
ProProtegido?: boolean | null
|
|
77
|
+
ProAssurance?: boolean | null
|
|
78
|
+
ProImage?: string | null
|
|
79
|
+
ProStar?: number | null
|
|
80
|
+
ProWidth?: number | null
|
|
81
|
+
ProHeight?: number | null
|
|
82
|
+
ProLength?: number | null
|
|
83
|
+
ProWeight?: number | null
|
|
84
|
+
ProQuantity?: number | null
|
|
85
|
+
ProOutstanding?: boolean | null
|
|
86
|
+
ProDelivery?: boolean | null
|
|
87
|
+
ProVoltaje?: string | null
|
|
88
|
+
pState: number
|
|
89
|
+
sTateLogistic?: number | null
|
|
90
|
+
createdAt: string
|
|
91
|
+
updatedAt: string
|
|
92
|
+
product_availables: ProductAvailable[]
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export interface ProductAvailable {
|
|
96
|
+
availableProductId: string
|
|
97
|
+
pId: string
|
|
98
|
+
idStore: string
|
|
99
|
+
dayAvailable: string
|
|
100
|
+
startDate: string
|
|
101
|
+
endDate: string
|
|
102
|
+
createdAt: string
|
|
103
|
+
updatedAt: string
|
|
104
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { useMemo } from 'react'
|
|
2
1
|
import { useQuery } from '@apollo/client'
|
|
2
|
+
import { useMemo } from 'react'
|
|
3
|
+
|
|
3
4
|
import { GET_ALL_CATEGORIES_WITH_PRODUCT_CLIENTS } from './queries'
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -44,7 +45,7 @@ export const useCatWithProductClient = (idStore) => {
|
|
|
44
45
|
// Utiliza useMemo para memorizar el resultado filtrado
|
|
45
46
|
const filteredData = useMemo(() => {
|
|
46
47
|
return data?.getCatProductsWithProductClient?.filter(
|
|
47
|
-
(category) => category?.productFoodsAll?.length > 0
|
|
48
|
+
(category) => {return category?.productFoodsAll?.length > 0}
|
|
48
49
|
) || []
|
|
49
50
|
}, [data])
|
|
50
51
|
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { useMutation, useQuery, ApolloError } from '@apollo/client'
|
|
2
|
+
import { useState } from 'react'
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
DELETE_ONE_CAT_PRODUCTS,
|
|
6
|
+
GET_ULTIMATE_CATEGORY_PRODUCTS,
|
|
7
|
+
UPDATE_CAT_IN_PRODUCT
|
|
8
|
+
} from '../useProductsFood/queriesStore'
|
|
9
|
+
|
|
10
|
+
import { GET_ONE_STORE_IN_CATEGORY } from './queries'
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Generic alert box handler
|
|
14
|
+
*/
|
|
15
|
+
interface AlertBoxPayload {
|
|
16
|
+
title?: string
|
|
17
|
+
message: string
|
|
18
|
+
color: 'error' | 'success' | 'warning' | 'info'
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
type SetAlertBox = (payload: AlertBoxPayload) => void
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Category entity
|
|
25
|
+
*/
|
|
26
|
+
interface Category {
|
|
27
|
+
idPc: string
|
|
28
|
+
pState: string
|
|
29
|
+
[key: string]: unknown
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Hook params
|
|
34
|
+
*/
|
|
35
|
+
interface UseCategoryInStoreParams {
|
|
36
|
+
catStoreId?: string
|
|
37
|
+
setAlertBox?: SetAlertBox
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Hook return shape
|
|
42
|
+
*/
|
|
43
|
+
interface UseCategoryInStoreResult {
|
|
44
|
+
categories: Category[]
|
|
45
|
+
data: Category[]
|
|
46
|
+
loading: boolean
|
|
47
|
+
error?: ApolloError
|
|
48
|
+
handlerDeleteCategoryInStore: (category?: Category) => Promise<unknown> | void
|
|
49
|
+
handleUpdateCatInProduct: (params: { data?: Array<{ pId: string }> }) => Promise<void>
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Custom hook to manage categories in store
|
|
54
|
+
* @param root0
|
|
55
|
+
* @param root0.catStoreId
|
|
56
|
+
* @param root0.setAlertBox
|
|
57
|
+
*/
|
|
58
|
+
export const useCategoryInStore = ({
|
|
59
|
+
catStoreId,
|
|
60
|
+
setAlertBox = () => {}
|
|
61
|
+
}: UseCategoryInStoreParams = {}): UseCategoryInStoreResult => {
|
|
62
|
+
const [categories, setOneCategoryInStore] = useState<Category[]>([])
|
|
63
|
+
|
|
64
|
+
const [deleteCatOfProducts] = useMutation(DELETE_ONE_CAT_PRODUCTS, {
|
|
65
|
+
onError: (e: ApolloError) => {
|
|
66
|
+
setAlertBox({
|
|
67
|
+
title: '',
|
|
68
|
+
message: e.graphQLErrors?.[0]?.message || 'Unexpected error',
|
|
69
|
+
color: 'error'
|
|
70
|
+
})
|
|
71
|
+
},
|
|
72
|
+
update: (cache) => {
|
|
73
|
+
cache.modify({
|
|
74
|
+
fields: {
|
|
75
|
+
catProductsAll (dataOld = []) {
|
|
76
|
+
return cache.writeQuery({
|
|
77
|
+
query: GET_ULTIMATE_CATEGORY_PRODUCTS,
|
|
78
|
+
data: dataOld
|
|
79
|
+
})
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
const [updatedCatWithProducts] = useMutation(UPDATE_CAT_IN_PRODUCT, {
|
|
87
|
+
onError: (e: ApolloError) => {
|
|
88
|
+
console.error({
|
|
89
|
+
message: e.graphQLErrors?.[0]?.message || 'Unexpected error',
|
|
90
|
+
color: 'error'
|
|
91
|
+
})
|
|
92
|
+
},
|
|
93
|
+
update: (cache) => {
|
|
94
|
+
cache.modify({
|
|
95
|
+
fields: {
|
|
96
|
+
catProductsAll (dataOld = []) {
|
|
97
|
+
return cache.writeQuery({
|
|
98
|
+
query: GET_ULTIMATE_CATEGORY_PRODUCTS,
|
|
99
|
+
data: dataOld
|
|
100
|
+
})
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
})
|
|
104
|
+
}
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
const { data } = useQuery(GET_ULTIMATE_CATEGORY_PRODUCTS)
|
|
108
|
+
|
|
109
|
+
const { loading, error } = useQuery(GET_ONE_STORE_IN_CATEGORY, {
|
|
110
|
+
variables: {
|
|
111
|
+
catStore: catStoreId
|
|
112
|
+
},
|
|
113
|
+
skip: !catStoreId,
|
|
114
|
+
onError: () => {
|
|
115
|
+
console.warn({ message: 'Failed loading category store', duration: 5000 })
|
|
116
|
+
},
|
|
117
|
+
onCompleted: (response) => {
|
|
118
|
+
if (response?.getOneCatStore) {
|
|
119
|
+
setOneCategoryInStore(response.getOneCatStore)
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Delete category from products
|
|
126
|
+
* @param category
|
|
127
|
+
*/
|
|
128
|
+
const handlerDeleteCategoryInStore = (category?: Category) => {
|
|
129
|
+
const { pState, idPc } = category || {}
|
|
130
|
+
if (!idPc || !pState) return
|
|
131
|
+
|
|
132
|
+
return deleteCatOfProducts({
|
|
133
|
+
variables: { idPc, pState }
|
|
134
|
+
})
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Update category in products
|
|
139
|
+
* @param root0
|
|
140
|
+
* @param root0.data
|
|
141
|
+
*/
|
|
142
|
+
const handleUpdateCatInProduct = async ({
|
|
143
|
+
data
|
|
144
|
+
}: {
|
|
145
|
+
data?: Array<{ pId: string }>
|
|
146
|
+
}): Promise<void> => {
|
|
147
|
+
if (!data?.length) return
|
|
148
|
+
|
|
149
|
+
await updatedCatWithProducts({
|
|
150
|
+
variables: {
|
|
151
|
+
input: {
|
|
152
|
+
setData: data.map(({ pId }) => {return { idProduct: pId }}),
|
|
153
|
+
idCat: ''
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
})
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return {
|
|
160
|
+
categories,
|
|
161
|
+
data: data?.catProductsAll ?? [],
|
|
162
|
+
loading,
|
|
163
|
+
error,
|
|
164
|
+
handlerDeleteCategoryInStore,
|
|
165
|
+
handleUpdateCatInProduct
|
|
166
|
+
}
|
|
167
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useQuery } from '@apollo/client'
|
|
2
|
-
import { useState } from 'react'
|
|
2
|
+
import { useState } from 'react'
|
|
3
|
+
|
|
3
4
|
import { SPANISH_MONTHS } from '../../utils/index'
|
|
4
5
|
import { GET_ALL_SALES } from '../useReport/queries'
|
|
5
6
|
export * from './useChartDataAllOrders'
|
|
@@ -68,13 +69,13 @@ export const useChartData = ({ year }) => {
|
|
|
68
69
|
],
|
|
69
70
|
borderColor: chartType === 'bar'
|
|
70
71
|
? [
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
72
|
+
'rgba(255, 99, 132, 1)',
|
|
73
|
+
'rgba(54, 162, 235, 1)',
|
|
74
|
+
'rgba(255, 206, 86, 1)',
|
|
75
|
+
'rgba(75, 192, 192, 1)',
|
|
76
|
+
'rgba(153, 102, 255, 1)',
|
|
77
|
+
'rgba(255, 159, 64, 1)'
|
|
78
|
+
]
|
|
78
79
|
: 'rgb(255 0 0)',
|
|
79
80
|
tension: 0.6,
|
|
80
81
|
fill: false,
|