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,85 +0,0 @@
|
|
|
1
|
-
export const isValidCodeRef = (codeRef) => {
|
|
2
|
-
return typeof codeRef === 'string' && codeRef.trim() !== ''
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
export const updateExistingOrders = (
|
|
6
|
-
existingOrders,
|
|
7
|
-
pCodeRef,
|
|
8
|
-
pSState,
|
|
9
|
-
objectToAdd
|
|
10
|
-
) => {
|
|
11
|
-
if (typeof existingOrders !== 'object' || existingOrders === null) {
|
|
12
|
-
// existingOrders no es un objeto válido
|
|
13
|
-
return existingOrders
|
|
14
|
-
}
|
|
15
|
-
if (typeof pCodeRef !== 'string') {
|
|
16
|
-
// Los tipos de datos de pCodeRef
|
|
17
|
-
return existingOrders
|
|
18
|
-
}
|
|
19
|
-
if (!isValidCodeRef(pCodeRef)) {
|
|
20
|
-
// Valores de entrada no válidos, devuelve existingOrders sin cambios
|
|
21
|
-
return existingOrders
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const updatedExistingOrders = { ...existingOrders } // Copiar el objeto existente
|
|
25
|
-
|
|
26
|
-
const statusKeys = {
|
|
27
|
-
1: 'ACCEPT',
|
|
28
|
-
2: 'PROCESSING',
|
|
29
|
-
3: 'READY',
|
|
30
|
-
4: 'CONCLUDES',
|
|
31
|
-
5: 'REJECTED'
|
|
32
|
-
}
|
|
33
|
-
const targetArray = statusKeys[pSState]
|
|
34
|
-
|
|
35
|
-
if (!targetArray || !(targetArray in existingOrders)) {
|
|
36
|
-
// El valor de pSState no está mapeado a ninguna propiedad existente en existingOrders
|
|
37
|
-
return existingOrders
|
|
38
|
-
}
|
|
39
|
-
Object.keys(updatedExistingOrders).forEach((key) => {
|
|
40
|
-
if (Array.isArray(updatedExistingOrders[key])) {
|
|
41
|
-
const oneSale = updatedExistingOrders[key].find((order) => {
|
|
42
|
-
return order.pCodeRef === pCodeRef
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
updatedExistingOrders[key] = updatedExistingOrders[key].filter(
|
|
46
|
-
(order) => {
|
|
47
|
-
return order.pCodeRef !== pCodeRef
|
|
48
|
-
}
|
|
49
|
-
)
|
|
50
|
-
|
|
51
|
-
if (oneSale !== undefined && oneSale !== null) {
|
|
52
|
-
const updatedOneSale = { ...oneSale, pSState }
|
|
53
|
-
|
|
54
|
-
if (!Array.isArray(updatedExistingOrders[targetArray])) {
|
|
55
|
-
updatedExistingOrders[targetArray] = []
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
updatedExistingOrders[targetArray] = [
|
|
59
|
-
updatedOneSale,
|
|
60
|
-
...updatedExistingOrders[targetArray]
|
|
61
|
-
]
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
if (objectToAdd && objectToAdd.pCodeRef === pCodeRef) {
|
|
67
|
-
if (!Array.isArray(updatedExistingOrders[targetArray])) {
|
|
68
|
-
updatedExistingOrders[targetArray] = []
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
updatedExistingOrders[targetArray] = [
|
|
72
|
-
objectToAdd,
|
|
73
|
-
...updatedExistingOrders[targetArray]
|
|
74
|
-
]
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// Asegurar que todas las propiedades estén presentes
|
|
78
|
-
Object.keys(statusKeys).forEach((statusKey) => {
|
|
79
|
-
if (!(statusKeys[statusKey] in updatedExistingOrders)) {
|
|
80
|
-
updatedExistingOrders[statusKeys[statusKey]] = []
|
|
81
|
-
}
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
return updatedExistingOrders
|
|
85
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { useMutation } from '@apollo/client'
|
|
2
|
-
import { updateCacheMod } from '../../utils'
|
|
3
|
-
import { GET_EXTRAS_PRODUCT_FOOD_OPTIONAL, GET_EXTRAS_PRODUCT_FOOD_SUB_OPTIONAL } from '../useProductsFood/queriesStore'
|
|
4
|
-
|
|
5
|
-
export const useUpdateExtProductFoodsSubOptional = ({
|
|
6
|
-
sendNotification = (args) => { return args }
|
|
7
|
-
} = {}) => {
|
|
8
|
-
const [updateExtProductSubOptional] = useMutation(GET_EXTRAS_PRODUCT_FOOD_SUB_OPTIONAL, {
|
|
9
|
-
onCompleted: (data) => {
|
|
10
|
-
console.log('🚀 ~ useUpdateExtProductFoodsSubOptional ~ data:', data)
|
|
11
|
-
const { updateExtProductSubOptional } = data ?? {}
|
|
12
|
-
const { success, message, errors } = updateExtProductSubOptional ?? {}
|
|
13
|
-
sendNotification({
|
|
14
|
-
description: message,
|
|
15
|
-
title: success ? 'Sub item creado' : 'Error',
|
|
16
|
-
backgroundColor: success ? 'success' : 'error'
|
|
17
|
-
})
|
|
18
|
-
for (const err of errors || []) {
|
|
19
|
-
const { message: msg } = err || {}
|
|
20
|
-
sendNotification({
|
|
21
|
-
description: msg,
|
|
22
|
-
title: 'Error',
|
|
23
|
-
backgroundColor: 'error'
|
|
24
|
-
})
|
|
25
|
-
}
|
|
26
|
-
return data
|
|
27
|
-
}
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
const handleMutateExtProductFoodsSubOptional = ({
|
|
31
|
-
pId,
|
|
32
|
-
title,
|
|
33
|
-
listId,
|
|
34
|
-
id,
|
|
35
|
-
state = 1
|
|
36
|
-
}) => {
|
|
37
|
-
updateExtProductSubOptional({
|
|
38
|
-
variables: {
|
|
39
|
-
input: {
|
|
40
|
-
pId,
|
|
41
|
-
OptionalSubProName: title,
|
|
42
|
-
exCodeOptionExtra: listId,
|
|
43
|
-
exCode: id,
|
|
44
|
-
state
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
update: (cache, { data: { ExtProductFoodsOptionalAll } }) => {
|
|
48
|
-
return updateCacheMod({
|
|
49
|
-
cache,
|
|
50
|
-
query: GET_EXTRAS_PRODUCT_FOOD_OPTIONAL,
|
|
51
|
-
nameFun: 'ExtProductFoodsOptionalAll',
|
|
52
|
-
dataNew: ExtProductFoodsOptionalAll
|
|
53
|
-
})
|
|
54
|
-
}
|
|
55
|
-
})
|
|
56
|
-
}
|
|
57
|
-
return {
|
|
58
|
-
handleMutateExtProductFoodsSubOptional
|
|
59
|
-
}
|
|
60
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { useCallback } from 'react'
|
|
2
|
-
import { gql, useMutation } from '@apollo/client'
|
|
3
|
-
|
|
4
|
-
const UPDATE_MODULE_ORDER = gql`
|
|
5
|
-
mutation UpdateModuleOrder($input: [UpdateModuleOrderInput]!) {
|
|
6
|
-
updateModuleOrder(input: $input) {
|
|
7
|
-
success
|
|
8
|
-
message
|
|
9
|
-
modules {
|
|
10
|
-
mId
|
|
11
|
-
mPriority
|
|
12
|
-
}
|
|
13
|
-
errors {
|
|
14
|
-
path
|
|
15
|
-
message
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
`
|
|
20
|
-
|
|
21
|
-
export const useUpdateModuleOrder = () => {
|
|
22
|
-
const [updateModuleOrderMutation] = useMutation(UPDATE_MODULE_ORDER)
|
|
23
|
-
|
|
24
|
-
const updateModulesOrder = useCallback(async (newOrder) => {
|
|
25
|
-
// Enviar la actualización a la API (GraphQL)
|
|
26
|
-
try {
|
|
27
|
-
await updateModuleOrderMutation({
|
|
28
|
-
variables: { input: newOrder.map(({ mId, mPriority }) => ({ mId, mPriority })) }
|
|
29
|
-
})
|
|
30
|
-
} catch (error) {
|
|
31
|
-
console.error('Error updating module order:', error)
|
|
32
|
-
throw new Error('Failed to update module order')
|
|
33
|
-
}
|
|
34
|
-
}, [updateModuleOrderMutation])
|
|
35
|
-
|
|
36
|
-
return [updateModulesOrder]
|
|
37
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { useMutation } from '@apollo/client'
|
|
2
|
-
import { UPDATE_MULTI_EXTRAS_PRODUCT_FOOD } from './queries'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Custom hook para manejar la actualización de múltiples extras de productos alimenticios.
|
|
6
|
-
* @param {Function} cleanLines - Función para limpiar líneas después de completar la mutación.
|
|
7
|
-
* @param {Function} handleCleanLines - Función.
|
|
8
|
-
* @returns {Array} Retorna un array con la función de mutación y el estado de carga.
|
|
9
|
-
*/
|
|
10
|
-
export const useUpdateMultipleExtProduct = ({
|
|
11
|
-
cleanLines = () => { },
|
|
12
|
-
handleCleanLines = () => { },
|
|
13
|
-
sendNotification = () => { }
|
|
14
|
-
} = {
|
|
15
|
-
cleanLines: () => { },
|
|
16
|
-
handleCleanLines: () => { },
|
|
17
|
-
sendNotification: () => { }
|
|
18
|
-
}) => {
|
|
19
|
-
const [updateMultipleExtProduct, { loading }] = useMutation(UPDATE_MULTI_EXTRAS_PRODUCT_FOOD, {
|
|
20
|
-
onCompleted: (data) => {
|
|
21
|
-
const { updateMultipleExtProduct: result } = data
|
|
22
|
-
const { success, message } = result ?? {}
|
|
23
|
-
sendNotification({
|
|
24
|
-
title: message,
|
|
25
|
-
description: success ? 'Operación exitosa' : 'Error',
|
|
26
|
-
backgroundColor: success ? 'success' : 'error'
|
|
27
|
-
})
|
|
28
|
-
cleanLines()
|
|
29
|
-
}
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
return [updateMultipleExtProduct, { loading }]
|
|
33
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { gql } from '@apollo/client'
|
|
2
|
-
|
|
3
|
-
// CREATE EXTRAS PRODUCT
|
|
4
|
-
export const UPDATE_MULTI_EXTRAS_PRODUCT_FOOD = gql`
|
|
5
|
-
mutation updateMultipleExtProduct($inputLineItems: ILineItemsExtraFinal) {
|
|
6
|
-
updateMultipleExtProduct(inputLineItems: $inputLineItems) {
|
|
7
|
-
success
|
|
8
|
-
message
|
|
9
|
-
data {
|
|
10
|
-
pId
|
|
11
|
-
exPid
|
|
12
|
-
exState
|
|
13
|
-
extraName
|
|
14
|
-
extraPrice
|
|
15
|
-
state
|
|
16
|
-
createdAt
|
|
17
|
-
updatedAt
|
|
18
|
-
}
|
|
19
|
-
errors {
|
|
20
|
-
path
|
|
21
|
-
message
|
|
22
|
-
type
|
|
23
|
-
context {
|
|
24
|
-
limit
|
|
25
|
-
value
|
|
26
|
-
label
|
|
27
|
-
key
|
|
28
|
-
__typename
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
`
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { useMutation } from '@apollo/client'
|
|
2
|
-
import { UPDATE_MULTIPLE_PRODUCTS } from './queries'
|
|
3
|
-
import { CATEGORY_EMPTY } from '../../utils/index'
|
|
4
|
-
import { useCategoriesProduct } from '../useCategoriesProduct'
|
|
5
|
-
|
|
6
|
-
export const useUpdateMultipleProducts = ({
|
|
7
|
-
sendNotification = () => { }
|
|
8
|
-
}) => {
|
|
9
|
-
const [updateMultipleProducts, {
|
|
10
|
-
data,
|
|
11
|
-
loading,
|
|
12
|
-
error
|
|
13
|
-
}] = useMutation(UPDATE_MULTIPLE_PRODUCTS)
|
|
14
|
-
|
|
15
|
-
const [dataCategoriesProducts] = useCategoriesProduct()
|
|
16
|
-
const findEmptyCategory = dataCategoriesProducts?.find(({ pName }) => pName === CATEGORY_EMPTY)
|
|
17
|
-
const updateProducts = async (products) => {
|
|
18
|
-
const newProducts = products.map(product => {
|
|
19
|
-
const {
|
|
20
|
-
PRECIO_AL_PUBLICO: ProPrice,
|
|
21
|
-
DESCRIPCION: ProDescription,
|
|
22
|
-
NOMBRE: pName,
|
|
23
|
-
pCode,
|
|
24
|
-
CANTIDAD: stock = 0,
|
|
25
|
-
'IMPUESTO (%)': vat,
|
|
26
|
-
CODIGO_DE_BARRAS: ProBarCode
|
|
27
|
-
} = product
|
|
28
|
-
return {
|
|
29
|
-
idStore: '',
|
|
30
|
-
ProPrice,
|
|
31
|
-
ProDescuento: 0,
|
|
32
|
-
ValueDelivery: 0,
|
|
33
|
-
ProDescription,
|
|
34
|
-
pName,
|
|
35
|
-
pCode,
|
|
36
|
-
carProId: findEmptyCategory?.carProId ?? null,
|
|
37
|
-
pState: 1,
|
|
38
|
-
sTateLogistic: 1,
|
|
39
|
-
ProStar: 0,
|
|
40
|
-
stock,
|
|
41
|
-
ProImage: '/images/placeholder-image.webp',
|
|
42
|
-
vat,
|
|
43
|
-
ProBarCode: String(ProBarCode) || '',
|
|
44
|
-
ProHeight: null,
|
|
45
|
-
ProWeight: '',
|
|
46
|
-
ProOutstanding: 0,
|
|
47
|
-
ProDelivery: 0
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
)
|
|
51
|
-
try {
|
|
52
|
-
const response = await updateMultipleProducts({ variables: { input: newProducts } })
|
|
53
|
-
// sendNotification
|
|
54
|
-
for (const { errors } of response.data.updateMultipleProducts) {
|
|
55
|
-
if (errors) {
|
|
56
|
-
sendNotification({
|
|
57
|
-
backgroundColor: 'error',
|
|
58
|
-
description: errors[0].message,
|
|
59
|
-
title: 'Error'
|
|
60
|
-
})
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return response.data.updateMultipleProducts
|
|
64
|
-
} catch (e) {
|
|
65
|
-
sendNotification({
|
|
66
|
-
backgroundColor: 'error',
|
|
67
|
-
description: 'Ocurrió un error al actualizar los productos',
|
|
68
|
-
title: 'Error'
|
|
69
|
-
})
|
|
70
|
-
return []
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return {
|
|
75
|
-
updateProducts,
|
|
76
|
-
data,
|
|
77
|
-
loading,
|
|
78
|
-
error
|
|
79
|
-
}
|
|
80
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { gql } from '@apollo/client'
|
|
2
|
-
|
|
3
|
-
export const UPDATE_MULTIPLE_PRODUCTS = gql`
|
|
4
|
-
mutation updateMultipleProducts($input: [InputProductFood]) {
|
|
5
|
-
updateMultipleProducts(input: $input) {
|
|
6
|
-
success
|
|
7
|
-
message
|
|
8
|
-
errors {
|
|
9
|
-
path
|
|
10
|
-
message
|
|
11
|
-
type
|
|
12
|
-
context {
|
|
13
|
-
limit
|
|
14
|
-
value
|
|
15
|
-
label
|
|
16
|
-
key
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
data {
|
|
20
|
-
pId
|
|
21
|
-
sizeId
|
|
22
|
-
colorId
|
|
23
|
-
cId
|
|
24
|
-
dId
|
|
25
|
-
ctId
|
|
26
|
-
fId
|
|
27
|
-
pName
|
|
28
|
-
pCode
|
|
29
|
-
ProPrice
|
|
30
|
-
carProId
|
|
31
|
-
ProDescuento
|
|
32
|
-
ProUniDisponibles
|
|
33
|
-
ValueDelivery
|
|
34
|
-
ProDescription
|
|
35
|
-
ProProtegido
|
|
36
|
-
ProAssurance
|
|
37
|
-
ProStar
|
|
38
|
-
pState
|
|
39
|
-
ProImage
|
|
40
|
-
ProWidth
|
|
41
|
-
ProHeight
|
|
42
|
-
ProLength
|
|
43
|
-
ProWeight
|
|
44
|
-
ProQuantity
|
|
45
|
-
ProOutstanding
|
|
46
|
-
ProDelivery
|
|
47
|
-
ProVoltaje
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
`
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './parseNumber'
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Parses a formatted number (string or number) and converts it into a float with two decimal places.
|
|
3
|
-
* @param {string|number} value - The number to parse (e.g., "1.500,00", "1500.00", 1500).
|
|
4
|
-
* @returns {string} Parsed number as a string in the format "1500.00".
|
|
5
|
-
* @throws Will throw an error if the input is not a valid formatted number.
|
|
6
|
-
*/
|
|
7
|
-
export const parseNumber = (value) => {
|
|
8
|
-
// Convert value to string if it's a number
|
|
9
|
-
const stringValue = typeof value === 'number' ? value.toString() : value
|
|
10
|
-
|
|
11
|
-
if (typeof stringValue !== 'string') {
|
|
12
|
-
throw new Error('Input must be a string or number')
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
// Remove thousands separators and adjust decimal separator
|
|
16
|
-
const sanitizedValue = stringValue
|
|
17
|
-
.replace(/\./g, '') // Removes thousands separators (.)
|
|
18
|
-
.replace(',', '.') // Changes comma to period for decimal
|
|
19
|
-
|
|
20
|
-
// Parse the sanitized value as a float
|
|
21
|
-
const parsedNumber = parseFloat(sanitizedValue)
|
|
22
|
-
if (isNaN(parsedNumber)) {
|
|
23
|
-
throw new Error('Invalid number format')
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// Format the number with two decimal places
|
|
27
|
-
return parsedNumber.toFixed(2)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Example usage:
|
|
31
|
-
console.log(parseNumber('1.500,00')) // "1500.00"
|
|
32
|
-
console.log(parseNumber('1500.00')) // "1500.00"
|
|
33
|
-
console.log(parseNumber('1,500.50')) // "1500.50"
|
|
34
|
-
console.log(parseNumber('500')) // "500.00"
|
|
35
|
-
console.log(parseNumber('0,50')) // "0.50"
|
|
36
|
-
console.log(parseNumber(1500)) // "1500.00"
|
|
37
|
-
console.log(parseNumber(1500.5)) // "1500.50"
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
export const validateProductDataExcel = (product, productIndex) => {
|
|
2
|
-
const expectedHeaders = [
|
|
3
|
-
{
|
|
4
|
-
name: 'NOMBRE',
|
|
5
|
-
required: true,
|
|
6
|
-
types: ['string']
|
|
7
|
-
},
|
|
8
|
-
{
|
|
9
|
-
name: 'PRECIO_AL_PUBLICO',
|
|
10
|
-
required: false,
|
|
11
|
-
types: ['number', 'string']
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
name: 'VALOR_DE_COMPRA',
|
|
15
|
-
required: false,
|
|
16
|
-
types: ['number', 'string']
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
name: 'CANTIDAD',
|
|
20
|
-
required: true,
|
|
21
|
-
types: ['number']
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
name: 'DESCRIPCION',
|
|
25
|
-
required: true,
|
|
26
|
-
types: ['string']
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
name: 'DESCUENTO',
|
|
30
|
-
required: false,
|
|
31
|
-
types: ['number', 'string']
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
name: 'CATEGORIA',
|
|
35
|
-
required: false,
|
|
36
|
-
types: ['string']
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
name: 'CODIGO_DE_BARRAS',
|
|
40
|
-
required: false,
|
|
41
|
-
types: ['string', 'number']
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
name: 'IMPUESTO (%)',
|
|
45
|
-
required: false,
|
|
46
|
-
types: ['number', 'string']
|
|
47
|
-
}
|
|
48
|
-
]
|
|
49
|
-
|
|
50
|
-
const errors = []
|
|
51
|
-
|
|
52
|
-
// Validar encabezados requeridos y tipos
|
|
53
|
-
expectedHeaders.forEach(({ name, required, types }) => {
|
|
54
|
-
const value = product[name]
|
|
55
|
-
|
|
56
|
-
if (required && (value === undefined || value === null)) {
|
|
57
|
-
errors.push(`Producto ${productIndex + 1}: Falta la columna requerida: ${name}.`)
|
|
58
|
-
} else if (value !== undefined && value !== null) {
|
|
59
|
-
const isValidType = types.some(type => {
|
|
60
|
-
if (type === 'number') {
|
|
61
|
-
return typeof value === 'number' && !isNaN(value)
|
|
62
|
-
}
|
|
63
|
-
return typeof value === type
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
if (!isValidType) {
|
|
67
|
-
errors.push(`Producto ${productIndex + 1}: El campo ${name} debe ser de tipo ${types.join(' o ')}.`)
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
return errors // Retorna todos los errores encontrados
|
|
73
|
-
}
|