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,215 @@
|
|
|
1
|
+
import { gql } from '@apollo/client'
|
|
2
|
+
|
|
3
|
+
export const CREATE_CLIENTS = gql`
|
|
4
|
+
mutation createClients ($input: IClients) {
|
|
5
|
+
createClients(input: $input) {
|
|
6
|
+
success
|
|
7
|
+
message
|
|
8
|
+
errors {
|
|
9
|
+
path
|
|
10
|
+
message
|
|
11
|
+
type
|
|
12
|
+
context {
|
|
13
|
+
limit
|
|
14
|
+
value
|
|
15
|
+
label
|
|
16
|
+
key
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
data {
|
|
20
|
+
cliId
|
|
21
|
+
idStore
|
|
22
|
+
idUser
|
|
23
|
+
clState
|
|
24
|
+
ClientAddress
|
|
25
|
+
clientNumber
|
|
26
|
+
ccClient
|
|
27
|
+
gender
|
|
28
|
+
clientLastName
|
|
29
|
+
clientName
|
|
30
|
+
default
|
|
31
|
+
createAt
|
|
32
|
+
updateAt
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
`
|
|
37
|
+
export const DELETE_ONE_CLIENTS = gql`
|
|
38
|
+
mutation deleteClient($cliId: ID, $clState: Int!) {
|
|
39
|
+
deleteClient(cliId: $cliId, clState: $clState) {
|
|
40
|
+
success
|
|
41
|
+
message
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
`
|
|
45
|
+
export const GET_ALL_CLIENTS = gql`
|
|
46
|
+
query getAllClients($idStore: ID, $search: String, $min: Int, $max: Int, $fromDate: DateTime, $toDate: DateTime, $page: Int) {
|
|
47
|
+
getAllClients(idStore: $idStore, search: $search, min: $min, max: $max, fromDate: $fromDate, toDate: $toDate, page: $page) {
|
|
48
|
+
success
|
|
49
|
+
message
|
|
50
|
+
data {
|
|
51
|
+
cliId
|
|
52
|
+
idStore
|
|
53
|
+
gender
|
|
54
|
+
clState
|
|
55
|
+
clientNumber
|
|
56
|
+
ccClient
|
|
57
|
+
clientLastName
|
|
58
|
+
|
|
59
|
+
clientName
|
|
60
|
+
default
|
|
61
|
+
createAt
|
|
62
|
+
updateAt
|
|
63
|
+
}
|
|
64
|
+
pagination {
|
|
65
|
+
totalRecords
|
|
66
|
+
totalPages
|
|
67
|
+
currentPage
|
|
68
|
+
}
|
|
69
|
+
errors {
|
|
70
|
+
path
|
|
71
|
+
message
|
|
72
|
+
type
|
|
73
|
+
context {
|
|
74
|
+
limit
|
|
75
|
+
value
|
|
76
|
+
label
|
|
77
|
+
key
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
`
|
|
85
|
+
export const GET_ONE_CLIENT = gql`
|
|
86
|
+
query getOneClients($cliId: ID) {
|
|
87
|
+
getOneClients(cliId: $cliId) {
|
|
88
|
+
cliId
|
|
89
|
+
idStore
|
|
90
|
+
idUser
|
|
91
|
+
clState
|
|
92
|
+
clientNumber
|
|
93
|
+
ClientAddress
|
|
94
|
+
gender
|
|
95
|
+
ccClient
|
|
96
|
+
clientLastName
|
|
97
|
+
clientName
|
|
98
|
+
default
|
|
99
|
+
createAt
|
|
100
|
+
updateAt
|
|
101
|
+
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
`
|
|
105
|
+
|
|
106
|
+
export const EDIT_ONE_CLIENT = gql`
|
|
107
|
+
mutation editOneClient($input: IClients) {
|
|
108
|
+
editOneClient(input: $input) {
|
|
109
|
+
success
|
|
110
|
+
message
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
`
|
|
114
|
+
|
|
115
|
+
export const CREATE_SHOPPING_CARD = gql`
|
|
116
|
+
mutation registerShoppingCard($input: IShoppingCard, $idSubArray: IID_SUB_ITEMS){
|
|
117
|
+
registerShoppingCard(input: $input, idSubArray: $idSubArray){
|
|
118
|
+
ShoppingCard
|
|
119
|
+
id
|
|
120
|
+
pId
|
|
121
|
+
subProductsId
|
|
122
|
+
ShoppingCardRefCode
|
|
123
|
+
uuid
|
|
124
|
+
discountCardProduct
|
|
125
|
+
idUser
|
|
126
|
+
cName
|
|
127
|
+
idStore
|
|
128
|
+
cState
|
|
129
|
+
cDatCre
|
|
130
|
+
cDatMod
|
|
131
|
+
csDescription
|
|
132
|
+
cantProducts
|
|
133
|
+
comments
|
|
134
|
+
# idSubArray
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
`
|
|
138
|
+
export const CREATE_SHOPPING_CARD_TO_USER_STORE = gql`
|
|
139
|
+
mutation registerSalesStore(
|
|
140
|
+
$input: [IShoppingCart]
|
|
141
|
+
$id: ID
|
|
142
|
+
$tableId: ID
|
|
143
|
+
$discount: DiscountInput
|
|
144
|
+
$idStore: ID
|
|
145
|
+
$pCodeRef: String
|
|
146
|
+
$change: Float
|
|
147
|
+
$shoppingCartRefCode: String
|
|
148
|
+
$payId: ID
|
|
149
|
+
$pickUp: Int
|
|
150
|
+
$totalProductsPrice: Float
|
|
151
|
+
$valueDelivery: Float
|
|
152
|
+
$idSubArray: IID_SUB_ITEMS
|
|
153
|
+
) {
|
|
154
|
+
registerSalesStore(
|
|
155
|
+
input: $input
|
|
156
|
+
id: $id
|
|
157
|
+
tableId: $tableId
|
|
158
|
+
discount: $discount
|
|
159
|
+
shoppingCartRefCode: $shoppingCartRefCode
|
|
160
|
+
idStore: $idStore
|
|
161
|
+
pCodeRef: $pCodeRef
|
|
162
|
+
change: $change
|
|
163
|
+
|
|
164
|
+
payId: $payId
|
|
165
|
+
pickUp: $pickUp
|
|
166
|
+
totalProductsPrice: $totalProductsPrice
|
|
167
|
+
valueDelivery: $valueDelivery
|
|
168
|
+
idSubArray: $idSubArray
|
|
169
|
+
) {
|
|
170
|
+
success
|
|
171
|
+
message
|
|
172
|
+
errors {
|
|
173
|
+
path
|
|
174
|
+
message
|
|
175
|
+
type
|
|
176
|
+
context {
|
|
177
|
+
limit
|
|
178
|
+
value
|
|
179
|
+
label
|
|
180
|
+
key
|
|
181
|
+
__typename
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
data {
|
|
185
|
+
pCodeRef
|
|
186
|
+
idStore
|
|
187
|
+
id
|
|
188
|
+
channel
|
|
189
|
+
payId
|
|
190
|
+
pSState
|
|
191
|
+
createdAt
|
|
192
|
+
updatedAt
|
|
193
|
+
unidProducts
|
|
194
|
+
totalProductsPrice
|
|
195
|
+
getOneStore {
|
|
196
|
+
idStore
|
|
197
|
+
cId
|
|
198
|
+
dId
|
|
199
|
+
catStore
|
|
200
|
+
scheduleOpenAll
|
|
201
|
+
dailyGoal
|
|
202
|
+
deliveryTimeMinutes
|
|
203
|
+
}
|
|
204
|
+
getUser {
|
|
205
|
+
id
|
|
206
|
+
name
|
|
207
|
+
email
|
|
208
|
+
createdAt
|
|
209
|
+
updatedAt
|
|
210
|
+
__typename
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
`
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
*/
|
|
4
|
+
class AleaGen {
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param seed
|
|
8
|
+
*/
|
|
9
|
+
constructor (seed) {
|
|
10
|
+
if (seed == null) { seed = +(new Date()) }
|
|
11
|
+
let n = 0xefc8249d
|
|
12
|
+
// Apply the seeding algorithm from Baagoe.
|
|
13
|
+
this.c = 1
|
|
14
|
+
this.s0 = mash(' ')
|
|
15
|
+
this.s1 = mash(' ')
|
|
16
|
+
this.s2 = mash(' ')
|
|
17
|
+
this.s0 -= mash(seed)
|
|
18
|
+
if (this.s0 < 0) {
|
|
19
|
+
this.s0 += 1
|
|
20
|
+
}
|
|
21
|
+
this.s1 -= mash(seed)
|
|
22
|
+
if (this.s1 < 0) {
|
|
23
|
+
this.s1 += 1
|
|
24
|
+
}
|
|
25
|
+
this.s2 -= mash(seed)
|
|
26
|
+
if (this.s2 < 0) {
|
|
27
|
+
this.s2 += 1
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
*
|
|
31
|
+
* @param data
|
|
32
|
+
*/
|
|
33
|
+
function mash (data) {
|
|
34
|
+
data = String(data)
|
|
35
|
+
for (let i = 0; i < data.length; i++) {
|
|
36
|
+
n += data.charCodeAt(i)
|
|
37
|
+
let h = 0.02519603282416938 * n
|
|
38
|
+
n = h >>> 0
|
|
39
|
+
h -= n
|
|
40
|
+
h *= n
|
|
41
|
+
n = h >>> 0
|
|
42
|
+
h -= n
|
|
43
|
+
n += h * 0x100000000 // 2^32
|
|
44
|
+
}
|
|
45
|
+
return (n >>> 0) * 2.3283064365386963e-10 // 2^-32
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
*
|
|
51
|
+
*/
|
|
52
|
+
next () {
|
|
53
|
+
const { c, s0, s1, s2 } = this
|
|
54
|
+
const t = 2091639 * s0 + c * 2.3283064365386963e-10 // 2^-32
|
|
55
|
+
this.s0 = s1
|
|
56
|
+
this.s1 = s2
|
|
57
|
+
return this.s2 = t - (this.c = t | 0)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
*
|
|
62
|
+
* @param f
|
|
63
|
+
* @param t
|
|
64
|
+
*/
|
|
65
|
+
copy (f, t) {
|
|
66
|
+
t.c = f.c
|
|
67
|
+
t.s0 = f.s0
|
|
68
|
+
t.s1 = f.s1
|
|
69
|
+
t.s2 = f.s2
|
|
70
|
+
return t
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
export default AleaGen
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export const BACKGROUND_COLORS = [
|
|
2
|
+
'#F7F9FC',
|
|
3
|
+
'#EEEDFD',
|
|
4
|
+
'#FFEBEE',
|
|
5
|
+
'#FDEFE2',
|
|
6
|
+
'#E7F9F3',
|
|
7
|
+
'#EDEEFD',
|
|
8
|
+
'#ECFAFE',
|
|
9
|
+
'#F2FFD1',
|
|
10
|
+
'#FFF7E0',
|
|
11
|
+
'#FDF1F7',
|
|
12
|
+
'#EAEFE6',
|
|
13
|
+
'#E0E6EB',
|
|
14
|
+
'#E4E2F3',
|
|
15
|
+
'#E6DFEC',
|
|
16
|
+
'#E2F4E8',
|
|
17
|
+
'#E6EBEF',
|
|
18
|
+
'#EBE6EF',
|
|
19
|
+
'#E8DEF6',
|
|
20
|
+
'#D8E8F3',
|
|
21
|
+
'#ECE1FE'
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
export const TEXT_COLORS = [
|
|
25
|
+
'#060A23',
|
|
26
|
+
'#4409B9',
|
|
27
|
+
'#BD0F2C',
|
|
28
|
+
'#C56511',
|
|
29
|
+
'#216E55',
|
|
30
|
+
'#05128A',
|
|
31
|
+
'#1F84A3',
|
|
32
|
+
'#526E0C',
|
|
33
|
+
'#935F10',
|
|
34
|
+
'#973562',
|
|
35
|
+
'#69785E',
|
|
36
|
+
'#2D3A46',
|
|
37
|
+
'#280F6D',
|
|
38
|
+
'#37364F',
|
|
39
|
+
'#363548',
|
|
40
|
+
'#4D176E',
|
|
41
|
+
'#AB133E',
|
|
42
|
+
'#420790',
|
|
43
|
+
'#222A54',
|
|
44
|
+
'#192251'
|
|
45
|
+
]
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import AleaGen from './alea.js'
|
|
2
|
+
import MersenneTwister from './mersenne_twister.js'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param opts
|
|
7
|
+
*/
|
|
8
|
+
function minMax (opts) {
|
|
9
|
+
const { random, min, max } = opts
|
|
10
|
+
return Math.floor(random * (max - min + 1) + min)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const randomNumber = (opts) => {
|
|
14
|
+
const { value, min, max } = opts
|
|
15
|
+
|
|
16
|
+
const prepareSeed = new AleaGen(value)
|
|
17
|
+
const seedOutput = prepareSeed.s1 * 10000000
|
|
18
|
+
|
|
19
|
+
const mersenne = new MersenneTwister(seedOutput)
|
|
20
|
+
|
|
21
|
+
return minMax({ random: mersenne.random(), min, max })
|
|
22
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
const MersenneTwister = function (seed) {
|
|
2
|
+
if (seed === undefined) {
|
|
3
|
+
// kept random number same size as time used previously to ensure no unexpected results downstream
|
|
4
|
+
seed = Math.floor(Math.random() * Math.pow(10, 13))
|
|
5
|
+
}
|
|
6
|
+
/* Period parameters */
|
|
7
|
+
this.N = 624
|
|
8
|
+
this.M = 397
|
|
9
|
+
this.MATRIX_A = 0x9908b0df /* constant vector a */
|
|
10
|
+
this.UPPER_MASK = 0x80000000 /* most significant w-r bits */
|
|
11
|
+
this.LOWER_MASK = 0x7fffffff /* least significant r bits */
|
|
12
|
+
this.mt = new Array(this.N) /* the array for the state vector */
|
|
13
|
+
this.mti = this.N + 1 /* mti==N + 1 means mt[N] is not initialized */
|
|
14
|
+
this.init_genrand(seed)
|
|
15
|
+
}
|
|
16
|
+
/* initializes mt[N] with a seed */
|
|
17
|
+
MersenneTwister.prototype.init_genrand = function (s) {
|
|
18
|
+
this.mt[0] = s >>> 0
|
|
19
|
+
for (this.mti = 1; this.mti < this.N; this.mti++) {
|
|
20
|
+
s = this.mt[this.mti - 1] ^ (this.mt[this.mti - 1] >>> 30)
|
|
21
|
+
this.mt[this.mti] = (((((s & 0xffff0000) >>> 16) * 1812433253) << 16) + (s & 0x0000ffff) * 1812433253) + this.mti
|
|
22
|
+
/* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */
|
|
23
|
+
/* In the previous versions, MSBs of the seed affect */
|
|
24
|
+
/* only MSBs of the array mt[]. */
|
|
25
|
+
/* 2002/01/09 modified by Makoto Matsumoto */
|
|
26
|
+
this.mt[this.mti] >>>= 0
|
|
27
|
+
/* for >32 bit machines */
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/* initialize by an array with array-length */
|
|
31
|
+
/* init_key is the array for initializing keys */
|
|
32
|
+
/* key_length is its length */
|
|
33
|
+
/* slight change for C++, 2004/2/26 */
|
|
34
|
+
MersenneTwister.prototype.init_by_array = function (init_key, key_length) {
|
|
35
|
+
let i = 1; let j = 0; let k; let s
|
|
36
|
+
this.init_genrand(19650218)
|
|
37
|
+
k = (this.N > key_length ? this.N : key_length)
|
|
38
|
+
for (; k; k--) {
|
|
39
|
+
s = this.mt[i - 1] ^ (this.mt[i - 1] >>> 30)
|
|
40
|
+
this.mt[i] = (this.mt[i] ^ (((((s & 0xffff0000) >>> 16) * 1664525) << 16) + ((s & 0x0000ffff) * 1664525))) + init_key[j] + j /* non linear */
|
|
41
|
+
this.mt[i] >>>= 0 /* for WORDSIZE > 32 machines */
|
|
42
|
+
i++
|
|
43
|
+
j++
|
|
44
|
+
if (i >= this.N) {
|
|
45
|
+
this.mt[0] = this.mt[this.N - 1]
|
|
46
|
+
i = 1
|
|
47
|
+
}
|
|
48
|
+
if (j >= key_length) {
|
|
49
|
+
j = 0
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
for (k = this.N - 1; k; k--) {
|
|
53
|
+
s = this.mt[i - 1] ^ (this.mt[i - 1] >>> 30)
|
|
54
|
+
this.mt[i] = (this.mt[i] ^ (((((s & 0xffff0000) >>> 16) * 1566083941) << 16) + (s & 0x0000ffff) * 1566083941)) - i /* non linear */
|
|
55
|
+
this.mt[i] >>>= 0 /* for WORDSIZE > 32 machines */
|
|
56
|
+
i++
|
|
57
|
+
if (i >= this.N) {
|
|
58
|
+
this.mt[0] = this.mt[this.N - 1]
|
|
59
|
+
i = 1
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
this.mt[0] = 0x80000000 /* MSB is 1; assuring non-zero initial array */
|
|
63
|
+
}
|
|
64
|
+
/* generates a random number on [0,0xffffffff]-interval */
|
|
65
|
+
MersenneTwister.prototype.genrand_int32 = function () {
|
|
66
|
+
let y
|
|
67
|
+
const mag01 = [0x0, this.MATRIX_A]
|
|
68
|
+
/* mag01[x] = x * MATRIX_A for x=0,1 */
|
|
69
|
+
if (this.mti >= this.N) { /* generate N words at one time */
|
|
70
|
+
let kk
|
|
71
|
+
if (this.mti === this.N + 1) { /* if init_genrand() has not been called, */
|
|
72
|
+
this.init_genrand(5489) /* a default initial seed is used */
|
|
73
|
+
}
|
|
74
|
+
for (kk = 0; kk < this.N - this.M; kk++) {
|
|
75
|
+
y = (this.mt[kk] & this.UPPER_MASK) | (this.mt[kk + 1] & this.LOWER_MASK)
|
|
76
|
+
this.mt[kk] = this.mt[kk + this.M] ^ (y >>> 1) ^ mag01[y & 0x1]
|
|
77
|
+
}
|
|
78
|
+
for (; kk < this.N - 1; kk++) {
|
|
79
|
+
y = (this.mt[kk] & this.UPPER_MASK) | (this.mt[kk + 1] & this.LOWER_MASK)
|
|
80
|
+
this.mt[kk] = this.mt[kk + (this.M - this.N)] ^ (y >>> 1) ^ mag01[y & 0x1]
|
|
81
|
+
}
|
|
82
|
+
y = (this.mt[this.N - 1] & this.UPPER_MASK) | (this.mt[0] & this.LOWER_MASK)
|
|
83
|
+
this.mt[this.N - 1] = this.mt[this.M - 1] ^ (y >>> 1) ^ mag01[y & 0x1]
|
|
84
|
+
this.mti = 0
|
|
85
|
+
}
|
|
86
|
+
y = this.mt[this.mti++]
|
|
87
|
+
/* Tempering */
|
|
88
|
+
y ^= (y >>> 11)
|
|
89
|
+
y ^= (y << 7) & 0x9d2c5680
|
|
90
|
+
y ^= (y << 15) & 0xefc60000
|
|
91
|
+
y ^= (y >>> 18)
|
|
92
|
+
return y >>> 0
|
|
93
|
+
}
|
|
94
|
+
/* generates a random number on [0,0x7fffffff]-interval */
|
|
95
|
+
MersenneTwister.prototype.genrand_int31 = function () {
|
|
96
|
+
return (this.genrand_int32() >>> 1)
|
|
97
|
+
}
|
|
98
|
+
/* generates a random number on [0,1]-real-interval */
|
|
99
|
+
MersenneTwister.prototype.genrand_real1 = function () {
|
|
100
|
+
return this.genrand_int32() * (1.0 / 4294967295.0)
|
|
101
|
+
/* divided by 2^32-1 */
|
|
102
|
+
}
|
|
103
|
+
/* generates a random number on [0,1)-real-interval */
|
|
104
|
+
MersenneTwister.prototype.random = function () {
|
|
105
|
+
return this.genrand_int32() * (1.0 / 4294967296.0)
|
|
106
|
+
/* divided by 2^32 */
|
|
107
|
+
}
|
|
108
|
+
/* generates a random number on (0,1)-real-interval */
|
|
109
|
+
MersenneTwister.prototype.genrand_real3 = function () {
|
|
110
|
+
return (this.genrand_int32() + 0.5) * (1.0 / 4294967296.0)
|
|
111
|
+
/* divided by 2^32 */
|
|
112
|
+
}
|
|
113
|
+
/* generates a random number on [0,1) with 53-bit resolution */
|
|
114
|
+
MersenneTwister.prototype.genrand_res53 = function () {
|
|
115
|
+
const a = this.genrand_int32() >>> 5; const b = this.genrand_int32() >>> 6
|
|
116
|
+
return (a * 67108864.0 + b) * (1.0 / 9007199254740992.0)
|
|
117
|
+
}
|
|
118
|
+
export default MersenneTwister
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { randomNumber } from './helpers'
|
|
2
|
+
import { BACKGROUND_COLORS, TEXT_COLORS } from './helpers/colors'
|
|
3
|
+
|
|
4
|
+
export const useColorByLetters = (params?: { value?: string }) => {
|
|
5
|
+
const value = params?.value ?? '';
|
|
6
|
+
const key = randomNumber({ value, min: 0, max: 19 })
|
|
7
|
+
|
|
8
|
+
const getCustomColors = (text: string) => {
|
|
9
|
+
const key = randomNumber({ text, min: 0, max: 19 })
|
|
10
|
+
return {
|
|
11
|
+
key,
|
|
12
|
+
color: TEXT_COLORS[key],
|
|
13
|
+
borderColor: TEXT_COLORS[key],
|
|
14
|
+
bgColor: BACKGROUND_COLORS[key]
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
key,
|
|
19
|
+
color: TEXT_COLORS[key],
|
|
20
|
+
borderColor: TEXT_COLORS[key],
|
|
21
|
+
bgColor: BACKGROUND_COLORS[key],
|
|
22
|
+
getCustomColors
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const useConnection = ({ setConnectionStatus }) => {
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
*/
|
|
5
|
+
async function updateConnectionStatus () {
|
|
6
|
+
if (navigator.onLine) {
|
|
7
|
+
setConnectionStatus(navigator.onLine)
|
|
8
|
+
} else {
|
|
9
|
+
setConnectionStatus(navigator.onLine)
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (typeof window !== 'undefined') {
|
|
14
|
+
// Attaching event handler for the online event
|
|
15
|
+
window.addEventListener('online', function () {
|
|
16
|
+
updateConnectionStatus()
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
// Attaching event handler for the offline event
|
|
20
|
+
window.addEventListener('offline', function () {
|
|
21
|
+
updateConnectionStatus()
|
|
22
|
+
})
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useQuery } from '@apollo/client'
|
|
2
|
+
|
|
3
|
+
import { GET_ALL_COUNTRIES } from './queries'
|
|
4
|
+
/**
|
|
5
|
+
|
|
6
|
+
* Hook personalizado para obtener todos los países.
|
|
7
|
+
*
|
|
8
|
+
* @returns {Object} - Retorna un objeto con la data de los países y cualquier otro estado/error relacionado con la consulta.
|
|
9
|
+
*/
|
|
10
|
+
export function useCountries () {
|
|
11
|
+
const { data, loading, error } = useQuery(GET_ALL_COUNTRIES)
|
|
12
|
+
|
|
13
|
+
// Aquí puedes manejar la lógica adicional que necesites, como mapear la data, manejar errores, etc.
|
|
14
|
+
|
|
15
|
+
return {
|
|
16
|
+
data: data ? data.countries : [],
|
|
17
|
+
loading,
|
|
18
|
+
error
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { useMutation, gql } from '@apollo/client'
|
|
2
|
+
|
|
3
|
+
const CREATE_DELIVERY_TIME = gql`
|
|
4
|
+
mutation CreateDeliveryTime($minutes: Int!) {
|
|
5
|
+
createDeliveryTime(minutes: $minutes) {
|
|
6
|
+
success
|
|
7
|
+
message
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
`
|
|
11
|
+
|
|
12
|
+
export const useCreateDeliveryTime = ({
|
|
13
|
+
sendNotification = ({ description, title, backgroundColor }) => {
|
|
14
|
+
return { description, title, backgroundColor }
|
|
15
|
+
}
|
|
16
|
+
}) => {
|
|
17
|
+
const [createDeliveryTimeMutation, { loading, error }] =
|
|
18
|
+
useMutation(CREATE_DELIVERY_TIME)
|
|
19
|
+
|
|
20
|
+
const createDeliveryTime = async (minutes) => {
|
|
21
|
+
try {
|
|
22
|
+
if (!minutes) {
|
|
23
|
+
sendNotification({
|
|
24
|
+
backgroundColor: 'error',
|
|
25
|
+
title: 'Error',
|
|
26
|
+
description: 'The delivery time is required.'
|
|
27
|
+
})
|
|
28
|
+
return
|
|
29
|
+
}
|
|
30
|
+
const { data } = await createDeliveryTimeMutation({
|
|
31
|
+
variables: { minutes: parseInt(minutes) }
|
|
32
|
+
})
|
|
33
|
+
if (data?.createDeliveryTime?.success) {
|
|
34
|
+
sendNotification({
|
|
35
|
+
title: 'Delivery Time Created',
|
|
36
|
+
description: data.createDeliveryTime.message,
|
|
37
|
+
backgroundColor: 'success'
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
return data.createDeliveryTime
|
|
41
|
+
} catch (error) {
|
|
42
|
+
sendNotification({
|
|
43
|
+
backgroundColor: 'error',
|
|
44
|
+
title: 'Error',
|
|
45
|
+
description: 'An error occurred while creating the delivery time.'
|
|
46
|
+
})
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return { createDeliveryTime, loading, error }
|
|
51
|
+
}
|