npm-pkg-hook 1.12.7 → 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/.babelrc +0 -0
- package/.env +5 -0
- package/.github/pull_request_template.md +18 -0
- package/.github/workflows/pepeline.yaml +30 -0
- package/dist/index.js +47755 -10080
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +47071 -9610
- package/dist/index.mjs.map +1 -0
- package/eslint.config.mts +153 -0
- package/expire.json +1 -0
- package/jsconfig.json +28 -0
- package/package.json +24 -61
- package/script.txt +7 -0
- package/src/config/client/errors.ts +39 -0
- package/src/config/client/index.ts +1 -0
- package/src/config/content/en.json +5 -0
- package/src/config/content/es.json +5 -0
- package/src/config/content/index.ts +16 -0
- package/src/cookies/index.ts +3 -0
- package/src/hooks/addTenMinutes/index.ts +14 -0
- package/src/hooks/calculateLogLatHaversine/index.ts +41 -0
- package/src/hooks/completeSchedules/index.ts +22 -0
- package/src/hooks/convertToMilitaryTime/index.ts +18 -0
- package/src/hooks/generateStoreURL/index.ts +41 -0
- package/src/hooks/generateTemplate/index.ts +66 -0
- package/src/hooks/getCardType/index.ts +24 -0
- package/src/hooks/getCategoriesWithProduct/helpers/index.ts +7 -0
- package/src/hooks/getCategoriesWithProduct/index.ts +62 -0
- package/src/hooks/getGlobalSession/index.ts +69 -0
- package/src/hooks/getSession/index.ts +72 -0
- package/src/hooks/getTodayTimestamps/index.ts +70 -0
- package/src/hooks/getTotalHours/index.ts +76 -0
- package/src/hooks/handleLogin/index.ts +14 -0
- package/src/hooks/index.ts +153 -0
- package/src/hooks/isTokenExpired/index.ts +17 -0
- package/src/hooks/newMessageSubscription/index.ts +28 -0
- package/src/hooks/newStoreOrderSubscription/index.ts +26 -0
- package/src/hooks/statusOpenStores/helpers/index.ts +124 -0
- package/src/hooks/statusOpenStores/index.ts +221 -0
- package/src/hooks/updateExtProductFoodsOptional/index.ts +49 -0
- package/src/hooks/useAcumulateDate/index.ts +18 -0
- package/src/hooks/useAllStoresPendingToRegister/index.ts +37 -0
- package/src/hooks/useAmountInput/index.ts +127 -0
- package/src/hooks/useAnimationFrame/index.ts +45 -0
- package/src/hooks/useAnimationText/index.ts +31 -0
- package/src/hooks/useAsideCart/helpers/index.ts +22 -0
- package/src/hooks/useAsideCart/index.ts +217 -0
- package/src/hooks/useAsideCart/queries.ts +10 -0
- package/src/hooks/useBanner/index.ts +20 -0
- package/src/hooks/useCart/index.ts +2 -0
- package/src/hooks/useCart/queries.ts +174 -0
- package/src/hooks/useCart/useCart/helpers/index.ts +79 -0
- package/src/hooks/useCart/useCart/index.ts +424 -0
- package/src/hooks/useCart/useGetCart/index.ts +34 -0
- package/src/hooks/useCatWithProduct/index.ts +54 -0
- package/src/hooks/useCatWithProduct/queries.ts +200 -0
- package/src/hooks/useCatWithProduct/types/index.ts +104 -0
- package/src/hooks/useCatWithProductClient/index.ts +57 -0
- package/src/hooks/useCatWithProductClient/queries.ts +56 -0
- package/src/hooks/useCategoriesProduct/index.ts +14 -0
- package/src/hooks/useCategoriesProduct/queries.ts +16 -0
- package/src/hooks/useCategoryInStore/index.ts +167 -0
- package/src/hooks/useCategoryInStore/queries.ts +78 -0
- package/src/hooks/useCategoryStore/index.ts +8 -0
- package/src/hooks/useCategoryStore/queries.ts +16 -0
- package/src/hooks/useChartData/index.ts +171 -0
- package/src/hooks/useChartData/useChartData/index.ts +200 -0
- package/src/hooks/useChartData/useChartDataAllOrders/index.ts +94 -0
- package/src/hooks/useChatRoomSubscription/index.ts +28 -0
- package/src/hooks/useCheckbox/index.ts +115 -0
- package/src/hooks/useCities/index.ts +14 -0
- package/src/hooks/useCities/queries.ts +12 -0
- package/src/hooks/useClients/index.ts +97 -0
- package/src/hooks/useClients/queries.ts +215 -0
- package/src/hooks/useColorByLetters/helpers/alea.ts +73 -0
- package/src/hooks/useColorByLetters/helpers/colors.ts +45 -0
- package/src/hooks/useColorByLetters/helpers/index.ts +22 -0
- package/src/hooks/useColorByLetters/helpers/mersenne_twister.ts +118 -0
- package/src/hooks/useColorByLetters/index.ts +24 -0
- package/src/hooks/useConnection/index.ts +24 -0
- package/src/hooks/useCountries/index.ts +20 -0
- package/src/hooks/useCountries/queries.ts +12 -0
- package/src/hooks/useCreateDeliveryTime/index.ts +51 -0
- package/src/hooks/useCreateOrderStatusType/index.ts +134 -0
- package/src/hooks/useCreateProduct/helpers/index.ts +23 -0
- package/src/hooks/useCreateProduct/helpers/manageCacheDataCatProduct/index.ts +52 -0
- package/src/hooks/useCreateProduct/helpers/useEditImageProduct/index.ts +182 -0
- package/src/hooks/useCreateProduct/index.ts +337 -0
- package/src/hooks/useCreateStorePendingToRegister/index.ts +17 -0
- package/src/hooks/useCreateStorePendingToRegister/queries.ts +10 -0
- package/src/hooks/useDashboardComponents/index.ts +50 -0
- package/src/hooks/useDeleteExtraProductFoods/index.ts +13 -0
- package/src/hooks/useDeleteSubProductOptional/index.ts +32 -0
- package/src/hooks/useDeleteSubProductOptional/queries.ts +10 -0
- package/src/hooks/useDeliveryTime/index.ts +29 -0
- package/src/hooks/useDepartments/index.ts +14 -0
- package/src/hooks/useDepartments/queries.ts +13 -0
- package/src/hooks/useDessert/helpers/index.ts +51 -0
- package/src/hooks/useDessert/index.ts +529 -0
- package/src/hooks/useDessertWithPrice/helpers/index.ts +76 -0
- package/src/hooks/useDessertWithPrice/index.ts +381 -0
- package/src/hooks/useDessertWithPrice/queries.ts +18 -0
- package/src/hooks/useDevWS/index.ts +53 -0
- package/src/hooks/useDevices/index.ts +2 -0
- package/src/hooks/useDevices/queries.ts +28 -0
- package/src/hooks/useDevices/useGetDevices.ts +28 -0
- package/src/hooks/useDevices/useRegisterDevices.ts +75 -0
- package/src/hooks/useDownloadReports/helpers/downloadFileFromResponse.ts +21 -0
- package/src/hooks/useDownloadReports/index.ts +2 -0
- package/src/hooks/useDownloadReports/useDownloadReportByDay/index.ts +105 -0
- package/src/hooks/useDownloadReports/useGetReportByDateRange/index.ts +116 -0
- package/src/hooks/useDrag/index.ts +79 -0
- package/src/hooks/useDropzone/index.ts +94 -0
- package/src/hooks/useDynamicAuth/index.ts +14 -0
- package/src/hooks/useDynamicAuth/queries.ts +24 -0
- package/src/hooks/useEditCategory/index.ts +41 -0
- package/src/hooks/useEditOneExtProductFoodOptional/index.ts +28 -0
- package/src/hooks/useEditOneExtProductFoodOptional/queries.ts +16 -0
- package/src/hooks/useEditSubProductOptional/index.ts +12 -0
- package/src/hooks/useEditSubProductOptional/queries.ts +10 -0
- package/src/hooks/useEmployee/index.ts +18 -0
- package/src/hooks/useEmployee/queries.ts +85 -0
- package/src/hooks/useEmployee/useCreateEmployee.ts +90 -0
- package/src/hooks/useEvent/index.ts +34 -0
- package/src/hooks/useFavoriteStores/index.ts +31 -0
- package/src/hooks/useFavoriteStores/queries.ts +54 -0
- package/src/hooks/useFetchJson/index.ts +25 -0
- package/src/hooks/useFetchMoreInteractions/index.jsx +39 -0
- package/src/hooks/useFilterConfigs/index.ts +173 -0
- package/src/hooks/useFingerprintjs/index.ts +197 -0
- package/src/hooks/useFormTools/index.ts +143 -0
- package/src/hooks/useFormatDate/index.ts +91 -0
- package/src/hooks/useFormatNumberPhone/index.ts +23 -0
- package/src/hooks/useFullScreenMode/index.ts +61 -0
- package/src/hooks/useGenerateNumberArray/index.ts +17 -0
- package/src/hooks/useGetAllLocationUser/index.ts +13 -0
- package/src/hooks/useGetAllLocationUser/queries.ts +44 -0
- package/src/hooks/useGetAllSales/index.ts +26 -0
- package/src/hooks/useGetCookies/index.ts +43 -0
- package/src/hooks/useGetExtProductFoodsSubOptionalAll/index.ts +15 -0
- package/src/hooks/useGetFoodRecomended/index.ts +33 -0
- package/src/hooks/useGetFoodRecomended/queries.ts +47 -0
- package/src/hooks/useGetMessagesToRoom/index.ts +23 -0
- package/src/hooks/useGetMinPrice/index.ts +13 -0
- package/src/hooks/useGetMinPrice/queries.ts +7 -0
- package/src/hooks/useGetOneStoreRating/index.ts +41 -0
- package/src/hooks/useGetOneStoreRating/queries.ts +18 -0
- package/src/hooks/useGetSalesAmountToday/index.ts +31 -0
- package/src/hooks/useGetStoreCookie/index.ts +21 -0
- package/src/hooks/useGoogleLogin/index.ts +169 -0
- package/src/hooks/useGoogleLogin/loadScript.ts +15 -0
- package/src/hooks/useGoogleLogin/removeScript.ts +7 -0
- package/src/hooks/useHover/index.ts +32 -0
- package/src/hooks/useImageOptimization/index.ts +32 -0
- package/src/hooks/useImageUploaderProduct/helper/canvasUtils.ts +146 -0
- package/src/hooks/useImageUploaderProduct/helper/getOrientation.ts +54 -0
- package/src/hooks/useImageUploaderProduct/helper/index.ts +5 -0
- package/src/hooks/useImageUploaderProduct/index.ts +295 -0
- package/src/hooks/useImageWeight/index.ts +55 -0
- package/src/hooks/useImagesStore/index.ts +227 -0
- package/src/hooks/useImagesStore/queries.ts +193 -0
- package/src/hooks/useImagesStore/utils/index.ts +4 -0
- package/src/hooks/useIncomingOrders/index.ts +11 -0
- package/src/hooks/useIncomingOrders/queries.ts +87 -0
- package/src/hooks/useInnerHtml/index.ts +39 -0
- package/src/hooks/useIntersection/index.ts +84 -0
- package/src/hooks/useInventory/index.ts +2 -0
- package/src/hooks/useInventory/queries.ts +58 -0
- package/src/hooks/useInventory/useGetProductsInStock.ts +16 -0
- package/src/hooks/useInventory/useUpdateManageStock.ts +41 -0
- package/src/hooks/useKeypress/index.ts +28 -0
- package/src/hooks/useLazyScript/index.ts +74 -0
- package/src/hooks/useLocalBackendIp/index.ts +34 -0
- package/src/hooks/useLocalSorage/index.ts +36 -0
- package/src/hooks/useLocationManager/index.ts +63 -0
- package/src/hooks/useLocationNavigate/index.ts +54 -0
- package/src/hooks/useLoginEmployeeInStore/index.ts +38 -0
- package/src/hooks/useLogout/helpers/BroadcastChannel.ts +74 -0
- package/src/hooks/useLogout/helpers/apiBaseUrl.ts +12 -0
- package/src/hooks/useLogout/helpers/fetchData.ts +37 -0
- package/src/hooks/useLogout/helpers/getCsrfToken.ts +37 -0
- package/src/hooks/useLogout/helpers/index.ts +65 -0
- package/src/hooks/useLogout/helpers/logger.ts +88 -0
- package/src/hooks/useLogout/helpers/parseUrl.ts +39 -0
- package/src/hooks/useLogout/index.ts +105 -0
- package/src/hooks/useManageNewOrder/helpers/index.ts +45 -0
- package/src/hooks/useManageNewOrder/helpers/mock.ts +0 -0
- package/src/hooks/useManageNewOrder/index.ts +104 -0
- package/src/hooks/useManageQueryParams/index.ts +120 -0
- package/src/hooks/useMobile/index.ts +65 -0
- package/src/hooks/useModules/helpers/index.ts +1 -0
- package/src/hooks/useModules/helpers/validateModules.ts +29 -0
- package/src/hooks/useModules/index.ts +124 -0
- package/src/hooks/useMouse/index.ts +55 -0
- package/src/hooks/useMutateHeight/index.ts +36 -0
- package/src/hooks/useOrderClient/index.ts +5 -0
- package/src/hooks/useOrderStatusTypes/index.ts +2 -0
- package/src/hooks/useOrderStatusTypes/useOrderStatusTypes/index.ts +133 -0
- package/src/hooks/useOrderStatusTypes/useUpdateOrderStatusPriorities/index.ts +99 -0
- package/src/hooks/useOrders/index.ts +3 -0
- package/src/hooks/useOrders/queries.ts +99 -0
- package/src/hooks/useOrders/useChangeOrderState/index.ts +128 -0
- package/src/hooks/useOrders/useOrdersFromStore/index.ts +78 -0
- package/src/hooks/usePWAInstall/index.ts +38 -0
- package/src/hooks/usePaymentMethod/index.ts +3 -0
- package/src/hooks/usePaymentMethod/paymentMethod.gql.ts +62 -0
- package/src/hooks/usePaymentMethod/paymentMethod.types.ts +28 -0
- package/src/hooks/usePaymentMethod/useCreatePaymentMethod/index.ts +25 -0
- package/src/hooks/usePaymentMethod/useGetAllPaymentMethods/index.ts +19 -0
- package/src/hooks/usePaymentMethod/useGetPaymentMethod/index.ts +26 -0
- package/src/hooks/usePortFetcher/index.ts +33 -0
- package/src/hooks/usePrintSaleTicket/index.ts +68 -0
- package/src/hooks/useProductsFood/index.ts +341 -0
- package/src/hooks/useProductsFood/queriesStore.ts +964 -0
- package/src/hooks/useProductsFood/types/index.ts +0 -0
- package/src/hooks/useProductsFood/useEditProduct.ts +49 -0
- package/src/hooks/useProductsFood/usetagsProducts.ts +101 -0
- package/src/hooks/useProviders/index.ts +3 -0
- package/src/hooks/useProviders/queries.ts +31 -0
- package/src/hooks/useProviders/useProvidersCreateStore/index.ts +13 -0
- package/src/hooks/useProviders/useProvidersDataStore/index.ts +25 -0
- package/src/hooks/useProvidersStore/index.ts +25 -0
- package/src/hooks/useProvidersStore/queries.ts +31 -0
- package/src/hooks/usePushNotificationOrder/index.ts +52 -0
- package/src/hooks/usePushNotifications/helpers/index.ts +123 -0
- package/src/hooks/usePushNotifications/index.ts +150 -0
- package/src/hooks/useQueryLocationsMap/index.ts +20 -0
- package/src/hooks/useQueryLocationsMap/queries.ts +40 -0
- package/src/hooks/useRatingArrayData/index.ts +54 -0
- package/src/hooks/useRatingArrayData/queries.ts +19 -0
- package/src/hooks/useReactToPrint/index.txt +1223 -0
- package/src/hooks/useRemoveExtraProductFoodsOptional/index.ts +24 -0
- package/src/hooks/useRemoveExtraProductFoodsOptional/queries.ts +48 -0
- package/src/hooks/useReport/index.ts +48 -0
- package/src/hooks/useReport/queries.ts +72 -0
- package/src/hooks/useRestaurant/helpers/index.ts +28 -0
- package/src/hooks/useRestaurant/helpers/manageStatusOpen.ts +26 -0
- package/src/hooks/useRestaurant/index.ts +71 -0
- package/src/hooks/useRestaurant/queries.ts +81 -0
- package/src/hooks/useRoads/index.ts +20 -0
- package/src/hooks/useRoads/queries.ts +13 -0
- package/src/hooks/useRoles/index.ts +4 -0
- package/src/hooks/useRoles/queries.ts +70 -0
- package/src/hooks/useRoles/useCreateRole.ts +40 -0
- package/src/hooks/useRoles/useGetRoles.ts +37 -0
- package/src/hooks/useRoles/useRemoveRoles.ts +40 -0
- package/src/hooks/useRoles/useUpdateRolesPriority.ts +44 -0
- package/src/hooks/useSales/helpers/add-product.utils.ts +120 -0
- package/src/hooks/useSales/helpers/apply-discount-to-cart.utils.ts +292 -0
- package/src/hooks/useSales/helpers/comment-product.utils.ts +41 -0
- package/src/hooks/useSales/helpers/constants/index.ts +38 -0
- package/src/hooks/useSales/helpers/extras.utils.ts +42 -0
- package/src/hooks/useSales/helpers/filterProductsByCarProId.utils.ts +17 -0
- package/src/hooks/useSales/helpers/increment-product-quantity.utils.ts +76 -0
- package/src/hooks/useSales/helpers/index.ts +3 -0
- package/src/hooks/useSales/helpers/initializer.utils.ts +22 -0
- package/src/hooks/useSales/helpers/isStockInsufficient.ts +3 -0
- package/src/hooks/useSales/helpers/remove-product.utils.test.ts +49 -0
- package/src/hooks/useSales/helpers/remove-product.utils.ts +34 -0
- package/src/hooks/useSales/helpers/resolveProduct.ts +29 -0
- package/src/hooks/useSales/helpers/useAddToCart.ts +64 -0
- package/src/hooks/useSales/index.ts +1418 -0
- package/src/hooks/useSales/queries.ts +532 -0
- package/src/hooks/useSales/types/index.ts +206 -0
- package/src/hooks/useSales/types/use-sales.types.ts +8 -0
- package/src/hooks/useSales/useGetSale.ts +21 -0
- package/src/hooks/useSales/useTotalSales.ts +24 -0
- package/src/hooks/useSaveAvailableProduct/helpers/index.ts +38 -0
- package/src/hooks/useSaveAvailableProduct/index.ts +32 -0
- package/src/hooks/useSaveAvailableProduct/queries.ts +10 -0
- package/src/hooks/useSaveLocation/index.ts +17 -0
- package/src/hooks/useSaveLocation/queries.ts +19 -0
- package/src/hooks/useSchedule/index.ts +35 -0
- package/src/hooks/useSchedule/queries.ts +43 -0
- package/src/hooks/useSchedule/schedule.ts +79 -0
- package/src/hooks/useScheduleData/index.ts +135 -0
- package/src/hooks/useScroll/index.ts +56 -0
- package/src/hooks/useScrollRotate/index.ts +16 -0
- package/src/hooks/useSetImageProducts/index.ts +59 -0
- package/src/hooks/useSetImageProducts/queries.ts +18 -0
- package/src/hooks/useSetSession/index.ts +44 -0
- package/src/hooks/useSetState/index.ts +24 -0
- package/src/hooks/useSetupSchedule/helpers/index.ts +85 -0
- package/src/hooks/useSetupSchedule/index.ts +284 -0
- package/src/hooks/useStatusOpenStore/helpers/index.ts +124 -0
- package/src/hooks/useStatusOpenStore/index.ts +195 -0
- package/src/hooks/useStatusOrdersClient/helpers/index.ts +14 -0
- package/src/hooks/useStatusOrdersClient/index.ts +18 -0
- package/src/hooks/useStatusOrdersClient/queries.ts +80 -0
- package/src/hooks/useStock/index.ts +1 -0
- package/src/hooks/useStock/useStockUpdatedAllSubscription.ts +40 -0
- package/src/hooks/useStockMovements/helpers/index.ts +16 -0
- package/src/hooks/useStockMovements/index.ts +39 -0
- package/src/hooks/useStore/index.ts +83 -0
- package/src/hooks/useStore/queries.ts +163 -0
- package/src/hooks/useStoreCalendar/index.ts +5 -0
- package/src/hooks/useStoreContacts/index.ts +53 -0
- package/src/hooks/useStoreContacts/queries.ts +48 -0
- package/src/hooks/useStoreTable/index.ts +2 -0
- package/src/hooks/useStoreTable/queries.ts +47 -0
- package/src/hooks/useStoreTable/useStoreTableCreate.ts +77 -0
- package/src/hooks/useStoreTable/useStoreTables.ts +15 -0
- package/src/hooks/useSubscriptionValidation/index.ts +112 -0
- package/src/hooks/useTagProducts/index.ts +3 -0
- package/src/hooks/useTagProducts/useDeleteOneTag.ts +106 -0
- package/src/hooks/useTagProducts/useGetAllTags.ts +68 -0
- package/src/hooks/useTagProducts/useRegisterMultipleTags.ts +157 -0
- package/src/hooks/useTheme/index.ts +65 -0
- package/src/hooks/useTimeAgo/useTimeAgo.ts +39 -0
- package/src/hooks/useTokenCards/index.ts +45 -0
- package/src/hooks/useTopProductsMovements/index.ts +27 -0
- package/src/hooks/useTotalAllSales/index.ts +25 -0
- package/src/hooks/useTotalProductsInStock/index.ts +23 -0
- package/src/hooks/useTotalProductsSold/index.ts +23 -0
- package/src/hooks/useTotalProductsSolded/index.ts +20 -0
- package/src/hooks/useUpdateCart/index.ts +131 -0
- package/src/hooks/useUpdateCartCookie/index.ts +60 -0
- package/src/hooks/useUpdateDashboardComponent/index.ts +91 -0
- package/src/hooks/useUpdateExistingOrders/index.ts +85 -0
- package/src/hooks/useUpdateExtProductFoodsSubOptional/index.ts +61 -0
- package/src/hooks/useUpdateModuleOrder/index.ts +37 -0
- package/src/hooks/useUpdateMultipleExtProduct/index.ts +34 -0
- package/src/hooks/useUpdateMultipleExtProduct/queries.ts +33 -0
- package/src/hooks/useUpdateMultipleProducts/index.ts +117 -0
- package/src/hooks/useUpdateMultipleProducts/queries.ts +51 -0
- package/src/hooks/useUploadProducts/helpers/index.ts +1 -0
- package/src/hooks/useUploadProducts/helpers/parseNumber.ts +37 -0
- package/src/hooks/useUploadProducts/helpers/validateProductDataExcel.ts +73 -0
- package/src/hooks/useUploadProducts/index.ts +442 -0
- package/src/hooks/useUpsertGoal/index.ts +68 -0
- package/src/hooks/useUser/index.ts +24 -0
- package/src/hooks/useUser/queries.ts +131 -0
- package/src/hooks/useWeeklyStockMovement/helpers/index.ts +32 -0
- package/src/hooks/useWeeklyStockMovement/index.ts +52 -0
- package/src/hooks/useWindowSize/index.ts +45 -0
- package/src/index.ts +13 -0
- package/src/mock/dessert/index.ts +16 -0
- package/src/mock/index.ts +1 -0
- package/src/security/index.ts +1 -0
- package/src/services/index.ts +1 -0
- package/src/utils/UtilDateRange.ts +56 -0
- package/src/utils/generateCode.ts +222 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/utils.ts +344 -0
- package/tsconfig.eslint.json +16 -0
- package/tsconfig.json +21 -0
- package/tsup.config.ts +24 -0
- package/dist/index.cjs +0 -20089
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useCallback,
|
|
3
|
+
useEffect,
|
|
4
|
+
useState
|
|
5
|
+
} from 'react'
|
|
6
|
+
|
|
7
|
+
import { validationSubmitHooks } from '../../utils'
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
interface UseFormToolsProps {
|
|
11
|
+
initialValues?: Record<string, any>;
|
|
12
|
+
sendNotification?: ({
|
|
13
|
+
title,
|
|
14
|
+
description,
|
|
15
|
+
backgroundColor
|
|
16
|
+
}: {
|
|
17
|
+
title?: string;
|
|
18
|
+
description?: string;
|
|
19
|
+
backgroundColor?: string;
|
|
20
|
+
}) => void;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @param root0
|
|
25
|
+
* @param root0.initialValues
|
|
26
|
+
* @param root0.sendNotification
|
|
27
|
+
* @version 0.0.1
|
|
28
|
+
* @description Hook con herramientas de validación y eventos de cambio
|
|
29
|
+
* @return {Array} devuelve la función onChange a ejecutar y el estado de error de cada input
|
|
30
|
+
*/
|
|
31
|
+
export const useFormTools = ({
|
|
32
|
+
initialValues = {},
|
|
33
|
+
sendNotification = ({
|
|
34
|
+
title = '',
|
|
35
|
+
description = '',
|
|
36
|
+
backgroundColor = ''
|
|
37
|
+
}) => {
|
|
38
|
+
console.log({ title, description, backgroundColor })
|
|
39
|
+
}
|
|
40
|
+
}: UseFormToolsProps = {}) => {
|
|
41
|
+
const [dataForm, setDataForm] = useState<Record<string, any>>({ ...initialValues })
|
|
42
|
+
const [errorForm, setErrorForm] = useState<Record<string, boolean>>({})
|
|
43
|
+
const [errorSubmit, setErrorSubmit] = useState(false)
|
|
44
|
+
const [calledSubmit, setCalledSubmit] = useState(false)
|
|
45
|
+
// Handle Change
|
|
46
|
+
const handleChange = useCallback((e: React.ChangeEvent<HTMLInputElement>, error: boolean) => {
|
|
47
|
+
setDataForm({ ...dataForm, [e.target.name]: e.target.value })
|
|
48
|
+
setErrorForm({ ...errorForm, [e.target.name]: error })
|
|
49
|
+
}, [setDataForm, dataForm, errorForm, setErrorForm])
|
|
50
|
+
|
|
51
|
+
// Forzar datos desde una ventana externa
|
|
52
|
+
const handleForcedData = useCallback((data: Record<string, any>) => {
|
|
53
|
+
setDataForm(data)
|
|
54
|
+
}, [setDataForm])
|
|
55
|
+
|
|
56
|
+
// Forzar datos de error desde una ventana externa
|
|
57
|
+
const setForcedError = useCallback((errors: Record<string, boolean>) => {
|
|
58
|
+
setErrorForm(errors)
|
|
59
|
+
}, [setErrorForm])
|
|
60
|
+
|
|
61
|
+
// Handle submit, al enviar formulario
|
|
62
|
+
const listErrors = Object.values(errorForm)
|
|
63
|
+
const errors = listErrors.find((error) => {
|
|
64
|
+
return error === true
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
const handleSubmit = ({
|
|
68
|
+
event,
|
|
69
|
+
msgError = '',
|
|
70
|
+
msgSuccess,
|
|
71
|
+
action = () => { return Promise.resolve() },
|
|
72
|
+
actionAfterSuccess = () => { }
|
|
73
|
+
}: {
|
|
74
|
+
event: React.FormEvent<HTMLFormElement>,
|
|
75
|
+
msgError?: string,
|
|
76
|
+
msgSuccess?: string,
|
|
77
|
+
action?: () => Promise<any>,
|
|
78
|
+
actionAfterSuccess?: () => void
|
|
79
|
+
}) => {
|
|
80
|
+
event.preventDefault()
|
|
81
|
+
setCalledSubmit(true)
|
|
82
|
+
let errSub = false
|
|
83
|
+
|
|
84
|
+
// Valida los errores locales
|
|
85
|
+
for (const x in errorForm) {
|
|
86
|
+
if (errorForm[x]) errSub = true
|
|
87
|
+
}
|
|
88
|
+
if (errSub) {
|
|
89
|
+
sendNotification({
|
|
90
|
+
description: 'Completa los campos requeridos',
|
|
91
|
+
title: 'Error',
|
|
92
|
+
backgroundColor: 'error'
|
|
93
|
+
})
|
|
94
|
+
}
|
|
95
|
+
if (errors) {
|
|
96
|
+
setErrorSubmit(true)
|
|
97
|
+
return setForcedError({ ...errorForm })
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (errSub) return setErrorSubmit(errSub)
|
|
101
|
+
|
|
102
|
+
// Valida los errores desde el evento
|
|
103
|
+
const errores = validationSubmitHooks(event.currentTarget.elements)
|
|
104
|
+
setErrorForm(errores)
|
|
105
|
+
for (const x in errores) {
|
|
106
|
+
// @ts-ignore
|
|
107
|
+
if (errores[x]) errSub = true
|
|
108
|
+
}
|
|
109
|
+
if (errSub) return setErrorSubmit(errSub)
|
|
110
|
+
|
|
111
|
+
// Ejecuta la accion si es válido
|
|
112
|
+
if (!errSub && typeof action === 'function') {
|
|
113
|
+
const result = action()
|
|
114
|
+
if (result && typeof result.then === 'function') {
|
|
115
|
+
result.then((res) => {
|
|
116
|
+
if (res) {
|
|
117
|
+
sendNotification({
|
|
118
|
+
title: msgSuccess ?? 'Operación exitosa',
|
|
119
|
+
description: 'Operación exitosa',
|
|
120
|
+
backgroundColor: 'success'
|
|
121
|
+
})
|
|
122
|
+
if (actionAfterSuccess) actionAfterSuccess()
|
|
123
|
+
}
|
|
124
|
+
}).catch((e) => {
|
|
125
|
+
sendNotification({
|
|
126
|
+
title: msgError || e?.message || 'Ha ocurrido un error',
|
|
127
|
+
backgroundColor: 'error'
|
|
128
|
+
})
|
|
129
|
+
})
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
setErrorSubmit(errSub)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
useEffect(() => { return setCalledSubmit(false) }, [calledSubmit])
|
|
137
|
+
useEffect(() => {
|
|
138
|
+
return setCalledSubmit(false)
|
|
139
|
+
},
|
|
140
|
+
[])
|
|
141
|
+
|
|
142
|
+
return [handleChange, handleSubmit, handleForcedData, { dataForm, errorForm, errorSubmit, calledSubmit, setForcedError }]
|
|
143
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
interface UseFormatDateProps {
|
|
2
|
+
date?: string | number | Date;
|
|
3
|
+
local?: string;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export const useFormatDate = ({
|
|
7
|
+
date,
|
|
8
|
+
local = 'ES-CO'
|
|
9
|
+
}: UseFormatDateProps = {}) => {
|
|
10
|
+
const dateToFormat = new Date(date ?? Date.now())
|
|
11
|
+
const fullDate = dateToFormat.toLocaleDateString(local, { year: 'numeric', month: '2-digit', day: '2-digit' })
|
|
12
|
+
const day = fullDate.split('/')[0]
|
|
13
|
+
const month = fullDate.split('/')[1]
|
|
14
|
+
const year = fullDate.split('/')[2]
|
|
15
|
+
const yearMonthDay = dateToFormat.toLocaleDateString('ES-CO')
|
|
16
|
+
const numberDay = dateToFormat.getDay()
|
|
17
|
+
const shortDayName = dateToFormat.toLocaleDateString(local, { weekday: 'short' })
|
|
18
|
+
const longDayName = dateToFormat.toLocaleDateString(local, { weekday: 'long' })
|
|
19
|
+
const hourMinutes12 = dateToFormat.toLocaleTimeString('ES-CO', { hour: '2-digit', minute: '2-digit' })
|
|
20
|
+
const hourMinutes24 = dateToFormat.toLocaleTimeString('ES-CO', { hour: '2-digit', minute: '2-digit', hour12: false })
|
|
21
|
+
const handleHourPmAM = (hour: string) => {
|
|
22
|
+
const hourPmAm = new Date(`1/1/1999 ${hour}`).toLocaleString('en-US', { hour: 'numeric', minute: 'numeric', hour12: true })
|
|
23
|
+
return hour ? hourPmAm : ''
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Formats a date into Colombian time zone and Spanish locale for POS display.
|
|
27
|
+
* Example output: "15 de mayo de 2025 a las 14:23"
|
|
28
|
+
*
|
|
29
|
+
* @param {string | number | Date} dateInput - Date to format (ISO string, timestamp or Date object)
|
|
30
|
+
* @returns {string} - Formatted date string in Colombian time
|
|
31
|
+
*/
|
|
32
|
+
function formatDateInTimeZone (dateInput : string | number | Date): string {
|
|
33
|
+
const timeZone = 'America/Bogota'
|
|
34
|
+
const locale = 'es-CO'
|
|
35
|
+
const options: Intl.DateTimeFormatOptions = {
|
|
36
|
+
timeZone,
|
|
37
|
+
year: 'numeric',
|
|
38
|
+
month: 'long',
|
|
39
|
+
day: '2-digit',
|
|
40
|
+
hour: '2-digit',
|
|
41
|
+
minute: '2-digit',
|
|
42
|
+
hour12: false
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const date = new Date(dateInput)
|
|
46
|
+
const formatted = new Intl.DateTimeFormat(locale, options).format(date)
|
|
47
|
+
|
|
48
|
+
// Cambiar coma por "a las" para mejor legibilidad
|
|
49
|
+
return formatted.replace(',', ' a las')
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Formats a date into YYYY-MM-DD using a given IANA timezone.
|
|
53
|
+
*
|
|
54
|
+
* @param {string | number | Date} inputDate - The date to format.
|
|
55
|
+
* @param {string} timeZone - IANA timezone string (default is "America/Bogota").
|
|
56
|
+
* @returns {string} Formatted date string in YYYY-MM-DD.
|
|
57
|
+
* @throws {Error} If the input date is invalid.
|
|
58
|
+
*/
|
|
59
|
+
const formatToLocalDateYMD = (inputDate: string | number | Date, timeZone = 'America/Bogota') => {
|
|
60
|
+
const date = new Date(inputDate)
|
|
61
|
+
|
|
62
|
+
if (isNaN(date.getTime())) {
|
|
63
|
+
throw new Error('Invalid date input provided to formatToLocalDateYMD')
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const localDateStr = date.toLocaleString('en-US', { timeZone })
|
|
67
|
+
const localDate = new Date(localDateStr)
|
|
68
|
+
|
|
69
|
+
const year = localDate.getFullYear()
|
|
70
|
+
const month = String(localDate.getMonth() + 1).padStart(2, '0')
|
|
71
|
+
const day = String(localDate.getDate()).padStart(2, '0')
|
|
72
|
+
|
|
73
|
+
return `${year}-${month}-${day}`
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return {
|
|
77
|
+
day,
|
|
78
|
+
fullDate,
|
|
79
|
+
formatToLocalDateYMD,
|
|
80
|
+
hourMinutes12,
|
|
81
|
+
numberDay,
|
|
82
|
+
yearMonthDay,
|
|
83
|
+
hourMinutes24,
|
|
84
|
+
longDayName,
|
|
85
|
+
shortDayName,
|
|
86
|
+
month,
|
|
87
|
+
year,
|
|
88
|
+
handleHourPmAM,
|
|
89
|
+
formatDateInTimeZone
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Description
|
|
3
|
+
* @param {any} phoneNumber type number or string
|
|
4
|
+
* @returns {any}
|
|
5
|
+
*/
|
|
6
|
+
export const formatPhoneNumber = (phoneNumber) => {
|
|
7
|
+
const cleaned = ('' + phoneNumber).replace(/\D/g, '')
|
|
8
|
+
const match = cleaned.match(/^(\d{3})(\d{3})(\d{4})$/)
|
|
9
|
+
if (match) {
|
|
10
|
+
return `(${match[1]}) ${match[2]}-${match[3]}`
|
|
11
|
+
}
|
|
12
|
+
return phoneNumber
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Description
|
|
17
|
+
* @param {any} phoneNumber type number or string
|
|
18
|
+
* @returns {any}
|
|
19
|
+
*/
|
|
20
|
+
export const validatePhoneNumber = (phoneNumber) => {
|
|
21
|
+
const regex = /^\(\d{3}\) \d{3}-\d{4}$/
|
|
22
|
+
return regex.test(phoneNumber)
|
|
23
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React, { useState, useRef, useEffect } from 'react'
|
|
2
|
+
|
|
3
|
+
export const useFullscreenMode = () => {
|
|
4
|
+
const [isFullscreen, setFullscreen] = useState(false)
|
|
5
|
+
const elementRef = useRef()
|
|
6
|
+
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
const changeHandler = () => { return setFullscreen(mode => { return !mode }) }
|
|
9
|
+
|
|
10
|
+
document.addEventListener('fullscreenchange', changeHandler, false)
|
|
11
|
+
document.addEventListener('mozfullscreenchange', changeHandler, false)
|
|
12
|
+
document.addEventListener('MSFullScreenChange', changeHandler, false)
|
|
13
|
+
document.addEventListener(
|
|
14
|
+
'webkitfullscreenchange',
|
|
15
|
+
changeHandler,
|
|
16
|
+
false
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
return () => {
|
|
20
|
+
document.removeEventListener('fullscreenchange', changeHandler)
|
|
21
|
+
document.removeEventListener('mozfullscreenchange', changeHandler)
|
|
22
|
+
document.removeEventListener('MSFullScreenChange', changeHandler)
|
|
23
|
+
document.removeEventListener(
|
|
24
|
+
'webkitfullscreenchange',
|
|
25
|
+
changeHandler
|
|
26
|
+
)
|
|
27
|
+
}
|
|
28
|
+
}, [])
|
|
29
|
+
|
|
30
|
+
const goFullscreen = () => {
|
|
31
|
+
if (elementRef.current.requestFullscreen) {
|
|
32
|
+
elementRef.current.requestFullscreen()
|
|
33
|
+
} else if (elementRef.current.mozRequestFullscreen) {
|
|
34
|
+
// Firefox
|
|
35
|
+
elementRef.current.mozRequestFullscreen()
|
|
36
|
+
} else if (elementRef.current.webkitRequestFullscreen) {
|
|
37
|
+
// Chrome, safari, opera
|
|
38
|
+
elementRef.current.webkitRequestFullscreen()
|
|
39
|
+
} else if (elementRef.current.msRequestFullscreen) {
|
|
40
|
+
// IE, edge
|
|
41
|
+
elementRef.current.msRequestFullscreen()
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const exitFullScreen = () => {
|
|
46
|
+
if (document.exitFullscreen) {
|
|
47
|
+
document.exitFullscreen()
|
|
48
|
+
} else if (document.mozCancelFullScreen) {
|
|
49
|
+
document.mozCancelFullScreen()
|
|
50
|
+
} else if (document.webkitExitFullscreen) {
|
|
51
|
+
document.webkitExitFullscreen()
|
|
52
|
+
} else if (document.msExitFullscreen) {
|
|
53
|
+
document.msExitFullscreen()
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const ToggleIcon = (
|
|
58
|
+
<button onDoubleClick={() => { return (!isFullscreen ? goFullscreen() : exitFullScreen()) }}>{!isFullscreen ? 'FullScreen' : 'Normal'}</button>
|
|
59
|
+
)
|
|
60
|
+
return [elementRef, ToggleIcon] // Icon, ref
|
|
61
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const addButtonValues = (values, max) => {
|
|
2
|
+
const value1 = values.splice(Math.floor(Math.random() * (max - 0)) + 0, 1)
|
|
3
|
+
return { max: max - 2, values: [value1] }
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export const useGenerateNumberArray = () => {
|
|
7
|
+
const values = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
|
8
|
+
let max = 9
|
|
9
|
+
const buttons = Array.from(Array(10)).map(() => {
|
|
10
|
+
return Array.from(Array(1)).map(() => {
|
|
11
|
+
const buttonValues = addButtonValues(values, max)
|
|
12
|
+
max = buttonValues.max
|
|
13
|
+
return buttonValues.values
|
|
14
|
+
})
|
|
15
|
+
})
|
|
16
|
+
return buttons
|
|
17
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useQuery } from '@apollo/client'
|
|
2
|
+
|
|
3
|
+
import { GET_ALL_LOCATIONS } from './queries'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* useGetAllLocationUser
|
|
7
|
+
* @returns {any}
|
|
8
|
+
*/
|
|
9
|
+
export const useGetAllLocationUser = () => {
|
|
10
|
+
const { data, loading } = useQuery(GET_ALL_LOCATIONS)
|
|
11
|
+
|
|
12
|
+
return [data, { loading }]
|
|
13
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { gql } from '@apollo/client'
|
|
2
|
+
|
|
3
|
+
export const GET_ALL_LOCATIONS = gql`
|
|
4
|
+
|
|
5
|
+
query getUserLocations {
|
|
6
|
+
getUserLocations {
|
|
7
|
+
locationId
|
|
8
|
+
# id
|
|
9
|
+
cId
|
|
10
|
+
dId
|
|
11
|
+
ctId
|
|
12
|
+
uLatitud
|
|
13
|
+
uLongitude
|
|
14
|
+
uLocationKnow
|
|
15
|
+
uPiso
|
|
16
|
+
DatCre
|
|
17
|
+
DatMod
|
|
18
|
+
pais {
|
|
19
|
+
cId
|
|
20
|
+
cName
|
|
21
|
+
cCalCod
|
|
22
|
+
cState
|
|
23
|
+
cDatCre
|
|
24
|
+
cDatMod
|
|
25
|
+
}
|
|
26
|
+
city {
|
|
27
|
+
ctId
|
|
28
|
+
dId
|
|
29
|
+
cName
|
|
30
|
+
cState
|
|
31
|
+
cDatCre
|
|
32
|
+
cDatMod
|
|
33
|
+
}
|
|
34
|
+
department {
|
|
35
|
+
dId
|
|
36
|
+
cId
|
|
37
|
+
dName
|
|
38
|
+
dState
|
|
39
|
+
dDatCre
|
|
40
|
+
dDatMod
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
`
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useQuery } from '@apollo/client'
|
|
2
|
+
|
|
3
|
+
import { GET_ALL_SALES_STATISTICS } from '../useSales/queries'
|
|
4
|
+
|
|
5
|
+
export const useGetAllSales = ({
|
|
6
|
+
fromDate = '',
|
|
7
|
+
toDate = ''
|
|
8
|
+
} = {}) => {
|
|
9
|
+
const {
|
|
10
|
+
data,
|
|
11
|
+
loading,
|
|
12
|
+
error
|
|
13
|
+
} = useQuery(GET_ALL_SALES_STATISTICS, {
|
|
14
|
+
fetchPolicy: 'cache-first',
|
|
15
|
+
variables: {
|
|
16
|
+
fromDate,
|
|
17
|
+
toDate
|
|
18
|
+
}
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
data: data?.getAllSalesStoreStatistic || [],
|
|
23
|
+
error,
|
|
24
|
+
loading
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import Cookies from 'js-cookie'
|
|
2
|
+
|
|
3
|
+
export const useGetCookies = () => {
|
|
4
|
+
const getCookies = (cookieNames) => {
|
|
5
|
+
try {
|
|
6
|
+
if (!Array.isArray(cookieNames)) {
|
|
7
|
+
throw new Error('Input cookie names should be an array.')
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const cookiesData = []
|
|
11
|
+
|
|
12
|
+
for (const cookieName of cookieNames) {
|
|
13
|
+
const cookieValue = Cookies.get(cookieName)
|
|
14
|
+
if (cookieValue) {
|
|
15
|
+
cookiesData.push({ name: cookieName, value: cookieValue })
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return cookiesData
|
|
19
|
+
} catch (error) {
|
|
20
|
+
console.error('Error al traer las cookies:', error)
|
|
21
|
+
return []
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const getCookie = (cookieName) => {
|
|
26
|
+
try {
|
|
27
|
+
if (typeof cookieName !== 'string') {
|
|
28
|
+
throw new Error('Input cookie name should be a string.')
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const cookieValue = Cookies.get(cookieName)
|
|
32
|
+
if (cookieValue) {
|
|
33
|
+
return { name: cookieName, value: cookieValue }
|
|
34
|
+
}
|
|
35
|
+
return null
|
|
36
|
+
} catch (error) {
|
|
37
|
+
console.error('Error al traer la cookie:', error)
|
|
38
|
+
return null
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return { getCookies, getCookie }
|
|
43
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useLazyQuery } from '@apollo/client'
|
|
2
|
+
|
|
3
|
+
import { GET_EXTRAS_PRODUCT_FOOD_OPTIONAL } from '../useProductsFood/queriesStore'
|
|
4
|
+
|
|
5
|
+
export const useGetExtProductFoodsSubOptionalAll = ({ setDataOptional = () => { } } = {}) => {
|
|
6
|
+
const [ExtProductFoodsSubOptionalAll] = useLazyQuery(
|
|
7
|
+
GET_EXTRAS_PRODUCT_FOOD_OPTIONAL,
|
|
8
|
+
{
|
|
9
|
+
onError: () => {
|
|
10
|
+
setDataOptional([])
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
)
|
|
14
|
+
return [ExtProductFoodsSubOptionalAll]
|
|
15
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useQuery } from '@apollo/client'
|
|
2
|
+
|
|
3
|
+
import { GET_ALL_PRODUCT_STORE_RECOMENDED } from './queries'
|
|
4
|
+
|
|
5
|
+
export const useGetFoodRecomended = ({
|
|
6
|
+
name = ''
|
|
7
|
+
}) => {
|
|
8
|
+
const {
|
|
9
|
+
data,
|
|
10
|
+
called,
|
|
11
|
+
fetchMore,
|
|
12
|
+
loading,
|
|
13
|
+
error
|
|
14
|
+
} = useQuery(GET_ALL_PRODUCT_STORE_RECOMENDED, {
|
|
15
|
+
fetchPolicy: 'cache-and-network',
|
|
16
|
+
skip: !name,
|
|
17
|
+
notifyOnNetworkStatusChange: true,
|
|
18
|
+
nextFetchPolicy: 'cache-first',
|
|
19
|
+
refetchWritePolicy: 'merge',
|
|
20
|
+
variables:
|
|
21
|
+
{
|
|
22
|
+
max: 6,
|
|
23
|
+
search: name
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
return [data?.productFoodsAllRecommended, {
|
|
28
|
+
called,
|
|
29
|
+
fetchMore,
|
|
30
|
+
loading,
|
|
31
|
+
error
|
|
32
|
+
}]
|
|
33
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { gql } from '@apollo/client'
|
|
2
|
+
|
|
3
|
+
export const GET_ALL_PRODUCT_STORE_RECOMENDED = gql`
|
|
4
|
+
query productFoodsAllRecommended($search: String, $min: Int, $max: Int, $gender: [String], $desc: [String], $categories: [ID], ) {
|
|
5
|
+
productFoodsAllRecommended(search: $search, min: $min, max: $max, gender: $gender, desc: $desc, categories: $categories,) {
|
|
6
|
+
pId
|
|
7
|
+
sizeId #Talla
|
|
8
|
+
colorId #Color
|
|
9
|
+
cId #Country
|
|
10
|
+
dId #Department
|
|
11
|
+
ctId #Cuidad
|
|
12
|
+
fId #Características
|
|
13
|
+
pName
|
|
14
|
+
ProPrice
|
|
15
|
+
ProDescuento
|
|
16
|
+
ProUniDisponibles
|
|
17
|
+
ProDescription
|
|
18
|
+
ProProtegido
|
|
19
|
+
ProAssurance
|
|
20
|
+
ProStar
|
|
21
|
+
sTateLogistic
|
|
22
|
+
ProImage
|
|
23
|
+
ProWidth
|
|
24
|
+
ProHeight
|
|
25
|
+
ProLength
|
|
26
|
+
ProWeight
|
|
27
|
+
ProQuantity
|
|
28
|
+
ProOutstanding
|
|
29
|
+
pDatCre
|
|
30
|
+
pDatMod
|
|
31
|
+
ProDelivery
|
|
32
|
+
ProVoltaje
|
|
33
|
+
pState
|
|
34
|
+
feat {
|
|
35
|
+
fId
|
|
36
|
+
thpId
|
|
37
|
+
hpqrQuestion
|
|
38
|
+
}
|
|
39
|
+
area {
|
|
40
|
+
aId
|
|
41
|
+
aName
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
`
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useQuery, gql } from '@apollo/client'
|
|
2
|
+
|
|
3
|
+
// Define la consulta GraphQL
|
|
4
|
+
const GET_MESSAGES = gql`
|
|
5
|
+
query getMessages($codeRoom: String!, $id: String!) {
|
|
6
|
+
getMessages(codeRoom: $codeRoom, id: $id) {
|
|
7
|
+
uuid
|
|
8
|
+
content
|
|
9
|
+
from
|
|
10
|
+
to
|
|
11
|
+
aDatCre
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
`
|
|
15
|
+
|
|
16
|
+
export const useGetMessagesToRoom = (codeRoom, id) => {
|
|
17
|
+
const { loading, error, data } = useQuery(GET_MESSAGES, {
|
|
18
|
+
context: { clientName: 'web-socket-chat' },
|
|
19
|
+
variables: { codeRoom, id }
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
return [data?.getMessages ?? [], { loading, error }]
|
|
23
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useQuery } from '@apollo/client'
|
|
2
|
+
|
|
3
|
+
import { GET_MIN_PEDIDO } from './queries'
|
|
4
|
+
|
|
5
|
+
export const useGetMinPrice = ({ idStore = '' } = {}) => {
|
|
6
|
+
const { data, loading, error } = useQuery(GET_MIN_PEDIDO, {
|
|
7
|
+
variables: {
|
|
8
|
+
idStore
|
|
9
|
+
}
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
return [data, { loading, error }]
|
|
13
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useLazyQuery } from '@apollo/client'
|
|
2
|
+
import { useState } from 'react'
|
|
3
|
+
|
|
4
|
+
import { GET_ONE_RATING_STORE } from './queries'
|
|
5
|
+
|
|
6
|
+
export const useGetOneStoreRating = () => {
|
|
7
|
+
const [ratings, setRatings] = useState({
|
|
8
|
+
rGoodTemperature: 0,
|
|
9
|
+
rGoodCondition: 0,
|
|
10
|
+
rTasty: 0,
|
|
11
|
+
appearance: 0
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
const [getOneRating] = useLazyQuery(GET_ONE_RATING_STORE, {
|
|
15
|
+
onCompleted: res => {
|
|
16
|
+
if (res) {
|
|
17
|
+
setRatings((prevState) => {
|
|
18
|
+
const {
|
|
19
|
+
rGoodTemperature,
|
|
20
|
+
rGoodCondition,
|
|
21
|
+
rTasty,
|
|
22
|
+
rAppearance
|
|
23
|
+
} = res.getOneRating || {}
|
|
24
|
+
return {
|
|
25
|
+
...prevState,
|
|
26
|
+
rGoodTemperature: rGoodTemperature || 0,
|
|
27
|
+
rGoodCondition: rGoodCondition || 0,
|
|
28
|
+
rTasty: rTasty || 0,
|
|
29
|
+
appearance: rAppearance || 0
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
ratings,
|
|
38
|
+
setRatings,
|
|
39
|
+
getOneRating
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { gql } from '@apollo/client'
|
|
2
|
+
|
|
3
|
+
export const GET_ONE_RATING_STORE = gql`
|
|
4
|
+
query getOneRating($idStore: ID){
|
|
5
|
+
getOneRating(idStore: $idStore){
|
|
6
|
+
idStore
|
|
7
|
+
rId
|
|
8
|
+
id
|
|
9
|
+
rAppearance
|
|
10
|
+
rTasty
|
|
11
|
+
rGoodTemperature
|
|
12
|
+
rGoodCondition
|
|
13
|
+
rState
|
|
14
|
+
createAt
|
|
15
|
+
updateAt
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
`
|