npm-pkg-hook 1.12.3 → 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 -146
- 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/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,38 +0,0 @@
|
|
|
1
|
-
import { useState, useEffect } from 'react'
|
|
2
|
-
import { useQuery, gql } from '@apollo/client'
|
|
3
|
-
import { fillMissingDates } from './helpers'
|
|
4
|
-
|
|
5
|
-
const GET_STOCK_MOVEMENTS = gql`
|
|
6
|
-
query {
|
|
7
|
-
getStockMovementsByDay {
|
|
8
|
-
date
|
|
9
|
-
total_in,
|
|
10
|
-
total_adjustment
|
|
11
|
-
total_out
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
`
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Custom hook to fetch stock movements data for visualization.
|
|
18
|
-
* @returns {Object} { data, loading, error }
|
|
19
|
-
*/
|
|
20
|
-
export const useStockMovements = () => {
|
|
21
|
-
const { data, loading, error } = useQuery(GET_STOCK_MOVEMENTS)
|
|
22
|
-
const [chartData, setChartData] = useState([])
|
|
23
|
-
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
if (data && data.getStockMovementsByDay) {
|
|
26
|
-
// Transform data to be compatible with Recharts
|
|
27
|
-
const formattedData = data.getStockMovementsByDay.map(entry => ({
|
|
28
|
-
date: entry.date,
|
|
29
|
-
TotalIn: entry.total_in ?? 0,
|
|
30
|
-
TotalOut: entry.total_out ?? 0,
|
|
31
|
-
TotalAdjustment: entry.total_adjustment ?? 0
|
|
32
|
-
}))
|
|
33
|
-
setChartData(formattedData)
|
|
34
|
-
}
|
|
35
|
-
}, [data])
|
|
36
|
-
|
|
37
|
-
return [fillMissingDates(chartData), { loading, error }]
|
|
38
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { useState, useEffect } from 'react'
|
|
2
|
-
import { useApolloClient, useQuery } from '@apollo/client'
|
|
3
|
-
import { GET_ONE_STORE, GET_ONE_STORE_BY_ID } from './queries' // Reemplaza con la importación correcta de tu consulta
|
|
4
|
-
import { errorHandler } from '../../config/client'
|
|
5
|
-
import { useLogout } from '../useLogout'
|
|
6
|
-
|
|
7
|
-
export const useStore = ({
|
|
8
|
-
isClient = false,
|
|
9
|
-
idStore = null,
|
|
10
|
-
callback = () => { }
|
|
11
|
-
} = {}) => {
|
|
12
|
-
const client = useApolloClient()
|
|
13
|
-
const [onClickLogout, { loading: load }] = useLogout()
|
|
14
|
-
|
|
15
|
-
// Variables para almacenar los datos del store
|
|
16
|
-
const [store, setStore] = useState({})
|
|
17
|
-
const [loading, setLoading] = useState(false)
|
|
18
|
-
const [error, setError] = useState(null)
|
|
19
|
-
|
|
20
|
-
// Intentar leer los datos de la caché
|
|
21
|
-
const cachedData = client.readQuery({ query: GET_ONE_STORE })
|
|
22
|
-
|
|
23
|
-
useEffect(() => {
|
|
24
|
-
if (cachedData) {
|
|
25
|
-
const array = store ? Object.keys(store) : []
|
|
26
|
-
// Comprobar si los datos de la caché ya están establecidos en el estado
|
|
27
|
-
if ((!store || Array.isArray(array)) && array?.length === 0) {
|
|
28
|
-
setStore(cachedData.getStore)
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
callback(store)
|
|
32
|
-
}, [cachedData, store])
|
|
33
|
-
|
|
34
|
-
if (isClient && !!idStore) {
|
|
35
|
-
const {
|
|
36
|
-
data,
|
|
37
|
-
refetch,
|
|
38
|
-
loading: loadingClient,
|
|
39
|
-
error: errorStoreClient
|
|
40
|
-
} = useQuery(GET_ONE_STORE_BY_ID, {
|
|
41
|
-
skip: !isClient,
|
|
42
|
-
variables: {
|
|
43
|
-
idStore
|
|
44
|
-
}
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
const dataOneStoreClient = !loadingClient ? data?.getOneStore : {}
|
|
48
|
-
|
|
49
|
-
return [dataOneStoreClient, {
|
|
50
|
-
refetch,
|
|
51
|
-
loading: loadingClient,
|
|
52
|
-
error: errorStoreClient
|
|
53
|
-
}]
|
|
54
|
-
} else {
|
|
55
|
-
const { loading: loadingServer } = useQuery(GET_ONE_STORE, {
|
|
56
|
-
skip: isClient && !idStore,
|
|
57
|
-
variables: {
|
|
58
|
-
idStore
|
|
59
|
-
},
|
|
60
|
-
fetchPolicy: 'cache-first',
|
|
61
|
-
onCompleted: (data) => {
|
|
62
|
-
const { getStore } = data || {}
|
|
63
|
-
setStore(getStore)
|
|
64
|
-
setLoading(false)
|
|
65
|
-
},
|
|
66
|
-
onError: (err) => {
|
|
67
|
-
if (err.networkError && err.networkError.result) {
|
|
68
|
-
const response = errorHandler(err.networkError.result)
|
|
69
|
-
if (response) {
|
|
70
|
-
onClickLogout()
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
setError(err)
|
|
74
|
-
setLoading(false)
|
|
75
|
-
}
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
return [store, { loading: load || loadingServer || loading, error }]
|
|
79
|
-
}
|
|
80
|
-
}
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import { gql } from '@apollo/client'
|
|
2
|
-
|
|
3
|
-
export const CREATE_ONE_STORE = gql`
|
|
4
|
-
mutation newRegisterStore($input: IStore){
|
|
5
|
-
newRegisterStore(input: $input){
|
|
6
|
-
success
|
|
7
|
-
message
|
|
8
|
-
idStore
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
`
|
|
12
|
-
|
|
13
|
-
export const GET_ONE_STORE = gql`
|
|
14
|
-
query getStore($id: ID, $idStore: ID) {
|
|
15
|
-
getStore(id: $id, idStore: $idStore) {
|
|
16
|
-
cId
|
|
17
|
-
id
|
|
18
|
-
deliveryTimeMinutes
|
|
19
|
-
scheduleOpenAll
|
|
20
|
-
dId
|
|
21
|
-
idStore
|
|
22
|
-
ctId
|
|
23
|
-
neighborhoodStore
|
|
24
|
-
Viaprincipal
|
|
25
|
-
catStore
|
|
26
|
-
storeOwner
|
|
27
|
-
storeName
|
|
28
|
-
ImageName
|
|
29
|
-
emailStore
|
|
30
|
-
storePhone
|
|
31
|
-
socialRaz
|
|
32
|
-
Image
|
|
33
|
-
banner
|
|
34
|
-
|
|
35
|
-
documentIdentifier
|
|
36
|
-
uPhoNum
|
|
37
|
-
storeName
|
|
38
|
-
ULocation
|
|
39
|
-
upLat
|
|
40
|
-
upLon
|
|
41
|
-
uState
|
|
42
|
-
siteWeb
|
|
43
|
-
dailyGoal
|
|
44
|
-
description
|
|
45
|
-
createdAt
|
|
46
|
-
secVia
|
|
47
|
-
NitStore
|
|
48
|
-
typeRegiments
|
|
49
|
-
typeContribute
|
|
50
|
-
addressStore
|
|
51
|
-
pais {
|
|
52
|
-
cId
|
|
53
|
-
cName
|
|
54
|
-
cCalCod
|
|
55
|
-
cState
|
|
56
|
-
cDatCre
|
|
57
|
-
cDatMod
|
|
58
|
-
}
|
|
59
|
-
city {
|
|
60
|
-
ctId
|
|
61
|
-
dId
|
|
62
|
-
cName
|
|
63
|
-
cState
|
|
64
|
-
cDatCre
|
|
65
|
-
cDatMod
|
|
66
|
-
}
|
|
67
|
-
department {
|
|
68
|
-
dId
|
|
69
|
-
cId
|
|
70
|
-
dName
|
|
71
|
-
dState
|
|
72
|
-
dDatCre
|
|
73
|
-
dDatMod
|
|
74
|
-
}
|
|
75
|
-
getStoreSchedules {
|
|
76
|
-
idStore
|
|
77
|
-
schId
|
|
78
|
-
id
|
|
79
|
-
schDay
|
|
80
|
-
schHoSta
|
|
81
|
-
schHoEnd
|
|
82
|
-
schState
|
|
83
|
-
}
|
|
84
|
-
cateStore {
|
|
85
|
-
catStore
|
|
86
|
-
cName
|
|
87
|
-
cState
|
|
88
|
-
createdAt
|
|
89
|
-
updatedAt
|
|
90
|
-
csDescription
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
`
|
|
95
|
-
export const GET_ONE_STORE_BY_ID = gql`
|
|
96
|
-
query getOneStore($StoreName: String, $idStore: ID){
|
|
97
|
-
getOneStore(idStore: $idStore, StoreName: $StoreName) {
|
|
98
|
-
idStore
|
|
99
|
-
cId
|
|
100
|
-
id
|
|
101
|
-
dId
|
|
102
|
-
ctId
|
|
103
|
-
catStore
|
|
104
|
-
neighborhoodStore
|
|
105
|
-
Viaprincipal
|
|
106
|
-
storeOwner
|
|
107
|
-
storeName
|
|
108
|
-
emailStore
|
|
109
|
-
storePhone
|
|
110
|
-
socialRaz
|
|
111
|
-
Image
|
|
112
|
-
banner
|
|
113
|
-
documentIdentifier
|
|
114
|
-
uPhoNum
|
|
115
|
-
ULocation
|
|
116
|
-
upLat
|
|
117
|
-
upLon
|
|
118
|
-
uState
|
|
119
|
-
siteWeb
|
|
120
|
-
description
|
|
121
|
-
NitStore
|
|
122
|
-
typeRegiments
|
|
123
|
-
typeContribute
|
|
124
|
-
secVia
|
|
125
|
-
addressStore
|
|
126
|
-
createdAt
|
|
127
|
-
pais{
|
|
128
|
-
cId
|
|
129
|
-
cName
|
|
130
|
-
cCalCod
|
|
131
|
-
cState
|
|
132
|
-
cDatCre
|
|
133
|
-
cDatMod
|
|
134
|
-
}
|
|
135
|
-
city {
|
|
136
|
-
ctId
|
|
137
|
-
dId
|
|
138
|
-
cName
|
|
139
|
-
cState
|
|
140
|
-
cDatCre
|
|
141
|
-
cDatMod
|
|
142
|
-
}
|
|
143
|
-
department {
|
|
144
|
-
dId
|
|
145
|
-
cId
|
|
146
|
-
dName
|
|
147
|
-
dState
|
|
148
|
-
dDatCre
|
|
149
|
-
dDatMod
|
|
150
|
-
}
|
|
151
|
-
cateStore {
|
|
152
|
-
catStore
|
|
153
|
-
idUser
|
|
154
|
-
cName
|
|
155
|
-
cState
|
|
156
|
-
cDatCre
|
|
157
|
-
cDatMod
|
|
158
|
-
csDescription
|
|
159
|
-
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
`
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { useQuery, useMutation, useLazyQuery } from '@apollo/client'
|
|
2
|
-
import { useState } from 'react'
|
|
3
|
-
import {
|
|
4
|
-
GET_ALL_CONTACTS,
|
|
5
|
-
EDIT_ONE_CONTACT,
|
|
6
|
-
CREATE_CONTACTS,
|
|
7
|
-
GET_ONE_CONTACT
|
|
8
|
-
} from './queries'
|
|
9
|
-
|
|
10
|
-
export const useGetStoreContacts = ({
|
|
11
|
-
sendNotification = () => { },
|
|
12
|
-
max,
|
|
13
|
-
search = ''
|
|
14
|
-
} = {}) => {
|
|
15
|
-
const [clientes, setUseStoreContacts] = useState([])
|
|
16
|
-
const { loading, error, fetchMore, called } = useQuery(GET_ALL_CONTACTS, {
|
|
17
|
-
variables: {
|
|
18
|
-
max,
|
|
19
|
-
search
|
|
20
|
-
},
|
|
21
|
-
onCompleted: (data) => {
|
|
22
|
-
setUseStoreContacts(data)
|
|
23
|
-
}
|
|
24
|
-
})
|
|
25
|
-
return [clientes?.getAllContacts || [], { loading: called ? false : loading, error, fetchMore }]
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export const useDeleteUseStoreContacts = ({ sendNotification = () => { } } = {}) => {
|
|
29
|
-
const [getOneContacts, { data, error, loading }] = useLazyQuery(GET_ONE_CONTACT)
|
|
30
|
-
return [getOneContacts, data?.getOneContacts ?? {}, { loading, error }]
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export const useGetOneUseStoreContacts = ({ sendNotification = () => { } } = {}) => {
|
|
34
|
-
const [getOneContacts, { data, error, loading }] = useLazyQuery(GET_ONE_CONTACT)
|
|
35
|
-
return [getOneContacts, { data: data?.getOneContacts, loading, error }]
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export const useEditOneUseStoreContacts = ({ sendNotification = () => { } } = {}) => {
|
|
39
|
-
const [editOneContacts, { data, error, loading }] = useMutation(EDIT_ONE_CONTACT)
|
|
40
|
-
return [editOneContacts, { data: data?.editOneContacts, loading, error }]
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export const useCreateContacts = ({ sendNotification = () => { } } = {}) => {
|
|
44
|
-
const [createUseStoreContacts, { loading, error }] = useMutation(CREATE_CONTACTS)
|
|
45
|
-
|
|
46
|
-
return [createUseStoreContacts, { loading, error }]
|
|
47
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { gql } from '@apollo/client'
|
|
2
|
-
|
|
3
|
-
export const CREATE_CONTACTS = gql`
|
|
4
|
-
mutation createContacts ($input: IContacts) {
|
|
5
|
-
createContacts(input: $input) {
|
|
6
|
-
success
|
|
7
|
-
message
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
`
|
|
11
|
-
export const GET_ALL_CONTACTS = gql`
|
|
12
|
-
query getAllContacts($idStore: ID, $cId: ID, $dId: ID, $ctId: ID, $search: String, $min: Int, $pState: Int, $max: Int) {
|
|
13
|
-
getAllContacts(idStore: $idStore, cId: $cId, dId: $dId, ctId: $ctId, search: $search, min: $min, pState: $pState, max: $max) {
|
|
14
|
-
contactId
|
|
15
|
-
cntState
|
|
16
|
-
cntComments
|
|
17
|
-
cntNumberPhone
|
|
18
|
-
cntName
|
|
19
|
-
createAt
|
|
20
|
-
updateAt
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
`
|
|
24
|
-
|
|
25
|
-
export const GET_ONE_CONTACT = gql`
|
|
26
|
-
query getOneContacts($contactId: String) {
|
|
27
|
-
getOneContacts(contactId: $contactId) {
|
|
28
|
-
contactId
|
|
29
|
-
id
|
|
30
|
-
idStore
|
|
31
|
-
cntName
|
|
32
|
-
cntComments
|
|
33
|
-
cntNumberPhone
|
|
34
|
-
cntState
|
|
35
|
-
createAt
|
|
36
|
-
updateAt
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
`
|
|
40
|
-
|
|
41
|
-
export const EDIT_ONE_CONTACT = gql`
|
|
42
|
-
mutation editOneContacts($input: IContacts) {
|
|
43
|
-
editOneContacts(input: $input) {
|
|
44
|
-
success
|
|
45
|
-
message
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
`
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { gql } from '@apollo/client'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* GraphQL Mutation for creating a store table
|
|
5
|
-
*/
|
|
6
|
-
export const CREATE_TABLE_MUTATION = gql`
|
|
7
|
-
mutation storeTableCreate($tableName: String!, $seats: Int, $section: String, $tableState: Int) {
|
|
8
|
-
storeTableCreate(tableName: $tableName, seats: $seats, section: $section, tableState: $tableState) {
|
|
9
|
-
success
|
|
10
|
-
message
|
|
11
|
-
errors {
|
|
12
|
-
message
|
|
13
|
-
path
|
|
14
|
-
type
|
|
15
|
-
context {
|
|
16
|
-
limit
|
|
17
|
-
value
|
|
18
|
-
label
|
|
19
|
-
key
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
data {
|
|
23
|
-
tableId
|
|
24
|
-
tableName
|
|
25
|
-
seats
|
|
26
|
-
section
|
|
27
|
-
tableState
|
|
28
|
-
createdAt
|
|
29
|
-
updatedAt
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
`
|
|
34
|
-
|
|
35
|
-
export const STORE_TABLES_QUERY = gql`
|
|
36
|
-
query {
|
|
37
|
-
storeTables {
|
|
38
|
-
tableId
|
|
39
|
-
tableName
|
|
40
|
-
seats
|
|
41
|
-
section
|
|
42
|
-
tableState
|
|
43
|
-
createdAt
|
|
44
|
-
updatedAt
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
`
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { useState } from 'react'
|
|
2
|
-
import { gql, useMutation } from '@apollo/client'
|
|
3
|
-
import { CREATE_TABLE_MUTATION } from './queries'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Custom hook to handle table creation with validation and mutation logic
|
|
7
|
-
* @param {string} tableName Name of the table
|
|
8
|
-
* @param {number} seats Number of seats at the table
|
|
9
|
-
* @param {string} section Section where the table is located
|
|
10
|
-
* @param {number} tableState Current state of the table (e.g., Active, Occupied)
|
|
11
|
-
* @returns {Object} The state of the mutation including success, message, errors, and data
|
|
12
|
-
*/
|
|
13
|
-
export const useStoreTableCreate = ({
|
|
14
|
-
sendNotification = () => {}
|
|
15
|
-
} = {}) => {
|
|
16
|
-
const [loading, setLoading] = useState(false)
|
|
17
|
-
const [createTableMutation] = useMutation(CREATE_TABLE_MUTATION)
|
|
18
|
-
/**
|
|
19
|
-
* Function to create a table with validation and mutation
|
|
20
|
-
* @param {string} tableName Table name
|
|
21
|
-
* @param {number} seats Number of seats
|
|
22
|
-
* @param {string} section Table section
|
|
23
|
-
* @param {number} tableState Table state (e.g., 0 = Unavailable, 1 = Active, 2 = Occupied)
|
|
24
|
-
*/
|
|
25
|
-
const storeTableCreate = async (tableName, seats, section, tableState) => {
|
|
26
|
-
setLoading(true) // Start loading
|
|
27
|
-
try {
|
|
28
|
-
// Call the mutation to create the table
|
|
29
|
-
const result = await createTableMutation({
|
|
30
|
-
variables: {
|
|
31
|
-
tableName,
|
|
32
|
-
seats,
|
|
33
|
-
section,
|
|
34
|
-
tableState
|
|
35
|
-
},
|
|
36
|
-
update (cache, { data: { storeTableCreate } }) {
|
|
37
|
-
if (storeTableCreate.success) {
|
|
38
|
-
// Actualizar la lista de mesas en la caché
|
|
39
|
-
cache.modify({
|
|
40
|
-
fields: {
|
|
41
|
-
storeTables (existingTables = []) {
|
|
42
|
-
const newTableRef = {
|
|
43
|
-
tableId: null,
|
|
44
|
-
tableName,
|
|
45
|
-
seats,
|
|
46
|
-
section,
|
|
47
|
-
tableState: 1
|
|
48
|
-
}
|
|
49
|
-
return [...existingTables, newTableRef]
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
})
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
sendNotification({
|
|
58
|
-
backgroundColor: result.data.storeTableCreate.success ? 'success' : 'error',
|
|
59
|
-
description: result.data.storeTableCreate.message || '',
|
|
60
|
-
title: result.data.storeTableCreate.success ? 'Success' : 'Error'
|
|
61
|
-
})
|
|
62
|
-
return result
|
|
63
|
-
} catch (error) {
|
|
64
|
-
sendNotification({
|
|
65
|
-
backgroundColor: 'error',
|
|
66
|
-
description: error.message || 'Error occurred while creating the table.',
|
|
67
|
-
title: 'Creation Failed'
|
|
68
|
-
})
|
|
69
|
-
return { success: false, message: error.message }
|
|
70
|
-
} finally {
|
|
71
|
-
setLoading(false)
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return [storeTableCreate, { loading }]
|
|
76
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { useQuery } from '@apollo/client'
|
|
2
|
-
import { STORE_TABLES_QUERY } from './queries' // Ajusta la ruta a tu archivo de queries
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Custom hook to fetch store tables data
|
|
6
|
-
* @param {Object} args - Arguments for fetching store tables, e.g., info field.
|
|
7
|
-
* @param {Object} ctx - Context that provides restaurant-related information.
|
|
8
|
-
* @returns {Object} - Object containing tables data, loading state, and error.
|
|
9
|
-
*/
|
|
10
|
-
export const useStoreTables = () => {
|
|
11
|
-
const { data, loading, error } = useQuery(STORE_TABLES_QUERY)
|
|
12
|
-
|
|
13
|
-
return [data, { loading, error }]
|
|
14
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react'
|
|
2
|
-
import { gql, useQuery } from '@apollo/client'
|
|
3
|
-
|
|
4
|
-
const VALIDATE_SUBSCRIPTION_QUERY = gql`
|
|
5
|
-
query validateFreeSubscription($idStore: ID) {
|
|
6
|
-
validateFreeSubscription(idStore: $idStore) {
|
|
7
|
-
subscriptionId
|
|
8
|
-
status
|
|
9
|
-
businessName
|
|
10
|
-
currentPeriodEnd
|
|
11
|
-
currentPeriodStart
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
`
|
|
15
|
-
|
|
16
|
-
export const useSubscriptionValidation = (idStore) => {
|
|
17
|
-
const { loading, error, data } = useQuery(VALIDATE_SUBSCRIPTION_QUERY, {
|
|
18
|
-
variables: { idStore }
|
|
19
|
-
})
|
|
20
|
-
const [daysRemaining, setDaysRemaining] = useState(null)
|
|
21
|
-
const [daysElapsed, setDaysElapsed] = useState(null)
|
|
22
|
-
|
|
23
|
-
useEffect(() => {
|
|
24
|
-
if (data && data.validateFreeSubscription) {
|
|
25
|
-
const { currentPeriodEnd, currentPeriodStart } = data.validateFreeSubscription
|
|
26
|
-
const currentDate = new Date()
|
|
27
|
-
const endOfPeriod = new Date(parseInt(currentPeriodEnd))
|
|
28
|
-
const startOfPeriod = new Date(parseInt(currentPeriodStart))
|
|
29
|
-
|
|
30
|
-
const differenceInTimeUntilEnd = endOfPeriod.getTime() - currentDate.getTime()
|
|
31
|
-
const differenceInDaysUntilEnd = Math.ceil(differenceInTimeUntilEnd / (1000 * 3600 * 24))
|
|
32
|
-
setDaysRemaining(isNaN(differenceInDaysUntilEnd) ? 0 : differenceInDaysUntilEnd)
|
|
33
|
-
|
|
34
|
-
const differenceInTimeSinceStart = currentDate.getTime() - startOfPeriod.getTime()
|
|
35
|
-
const differenceInDaysSinceStart = Math.ceil(differenceInTimeSinceStart / (1000 * 3600 * 24))
|
|
36
|
-
setDaysElapsed(isNaN(differenceInDaysSinceStart) ? 0 : differenceInDaysSinceStart)
|
|
37
|
-
}
|
|
38
|
-
}, [data])
|
|
39
|
-
|
|
40
|
-
return { loading, error, subscriptionData: data?.validateFreeSubscription, daysRemaining, daysElapsed }
|
|
41
|
-
}
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { gql, useMutation } from '@apollo/client'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* GraphQL mutation to delete a tag by ID or name.
|
|
5
|
-
*/
|
|
6
|
-
const DELETE_ONE_TAG = gql`
|
|
7
|
-
mutation deleteOneTag($tgId: ID, $nameTag: String) {
|
|
8
|
-
deleteOneTag(tgId: $tgId, nameTag: $nameTag) {
|
|
9
|
-
success
|
|
10
|
-
message
|
|
11
|
-
data {
|
|
12
|
-
tgId
|
|
13
|
-
nameTag
|
|
14
|
-
state
|
|
15
|
-
}
|
|
16
|
-
errors {
|
|
17
|
-
path
|
|
18
|
-
message
|
|
19
|
-
type
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
`
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Custom hook to delete a tag by ID or name.
|
|
27
|
-
* @returns {Object} An object with the deleteTag function and mutation state.
|
|
28
|
-
*/
|
|
29
|
-
export const useDeleteOneTag = () => {
|
|
30
|
-
const [deleteOneTag, { data, loading, error }] = useMutation(DELETE_ONE_TAG, {
|
|
31
|
-
update(cache, { data }) {
|
|
32
|
-
const deleted = data?.deleteOneTag?.data
|
|
33
|
-
const success = data?.deleteOneTag?.success
|
|
34
|
-
|
|
35
|
-
if (!success || !deleted?.tgId) return
|
|
36
|
-
|
|
37
|
-
// Update cache for getAllTags
|
|
38
|
-
cache.modify({
|
|
39
|
-
fields: {
|
|
40
|
-
getAllTags(existing = {}) {
|
|
41
|
-
const filteredData = existing?.data?.filter(
|
|
42
|
-
(tag: any) => tag.tgId !== deleted.tgId
|
|
43
|
-
) || []
|
|
44
|
-
|
|
45
|
-
return {
|
|
46
|
-
...existing,
|
|
47
|
-
data: filteredData,
|
|
48
|
-
pagination: {
|
|
49
|
-
...existing.pagination,
|
|
50
|
-
totalRecords: Math.max((existing.pagination?.totalRecords || 1) - 1, 0)
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
})
|
|
56
|
-
},
|
|
57
|
-
// optional, remove if you prefer default behavior
|
|
58
|
-
onError(err) {
|
|
59
|
-
console.error('❌ Apollo error in deleteOneTag:', err)
|
|
60
|
-
}
|
|
61
|
-
})
|
|
62
|
-
/**
|
|
63
|
-
* Deletes a tag by ID or name.
|
|
64
|
-
* @param {Object} variables - Mutation input.
|
|
65
|
-
* @param {string} [variables.tgId] - Tag ID (optional).
|
|
66
|
-
* @param {string} [variables.nameTag] - Tag name (optional).
|
|
67
|
-
* @returns {Promise<Object>} Response from server.
|
|
68
|
-
*/
|
|
69
|
-
const handleDeleteTag = async ({
|
|
70
|
-
tgId,
|
|
71
|
-
nameTag
|
|
72
|
-
}: {
|
|
73
|
-
tgId?: string
|
|
74
|
-
nameTag?: string
|
|
75
|
-
}) => {
|
|
76
|
-
try {
|
|
77
|
-
const { data } = await deleteOneTag({
|
|
78
|
-
variables: {
|
|
79
|
-
tgId,
|
|
80
|
-
nameTag
|
|
81
|
-
}
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
return data.deleteOneTag
|
|
85
|
-
} catch (err: any) {
|
|
86
|
-
return {
|
|
87
|
-
success: false,
|
|
88
|
-
message: 'An error occurred while deleting the tag.',
|
|
89
|
-
data: null,
|
|
90
|
-
errors: [
|
|
91
|
-
{
|
|
92
|
-
path: 'mutation',
|
|
93
|
-
message: err.message || 'Unknown error',
|
|
94
|
-
type: 'server'
|
|
95
|
-
}
|
|
96
|
-
]
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return [handleDeleteTag, {
|
|
102
|
-
data,
|
|
103
|
-
loading,
|
|
104
|
-
error
|
|
105
|
-
}]
|
|
106
|
-
}
|