npm-pkg-hook 1.12.4 → 1.12.7
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.cjs +20089 -0
- package/dist/index.js +19854 -0
- package/dist/index.mjs +19854 -0
- package/package.json +28 -6
- package/.babelrc +0 -0
- package/.env +0 -5
- package/.eslintrc.js +0 -38
- package/.eslintrc.json +0 -127
- package/.github/pull_request_template.md +0 -18
- package/.github/workflows/pepeline.yaml +0 -30
- package/expire.json +0 -1
- package/jsconfig.json +0 -28
- package/script.txt +0 -7
- package/src/config/client/errors.js +0 -26
- package/src/config/client/index.js +0 -1
- package/src/config/content/en.json +0 -5
- package/src/config/content/es.json +0 -5
- package/src/config/content/index.js +0 -16
- package/src/cookies/index.js +0 -3
- package/src/hooks/addTenMinutes/index.js +0 -14
- package/src/hooks/calculateLogLatHaversine/index.js +0 -30
- package/src/hooks/completeSchedules/index.js +0 -22
- package/src/hooks/convertToMilitaryTime/index.js +0 -14
- package/src/hooks/generateStoreURL/index.js +0 -38
- package/src/hooks/generateTemplate/index.js +0 -62
- package/src/hooks/getCardType/index.js +0 -24
- package/src/hooks/getCategoriesWithProduct/helpers/index.js +0 -7
- package/src/hooks/getCategoriesWithProduct/index.js +0 -62
- package/src/hooks/getGlobalSession/index.js +0 -49
- package/src/hooks/getSession/index.js +0 -18
- package/src/hooks/getTodayTimestamps/index.js +0 -64
- package/src/hooks/getTotalHours/index.js +0 -48
- package/src/hooks/handleLogin/index.js +0 -10
- package/src/hooks/index.ts +0 -147
- package/src/hooks/isTokenExpired/index.js +0 -17
- package/src/hooks/newMessageSubscription/index.js +0 -28
- package/src/hooks/newStoreOrderSubscription/index.js +0 -26
- package/src/hooks/statusOpenStores/helpers/index.js +0 -101
- package/src/hooks/statusOpenStores/index.js +0 -156
- package/src/hooks/updateExtProductFoodsOptional/index.js +0 -40
- package/src/hooks/useAcumulateDate/index.js +0 -16
- package/src/hooks/useAllStoresPendingToRegister/index.js +0 -34
- package/src/hooks/useAmountInput/index.ts +0 -117
- package/src/hooks/useAnimationFrame/index.js +0 -45
- package/src/hooks/useAnimationText/index.jsx +0 -31
- package/src/hooks/useAsideCart/helpers/index.js +0 -22
- package/src/hooks/useAsideCart/index.js +0 -214
- package/src/hooks/useAsideCart/queries.js +0 -10
- package/src/hooks/useBanner/index.js +0 -19
- package/src/hooks/useCart/index.js +0 -2
- package/src/hooks/useCart/queries.js +0 -174
- package/src/hooks/useCart/useCart/helpers/index.js +0 -75
- package/src/hooks/useCart/useCart/index.js +0 -412
- package/src/hooks/useCart/useGetCart/index.js +0 -33
- package/src/hooks/useCatWithProduct/index.js +0 -48
- package/src/hooks/useCatWithProduct/queries.js +0 -200
- package/src/hooks/useCatWithProductClient/index.js +0 -56
- package/src/hooks/useCatWithProductClient/queries.js +0 -56
- package/src/hooks/useCategoriesProduct/index.js +0 -13
- package/src/hooks/useCategoriesProduct/queries.js +0 -16
- package/src/hooks/useCategoryInStore/index.js +0 -100
- package/src/hooks/useCategoryInStore/queries.js +0 -78
- package/src/hooks/useCategoryStore/index.js +0 -7
- package/src/hooks/useCategoryStore/queries.js +0 -16
- package/src/hooks/useChartData/index.js +0 -170
- package/src/hooks/useChartData/useChartData/index.js +0 -199
- package/src/hooks/useChartData/useChartDataAllOrders/index.js +0 -94
- package/src/hooks/useChatRoomSubscription/index.js +0 -28
- package/src/hooks/useCheckbox/index.js +0 -115
- package/src/hooks/useCities/index.js +0 -13
- package/src/hooks/useCities/queries.js +0 -12
- package/src/hooks/useClients/index.js +0 -96
- package/src/hooks/useClients/queries.js +0 -212
- package/src/hooks/useColorByLetters/helpers/alea.js +0 -54
- package/src/hooks/useColorByLetters/helpers/colors.js +0 -45
- package/src/hooks/useColorByLetters/helpers/index.js +0 -18
- package/src/hooks/useColorByLetters/helpers/mersenne_twister.js +0 -118
- package/src/hooks/useColorByLetters/index.js +0 -27
- package/src/hooks/useConnection/index.js +0 -24
- package/src/hooks/useCountries/index.js +0 -19
- package/src/hooks/useCountries/queries.js +0 -12
- package/src/hooks/useCreateDeliveryTime/index.js +0 -51
- package/src/hooks/useCreateOrderStatusType/index.ts +0 -132
- package/src/hooks/useCreateProduct/helpers/index.js +0 -23
- package/src/hooks/useCreateProduct/helpers/manageCacheDataCatProduct/index.js +0 -52
- package/src/hooks/useCreateProduct/helpers/useEditImageProduct/index.js +0 -176
- package/src/hooks/useCreateProduct/index.js +0 -334
- package/src/hooks/useCreateStorePendingToRegister/index.js +0 -13
- package/src/hooks/useCreateStorePendingToRegister/queries.js +0 -10
- package/src/hooks/useDashboardComponents/index.js +0 -50
- package/src/hooks/useDeleteExtraProductFoods/index.js +0 -12
- package/src/hooks/useDeleteSubProductOptional/index.js +0 -30
- package/src/hooks/useDeleteSubProductOptional/queries.js +0 -10
- package/src/hooks/useDeliveryTime/index.js +0 -27
- package/src/hooks/useDepartments/index.js +0 -13
- package/src/hooks/useDepartments/queries.js +0 -13
- package/src/hooks/useDessert/helpers/index.js +0 -51
- package/src/hooks/useDessert/index.js +0 -525
- package/src/hooks/useDessertWithPrice/helpers/index.js +0 -76
- package/src/hooks/useDessertWithPrice/index.js +0 -373
- package/src/hooks/useDessertWithPrice/queries.js +0 -18
- package/src/hooks/useDevWS/index.ts +0 -53
- package/src/hooks/useDevices/index.js +0 -2
- package/src/hooks/useDevices/queries.js +0 -28
- package/src/hooks/useDevices/useGetDevices.js +0 -28
- package/src/hooks/useDevices/useRegisterDevices.js +0 -75
- package/src/hooks/useDownloadReports/helpers/downloadFileFromResponse.ts +0 -21
- package/src/hooks/useDownloadReports/index.ts +0 -2
- package/src/hooks/useDownloadReports/useDownloadReportByDay/index.ts +0 -103
- package/src/hooks/useDownloadReports/useGetReportByDateRange/index.ts +0 -115
- package/src/hooks/useDrag/index.js +0 -63
- package/src/hooks/useDropzone/index.js +0 -94
- package/src/hooks/useDynamicAuth/index.js +0 -13
- package/src/hooks/useDynamicAuth/queries.js +0 -24
- package/src/hooks/useEditCategory/index.js +0 -41
- package/src/hooks/useEditOneExtProductFoodOptional/index.js +0 -28
- package/src/hooks/useEditOneExtProductFoodOptional/queries.js +0 -16
- package/src/hooks/useEditSubProductOptional/index.js +0 -11
- package/src/hooks/useEditSubProductOptional/queries.js +0 -10
- package/src/hooks/useEmployee/index.js +0 -17
- package/src/hooks/useEmployee/queries.js +0 -85
- package/src/hooks/useEmployee/useCreateEmployee.js +0 -86
- package/src/hooks/useEvent/index.js +0 -34
- package/src/hooks/useFavoriteStores/index.js +0 -29
- package/src/hooks/useFavoriteStores/queries.js +0 -54
- package/src/hooks/useFetchJson/index.js +0 -25
- package/src/hooks/useFetchMoreInteractions/index.jsx +0 -39
- package/src/hooks/useFingerprintjs/index.js +0 -172
- package/src/hooks/useFormTools/index.js +0 -116
- package/src/hooks/useFormatDate/index.js +0 -86
- package/src/hooks/useFormatNumberPhone/index.js +0 -23
- package/src/hooks/useFullScreenMode/index.js +0 -65
- package/src/hooks/useGenerateNumberArray/index.js +0 -17
- package/src/hooks/useGetAllLocationUser/index.js +0 -12
- package/src/hooks/useGetAllLocationUser/queries.js +0 -44
- package/src/hooks/useGetCookies/index.js +0 -43
- package/src/hooks/useGetExtProductFoodsSubOptionalAll/index.js +0 -14
- package/src/hooks/useGetFoodRecomended/index.js +0 -32
- package/src/hooks/useGetFoodRecomended/queries.js +0 -47
- package/src/hooks/useGetMessagesToRoom/index.js +0 -23
- package/src/hooks/useGetMinPrice/index.js +0 -12
- package/src/hooks/useGetMinPrice/queries.js +0 -7
- package/src/hooks/useGetOneStoreRating/index.js +0 -40
- package/src/hooks/useGetOneStoreRating/queries.js +0 -18
- package/src/hooks/useGetSalesAmountToday/index.js +0 -31
- package/src/hooks/useGetStoreCookie/index.js +0 -21
- package/src/hooks/useGoogleLogin/index.js +0 -160
- package/src/hooks/useGoogleLogin/loadScript.js +0 -15
- package/src/hooks/useGoogleLogin/removeScript.js +0 -7
- package/src/hooks/useHover/index.js +0 -29
- package/src/hooks/useImageOptimization/index.js +0 -28
- package/src/hooks/useImageUploaderProduct/helper/canvasUtils.ts +0 -130
- package/src/hooks/useImageUploaderProduct/helper/getOrientation.ts +0 -53
- package/src/hooks/useImageUploaderProduct/helper/index.ts +0 -5
- package/src/hooks/useImageUploaderProduct/index.ts +0 -292
- package/src/hooks/useImageWeight/index.js +0 -51
- package/src/hooks/useImagesStore/index.js +0 -225
- package/src/hooks/useImagesStore/queries.js +0 -193
- package/src/hooks/useImagesStore/utils/index.js +0 -4
- package/src/hooks/useIncomingOrders/index.js +0 -10
- package/src/hooks/useIncomingOrders/queries.js +0 -87
- package/src/hooks/useInnerHtml/index.js +0 -39
- package/src/hooks/useIntersection/index.js +0 -84
- package/src/hooks/useInventory/index.js +0 -2
- package/src/hooks/useInventory/queries.js +0 -58
- package/src/hooks/useInventory/useGetProductsInStock.js +0 -15
- package/src/hooks/useInventory/useUpdateManageStock.js +0 -41
- package/src/hooks/useKeypress/index.js +0 -28
- package/src/hooks/useLazyScript/index.js +0 -71
- package/src/hooks/useLocalBackendIp/index.js +0 -34
- package/src/hooks/useLocalSorage/index.js +0 -36
- package/src/hooks/useLocationManager/index.js +0 -63
- package/src/hooks/useLocationNavigate/index.js +0 -54
- package/src/hooks/useLoginEmployeeInStore/index.js +0 -38
- package/src/hooks/useLogout/helpers/BroadcastChannel.js +0 -31
- package/src/hooks/useLogout/helpers/apiBaseUrl.js +0 -8
- package/src/hooks/useLogout/helpers/fetchData.js +0 -28
- package/src/hooks/useLogout/helpers/getCsrfToken.js +0 -30
- package/src/hooks/useLogout/helpers/index.js +0 -57
- package/src/hooks/useLogout/helpers/logger.js +0 -70
- package/src/hooks/useLogout/helpers/parseUrl.js +0 -36
- package/src/hooks/useLogout/index.js +0 -96
- package/src/hooks/useManageNewOrder/helpers/index.js +0 -45
- package/src/hooks/useManageNewOrder/helpers/mock.js +0 -0
- package/src/hooks/useManageNewOrder/index.js +0 -102
- package/src/hooks/useManageQueryParams/index.js +0 -40
- package/src/hooks/useMobile/index.js +0 -65
- package/src/hooks/useModules/helpers/index.js +0 -1
- package/src/hooks/useModules/helpers/validateModules.js +0 -29
- package/src/hooks/useModules/index.js +0 -58
- package/src/hooks/useMouse/index.ts +0 -50
- package/src/hooks/useMutateHeight/index.js +0 -36
- package/src/hooks/useOrderClient/index.js +0 -5
- package/src/hooks/useOrderStatusTypes/index.ts +0 -2
- package/src/hooks/useOrderStatusTypes/useOrderStatusTypes/index.ts +0 -133
- package/src/hooks/useOrderStatusTypes/useUpdateOrderStatusPriorities/index.ts +0 -97
- package/src/hooks/useOrders/index.js +0 -3
- package/src/hooks/useOrders/queries.js +0 -89
- package/src/hooks/useOrders/useChangeOrderState/index.ts +0 -125
- package/src/hooks/useOrders/useOrdersFromStore/index.ts +0 -77
- package/src/hooks/usePWAInstall/index.js +0 -38
- package/src/hooks/usePortFetcher/index.ts +0 -33
- package/src/hooks/usePrintSaleTicket/index.ts +0 -64
- package/src/hooks/useProductsFood/index.js +0 -253
- package/src/hooks/useProductsFood/queriesStore.js +0 -964
- package/src/hooks/useProductsFood/useEditProduct.js +0 -48
- package/src/hooks/useProductsFood/usetagsProducts.js +0 -98
- package/src/hooks/useProviders/index.js +0 -3
- package/src/hooks/useProviders/queries.js +0 -31
- package/src/hooks/useProviders/useProvidersCreateStore/index.js +0 -12
- package/src/hooks/useProviders/useProvidersDataStore/index.js +0 -24
- package/src/hooks/useProvidersStore/index.js +0 -24
- package/src/hooks/useProvidersStore/queries.js +0 -31
- package/src/hooks/usePushNotificationOrder/index.js +0 -52
- package/src/hooks/usePushNotifications/helpers/index.js +0 -114
- package/src/hooks/usePushNotifications/index.js +0 -149
- package/src/hooks/useQueryLocationsMap/index.js +0 -19
- package/src/hooks/useQueryLocationsMap/queries.js +0 -40
- package/src/hooks/useRatingArrayData/index.js +0 -54
- package/src/hooks/useRatingArrayData/queries.js +0 -19
- package/src/hooks/useReactToPrint/index.js +0 -1223
- package/src/hooks/useRemoveExtraProductFoodsOptional/index.js +0 -23
- package/src/hooks/useRemoveExtraProductFoodsOptional/queries.js +0 -48
- package/src/hooks/useReport/index.js +0 -47
- package/src/hooks/useReport/queries.js +0 -123
- package/src/hooks/useRestaurant/helpers/index.js +0 -24
- package/src/hooks/useRestaurant/helpers/manageStatusOpen.js +0 -26
- package/src/hooks/useRestaurant/index.js +0 -69
- package/src/hooks/useRestaurant/queries.js +0 -81
- package/src/hooks/useRoads/index.js +0 -19
- package/src/hooks/useRoads/queries.js +0 -13
- package/src/hooks/useRoles/index.js +0 -4
- package/src/hooks/useRoles/queries.js +0 -70
- package/src/hooks/useRoles/useCreateRole.js +0 -37
- package/src/hooks/useRoles/useGetRoles.js +0 -36
- package/src/hooks/useRoles/useRemoveRoles.js +0 -40
- package/src/hooks/useRoles/useUpdateRolesPriority.js +0 -44
- package/src/hooks/useSales/helpers/index.js +0 -55
- package/src/hooks/useSales/index.js +0 -1381
- package/src/hooks/useSales/queries.js +0 -424
- package/src/hooks/useSales/useGetAllSales/index.js +0 -25
- package/src/hooks/useSales/useGetSale.js +0 -13
- package/src/hooks/useSales/useTotalSales.js +0 -23
- package/src/hooks/useSaveAvailableProduct/helpers/index.js +0 -38
- package/src/hooks/useSaveAvailableProduct/index.js +0 -31
- package/src/hooks/useSaveAvailableProduct/queries.js +0 -10
- package/src/hooks/useSaveLocation/index.js +0 -16
- package/src/hooks/useSaveLocation/queries.js +0 -19
- package/src/hooks/useSchedule/index.js +0 -78
- package/src/hooks/useSchedule/index.jsx +0 -22
- package/src/hooks/useSchedule/queries.js +0 -43
- package/src/hooks/useScheduleData/index.js +0 -123
- package/src/hooks/useScroll/index.js +0 -56
- package/src/hooks/useScrollRotate/index.js +0 -16
- package/src/hooks/useSetImageProducts/index.js +0 -57
- package/src/hooks/useSetImageProducts/queries.js +0 -18
- package/src/hooks/useSetSession/index.js +0 -44
- package/src/hooks/useSetState/index.js +0 -24
- package/src/hooks/useSetupSchedule/helpers/index.js +0 -85
- package/src/hooks/useSetupSchedule/index.js +0 -272
- package/src/hooks/useStatusOpenStore/helpers/index.js +0 -101
- package/src/hooks/useStatusOpenStore/index.js +0 -179
- package/src/hooks/useStatusOrdersClient/helpers/index.js +0 -14
- package/src/hooks/useStatusOrdersClient/index.js +0 -17
- package/src/hooks/useStatusOrdersClient/queries.js +0 -80
- package/src/hooks/useStockMovements/helpers/index.js +0 -16
- package/src/hooks/useStockMovements/index.js +0 -38
- package/src/hooks/useStore/index.js +0 -80
- package/src/hooks/useStore/queries.js +0 -163
- package/src/hooks/useStoreCalendar/index.js +0 -5
- package/src/hooks/useStoreContacts/index.js +0 -47
- package/src/hooks/useStoreContacts/queries.js +0 -48
- package/src/hooks/useStoreTable/index.js +0 -2
- package/src/hooks/useStoreTable/queries.js +0 -47
- package/src/hooks/useStoreTable/useStoreTableCreate.js +0 -76
- package/src/hooks/useStoreTable/useStoreTables.js +0 -14
- package/src/hooks/useSubscriptionValidation/index.js +0 -41
- package/src/hooks/useTagProducts/index.ts +0 -3
- package/src/hooks/useTagProducts/useDeleteOneTag.ts +0 -106
- package/src/hooks/useTagProducts/useGetAllTags.ts +0 -68
- package/src/hooks/useTagProducts/useRegisterMultipleTags.ts +0 -156
- package/src/hooks/useTimeAgo/useTimeAgo.js +0 -39
- package/src/hooks/useTokenCards/index.js +0 -41
- package/src/hooks/useTopProductsMovements/index.js +0 -27
- package/src/hooks/useTotalAllSales/index.js +0 -25
- package/src/hooks/useTotalProductsInStock/index.js +0 -23
- package/src/hooks/useTotalProductsSold/index.js +0 -23
- package/src/hooks/useTotalProductsSolded/index.js +0 -20
- package/src/hooks/useUpdateCart/index.js +0 -130
- package/src/hooks/useUpdateCartCookie/index.js +0 -43
- package/src/hooks/useUpdateDashboardComponent/index.ts +0 -91
- package/src/hooks/useUpdateExistingOrders/index.js +0 -85
- package/src/hooks/useUpdateExtProductFoodsSubOptional/index.js +0 -60
- package/src/hooks/useUpdateModuleOrder/index.js +0 -37
- package/src/hooks/useUpdateMultipleExtProduct/index.js +0 -33
- package/src/hooks/useUpdateMultipleExtProduct/queries.js +0 -33
- package/src/hooks/useUpdateMultipleProducts/index.js +0 -80
- package/src/hooks/useUpdateMultipleProducts/queries.js +0 -51
- package/src/hooks/useUploadProducts/helpers/index.js +0 -1
- package/src/hooks/useUploadProducts/helpers/parseNumber.js +0 -37
- package/src/hooks/useUploadProducts/helpers/validateProductDataExcel.js +0 -73
- package/src/hooks/useUploadProducts/index.js +0 -422
- package/src/hooks/useUpsertGoal/index.js +0 -68
- package/src/hooks/useUser/index.js +0 -23
- package/src/hooks/useUser/queries.js +0 -131
- package/src/hooks/useWeeklyStockMovement/helpers/index.js +0 -32
- package/src/hooks/useWeeklyStockMovement/index.js +0 -51
- package/src/hooks/useWindowSize/index.js +0 -38
- package/src/index.jsx +0 -9
- package/src/mock/dessert/index.js +0 -16
- package/src/mock/index.js +0 -1
- package/src/security/index.js +0 -1
- package/src/services/index.js +0 -0
- package/src/utils/UtilDateRange.js +0 -31
- package/src/utils/index.js +0 -306
- package/tsconfig.json +0 -5
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { gql } from '@apollo/client'
|
|
2
|
-
|
|
3
|
-
export const CHANGE_STATE_STORE_ORDER = gql`
|
|
4
|
-
mutation changePPStateOrder($pPStateP: Int, $pCodeRef: String, $pDatMod: String) {
|
|
5
|
-
changePPStateOrder(pPStateP: $pPStateP, pCodeRef: $pCodeRef, pDatMod: $pDatMod){
|
|
6
|
-
success
|
|
7
|
-
message
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
`
|
|
12
|
-
export const GET_ALL_ORDER = gql`
|
|
13
|
-
query getAllOrderStoreFinal($idStore: ID, $search: String, $min: Int, $max: Int, $statusOrder: Int, $fromDate: DateTime, $toDate: DateTime) {
|
|
14
|
-
getAllOrderStoreFinal(idStore: $idStore, search: $search, min: $min, max: $max, statusOrder: $statusOrder, toDate: $toDate,fromDate: $fromDate ) {
|
|
15
|
-
pdpId
|
|
16
|
-
idStore
|
|
17
|
-
pCodeRef
|
|
18
|
-
payMethodPState
|
|
19
|
-
pPRecoger
|
|
20
|
-
totalProductsPrice
|
|
21
|
-
pSState
|
|
22
|
-
pDatCre
|
|
23
|
-
channel
|
|
24
|
-
locationUser
|
|
25
|
-
pDatMod
|
|
26
|
-
getAllPedidoStore{
|
|
27
|
-
pdpId
|
|
28
|
-
pId
|
|
29
|
-
idStore
|
|
30
|
-
ShoppingCard
|
|
31
|
-
pCodeRef
|
|
32
|
-
pPStateP
|
|
33
|
-
payMethodPState
|
|
34
|
-
pPRecoger
|
|
35
|
-
pDatCre
|
|
36
|
-
pDatMod
|
|
37
|
-
getAllShoppingCard {
|
|
38
|
-
ShoppingCard
|
|
39
|
-
comments
|
|
40
|
-
cantProducts
|
|
41
|
-
pId
|
|
42
|
-
productFood{
|
|
43
|
-
pId
|
|
44
|
-
carProId
|
|
45
|
-
colorId
|
|
46
|
-
idStore
|
|
47
|
-
pName
|
|
48
|
-
ProPrice
|
|
49
|
-
ProDescuento
|
|
50
|
-
ProDescription
|
|
51
|
-
ValueDelivery
|
|
52
|
-
ProImage
|
|
53
|
-
ProStar
|
|
54
|
-
pState
|
|
55
|
-
pDatCre
|
|
56
|
-
pDatMod
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
`
|
|
63
|
-
|
|
64
|
-
export const GET_ALL_ORDER_FROM_STORE = gql`
|
|
65
|
-
query getAllSalesStore {
|
|
66
|
-
getAllSalesStore {
|
|
67
|
-
change
|
|
68
|
-
channel
|
|
69
|
-
status
|
|
70
|
-
createdAt
|
|
71
|
-
pCodeRef
|
|
72
|
-
idStore
|
|
73
|
-
pdpId
|
|
74
|
-
locationUser
|
|
75
|
-
shoppingCartRefCode
|
|
76
|
-
payMethodPState
|
|
77
|
-
updatedAt
|
|
78
|
-
totalProductsPrice
|
|
79
|
-
unidProducts
|
|
80
|
-
getUser {
|
|
81
|
-
associateStore
|
|
82
|
-
avatar
|
|
83
|
-
createdAt
|
|
84
|
-
id
|
|
85
|
-
email
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
`
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { gql, useApolloClient, useMutation } from '@apollo/client'
|
|
2
|
-
import { SendNotificationFn } from '../../useImageUploaderProduct'
|
|
3
|
-
import { updateExistingOrders } from '../../useUpdateExistingOrders'
|
|
4
|
-
/**
|
|
5
|
-
* GraphQL mutation to change the state of a store order (pedido).
|
|
6
|
-
*/
|
|
7
|
-
const CHANGE_STATE_STORE_ORDER = gql`
|
|
8
|
-
mutation changePPStateOrder($idStatus: ID, $pCodeRef: String, $pDatMod: String) {
|
|
9
|
-
changePPStateOrder(idStatus: $idStatus, pCodeRef: $pCodeRef, pDatMod: $pDatMod) {
|
|
10
|
-
success
|
|
11
|
-
message
|
|
12
|
-
errors {
|
|
13
|
-
path
|
|
14
|
-
message
|
|
15
|
-
type
|
|
16
|
-
}
|
|
17
|
-
data {
|
|
18
|
-
pdpId
|
|
19
|
-
id
|
|
20
|
-
idStore
|
|
21
|
-
pPStateP
|
|
22
|
-
pSState
|
|
23
|
-
|
|
24
|
-
ppState
|
|
25
|
-
pCodeRef
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
`
|
|
30
|
-
|
|
31
|
-
interface IUseChangeStateOrder {
|
|
32
|
-
sendNotification: SendNotificationFn
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Hook to trigger the `changePPStateOrder` mutation.
|
|
36
|
-
* @returns {Object} Contains the mutation function, loading and error state.
|
|
37
|
-
*/
|
|
38
|
-
export const useChangeStateOrder = ({
|
|
39
|
-
sendNotification
|
|
40
|
-
}: IUseChangeStateOrder) => {
|
|
41
|
-
const client = useApolloClient()
|
|
42
|
-
|
|
43
|
-
const [changeState, { loading, error, data }] = useMutation(CHANGE_STATE_STORE_ORDER, {
|
|
44
|
-
onCompleted: (res) => {
|
|
45
|
-
if (!res || !res.changePPStateOrder) {
|
|
46
|
-
return
|
|
47
|
-
}
|
|
48
|
-
const { success, data } = res?.changePPStateOrder || {}
|
|
49
|
-
if (success) {
|
|
50
|
-
const { pCodeRef, pSState } = data ?? {
|
|
51
|
-
pCodeRef: null,
|
|
52
|
-
pSState: null
|
|
53
|
-
}
|
|
54
|
-
if (!pCodeRef || !pSState) {
|
|
55
|
-
return
|
|
56
|
-
}
|
|
57
|
-
// client.cache.modify({
|
|
58
|
-
// fields: {
|
|
59
|
-
// getAllOrdersFromStore(existingOrders = []) {
|
|
60
|
-
// try {
|
|
61
|
-
// // return
|
|
62
|
-
// console.log({ cache: updateExistingOrders(existingOrders, pCodeRef, pSState) })
|
|
63
|
-
// } catch (e) {
|
|
64
|
-
// return existingOrders
|
|
65
|
-
// }
|
|
66
|
-
// }
|
|
67
|
-
// }
|
|
68
|
-
// })
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Triggers the mutation to update the pedido state.
|
|
75
|
-
* @param {Object} params
|
|
76
|
-
* @param {number} params.idStatus - New state of the pedido (required).
|
|
77
|
-
* @param {string} params.pCodeRef - Reference code for the pedido (required).
|
|
78
|
-
* @param {string} params.pDatMod - Modification date in ISO format (required).
|
|
79
|
-
* @returns {Promise<Object>} Response from the mutation.
|
|
80
|
-
*/
|
|
81
|
-
const changeStateOrder = async ({
|
|
82
|
-
idStatus,
|
|
83
|
-
pCodeRef,
|
|
84
|
-
pDatMod,
|
|
85
|
-
}: {
|
|
86
|
-
idStatus: string
|
|
87
|
-
pCodeRef: string
|
|
88
|
-
pDatMod: string
|
|
89
|
-
}) => {
|
|
90
|
-
try {
|
|
91
|
-
const response = await changeState({
|
|
92
|
-
variables:
|
|
93
|
-
{
|
|
94
|
-
idStatus,
|
|
95
|
-
pCodeRef,
|
|
96
|
-
pDatMod
|
|
97
|
-
},
|
|
98
|
-
})
|
|
99
|
-
const { success, message } = response?.data?.changePPStateOrder ?? {
|
|
100
|
-
success: false,
|
|
101
|
-
message: ''
|
|
102
|
-
}
|
|
103
|
-
sendNotification({
|
|
104
|
-
title: success ? 'Exitoso' : 'Error',
|
|
105
|
-
description: message,
|
|
106
|
-
backgroundColor: success ? 'success' : 'error'
|
|
107
|
-
})
|
|
108
|
-
return response?.data?.changePPStateOrder ?? {
|
|
109
|
-
success: false,
|
|
110
|
-
message,
|
|
111
|
-
}
|
|
112
|
-
} catch (err) {
|
|
113
|
-
return {
|
|
114
|
-
success: false,
|
|
115
|
-
message: err.message || 'Unexpected error occurred',
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
return [changeStateOrder, {
|
|
121
|
-
loading,
|
|
122
|
-
error,
|
|
123
|
-
data,
|
|
124
|
-
}]
|
|
125
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { useQuery } from '@apollo/client'
|
|
2
|
-
import { GET_ALL_ORDER, GET_ALL_ORDER_FROM_STORE } from '../queries.js'
|
|
3
|
-
import groupBy from 'lodash/groupBy'
|
|
4
|
-
|
|
5
|
-
export const useOrders = ({
|
|
6
|
-
refetchWritePolicy = 'merge',
|
|
7
|
-
refetchReadPolicy,
|
|
8
|
-
refetch,
|
|
9
|
-
statusOrder,
|
|
10
|
-
fromDate,
|
|
11
|
-
toDate,
|
|
12
|
-
nextFetchPolicy = 'cache-first',
|
|
13
|
-
fetchPolicy = 'cache-and-network',
|
|
14
|
-
pollInterval = 60000,
|
|
15
|
-
onError
|
|
16
|
-
}) => {
|
|
17
|
-
const { data, loading, error, fetchMore } = useQuery(GET_ALL_ORDER, {
|
|
18
|
-
notifyOnNetworkStatusChange: true,
|
|
19
|
-
refetchWritePolicy,
|
|
20
|
-
pollInterval,
|
|
21
|
-
fetchPolicy,
|
|
22
|
-
refetch,
|
|
23
|
-
refetchReadPolicy,
|
|
24
|
-
nextFetchPolicy,
|
|
25
|
-
onError: onError || (() => {
|
|
26
|
-
|
|
27
|
-
}),
|
|
28
|
-
variables: {
|
|
29
|
-
statusOrder,
|
|
30
|
-
fromDate,
|
|
31
|
-
toDate
|
|
32
|
-
}
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
return [
|
|
36
|
-
data?.getAllOrderStoreFinal,
|
|
37
|
-
{ loading, error, data, fetchMore }
|
|
38
|
-
]
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export const useOrdersFromStore = ({
|
|
42
|
-
idStore,
|
|
43
|
-
cId,
|
|
44
|
-
dId,
|
|
45
|
-
ctId,
|
|
46
|
-
search = '',
|
|
47
|
-
min,
|
|
48
|
-
fromDate,
|
|
49
|
-
toDate,
|
|
50
|
-
max,
|
|
51
|
-
statusOrder,
|
|
52
|
-
callback = (data) => {
|
|
53
|
-
return data
|
|
54
|
-
}
|
|
55
|
-
}) => {
|
|
56
|
-
const key = 'status'
|
|
57
|
-
const {
|
|
58
|
-
data,
|
|
59
|
-
loading,
|
|
60
|
-
refetch,
|
|
61
|
-
error,
|
|
62
|
-
called
|
|
63
|
-
} = useQuery(GET_ALL_ORDER_FROM_STORE, {
|
|
64
|
-
notifyOnNetworkStatusChange: true,
|
|
65
|
-
fetchPolicy: 'network-only',
|
|
66
|
-
onCompleted: (data) => {
|
|
67
|
-
if (typeof callback === 'function') {
|
|
68
|
-
callback(data)
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
})
|
|
72
|
-
const grouped = groupBy(data?.getAllSalesStore ?? [], key)
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
return [grouped, { refetch, loading: called ? false : loading, error }]
|
|
76
|
-
}
|
|
77
|
-
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { useState, useEffect } from 'react'
|
|
2
|
-
|
|
3
|
-
export const usePWAInstall = () => {
|
|
4
|
-
const [deferredPrompt, setDeferredPrompt] = useState(null)
|
|
5
|
-
const [isInstallable, setIsInstallable] = useState(false)
|
|
6
|
-
|
|
7
|
-
useEffect(() => {
|
|
8
|
-
const handleBeforeInstallPrompt = (e) => {
|
|
9
|
-
e.preventDefault() // Evita que el navegador muestre el diálogo automáticamente
|
|
10
|
-
setDeferredPrompt(e) // Almacena el evento para que puedas llamarlo más tarde
|
|
11
|
-
setIsInstallable(true) // Marca que la PWA es instalable
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
window.addEventListener('beforeinstallprompt', handleBeforeInstallPrompt)
|
|
15
|
-
|
|
16
|
-
return () => {
|
|
17
|
-
window.removeEventListener('beforeinstallprompt', handleBeforeInstallPrompt)
|
|
18
|
-
}
|
|
19
|
-
}, [])
|
|
20
|
-
|
|
21
|
-
const installPWA = () => {
|
|
22
|
-
if (deferredPrompt) {
|
|
23
|
-
deferredPrompt.prompt()
|
|
24
|
-
|
|
25
|
-
deferredPrompt.userChoice.then((choiceResult) => {
|
|
26
|
-
if (choiceResult.outcome === 'accepted') {
|
|
27
|
-
console.log('User accepted the install prompt')
|
|
28
|
-
} else {
|
|
29
|
-
console.log('User dismissed the install prompt')
|
|
30
|
-
}
|
|
31
|
-
setDeferredPrompt(null) // Limpia el evento después de usarlo
|
|
32
|
-
setIsInstallable(false) // Oculta el botón de instalación
|
|
33
|
-
})
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return { isInstallable, installPWA }
|
|
38
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Custom hook to fetch a free port from the API route `/api/port`.
|
|
5
|
-
*
|
|
6
|
-
* @returns {Object} Object containing the fetched port and loading/error states
|
|
7
|
-
*/
|
|
8
|
-
export const usePortFetcher = () => {
|
|
9
|
-
const [port, setPort] = useState<string | null>(null)
|
|
10
|
-
const [loading, setLoading] = useState(true)
|
|
11
|
-
const [error, setError] = useState<string | null>(null)
|
|
12
|
-
|
|
13
|
-
useEffect(() => {
|
|
14
|
-
const fetchPort = async () => {
|
|
15
|
-
try {
|
|
16
|
-
const res = await fetch('/api/port')
|
|
17
|
-
if (!res.ok) throw new Error('Failed to fetch port')
|
|
18
|
-
|
|
19
|
-
const data = await res.json()
|
|
20
|
-
setPort(data.port)
|
|
21
|
-
} catch (err: any) {
|
|
22
|
-
console.error('Error fetching port:', err)
|
|
23
|
-
setError(err.message || 'Unknown error')
|
|
24
|
-
} finally {
|
|
25
|
-
setLoading(false)
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
fetchPort()
|
|
30
|
-
}, [])
|
|
31
|
-
|
|
32
|
-
return { port, loading, error }
|
|
33
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
// usePrintSaleTicket.ts
|
|
2
|
-
import { gql, useMutation, MutationHookOptions } from '@apollo/client'
|
|
3
|
-
import { useCallback } from 'react'
|
|
4
|
-
|
|
5
|
-
/* ------------------------------
|
|
6
|
-
TYPES
|
|
7
|
-
------------------------------ */
|
|
8
|
-
|
|
9
|
-
export interface PrintSaleTicketResponse {
|
|
10
|
-
printSaleTicket: {
|
|
11
|
-
message: string
|
|
12
|
-
success: boolean
|
|
13
|
-
data: string | null
|
|
14
|
-
__typename: string
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface PrintSaleTicketVars {
|
|
19
|
-
saleId: string
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/* ------------------------------
|
|
23
|
-
GQL
|
|
24
|
-
------------------------------ */
|
|
25
|
-
|
|
26
|
-
const PRINT_SALE_TICKET = gql`
|
|
27
|
-
mutation printSaleTicket($saleId: ID!) {
|
|
28
|
-
printSaleTicket(saleId: $saleId) {
|
|
29
|
-
message
|
|
30
|
-
success
|
|
31
|
-
data
|
|
32
|
-
__typename
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
`
|
|
36
|
-
|
|
37
|
-
/* ------------------------------
|
|
38
|
-
HOOK
|
|
39
|
-
------------------------------ */
|
|
40
|
-
|
|
41
|
-
export function usePrintSaleTicket(
|
|
42
|
-
options?: MutationHookOptions<PrintSaleTicketResponse, PrintSaleTicketVars>
|
|
43
|
-
) {
|
|
44
|
-
const [runMutation, { loading, data, error }] = useMutation<
|
|
45
|
-
PrintSaleTicketResponse,
|
|
46
|
-
PrintSaleTicketVars
|
|
47
|
-
>(PRINT_SALE_TICKET, options)
|
|
48
|
-
|
|
49
|
-
const printSale = useCallback(
|
|
50
|
-
async (saleId: string) => {
|
|
51
|
-
const result = await runMutation({
|
|
52
|
-
variables: { saleId }
|
|
53
|
-
})
|
|
54
|
-
return result.data?.printSaleTicket
|
|
55
|
-
},
|
|
56
|
-
[runMutation]
|
|
57
|
-
)
|
|
58
|
-
|
|
59
|
-
return [printSale, {
|
|
60
|
-
loading,
|
|
61
|
-
data: data?.printSaleTicket,
|
|
62
|
-
error
|
|
63
|
-
}]
|
|
64
|
-
}
|
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useLazyQuery,
|
|
3
|
-
useMutation,
|
|
4
|
-
useQuery
|
|
5
|
-
} from '@apollo/client'
|
|
6
|
-
import { useState } from 'react'
|
|
7
|
-
import {
|
|
8
|
-
GET_ALL_EXTRA_PRODUCT,
|
|
9
|
-
GET_ALL_PRODUCT_STORE,
|
|
10
|
-
GET_EXTRAS_PRODUCT_FOOD_OPTIONAL,
|
|
11
|
-
GET_ONE_PRODUCTS_FOOD,
|
|
12
|
-
UPDATE_PRODUCT_FOOD
|
|
13
|
-
} from './queriesStore'
|
|
14
|
-
export * from './useEditProduct'
|
|
15
|
-
|
|
16
|
-
export const useProductsFood = ({
|
|
17
|
-
categories = [],
|
|
18
|
-
desc = [],
|
|
19
|
-
fetchPolicy = 'cache-and-network',
|
|
20
|
-
fromDate = null,
|
|
21
|
-
gender = [],
|
|
22
|
-
max = 100,
|
|
23
|
-
min = null,
|
|
24
|
-
pState,
|
|
25
|
-
search = null,
|
|
26
|
-
toDate = null,
|
|
27
|
-
dataSale = [],
|
|
28
|
-
isShopppingCard = false
|
|
29
|
-
}) => {
|
|
30
|
-
const [showMore, setShowMore] = useState(500)
|
|
31
|
-
|
|
32
|
-
const { data, loading, fetchMore, refetch, error, called } = useQuery(GET_ALL_PRODUCT_STORE, {
|
|
33
|
-
fetchPolicy,
|
|
34
|
-
notifyOnNetworkStatusChange: true,
|
|
35
|
-
nextFetchPolicy: 'cache-first',
|
|
36
|
-
refetchWritePolicy: 'merge',
|
|
37
|
-
variables: {
|
|
38
|
-
categories,
|
|
39
|
-
desc,
|
|
40
|
-
// fromDate,
|
|
41
|
-
gender,
|
|
42
|
-
max,
|
|
43
|
-
min,
|
|
44
|
-
pState,
|
|
45
|
-
search
|
|
46
|
-
// toDate
|
|
47
|
-
}
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
const productsFood = data?.productFoodsAll?.data ?? []
|
|
51
|
-
|
|
52
|
-
if (!isShopppingCard) {
|
|
53
|
-
return [
|
|
54
|
-
productsFood, {
|
|
55
|
-
pagination: data?.productFoodsAll?.pagination || {},
|
|
56
|
-
loading: called ? false : loading,
|
|
57
|
-
error,
|
|
58
|
-
showMore,
|
|
59
|
-
fetchMore,
|
|
60
|
-
refetch,
|
|
61
|
-
setShowMore
|
|
62
|
-
}
|
|
63
|
-
]
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const updatedProductsFood = productsFood.map(product => ({
|
|
67
|
-
...product,
|
|
68
|
-
existsInSale: Array.isArray(dataSale) && dataSale.some(item => item.pId === product.pId)
|
|
69
|
-
}))
|
|
70
|
-
|
|
71
|
-
return [
|
|
72
|
-
updatedProductsFood, {
|
|
73
|
-
pagination: data?.productFoodsAll?.pagination || {},
|
|
74
|
-
loading: called ? false : loading,
|
|
75
|
-
error,
|
|
76
|
-
showMore,
|
|
77
|
-
fetchMore,
|
|
78
|
-
refetch,
|
|
79
|
-
setShowMore
|
|
80
|
-
}
|
|
81
|
-
]
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export const useDeleteProductsFood = ({
|
|
85
|
-
sendNotification = (arg) => { return arg },
|
|
86
|
-
onSuccess = (arg) => { return arg }
|
|
87
|
-
} = {
|
|
88
|
-
sendNotification: (arg) => { return arg },
|
|
89
|
-
onSuccess: (arg) => { return arg }
|
|
90
|
-
}) => {
|
|
91
|
-
const [updateProductFoods, { data, loading, error }] = useMutation(UPDATE_PRODUCT_FOOD)
|
|
92
|
-
|
|
93
|
-
const handleDelete = async product => {
|
|
94
|
-
const { pId, pState } = product || {}
|
|
95
|
-
return await updateProductFoods({
|
|
96
|
-
variables: {
|
|
97
|
-
input: {
|
|
98
|
-
pId,
|
|
99
|
-
pState
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
|
-
update (cache) {
|
|
103
|
-
cache.modify({
|
|
104
|
-
fields: {
|
|
105
|
-
productFoodsAll (dataOld = []) {
|
|
106
|
-
if (Array.isArray(dataOld) && dataOld?.length) {
|
|
107
|
-
const product = dataOld?.find((product) => {
|
|
108
|
-
return product.pId === pId
|
|
109
|
-
})
|
|
110
|
-
if (product) {
|
|
111
|
-
const newProductList = dataOld?.filter((product) => {
|
|
112
|
-
return product?.pId !== pId
|
|
113
|
-
})
|
|
114
|
-
return newProductList
|
|
115
|
-
}
|
|
116
|
-
return dataOld
|
|
117
|
-
} else {
|
|
118
|
-
return []
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
})
|
|
123
|
-
cache.modify({
|
|
124
|
-
fields: {
|
|
125
|
-
getCatProductsWithProduct (dataOld = []) {
|
|
126
|
-
if (Array.isArray(dataOld?.catProductsWithProduct) && dataOld?.catProductsWithProduct?.length) {
|
|
127
|
-
const newListCatProducts = dataOld?.catProductsWithProduct?.map((categories) => {
|
|
128
|
-
return {
|
|
129
|
-
...categories,
|
|
130
|
-
productFoodsAll: categories?.productFoodsAll?.length
|
|
131
|
-
? categories?.productFoodsAll?.filter((product) => {
|
|
132
|
-
return product?.pId !== pId
|
|
133
|
-
})
|
|
134
|
-
: []
|
|
135
|
-
}
|
|
136
|
-
})
|
|
137
|
-
return {
|
|
138
|
-
catProductsWithProduct: newListCatProducts,
|
|
139
|
-
totalCount: newListCatProducts?.length
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
return dataOld
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
})
|
|
146
|
-
}
|
|
147
|
-
}).then(() => {
|
|
148
|
-
onSuccess()
|
|
149
|
-
return sendNotification({
|
|
150
|
-
title: 'Éxito',
|
|
151
|
-
description: pState === 1 ? 'El producto se ha eliminado correctamente' : 'El producto se ha restaurando correctamente',
|
|
152
|
-
backgroundColor: 'success'
|
|
153
|
-
})
|
|
154
|
-
}).catch((e) => {
|
|
155
|
-
console.log(e)
|
|
156
|
-
return sendNotification({
|
|
157
|
-
title: 'Error',
|
|
158
|
-
description: 'Ocurrió un error',
|
|
159
|
-
backgroundColor: 'error'
|
|
160
|
-
})
|
|
161
|
-
})
|
|
162
|
-
}
|
|
163
|
-
return {
|
|
164
|
-
handleDelete, data, loading, error
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
export const useExtProductFoodsAll = () => {
|
|
169
|
-
const [ExtProductFoodsAll,
|
|
170
|
-
{
|
|
171
|
-
data,
|
|
172
|
-
loading,
|
|
173
|
-
error
|
|
174
|
-
}
|
|
175
|
-
] = useLazyQuery(GET_ALL_EXTRA_PRODUCT)
|
|
176
|
-
|
|
177
|
-
const handleExtProductFoodsAll = (pId) => {
|
|
178
|
-
if (!pId) return
|
|
179
|
-
return ExtProductFoodsAll({
|
|
180
|
-
variables: {
|
|
181
|
-
pId
|
|
182
|
-
}
|
|
183
|
-
})
|
|
184
|
-
}
|
|
185
|
-
return [handleExtProductFoodsAll,
|
|
186
|
-
{
|
|
187
|
-
data: data?.ExtProductFoodsAll || [],
|
|
188
|
-
loading,
|
|
189
|
-
error
|
|
190
|
-
}
|
|
191
|
-
]
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
export const useExtProductFoodsOptionalAll = () => {
|
|
195
|
-
const [ExtProductFoodsOptionalAll,
|
|
196
|
-
{
|
|
197
|
-
data,
|
|
198
|
-
loading,
|
|
199
|
-
error
|
|
200
|
-
}] = useLazyQuery(GET_EXTRAS_PRODUCT_FOOD_OPTIONAL)
|
|
201
|
-
|
|
202
|
-
const handleGetExtProductFood = (pId) => {
|
|
203
|
-
try {
|
|
204
|
-
ExtProductFoodsOptionalAll({
|
|
205
|
-
variables: {
|
|
206
|
-
pId
|
|
207
|
-
}
|
|
208
|
-
})
|
|
209
|
-
} catch (e) {
|
|
210
|
-
console.log(e)
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
return [handleGetExtProductFood,
|
|
214
|
-
{
|
|
215
|
-
data: data?.ExtProductFoodsOptionalAll || [],
|
|
216
|
-
loading,
|
|
217
|
-
error
|
|
218
|
-
}]
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
export const useGetOneProductsFood = ({ fetchOnlyProduct = false } = {}) => {
|
|
222
|
-
const [productFoodsOne,
|
|
223
|
-
{
|
|
224
|
-
data,
|
|
225
|
-
loading,
|
|
226
|
-
error
|
|
227
|
-
}] = useLazyQuery(GET_ONE_PRODUCTS_FOOD)
|
|
228
|
-
|
|
229
|
-
const [handleGetExtProductFood, { data: dataOptional }] = useExtProductFoodsOptionalAll()
|
|
230
|
-
const [handleExtProductFoodsAll, { data: dataExtra }] = useExtProductFoodsAll()
|
|
231
|
-
const handleGetOneProduct = async (food) => {
|
|
232
|
-
const { pId } = food
|
|
233
|
-
try {
|
|
234
|
-
productFoodsOne({
|
|
235
|
-
variables: {
|
|
236
|
-
pId
|
|
237
|
-
}
|
|
238
|
-
})
|
|
239
|
-
if (!fetchOnlyProduct) handleGetExtProductFood(pId)
|
|
240
|
-
if (!fetchOnlyProduct) handleExtProductFoodsAll(pId)
|
|
241
|
-
} catch (e) {
|
|
242
|
-
console.log(e)
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
const handleFunctionQuery = fetchOnlyProduct ? productFoodsOne : handleGetOneProduct
|
|
246
|
-
return [handleFunctionQuery, {
|
|
247
|
-
data: data?.productFoodsOne || {},
|
|
248
|
-
dataExtra,
|
|
249
|
-
dataOptional,
|
|
250
|
-
loading,
|
|
251
|
-
error
|
|
252
|
-
}]
|
|
253
|
-
}
|