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,132 +0,0 @@
|
|
|
1
|
-
import { gql, useMutation } from '@apollo/client'
|
|
2
|
-
|
|
3
|
-
const CREATE_ORDER_STATUS_TYPE = gql`
|
|
4
|
-
mutation CreateOrderStatusType($data: OrderStatusTypeInput!) {
|
|
5
|
-
createOrderStatusType(data: $data) {
|
|
6
|
-
success
|
|
7
|
-
message
|
|
8
|
-
data {
|
|
9
|
-
idStatus
|
|
10
|
-
name
|
|
11
|
-
description
|
|
12
|
-
color
|
|
13
|
-
priority
|
|
14
|
-
createdAt
|
|
15
|
-
updatedAt
|
|
16
|
-
}
|
|
17
|
-
errors {
|
|
18
|
-
message
|
|
19
|
-
path
|
|
20
|
-
type
|
|
21
|
-
__typename
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
`
|
|
26
|
-
|
|
27
|
-
interface OrderStatusTypeInput {
|
|
28
|
-
name: string
|
|
29
|
-
description?: string
|
|
30
|
-
color?: string
|
|
31
|
-
priority?: number
|
|
32
|
-
state?: number
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
interface OrderStatusType {
|
|
36
|
-
idStatus: string
|
|
37
|
-
name: string
|
|
38
|
-
description: string
|
|
39
|
-
color: string
|
|
40
|
-
priority: number
|
|
41
|
-
createdAt: string
|
|
42
|
-
updatedAt: string
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
interface ResponseOrderStatusType {
|
|
46
|
-
success: boolean
|
|
47
|
-
message: string
|
|
48
|
-
data?: OrderStatusType
|
|
49
|
-
errors?: Array<{
|
|
50
|
-
message: string
|
|
51
|
-
path?: string
|
|
52
|
-
type?: string
|
|
53
|
-
__typename?: string
|
|
54
|
-
}>
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* 🧩 Hook personalizado para crear un OrderStatusType
|
|
59
|
-
*/
|
|
60
|
-
export const useCreateOrderStatusType = ({
|
|
61
|
-
sendNotification
|
|
62
|
-
}: {
|
|
63
|
-
sendNotification: (options: {
|
|
64
|
-
title: string
|
|
65
|
-
description: string
|
|
66
|
-
backgroundColor: 'success' | 'error' | 'info' | 'warning'
|
|
67
|
-
}) => void
|
|
68
|
-
}) => {
|
|
69
|
-
const [createOrderStatusType, { data, loading, error }] =
|
|
70
|
-
useMutation<{ createOrderStatusType: ResponseOrderStatusType }>(
|
|
71
|
-
CREATE_ORDER_STATUS_TYPE,
|
|
72
|
-
{
|
|
73
|
-
update(cache, { data }) {
|
|
74
|
-
console.log("🚀 ~ useCreateOrderStatusType ~ data:", data, cache)
|
|
75
|
-
const newItem = data?.createOrderStatusType?.data
|
|
76
|
-
if (!newItem) return
|
|
77
|
-
|
|
78
|
-
cache.modify({
|
|
79
|
-
fields: {
|
|
80
|
-
getAllOrderStatusTypes(existing = {}) {
|
|
81
|
-
console.log("🚀 ~ useCreateOrderStatusType ~ existing:", existing)
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
})
|
|
86
|
-
},
|
|
87
|
-
|
|
88
|
-
onCompleted: (data) => {
|
|
89
|
-
const res = data.createOrderStatusType
|
|
90
|
-
const { success, message } = res ?? {
|
|
91
|
-
success: false,
|
|
92
|
-
message: 'Error desconocido'
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
sendNotification({
|
|
96
|
-
title: success
|
|
97
|
-
? 'Estado de orden creado'
|
|
98
|
-
: 'Error al crear el estado de orden',
|
|
99
|
-
description: message,
|
|
100
|
-
backgroundColor: success ? 'success' : 'error',
|
|
101
|
-
})
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
)
|
|
105
|
-
|
|
106
|
-
const handleCreateStatus = async (input: OrderStatusTypeInput) => {
|
|
107
|
-
try {
|
|
108
|
-
const response = await createOrderStatusType({
|
|
109
|
-
variables: { data: input },
|
|
110
|
-
})
|
|
111
|
-
|
|
112
|
-
return response.data?.createOrderStatusType
|
|
113
|
-
} catch (err) {
|
|
114
|
-
sendNotification({
|
|
115
|
-
title: 'Error al crear el estado de orden',
|
|
116
|
-
description: 'Ha ocurrido un error inesperado al crear el estado de orden.',
|
|
117
|
-
backgroundColor: 'error',
|
|
118
|
-
})
|
|
119
|
-
throw err
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return [
|
|
124
|
-
handleCreateStatus,
|
|
125
|
-
{
|
|
126
|
-
data: data?.createOrderStatusType,
|
|
127
|
-
loading,
|
|
128
|
-
error,
|
|
129
|
-
}
|
|
130
|
-
]
|
|
131
|
-
}
|
|
132
|
-
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
const MAX_PRICE = 999999999999.99
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Verifica si alguno de los valores en el array excede el precio máximo.
|
|
5
|
-
*
|
|
6
|
-
* @param {Array<number>} values - Lista de valores a verificar.
|
|
7
|
-
* @param {Function} sendNotification - Función para enviar notificaciones.
|
|
8
|
-
* @returns {boolean} - Retorna `true` si todos los valores están en rango, `false` si alguno excede el máximo.
|
|
9
|
-
*/
|
|
10
|
-
export const verifyPriceInRange = ({ values = [], sendNotification }) => {
|
|
11
|
-
const isAnyValueOutOfRange = values.some(value => value > MAX_PRICE)
|
|
12
|
-
// Si algún valor está fuera del rango, envía una notificación y retorna false
|
|
13
|
-
if (isAnyValueOutOfRange) {
|
|
14
|
-
sendNotification({
|
|
15
|
-
backgroundColor: 'warning',
|
|
16
|
-
title: 'Alerta',
|
|
17
|
-
description: 'El valor es muy elevado'
|
|
18
|
-
})
|
|
19
|
-
return false
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return true
|
|
23
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Updates category and products data with a new product.
|
|
3
|
-
* @param {object} dataOld - The old data containing category and product information.
|
|
4
|
-
* @param {string} carProId - The ID of the product to update.
|
|
5
|
-
* @returns {object} Updated data with the new product added, or the original data if the product was not found.
|
|
6
|
-
*/
|
|
7
|
-
export function getCatProductsWithProduct (dataOld = {}, carProId = '') {
|
|
8
|
-
try {
|
|
9
|
-
if (!carProId || !dataOld) return dataOld
|
|
10
|
-
// Make a copy of the old data to avoid modifying the original object directly
|
|
11
|
-
const copyDataOld = { ...dataOld }
|
|
12
|
-
|
|
13
|
-
// Get the category and products data from the old data or use an empty array if it's undefined
|
|
14
|
-
const catProductsWithProduct = copyDataOld?.catProductsWithProduct || []
|
|
15
|
-
|
|
16
|
-
// Find the index of the product to update
|
|
17
|
-
const indexToUpdate = catProductsWithProduct?.findIndex(product => product?.carProId === carProId)
|
|
18
|
-
|
|
19
|
-
if (indexToUpdate !== -1) {
|
|
20
|
-
// Create a new product
|
|
21
|
-
const newProduct = {
|
|
22
|
-
__typename: 'ProductFood',
|
|
23
|
-
carProId
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// Update the productFoodsAll for the specified product
|
|
27
|
-
const newData = catProductsWithProduct?.map((catProduct) => {
|
|
28
|
-
if (catProduct?.carProId === carProId) {
|
|
29
|
-
const newProductFoodsAll = [...catProduct?.productFoodsAll, newProduct]
|
|
30
|
-
return {
|
|
31
|
-
...catProduct,
|
|
32
|
-
productFoodsAll: newProductFoodsAll
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return { ...catProduct }
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
// Return the updated data
|
|
39
|
-
return {
|
|
40
|
-
catProductsWithProduct: newData,
|
|
41
|
-
totalCount: copyDataOld.totalCount
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// Return the original data if the product was not found
|
|
46
|
-
return copyDataOld
|
|
47
|
-
} catch (error) {
|
|
48
|
-
console.error('An error occurred while updating catProductsWithProduct:', error)
|
|
49
|
-
// Return the original data in case of an error
|
|
50
|
-
return dataOld
|
|
51
|
-
}
|
|
52
|
-
}
|
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-unused-vars */
|
|
2
|
-
import { useRef, useState } from 'react'
|
|
3
|
-
|
|
4
|
-
export const useEditImageProduct = ({ sendNotification = () => { }, initialState }) => {
|
|
5
|
-
const [openEditImage, setopenEditImage] = useState(false)
|
|
6
|
-
// eslint-disable-next-line no-unused-vars
|
|
7
|
-
const [tags, setTags] = useState([])
|
|
8
|
-
const [{ src, alt }, setPreviewImg] = useState([])
|
|
9
|
-
const [errors, setErrors] = useState({})
|
|
10
|
-
const handleOpenEditImage = () => {
|
|
11
|
-
setopenEditImage(!openEditImage)
|
|
12
|
-
}
|
|
13
|
-
// eslint-disable-next-line
|
|
14
|
-
const changeHandler = (name, value) => {
|
|
15
|
-
if (name === 'tags') {
|
|
16
|
-
setTags(value)
|
|
17
|
-
if (value.length > 0 && errors.tags) {
|
|
18
|
-
setErrors(prev => {
|
|
19
|
-
const prevErrors = { ...prev }
|
|
20
|
-
delete prevErrors.tags
|
|
21
|
-
return prevErrors
|
|
22
|
-
})
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
const [existImage, setExistImage] = useState(false)
|
|
27
|
-
const [crop, setCrop] = useState({ x: 0, y: 0 })
|
|
28
|
-
const [zoom, setZoom] = useState(0)
|
|
29
|
-
const imageRef = useRef(null)
|
|
30
|
-
const onCropChange = (crop) => {
|
|
31
|
-
setCrop(crop)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const onZoomChange = (zoom) => {
|
|
35
|
-
setZoom(zoom)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const onCropComplete = (crop, pixelCrop) => {
|
|
39
|
-
const canvas = document.createElement('canvas')
|
|
40
|
-
const img = imageRef.current
|
|
41
|
-
|
|
42
|
-
canvas.width = pixelCrop.width
|
|
43
|
-
canvas.height = pixelCrop.height
|
|
44
|
-
|
|
45
|
-
const ctx = canvas.getContext('2d')
|
|
46
|
-
ctx.drawImage(
|
|
47
|
-
img,
|
|
48
|
-
pixelCrop.x,
|
|
49
|
-
pixelCrop.y,
|
|
50
|
-
pixelCrop.width,
|
|
51
|
-
pixelCrop.height,
|
|
52
|
-
0, 0,
|
|
53
|
-
pixelCrop.width,
|
|
54
|
-
pixelCrop.height)
|
|
55
|
-
// ctx.drawImage(
|
|
56
|
-
// img,
|
|
57
|
-
// pixelCrop.x,
|
|
58
|
-
// pixelCrop.y,
|
|
59
|
-
// pixelCrop.width,
|
|
60
|
-
// pixelCrop.height,
|
|
61
|
-
// 0,
|
|
62
|
-
// 0,
|
|
63
|
-
// canvas.width,
|
|
64
|
-
// canvas.height
|
|
65
|
-
// )
|
|
66
|
-
const croppedUrl = canvas.toDataURL()
|
|
67
|
-
// console.log(croppedUrl)
|
|
68
|
-
// You can use the croppedUrl for whatever you want
|
|
69
|
-
// for example, you can set it as the src of an img element
|
|
70
|
-
// or send it to a server
|
|
71
|
-
// Convert the dataURL to a blob
|
|
72
|
-
fetch(croppedUrl)
|
|
73
|
-
.then(response => { return response.blob() })
|
|
74
|
-
.then(blob => {
|
|
75
|
-
// Create a new File
|
|
76
|
-
const file = new File([blob], 'cropped_image.jpg', { type: blob.type })
|
|
77
|
-
setPreviewImg(
|
|
78
|
-
file
|
|
79
|
-
? {
|
|
80
|
-
src: URL.createObjectURL(file),
|
|
81
|
-
alt: ''
|
|
82
|
-
}
|
|
83
|
-
: initialState
|
|
84
|
-
)
|
|
85
|
-
// You can use the file object to send it to a server or to download it
|
|
86
|
-
sendNotification({
|
|
87
|
-
backgroundColor: 'success',
|
|
88
|
-
title: 'Exito',
|
|
89
|
-
description: 'Imagen editada'
|
|
90
|
-
})
|
|
91
|
-
setExistImage(true)
|
|
92
|
-
handleOpenEditImage()
|
|
93
|
-
})
|
|
94
|
-
.catch(() => {
|
|
95
|
-
sendNotification({
|
|
96
|
-
backgroundColor: 'error',
|
|
97
|
-
title: 'Error',
|
|
98
|
-
description: 'Ha ocurrido un error!'
|
|
99
|
-
})
|
|
100
|
-
})
|
|
101
|
-
// You can use the file object to send it to a server or to download it
|
|
102
|
-
}
|
|
103
|
-
function getPixelCrop (image, crop, zoom) {
|
|
104
|
-
const imgWidth = image.naturalWidth
|
|
105
|
-
const imgHeight = image.naturalHeight
|
|
106
|
-
|
|
107
|
-
const scaledWidth = imgWidth * zoom
|
|
108
|
-
const scaledHeight = imgHeight * zoom
|
|
109
|
-
|
|
110
|
-
const x = (imgWidth * crop.x) / 100
|
|
111
|
-
const y = (imgHeight * crop.y) / 100
|
|
112
|
-
|
|
113
|
-
return {
|
|
114
|
-
x,
|
|
115
|
-
y,
|
|
116
|
-
width: scaledWidth,
|
|
117
|
-
height: scaledHeight
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
const handleEditImage = () => {
|
|
121
|
-
handleOpenEditImage()
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
const [Dimage, setImage] = useState('')
|
|
125
|
-
const [cropData, setCropData] = useState('#')
|
|
126
|
-
const [cropper, setCropper] = useState()
|
|
127
|
-
const onChange = (e) => {
|
|
128
|
-
e.preventDefault()
|
|
129
|
-
let files
|
|
130
|
-
if (e.dataTransfer) {
|
|
131
|
-
files = e.dataTransfer.files
|
|
132
|
-
} else if (e.target) {
|
|
133
|
-
files = e.target.files
|
|
134
|
-
}
|
|
135
|
-
const reader = new FileReader()
|
|
136
|
-
reader.onload = () => {
|
|
137
|
-
setImage(reader.result)
|
|
138
|
-
}
|
|
139
|
-
reader.readAsDataURL(files[0])
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
const getCropData = () => {
|
|
143
|
-
if (typeof cropper !== 'undefined') {
|
|
144
|
-
setCropData(cropper.getCroppedCanvas().toDataURL())
|
|
145
|
-
fetch(cropper)
|
|
146
|
-
.then(response => { return response.blob() })
|
|
147
|
-
.then(blob => {
|
|
148
|
-
// Create a new File
|
|
149
|
-
const file = new File([blob], 'cropped_image.jpg', { type: blob.type })
|
|
150
|
-
setPreviewImg(
|
|
151
|
-
file
|
|
152
|
-
? {
|
|
153
|
-
src: URL.createObjectURL(file),
|
|
154
|
-
alt: ''
|
|
155
|
-
}
|
|
156
|
-
: initialState
|
|
157
|
-
)
|
|
158
|
-
// You can use the file object to send it to a server or to download it
|
|
159
|
-
sendNotification({ title: 'Exito', description: 'Imagen editada' })
|
|
160
|
-
setExistImage(true)
|
|
161
|
-
handleOpenEditImage()
|
|
162
|
-
})
|
|
163
|
-
.catch(() => {
|
|
164
|
-
sendNotification({ title: 'Error', description: 'Ha ocurrido un error!' })
|
|
165
|
-
})
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
return {
|
|
169
|
-
img: null,
|
|
170
|
-
crop,
|
|
171
|
-
existImage,
|
|
172
|
-
zoom,
|
|
173
|
-
handleEditImage,
|
|
174
|
-
onCropChange
|
|
175
|
-
}
|
|
176
|
-
}
|
|
@@ -1,334 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-unused-vars */
|
|
2
|
-
import { useMutation } from '@apollo/client'
|
|
3
|
-
import { useRef, useState } from 'react'
|
|
4
|
-
import { convertBase64, RandomCode } from '../../utils'
|
|
5
|
-
import { useLocalStorage } from '../useLocalSorage'
|
|
6
|
-
import {
|
|
7
|
-
UPDATE_PRODUCT_FOOD
|
|
8
|
-
} from '../useProductsFood/queriesStore'
|
|
9
|
-
import { useStore } from '../useStore'
|
|
10
|
-
import { useTagsProducts } from './../useProductsFood/usetagsProducts'
|
|
11
|
-
import { useEditImageProduct } from './helpers/useEditImageProduct'
|
|
12
|
-
import { getCatProductsWithProduct } from './helpers/manageCacheDataCatProduct'
|
|
13
|
-
import { UPDATE_IMAGE_PRODUCT_FOOD } from '../useSetImageProducts/queries'
|
|
14
|
-
import { useSetImageProducts } from '../useSetImageProducts'
|
|
15
|
-
|
|
16
|
-
export const useCreateProduct = ({
|
|
17
|
-
router,
|
|
18
|
-
image,
|
|
19
|
-
setAlertBox = (args) => { return args },
|
|
20
|
-
sendNotification = (args) => { return args }
|
|
21
|
-
}) => {
|
|
22
|
-
const [errors, setErrors] = useState({
|
|
23
|
-
names: false,
|
|
24
|
-
ProPrice: false,
|
|
25
|
-
ProDescuento: false,
|
|
26
|
-
ProDescription: false,
|
|
27
|
-
ProWeight: false,
|
|
28
|
-
ProHeight: false,
|
|
29
|
-
ValueDelivery: false
|
|
30
|
-
})
|
|
31
|
-
const [values, setValues] = useState({
|
|
32
|
-
ProPrice: 0,
|
|
33
|
-
ProDescuento: 0,
|
|
34
|
-
ProDescription: '',
|
|
35
|
-
ProWeight: '',
|
|
36
|
-
ProHeight: '',
|
|
37
|
-
ValueDelivery: 0,
|
|
38
|
-
carProId: ''
|
|
39
|
-
})
|
|
40
|
-
const STEPS = Object.freeze({
|
|
41
|
-
PRODUCT: 0,
|
|
42
|
-
DESSERTS: 1,
|
|
43
|
-
COMPLEMENTS: 2,
|
|
44
|
-
DISPONIBILITY: 3
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
const [updateImageProducts] = useSetImageProducts()
|
|
48
|
-
const [names, setName] = useLocalStorage('namefood', '')
|
|
49
|
-
const [showMore, setShowMore] = useState(50)
|
|
50
|
-
const [search, setSearch] = useState('')
|
|
51
|
-
const [imageBase64, setImageBase64] = useState(null)
|
|
52
|
-
const [active, setActive] = useState(STEPS.PRODUCT)
|
|
53
|
-
const [pId, setPid] = useState(null)
|
|
54
|
-
|
|
55
|
-
const [searchFilter, setSearchFilter] = useState({ gender: [], desc: [], speciality: [] })
|
|
56
|
-
const [filter, setFilter] = useState({ gender: [], desc: [], speciality: [] })
|
|
57
|
-
const initialState = { alt: '/ images/DEFAULTBANNER.png', src: '/images/DEFAULTBANNER.png' }
|
|
58
|
-
const [{ alt, src }, setPreviewImg] = useState(initialState)
|
|
59
|
-
const fileInputRef = useRef(null)
|
|
60
|
-
const [arrTags, setTags] = useState([])
|
|
61
|
-
const [stock, setStock] = useState(1)
|
|
62
|
-
// Manage stock optional value boolean
|
|
63
|
-
const [checkStock, setCheckStock] = useState(false)
|
|
64
|
-
|
|
65
|
-
const handleIncreaseStock = () => {
|
|
66
|
-
setStock(prevStock => prevStock + 1)
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const handleDecreaseStock = () => {
|
|
70
|
-
setStock(prevStock => (prevStock > 1 ? prevStock - 1 : 1))
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const handleCheckStock = () => {
|
|
74
|
-
setCheckStock(prev => {
|
|
75
|
-
const newCheckStock = !prev
|
|
76
|
-
setStock(newCheckStock ? 1 : stock)
|
|
77
|
-
return newCheckStock
|
|
78
|
-
})
|
|
79
|
-
}
|
|
80
|
-
const [dataStore] = useStore()
|
|
81
|
-
const {
|
|
82
|
-
data,
|
|
83
|
-
tags,
|
|
84
|
-
setNewTags,
|
|
85
|
-
newTags,
|
|
86
|
-
handleRemoveTag,
|
|
87
|
-
handleRegister: handleRegisterTags,
|
|
88
|
-
handleAddTag
|
|
89
|
-
} = useTagsProducts({ sendNotification })
|
|
90
|
-
|
|
91
|
-
// HANDLESS
|
|
92
|
-
const [check, setCheck] = useState({
|
|
93
|
-
availability: true,
|
|
94
|
-
noAvailability: false,
|
|
95
|
-
desc: false,
|
|
96
|
-
freeShipping: false
|
|
97
|
-
})
|
|
98
|
-
|
|
99
|
-
const handleCheck = (e) => {
|
|
100
|
-
const { name, checked } = e.target
|
|
101
|
-
return setCheck((prev) => ({ ...prev, [name]: checked }))
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const handleUpdateBanner = event => {
|
|
105
|
-
const { files } = event.target
|
|
106
|
-
setPreviewImg(
|
|
107
|
-
files.length
|
|
108
|
-
? {
|
|
109
|
-
src: URL.createObjectURL(files[0]),
|
|
110
|
-
alt: files[0].name
|
|
111
|
-
}
|
|
112
|
-
: initialState
|
|
113
|
-
)
|
|
114
|
-
}
|
|
115
|
-
const handleChange = (e, error) => {
|
|
116
|
-
const { name, value } = e.target
|
|
117
|
-
setValues((prev) => ({
|
|
118
|
-
...prev,
|
|
119
|
-
[name]: value
|
|
120
|
-
}))
|
|
121
|
-
|
|
122
|
-
setErrors((prev) => ({
|
|
123
|
-
...prev,
|
|
124
|
-
[name]: error
|
|
125
|
-
}))
|
|
126
|
-
}
|
|
127
|
-
const handleChangeFilter = e => {
|
|
128
|
-
setSearch(e.target.value)
|
|
129
|
-
}
|
|
130
|
-
const onClickSearch = () => {
|
|
131
|
-
setSearchFilter({ ...filter })
|
|
132
|
-
}
|
|
133
|
-
const onClickClear = () => {
|
|
134
|
-
setSearchFilter({
|
|
135
|
-
gender: [],
|
|
136
|
-
desc: [],
|
|
137
|
-
speciality: []
|
|
138
|
-
})
|
|
139
|
-
}
|
|
140
|
-
const handleChangeClick = e => {
|
|
141
|
-
const {
|
|
142
|
-
name,
|
|
143
|
-
value,
|
|
144
|
-
checked
|
|
145
|
-
} = e.target
|
|
146
|
-
!checked
|
|
147
|
-
? setFilter(s => { return { ...s, [name]: s[name].filter(f => { return f !== value }) } })
|
|
148
|
-
: setFilter({ ...filter, [name]: [...filter[name], value] })
|
|
149
|
-
setSearchFilter({ ...filter })
|
|
150
|
-
}
|
|
151
|
-
const handleCheckFreeShipping = e => {
|
|
152
|
-
handleCheck(e)
|
|
153
|
-
setValues({
|
|
154
|
-
...values,
|
|
155
|
-
ValueDelivery: 0
|
|
156
|
-
})
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
const [updateProductFoods, { loading }] = useMutation(UPDATE_PRODUCT_FOOD, {
|
|
160
|
-
})
|
|
161
|
-
const [setImageProducts] = useMutation(UPDATE_IMAGE_PRODUCT_FOOD)
|
|
162
|
-
|
|
163
|
-
const onTargetClick = () => {
|
|
164
|
-
if (fileInputRef.current) {
|
|
165
|
-
fileInputRef.current.click()
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
// eslint-disable-next-line no-unused-vars
|
|
169
|
-
const { img } = useEditImageProduct({ sendNotification, initialState })
|
|
170
|
-
|
|
171
|
-
const handleRegister = async () => {
|
|
172
|
-
const {
|
|
173
|
-
ProPrice,
|
|
174
|
-
ProDescuento,
|
|
175
|
-
ProDescription,
|
|
176
|
-
ProWeight,
|
|
177
|
-
ProHeight,
|
|
178
|
-
ValueDelivery,
|
|
179
|
-
carProId
|
|
180
|
-
} = values ?? {
|
|
181
|
-
ProPrice: 0,
|
|
182
|
-
ProDescuento: 0,
|
|
183
|
-
ProDescription: '',
|
|
184
|
-
ProWeight: '',
|
|
185
|
-
ProHeight: 0,
|
|
186
|
-
ValueDelivery: 0,
|
|
187
|
-
carProId: ''
|
|
188
|
-
}
|
|
189
|
-
if (!carProId && !names) return setErrors({ ...errors, carProId: true })
|
|
190
|
-
const ProImage = '/images/placeholder-image.webp'
|
|
191
|
-
const pCode = RandomCode(10)
|
|
192
|
-
try {
|
|
193
|
-
const response = await updateProductFoods({
|
|
194
|
-
variables: {
|
|
195
|
-
input: {
|
|
196
|
-
idStore: dataStore?.getStore?.idStore || '',
|
|
197
|
-
ProPrice: check?.desc ? 0 : ProPrice,
|
|
198
|
-
ProDescuento: check?.desc ? 0 : ProDescuento,
|
|
199
|
-
ValueDelivery: check?.desc ? 0 : ValueDelivery,
|
|
200
|
-
ProDescription,
|
|
201
|
-
pName: names,
|
|
202
|
-
manageStock: checkStock,
|
|
203
|
-
pCode,
|
|
204
|
-
carProId,
|
|
205
|
-
stock,
|
|
206
|
-
pState: 1,
|
|
207
|
-
sTateLogistic: 1,
|
|
208
|
-
ProStar: 0,
|
|
209
|
-
ProImage,
|
|
210
|
-
ProHeight: parseFloat(ProHeight),
|
|
211
|
-
ProWeight,
|
|
212
|
-
ProOutstanding: check?.desc ? 1 : 0,
|
|
213
|
-
ProDelivery: check?.desc ? 1 : 0
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
// update (cache) {
|
|
217
|
-
// cache.modify({
|
|
218
|
-
// fields: {
|
|
219
|
-
// productFoodsAll (dataOld = []) {
|
|
220
|
-
// return cache.writeQuery({ query: GET_ALL_FOOD_PRODUCTS, data: dataOld })
|
|
221
|
-
// }
|
|
222
|
-
// // getCatProductsWithProduct () {
|
|
223
|
-
// // const updatedData = getCatProductsWithProduct(data, carProId)
|
|
224
|
-
// // return updatedData
|
|
225
|
-
// // }
|
|
226
|
-
// }
|
|
227
|
-
// })
|
|
228
|
-
// }
|
|
229
|
-
})
|
|
230
|
-
const { data } = response
|
|
231
|
-
const { updateProductFoods: dataResponse } = data
|
|
232
|
-
const { success, data: productData } = dataResponse
|
|
233
|
-
const { pId } = productData
|
|
234
|
-
if (success) {
|
|
235
|
-
handleRegisterTags({
|
|
236
|
-
pId,
|
|
237
|
-
nameTag: tags?.tag ?? null
|
|
238
|
-
})
|
|
239
|
-
}
|
|
240
|
-
const { errors } = response?.data?.updateProductFoods ?? {
|
|
241
|
-
errors: []
|
|
242
|
-
}
|
|
243
|
-
if (errors?.length > 0) {
|
|
244
|
-
errors.forEach(error => {
|
|
245
|
-
sendNotification({
|
|
246
|
-
backgroundColor: 'error',
|
|
247
|
-
title: 'Error',
|
|
248
|
-
description: error.message
|
|
249
|
-
})
|
|
250
|
-
})
|
|
251
|
-
return
|
|
252
|
-
}
|
|
253
|
-
if (image !== null) {
|
|
254
|
-
try {
|
|
255
|
-
await updateImageProducts({
|
|
256
|
-
pId: response?.data?.updateProductFoods?.data?.pId,
|
|
257
|
-
image
|
|
258
|
-
})
|
|
259
|
-
} catch {
|
|
260
|
-
sendNotification({
|
|
261
|
-
backgroundColor: 'error',
|
|
262
|
-
title: `Ocurrió un error en la imagen en el producto ${names}`,
|
|
263
|
-
description: 'error'
|
|
264
|
-
})
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
setPid(response?.data?.updateProductFoods?.data?.pId ?? null)
|
|
268
|
-
return response
|
|
269
|
-
} catch (error) {
|
|
270
|
-
setAlertBox({ message: 'Ha ocurrido un error', duration: 7000 })
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
// Manage tags
|
|
275
|
-
const changeHandler = (name, value) => {
|
|
276
|
-
if (name === 'tags') {
|
|
277
|
-
setTags(value)
|
|
278
|
-
if (value.length > 0 && errors.tags) {
|
|
279
|
-
setErrors(prev => {
|
|
280
|
-
const prevErrors = { ...prev }
|
|
281
|
-
delete prevErrors.tags
|
|
282
|
-
return prevErrors
|
|
283
|
-
})
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
return {
|
|
288
|
-
errors,
|
|
289
|
-
src,
|
|
290
|
-
names,
|
|
291
|
-
setName,
|
|
292
|
-
alt,
|
|
293
|
-
showMore,
|
|
294
|
-
success: true,
|
|
295
|
-
fileInputRef,
|
|
296
|
-
values,
|
|
297
|
-
search,
|
|
298
|
-
stock,
|
|
299
|
-
pId,
|
|
300
|
-
dataTags: data,
|
|
301
|
-
tags,
|
|
302
|
-
checkStock,
|
|
303
|
-
loading,
|
|
304
|
-
active,
|
|
305
|
-
idStore: dataStore?.getStore?.idStore || '',
|
|
306
|
-
arrTags,
|
|
307
|
-
newTags,
|
|
308
|
-
setNewTags,
|
|
309
|
-
setPid,
|
|
310
|
-
handleChange,
|
|
311
|
-
onClickClear,
|
|
312
|
-
handleChangeClick,
|
|
313
|
-
handleChangeFilter,
|
|
314
|
-
handleUpdateBanner,
|
|
315
|
-
onClickSearch,
|
|
316
|
-
handleDecreaseStock,
|
|
317
|
-
handleIncreaseStock,
|
|
318
|
-
changeHandler,
|
|
319
|
-
setErrors,
|
|
320
|
-
setCheck,
|
|
321
|
-
handleRegister,
|
|
322
|
-
setActive,
|
|
323
|
-
STEPS,
|
|
324
|
-
handleRegisterTags,
|
|
325
|
-
setShowMore,
|
|
326
|
-
handleCheckStock,
|
|
327
|
-
onTargetClick,
|
|
328
|
-
handleAddTag,
|
|
329
|
-
handleRemoveTag,
|
|
330
|
-
handleCheck,
|
|
331
|
-
handleCheckFreeShipping,
|
|
332
|
-
check
|
|
333
|
-
}
|
|
334
|
-
}
|