npm-pkg-hook 1.13.1 → 1.13.2
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/.github/pull_request_template.md +18 -0
- package/.github/workflows/pepeline.yaml +30 -0
- package/dist/index.js +1 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -6
- package/dist/index.mjs.map +1 -1
- package/eslint.config.mts +153 -0
- package/expire.json +1 -0
- package/jsconfig.json +28 -0
- package/package.json +1 -6
- 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 +154 -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 +24 -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 +43 -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 +77 -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.ts +4 -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 +11 -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
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useMutation } from '@apollo/client'
|
|
2
|
+
|
|
3
|
+
import { DELETE_CAT_EXTRA_PRODUCTS } from './queries'
|
|
4
|
+
|
|
5
|
+
export const useRemoveExtraProductFoodsOptional = () => {
|
|
6
|
+
const [DeleteExtProductFoodsOptional, { loading, error }] = useMutation(DELETE_CAT_EXTRA_PRODUCTS)
|
|
7
|
+
|
|
8
|
+
const handleDeleteOptional = async elem => {
|
|
9
|
+
const { state, opExPid } = elem || {}
|
|
10
|
+
DeleteExtProductFoodsOptional({
|
|
11
|
+
variables: {
|
|
12
|
+
state,
|
|
13
|
+
opExPid,
|
|
14
|
+
isCustomOpExPid: true
|
|
15
|
+
}
|
|
16
|
+
})
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
handleDeleteOptional,
|
|
20
|
+
DeleteExtProductFoodsOptional,
|
|
21
|
+
loading,
|
|
22
|
+
error
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { gql } from '@apollo/client'
|
|
2
|
+
|
|
3
|
+
export const DELETE_CAT_EXTRA_PRODUCTS = gql`
|
|
4
|
+
mutation DeleteExtProductFoodsOptional($opExPid: ID, $state: Int, $isCustomOpExPid: Boolean) {
|
|
5
|
+
DeleteExtProductFoodsOptional(opExPid: $opExPid, state: $state, isCustomOpExPid: $isCustomOpExPid) {
|
|
6
|
+
success
|
|
7
|
+
message
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
`
|
|
11
|
+
|
|
12
|
+
export const GET_EXTRAS_PRODUCT_FOOD_OPTIONAL = gql`
|
|
13
|
+
query ExtProductFoodsOptionalAll(
|
|
14
|
+
$search: String
|
|
15
|
+
$min: Int
|
|
16
|
+
$max: Int
|
|
17
|
+
$pId: ID
|
|
18
|
+
) {
|
|
19
|
+
ExtProductFoodsOptionalAll(
|
|
20
|
+
search: $search
|
|
21
|
+
min: $min
|
|
22
|
+
max: $max
|
|
23
|
+
pId: $pId
|
|
24
|
+
) {
|
|
25
|
+
pId
|
|
26
|
+
opExPid
|
|
27
|
+
OptionalProName
|
|
28
|
+
state
|
|
29
|
+
code
|
|
30
|
+
numbersOptionalOnly
|
|
31
|
+
createdAt
|
|
32
|
+
required
|
|
33
|
+
updatedAt
|
|
34
|
+
ExtProductFoodsSubOptionalAll {
|
|
35
|
+
pId
|
|
36
|
+
opExPid
|
|
37
|
+
idStore
|
|
38
|
+
opSubExPid
|
|
39
|
+
OptionalSubProName
|
|
40
|
+
exCodeOptionExtra
|
|
41
|
+
exCode
|
|
42
|
+
state
|
|
43
|
+
createdAt
|
|
44
|
+
updatedAt
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
`
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { useQuery, useLazyQuery } from '@apollo/client'
|
|
2
|
+
|
|
3
|
+
import { GET_ALL_SALES, GET_ALL_TOTAL_SALES } from './queries'
|
|
4
|
+
|
|
5
|
+
export const useReport = ({
|
|
6
|
+
fromDate = '',
|
|
7
|
+
more,
|
|
8
|
+
search = '',
|
|
9
|
+
channel = null,
|
|
10
|
+
toDate = '',
|
|
11
|
+
lazyQuery = false
|
|
12
|
+
}) => {
|
|
13
|
+
const [getAllSalesStore, { data: lazyDataSales, loading: lazyLoading }] = useLazyQuery(GET_ALL_SALES)
|
|
14
|
+
|
|
15
|
+
// Combine both queries to reduce separate requests
|
|
16
|
+
const { data, fetchMore, loading } = useQuery(GET_ALL_SALES, {
|
|
17
|
+
fetchPolicy: lazyQuery ? 'cache-and-network' : 'network-only',
|
|
18
|
+
skip: lazyQuery,
|
|
19
|
+
variables: {
|
|
20
|
+
min: 0,
|
|
21
|
+
fromDate,
|
|
22
|
+
channel,
|
|
23
|
+
search,
|
|
24
|
+
toDate,
|
|
25
|
+
max: more
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
// Get total sales in the same query
|
|
30
|
+
const { data: totalSalesData } = useQuery(GET_ALL_TOTAL_SALES, {
|
|
31
|
+
variables: {
|
|
32
|
+
fromDate,
|
|
33
|
+
toDate
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
const totalSales = totalSalesData?.getAllSalesStoreTotal ?? {}
|
|
38
|
+
console.log(totalSales)
|
|
39
|
+
return {
|
|
40
|
+
getAllSalesStore: lazyQuery ? getAllSalesStore : () => { }, // Return function only if in lazy mode
|
|
41
|
+
data: lazyQuery ? lazyDataSales : data, // Use data from lazy query if available
|
|
42
|
+
loading: lazyQuery ? lazyLoading || loading : loading,
|
|
43
|
+
totalSales: totalSales.TOTAL || 0,
|
|
44
|
+
restaurant: totalSales.restaurant || 0,
|
|
45
|
+
delivery: totalSales.delivery || 0,
|
|
46
|
+
fetchMore
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { gql } from '@apollo/client'
|
|
2
|
+
|
|
3
|
+
export const GET_ALL_SALES = gql`
|
|
4
|
+
query getAllSalesStore($idStore: ID,$search: String, $min: Int, $max: Int $fromDate: String, $toDate: String ) {
|
|
5
|
+
getAllSalesStore(idStore: $idStore, search: $search, min: $min, max: $max, toDate: $toDate, fromDate: $fromDate) {
|
|
6
|
+
totalProductsPrice
|
|
7
|
+
channel
|
|
8
|
+
pDatCre
|
|
9
|
+
pCodeRef
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
`
|
|
13
|
+
|
|
14
|
+
export const GET_ALL_TOTAL_SALES = gql`
|
|
15
|
+
query getAllSalesStoreTotal($idStore: ID,$search: String, $min: Int, $max: Int $fromDate: String, $toDate: String) {
|
|
16
|
+
getAllSalesStoreTotal(idStore: $idStore, search: $search, min: $min, max: $max, toDate: $toDate, fromDate: $fromDate) {
|
|
17
|
+
restaurant
|
|
18
|
+
delivery
|
|
19
|
+
TOTAL
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
`
|
|
23
|
+
export const GET_ALL_SALES_STATISTICS = gql`
|
|
24
|
+
query getAllSalesStoreStatistic($idStore: ID,$search: String, $min: Int, $max: Int $fromDate: DateTime, $toDate: DateTime ) {
|
|
25
|
+
getAllSalesStoreStatistic(idStore: $idStore, search: $search, min: $min, max: $max, toDate: $toDate, fromDate: $fromDate) {
|
|
26
|
+
pdpId
|
|
27
|
+
idStore
|
|
28
|
+
pCodeRef
|
|
29
|
+
payId
|
|
30
|
+
pPRecoger
|
|
31
|
+
totalProductsPrice
|
|
32
|
+
pSState
|
|
33
|
+
pDatCre
|
|
34
|
+
locationUser
|
|
35
|
+
pDatMod
|
|
36
|
+
getAllPedidoStore{
|
|
37
|
+
pdpId
|
|
38
|
+
pId
|
|
39
|
+
idStore
|
|
40
|
+
ShoppingCard
|
|
41
|
+
pCodeRef
|
|
42
|
+
pPStateP
|
|
43
|
+
payId
|
|
44
|
+
pPRecoger
|
|
45
|
+
pDatCre
|
|
46
|
+
pDatMod
|
|
47
|
+
getAllShoppingCard {
|
|
48
|
+
ShoppingCard
|
|
49
|
+
comments
|
|
50
|
+
cantProducts
|
|
51
|
+
pId
|
|
52
|
+
productFood{
|
|
53
|
+
pId
|
|
54
|
+
carProId
|
|
55
|
+
colorId
|
|
56
|
+
idStore
|
|
57
|
+
pName
|
|
58
|
+
ProPrice
|
|
59
|
+
ProDescuento
|
|
60
|
+
ProDescription
|
|
61
|
+
ValueDelivery
|
|
62
|
+
ProImage
|
|
63
|
+
ProStar
|
|
64
|
+
pState
|
|
65
|
+
pDatCre
|
|
66
|
+
pDatMod
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
`
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param array
|
|
4
|
+
*/
|
|
5
|
+
export function filterAndSortByDate (array = []) {
|
|
6
|
+
const isError = !Array.isArray(array) || !array.length
|
|
7
|
+
try {
|
|
8
|
+
if (isError) return []
|
|
9
|
+
|
|
10
|
+
const currentDate = new Date()
|
|
11
|
+
const sevenDaysAgo = currentDate.getTime() - 7 * 24 * 60 * 60 * 1000
|
|
12
|
+
|
|
13
|
+
const filteredAndSorted = array.map(item => {
|
|
14
|
+
const createdAtDate = new Date(item.createdAt)
|
|
15
|
+
const isNew = (createdAtDate.getTime() <= sevenDaysAgo)
|
|
16
|
+
return { ...item, isNew }
|
|
17
|
+
}).sort((a, b) => {
|
|
18
|
+
const dateA = new Date(a.createdAt).getTime()
|
|
19
|
+
const dateB = new Date(b.createdAt).getTime()
|
|
20
|
+
return dateB - dateA
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
return filteredAndSorted
|
|
24
|
+
} catch (error) {
|
|
25
|
+
if (isError) return []
|
|
26
|
+
if (Array.isArray(array)) return array
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { addTenMinutes } from '../../addTenMinutes'
|
|
2
|
+
import { statusOpenStores } from '../../statusOpenStores'
|
|
3
|
+
|
|
4
|
+
export const getStatusForStores = (stores = []) => {
|
|
5
|
+
return stores.map((store) => {
|
|
6
|
+
const min = addTenMinutes(store?.deliveryTimeMinutes)
|
|
7
|
+
if (store?.scheduleOpenAll) {
|
|
8
|
+
return {
|
|
9
|
+
...store,
|
|
10
|
+
status: { message: '', open: true },
|
|
11
|
+
open: 1,
|
|
12
|
+
min: min ?? ''
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
const dataSchedules =
|
|
16
|
+
(store?.getStoreSchedules?.length > 0 && store.getStoreSchedules) || []
|
|
17
|
+
const status = statusOpenStores({ dataSchedules })
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
...store,
|
|
21
|
+
status,
|
|
22
|
+
min: min ?? '',
|
|
23
|
+
open: status?.open ? 1 : 0
|
|
24
|
+
}
|
|
25
|
+
}).sort((a, b) => {return b.open - a.open})
|
|
26
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { useLazyQuery } from '@apollo/client'
|
|
2
|
+
import { useEffect, useState } from 'react'
|
|
3
|
+
|
|
4
|
+
import { useManageQueryParams } from '../useManageQueryParams'
|
|
5
|
+
|
|
6
|
+
import { filterAndSortByDate } from './helpers'
|
|
7
|
+
import { getStatusForStores } from './helpers/manageStatusOpen'
|
|
8
|
+
import { GET_ALL_RESTAURANT } from './queries'
|
|
9
|
+
|
|
10
|
+
export const useRestaurant = ({
|
|
11
|
+
location = {
|
|
12
|
+
query: {},
|
|
13
|
+
push: (props, state, { shallow }) => {
|
|
14
|
+
return { ...props, state, shallow }
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
} = {}) => {
|
|
18
|
+
const [loadingFilter, setLoadingFilter] = useState(false)
|
|
19
|
+
const { handleQuery, handleCleanQuery } = useManageQueryParams({
|
|
20
|
+
location
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
const [getAllStoreInStore, {
|
|
24
|
+
data,
|
|
25
|
+
loading,
|
|
26
|
+
error,
|
|
27
|
+
fetchMore
|
|
28
|
+
}] = useLazyQuery(GET_ALL_RESTAURANT, {
|
|
29
|
+
fetchPolicy: 'cache-and-network',
|
|
30
|
+
notifyOnNetworkStatusChange: true,
|
|
31
|
+
nextFetchPolicy: 'cache-first',
|
|
32
|
+
refetchWritePolicy: 'merge',
|
|
33
|
+
context: { clientName: 'admin-store' }
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
getAllStoreInStore({})
|
|
38
|
+
}, [location])
|
|
39
|
+
const handleSendQueries = (name, value) => {
|
|
40
|
+
if (value) handleQuery(name, value)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const handleCleanQueries = (name) => {
|
|
44
|
+
handleCleanQuery(name)
|
|
45
|
+
}
|
|
46
|
+
const handleFilterStore = async () => {
|
|
47
|
+
setLoadingFilter(true)
|
|
48
|
+
try {
|
|
49
|
+
await getAllStoreInStore({
|
|
50
|
+
|
|
51
|
+
}).then(() => {
|
|
52
|
+
setLoadingFilter(false)
|
|
53
|
+
})
|
|
54
|
+
} catch (error) {
|
|
55
|
+
setLoadingFilter(false)
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const dataRestaurant = data?.getAllStoreInStore || []
|
|
59
|
+
const dataSort = filterAndSortByDate(dataRestaurant)
|
|
60
|
+
const statuses = getStatusForStores(dataSort)
|
|
61
|
+
|
|
62
|
+
return [statuses, {
|
|
63
|
+
loading,
|
|
64
|
+
loadingFilter,
|
|
65
|
+
error,
|
|
66
|
+
fetchMore,
|
|
67
|
+
handleSendQueries,
|
|
68
|
+
handleFilterStore,
|
|
69
|
+
handleCleanQueries
|
|
70
|
+
}]
|
|
71
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { gql } from '@apollo/client'
|
|
2
|
+
export const GET_ALL_RESTAURANT = gql`
|
|
3
|
+
query getAllStoreInStore($search: String, $min: Int, $max: Int){
|
|
4
|
+
getAllStoreInStore(search: $search, min: $min, max: $max) {
|
|
5
|
+
open
|
|
6
|
+
scheduleOpenAll
|
|
7
|
+
getStoreSchedules {
|
|
8
|
+
idStore
|
|
9
|
+
schId
|
|
10
|
+
schDay
|
|
11
|
+
schHoSta
|
|
12
|
+
schHoEnd
|
|
13
|
+
schState
|
|
14
|
+
}
|
|
15
|
+
idStore
|
|
16
|
+
cId
|
|
17
|
+
id
|
|
18
|
+
dId
|
|
19
|
+
deliveryTimeMinutes
|
|
20
|
+
ctId
|
|
21
|
+
catStore
|
|
22
|
+
neighborhoodStore
|
|
23
|
+
Viaprincipal
|
|
24
|
+
storeOwner
|
|
25
|
+
storeName
|
|
26
|
+
cateStore{
|
|
27
|
+
catStore
|
|
28
|
+
cName
|
|
29
|
+
}
|
|
30
|
+
emailStore
|
|
31
|
+
storePhone
|
|
32
|
+
socialRaz
|
|
33
|
+
Image
|
|
34
|
+
banner
|
|
35
|
+
documentIdentifier
|
|
36
|
+
uPhoNum
|
|
37
|
+
ULocation
|
|
38
|
+
upLat
|
|
39
|
+
upLon
|
|
40
|
+
uState
|
|
41
|
+
siteWeb
|
|
42
|
+
description
|
|
43
|
+
NitStore
|
|
44
|
+
typeRegiments
|
|
45
|
+
typeContribute
|
|
46
|
+
secVia
|
|
47
|
+
addressStore
|
|
48
|
+
createdAt
|
|
49
|
+
pais{
|
|
50
|
+
cId
|
|
51
|
+
cName
|
|
52
|
+
cCalCod
|
|
53
|
+
cState
|
|
54
|
+
cDatCre
|
|
55
|
+
cDatMod
|
|
56
|
+
}
|
|
57
|
+
city {
|
|
58
|
+
ctId
|
|
59
|
+
dId
|
|
60
|
+
cName
|
|
61
|
+
cState
|
|
62
|
+
cDatCre
|
|
63
|
+
cDatMod
|
|
64
|
+
}
|
|
65
|
+
department {
|
|
66
|
+
dId
|
|
67
|
+
cId
|
|
68
|
+
dName
|
|
69
|
+
dState
|
|
70
|
+
dDatCre
|
|
71
|
+
dDatMod
|
|
72
|
+
}
|
|
73
|
+
getAllRatingStar {
|
|
74
|
+
rSId
|
|
75
|
+
rScore
|
|
76
|
+
idStore
|
|
77
|
+
createAt
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
`
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useQuery } from '@apollo/client'
|
|
2
|
+
|
|
3
|
+
import { GET_ALL_ROAD } from './queries'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Custom hook to fetch all roads.
|
|
7
|
+
*
|
|
8
|
+
* @returns {Object} - Returns an object containing road data and any associated query state/error.
|
|
9
|
+
*/
|
|
10
|
+
export function useRoads () {
|
|
11
|
+
const { data, loading, error } = useQuery(GET_ALL_ROAD)
|
|
12
|
+
|
|
13
|
+
// Here, you can handle any additional logic you might need, like mapping data, handling errors, etc.
|
|
14
|
+
|
|
15
|
+
return {
|
|
16
|
+
data: data || [],
|
|
17
|
+
loading,
|
|
18
|
+
error
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { gql } from '@apollo/client'
|
|
2
|
+
|
|
3
|
+
export const GET_ALL_ROLES = gql`
|
|
4
|
+
query getRoles($idStore: ID, $search: String, $min: Int, $max: Int, $fromDate: DateTime, $toDate: DateTime, $page: Int) {
|
|
5
|
+
getRoles(idStore: $idStore, search: $search, min: $min, max: $max, fromDate: $fromDate, toDate: $toDate, page: $page) {
|
|
6
|
+
success
|
|
7
|
+
message
|
|
8
|
+
errors {
|
|
9
|
+
path
|
|
10
|
+
message
|
|
11
|
+
type
|
|
12
|
+
context {
|
|
13
|
+
limit
|
|
14
|
+
value
|
|
15
|
+
label
|
|
16
|
+
key
|
|
17
|
+
}
|
|
18
|
+
__typename
|
|
19
|
+
}
|
|
20
|
+
pagination {
|
|
21
|
+
totalRecords
|
|
22
|
+
totalPages
|
|
23
|
+
currentPage
|
|
24
|
+
__typename
|
|
25
|
+
}
|
|
26
|
+
data {
|
|
27
|
+
idRole
|
|
28
|
+
name
|
|
29
|
+
priority
|
|
30
|
+
description
|
|
31
|
+
permissions
|
|
32
|
+
createdAt
|
|
33
|
+
updatedAt
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
`
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Mutación para crear un nuevo rol
|
|
41
|
+
*/
|
|
42
|
+
export const CREATE_ROLE_MUTATION = gql`
|
|
43
|
+
mutation createRoleMutation($input: IRole!) {
|
|
44
|
+
createRoleMutation(input: $input) {
|
|
45
|
+
success
|
|
46
|
+
message
|
|
47
|
+
errors {
|
|
48
|
+
path
|
|
49
|
+
message
|
|
50
|
+
type
|
|
51
|
+
context {
|
|
52
|
+
limit
|
|
53
|
+
value
|
|
54
|
+
label
|
|
55
|
+
key
|
|
56
|
+
}
|
|
57
|
+
__typename
|
|
58
|
+
}
|
|
59
|
+
data {
|
|
60
|
+
idRole
|
|
61
|
+
name
|
|
62
|
+
priority
|
|
63
|
+
description
|
|
64
|
+
permissions
|
|
65
|
+
createdAt
|
|
66
|
+
updatedAt
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
`
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { useMutation } from '@apollo/client'
|
|
2
|
+
|
|
3
|
+
import { CREATE_ROLE_MUTATION } from './queries'
|
|
4
|
+
/**
|
|
5
|
+
* Custom hook para crear un nuevo rol
|
|
6
|
+
* @param root0
|
|
7
|
+
* @param root0.sendNotification
|
|
8
|
+
* @returns {Object} - Estado de la mutación, incluyendo loading, error, data y la función createRoleMutation
|
|
9
|
+
*/
|
|
10
|
+
export const useCreateRole = ({
|
|
11
|
+
sendNotification = () => {
|
|
12
|
+
return {
|
|
13
|
+
title: '',
|
|
14
|
+
description: '',
|
|
15
|
+
backgroundColor: ''
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
} = {
|
|
19
|
+
sendNotification: () => {
|
|
20
|
+
}
|
|
21
|
+
}) => {
|
|
22
|
+
const [createRoleMutation, { loading, error, data }] = useMutation(CREATE_ROLE_MUTATION, {
|
|
23
|
+
onError: () => {
|
|
24
|
+
sendNotification({
|
|
25
|
+
title: 'Error',
|
|
26
|
+
description: 'Ocurrió un error inesperado',
|
|
27
|
+
backgroundColor: 'error'
|
|
28
|
+
})
|
|
29
|
+
},
|
|
30
|
+
onCompleted: () => {
|
|
31
|
+
return null
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
return [createRoleMutation, {
|
|
36
|
+
loading,
|
|
37
|
+
error,
|
|
38
|
+
data: data?.createRoleMutation ?? null
|
|
39
|
+
}]
|
|
40
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { useQuery } from '@apollo/client'
|
|
2
|
+
|
|
3
|
+
import { GET_ALL_ROLES } from './queries'
|
|
4
|
+
|
|
5
|
+
export const useGetRoles = ({
|
|
6
|
+
max,
|
|
7
|
+
order = 'DESC',
|
|
8
|
+
search,
|
|
9
|
+
sendNotification = () => { }
|
|
10
|
+
} = {}) => {
|
|
11
|
+
const {
|
|
12
|
+
loading,
|
|
13
|
+
error,
|
|
14
|
+
called,
|
|
15
|
+
data,
|
|
16
|
+
refetch
|
|
17
|
+
} = useQuery(GET_ALL_ROLES, {
|
|
18
|
+
onError: () => {
|
|
19
|
+
sendNotification({
|
|
20
|
+
title: 'Error',
|
|
21
|
+
description: 'Algo salió mal',
|
|
22
|
+
backgroundColor: 'error'
|
|
23
|
+
})
|
|
24
|
+
},
|
|
25
|
+
variables: {
|
|
26
|
+
search,
|
|
27
|
+
max: max || 25,
|
|
28
|
+
order
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
return [data?.getRoles, {
|
|
32
|
+
loading: called ? false : loading,
|
|
33
|
+
buttonLoading: loading,
|
|
34
|
+
error,
|
|
35
|
+
refetch
|
|
36
|
+
}]
|
|
37
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { useMutation, gql } from '@apollo/client'
|
|
2
|
+
|
|
3
|
+
// Define the GraphQL mutation
|
|
4
|
+
const REMOVE_ROLES_MUTATION = gql`
|
|
5
|
+
mutation removeRoles($roleIds: [ID!]!) {
|
|
6
|
+
removeRoles(roleIds: $roleIds) {
|
|
7
|
+
success
|
|
8
|
+
message
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
`
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Custom hook to call removeRoles mutation.
|
|
15
|
+
*
|
|
16
|
+
* @returns {Object} An object containing the mutation function and the loading/error state.
|
|
17
|
+
*/
|
|
18
|
+
export function useRemoveRoles () {
|
|
19
|
+
const [removeRoles, { loading, error, data }] = useMutation(REMOVE_ROLES_MUTATION, {
|
|
20
|
+
onError: (err) => {
|
|
21
|
+
console.error('Error removing roles:', err)
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
const removeRolesHandler = async ({ roleIds = [] }) => {
|
|
26
|
+
try {
|
|
27
|
+
const { data } = await removeRoles({ variables: { roleIds } })
|
|
28
|
+
return data.removeRoles
|
|
29
|
+
} catch (err) {
|
|
30
|
+
console.error('Error removing roles:', err)
|
|
31
|
+
throw err
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return [removeRolesHandler, {
|
|
36
|
+
loading,
|
|
37
|
+
error,
|
|
38
|
+
data
|
|
39
|
+
}]
|
|
40
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { useMutation, gql } from '@apollo/client'
|
|
2
|
+
|
|
3
|
+
// Define the mutation
|
|
4
|
+
const UPDATE_ROLES_PRIORITY = gql`
|
|
5
|
+
mutation updateRolesPriority($roles: [IParamsPriority]!) {
|
|
6
|
+
updateRolesPriority(roles: $roles) {
|
|
7
|
+
success
|
|
8
|
+
message
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
`
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Custom hook to update roles priority
|
|
15
|
+
* @returns {Object} - Returns the mutation function and the mutation state
|
|
16
|
+
*/
|
|
17
|
+
export const useUpdateRolesPriority = () => {
|
|
18
|
+
const [updateRolesPriority, { data, loading, error }] = useMutation(UPDATE_ROLES_PRIORITY)
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Function to update the priority of roles
|
|
22
|
+
* @param {Array} roles - The array of roles with their priorities to be updated
|
|
23
|
+
* @returns {Promise<void>}
|
|
24
|
+
*/
|
|
25
|
+
const handleUpdateRolesPriority = async (roles) => {
|
|
26
|
+
try {
|
|
27
|
+
const response = await updateRolesPriority({
|
|
28
|
+
variables: { roles }
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
// You can handle the response or any additional logic here
|
|
32
|
+
return response
|
|
33
|
+
} catch (err) {
|
|
34
|
+
// Handle the error as needed
|
|
35
|
+
console.error('Error updating roles priority:', err)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return [handleUpdateRolesPriority, {
|
|
40
|
+
data,
|
|
41
|
+
loading,
|
|
42
|
+
error
|
|
43
|
+
}]
|
|
44
|
+
}
|