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,422 +0,0 @@
|
|
|
1
|
-
import { useState } from 'react'
|
|
2
|
-
import * as XLSX from 'xlsx'
|
|
3
|
-
import { RandomCode } from '../../utils'
|
|
4
|
-
import { validateProductDataExcel } from './helpers/validateProductDataExcel'
|
|
5
|
-
|
|
6
|
-
const STEPS = {
|
|
7
|
-
UPLOAD_FILE: 0,
|
|
8
|
-
UPLOAD_PRODUCTS: 1
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const useUploadProducts = ({
|
|
12
|
-
sendNotification = () => { return null }
|
|
13
|
-
} = {
|
|
14
|
-
sendNotification: () => { return null }
|
|
15
|
-
}) => {
|
|
16
|
-
const [data, setData] = useState([])
|
|
17
|
-
const [isLoading, setIsLoading] = useState(false)
|
|
18
|
-
const [active, setActive] = useState(STEPS.UPLOAD_FILE)
|
|
19
|
-
const [overActive, setOverActive] = useState(STEPS.UPLOAD_FILE)
|
|
20
|
-
|
|
21
|
-
const handleOverActive = (index) => {
|
|
22
|
-
setOverActive(index)
|
|
23
|
-
}
|
|
24
|
-
const readExcelFile = (file) => {
|
|
25
|
-
return new Promise((resolve, reject) => {
|
|
26
|
-
const reader = new FileReader()
|
|
27
|
-
reader.onload = (e) => {
|
|
28
|
-
const data = new Uint8Array(e.target.result)
|
|
29
|
-
const workbook = XLSX.read(data, { type: 'array' })
|
|
30
|
-
const sheetName = workbook.SheetNames[0]
|
|
31
|
-
const worksheet = workbook.Sheets[sheetName]
|
|
32
|
-
const json = XLSX.utils.sheet_to_json(worksheet)
|
|
33
|
-
resolve(json)
|
|
34
|
-
}
|
|
35
|
-
reader.onerror = (error) => reject(error)
|
|
36
|
-
reader.readAsArrayBuffer(file)
|
|
37
|
-
})
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const onChangeFiles = async (files) => {
|
|
41
|
-
setIsLoading(true) // Activa el loader al inicio
|
|
42
|
-
try {
|
|
43
|
-
const filePromises = Array.from(files).map(file => readExcelFile(file))
|
|
44
|
-
const newData = await Promise.all(filePromises)
|
|
45
|
-
|
|
46
|
-
const newProducts = newData.flat().map((product, index) => {
|
|
47
|
-
const PRECIO_AL_PUBLICO = isNaN(product.PRECIO_AL_PUBLICO) ? 0.00 : product.PRECIO_AL_PUBLICO
|
|
48
|
-
const VALOR_DE_COMPRA = isNaN(product.VALOR_DE_COMPRA) ? 0.00 : product.VALOR_DE_COMPRA
|
|
49
|
-
const validationErrors = validateProductDataExcel(product, index)
|
|
50
|
-
|
|
51
|
-
const code = RandomCode(9)
|
|
52
|
-
return {
|
|
53
|
-
...product,
|
|
54
|
-
CANTIDAD: isNaN(product.CANTIDAD) ? 1 : product.CANTIDAD,
|
|
55
|
-
ORIGINAL_CANTIDAD: isNaN(product.CANTIDAD) ? 1 : product.CANTIDAD,
|
|
56
|
-
free: false,
|
|
57
|
-
product: product?.DESCRIPCION,
|
|
58
|
-
pCode: code,
|
|
59
|
-
editing: false,
|
|
60
|
-
PRECIO_AL_PUBLICO,
|
|
61
|
-
ProImage: '/images/placeholder-image.webp',
|
|
62
|
-
VALOR_DE_COMPRA,
|
|
63
|
-
manageStock: true,
|
|
64
|
-
errors: validationErrors.length > 0 ? validationErrors : null
|
|
65
|
-
}
|
|
66
|
-
})
|
|
67
|
-
|
|
68
|
-
// Notificación de errores
|
|
69
|
-
newProducts.forEach(product => {
|
|
70
|
-
if (product.errors) {
|
|
71
|
-
// Enviar una notificación por cada error encontrado
|
|
72
|
-
product.errors.forEach(error => {
|
|
73
|
-
sendNotification({
|
|
74
|
-
description: error,
|
|
75
|
-
title: 'Error',
|
|
76
|
-
backgroundColor: 'error'
|
|
77
|
-
})
|
|
78
|
-
})
|
|
79
|
-
}
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
// Validar el número total de productos antes de actualizar el estado
|
|
83
|
-
setData(prevData => {
|
|
84
|
-
const currentLength = prevData.length
|
|
85
|
-
const totalProducts = currentLength + newProducts.length
|
|
86
|
-
|
|
87
|
-
if (totalProducts > 100) {
|
|
88
|
-
sendNotification({
|
|
89
|
-
description: 'Cannot add more products. You have reached the 100-product limit.',
|
|
90
|
-
title: 'Error',
|
|
91
|
-
backgroundColor: 'error'
|
|
92
|
-
})
|
|
93
|
-
|
|
94
|
-
// Calcular la cantidad de productos que se pueden agregar sin exceder el límite
|
|
95
|
-
const remainingSlots = 100 - currentLength
|
|
96
|
-
const productsToAdd = newProducts.slice(0, remainingSlots)
|
|
97
|
-
return [...prevData, ...productsToAdd]
|
|
98
|
-
} else {
|
|
99
|
-
// Agregar todos los nuevos productos si no se excede el límite
|
|
100
|
-
return [...prevData, ...newProducts]
|
|
101
|
-
}
|
|
102
|
-
})
|
|
103
|
-
} catch (error) {
|
|
104
|
-
sendNotification({
|
|
105
|
-
description: 'Un error ha ocurrido mientras se cargaba el archivo de productos.',
|
|
106
|
-
title: 'Error',
|
|
107
|
-
backgroundColor: 'error'
|
|
108
|
-
})
|
|
109
|
-
} finally {
|
|
110
|
-
setIsLoading(false)
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const handleSetActive = (index) => {
|
|
115
|
-
if (typeof index !== 'number' || index < 0 || index >= Object.keys(STEPS).length) {
|
|
116
|
-
sendNotification({
|
|
117
|
-
description: 'Invalid step index',
|
|
118
|
-
title: 'Error',
|
|
119
|
-
backgroundColor: 'error'
|
|
120
|
-
})
|
|
121
|
-
return
|
|
122
|
-
}
|
|
123
|
-
if (active === STEPS.UPLOAD_FILE) {
|
|
124
|
-
setActive(data.length ? STEPS.UPLOAD_PRODUCTS : 0)
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
const updateProductQuantity = (index, quantityChange) => {
|
|
129
|
-
// Validar el índice
|
|
130
|
-
if (index < 0 || index >= data.length) {
|
|
131
|
-
console.warn('Invalid product index:', index)
|
|
132
|
-
return
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
const newData = [...data]
|
|
136
|
-
const newQuantity = newData[index].CANTIDAD + quantityChange
|
|
137
|
-
|
|
138
|
-
// Actualizar la cantidad solo si es mayor o igual a 0
|
|
139
|
-
if (newQuantity < 0) {
|
|
140
|
-
console.warn('Quantity cannot be negative, no update performed.')
|
|
141
|
-
return // No permitir cantidades negativas
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
// Actualizar la cantidad
|
|
145
|
-
newData[index].CANTIDAD = newQuantity
|
|
146
|
-
newData[index].ORIGINAL_CANTIDAD = newQuantity
|
|
147
|
-
// Eliminar el producto si la nueva cantidad es 0
|
|
148
|
-
if (newData[index].CANTIDAD === 0) {
|
|
149
|
-
newData.splice(index, 1)
|
|
150
|
-
|
|
151
|
-
// Verificar si no quedan más productos
|
|
152
|
-
if (newData.length === 0) {
|
|
153
|
-
setActive(STEPS.UPLOAD_FILE) // Restablecer el estado activo a 0 si no hay productos
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
setData(newData)
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Toggle the 'free' status of a specific product in the data array.
|
|
161
|
-
* Performs validation to ensure the product index is valid.
|
|
162
|
-
*
|
|
163
|
-
* @param {number} productIndex - The index of the product to update.
|
|
164
|
-
*/
|
|
165
|
-
const handleCheckFree = (productIndex) => {
|
|
166
|
-
setData((prevData) => {
|
|
167
|
-
// Validar que el índice es un número válido
|
|
168
|
-
if (typeof productIndex !== 'number' || productIndex < 0 || productIndex >= prevData.length) {
|
|
169
|
-
console.warn('Invalid product index:', productIndex)
|
|
170
|
-
return prevData // Retorna el estado anterior si el índice es inválido
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
// Validar que el producto existe y que tiene la propiedad 'free'
|
|
174
|
-
const product = prevData[productIndex]
|
|
175
|
-
if (!product || typeof product.free === 'undefined') {
|
|
176
|
-
console.warn('Product or "free" property not found for index:', productIndex)
|
|
177
|
-
return prevData // Retorna el estado anterior si no se encuentra el producto
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
// Evitar cambios innecesarios si el estado de 'free' no cambia
|
|
181
|
-
const updatedFreeStatus = !product.free
|
|
182
|
-
if (product.free === updatedFreeStatus) {
|
|
183
|
-
console.info('Product "free" status is already:', updatedFreeStatus)
|
|
184
|
-
return prevData // No actualiza si el estado es el mismo
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
// Crear una nueva copia de los datos actualizando solo el producto específico
|
|
188
|
-
return prevData.map((product, index) =>
|
|
189
|
-
index === productIndex
|
|
190
|
-
? {
|
|
191
|
-
...product,
|
|
192
|
-
free: updatedFreeStatus,
|
|
193
|
-
PRECIO_AL_PUBLICO: updatedFreeStatus ? 0 : product.oldPrice,
|
|
194
|
-
oldPrice: product.PRECIO_AL_PUBLICO
|
|
195
|
-
}
|
|
196
|
-
: product
|
|
197
|
-
)
|
|
198
|
-
})
|
|
199
|
-
}
|
|
200
|
-
const handleCleanAllProducts = () => {
|
|
201
|
-
setData([])
|
|
202
|
-
setActive(STEPS.UPLOAD_FILE)
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Toggle the 'editing' status of a specific product in the data array.
|
|
206
|
-
* Validates the product index and only updates if necessary.
|
|
207
|
-
*
|
|
208
|
-
* @param {number} productIndex - The index of the product to update.
|
|
209
|
-
*/
|
|
210
|
-
const handleToggleEditingStatus = (productIndex) => {
|
|
211
|
-
setData((prevData) => {
|
|
212
|
-
// Validar que el índice es un número válido
|
|
213
|
-
if (typeof productIndex !== 'number' || productIndex < 0 || productIndex >= prevData.length) {
|
|
214
|
-
sendNotification({
|
|
215
|
-
description: `Invalid product index: ${productIndex}`,
|
|
216
|
-
title: 'Error',
|
|
217
|
-
backgroundColor: 'error'
|
|
218
|
-
})
|
|
219
|
-
return prevData // Retorna el estado anterior si el índice es inválido
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
// Validar que el producto existe y tiene la propiedad 'editing'
|
|
223
|
-
const product = prevData[productIndex]
|
|
224
|
-
if (!product || typeof product.editing === 'undefined') {
|
|
225
|
-
sendNotification({
|
|
226
|
-
description: `Product or "editing" property not found for index: ${productIndex}`,
|
|
227
|
-
title: 'Error',
|
|
228
|
-
backgroundColor: 'error'
|
|
229
|
-
})
|
|
230
|
-
return prevData // Retorna el estado anterior si no se encuentra el producto
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
// Evitar cambios innecesarios si el estado de 'editing' no cambia
|
|
234
|
-
const updatedEditingStatus = !product.editing
|
|
235
|
-
if (product.editing === updatedEditingStatus) {
|
|
236
|
-
sendNotification({
|
|
237
|
-
description: `Product "editing" status is already: ${updatedEditingStatus}`,
|
|
238
|
-
title: 'Info',
|
|
239
|
-
backgroundColor: 'info'
|
|
240
|
-
})
|
|
241
|
-
return prevData // No actualiza si el estado es el mismo
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
// Crear una nueva copia de los datos actualizando solo el producto específico
|
|
245
|
-
return prevData.map((product, index) => {
|
|
246
|
-
return index === productIndex
|
|
247
|
-
? {
|
|
248
|
-
...product,
|
|
249
|
-
editing: updatedEditingStatus
|
|
250
|
-
}
|
|
251
|
-
: product
|
|
252
|
-
}
|
|
253
|
-
)
|
|
254
|
-
})
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
/**
|
|
258
|
-
* Confirm and update the quantity of a product in the data array.
|
|
259
|
-
* Only updates when the button is clicked.
|
|
260
|
-
*
|
|
261
|
-
* @param {number} productIndex - The index of the product to update.
|
|
262
|
-
*/
|
|
263
|
-
const handleSuccessUpdateQuantity = (productIndex) => {
|
|
264
|
-
const product = data[productIndex]
|
|
265
|
-
setData((prevData) => {
|
|
266
|
-
// Validar que `CANTIDAD` sea un número entero
|
|
267
|
-
const product = prevData[productIndex]
|
|
268
|
-
if (!Number.isInteger(product?.CANTIDAD)) {
|
|
269
|
-
sendNotification({
|
|
270
|
-
description: 'La cantidad debe ser un valor entero.',
|
|
271
|
-
title: 'Error',
|
|
272
|
-
backgroundColor: 'error'
|
|
273
|
-
})
|
|
274
|
-
return prevData // Retorna el estado anterior si `CANTIDAD` no es entero
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
// Crear una copia actualizada de prevData donde se actualiza `CANTIDAD` si es necesario
|
|
278
|
-
const updatedData = prevData.map((product, index) =>
|
|
279
|
-
index === productIndex
|
|
280
|
-
? { ...product, editing: false, ORIGINAL_CANTIDAD: product.CANTIDAD } // Actualización o cambio de estado
|
|
281
|
-
: product
|
|
282
|
-
)
|
|
283
|
-
|
|
284
|
-
// Filtrar productos con CANTIDAD mayor a 0
|
|
285
|
-
const filteredData = updatedData.filter(product => product.CANTIDAD > 0)
|
|
286
|
-
|
|
287
|
-
// Cambiar el estado a `STEPS.UPLOAD_FILE` si no quedan productos
|
|
288
|
-
if (filteredData.length === 0) {
|
|
289
|
-
setActive(STEPS.UPLOAD_FILE)
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
return filteredData
|
|
293
|
-
})
|
|
294
|
-
if (product.CANTIDAD !== data[productIndex].ORIGINAL_CANTIDAD) {
|
|
295
|
-
sendNotification({
|
|
296
|
-
description: `Cantidad actualizada con éxito para el producto ${product.NOMBRE} #${productIndex}.`,
|
|
297
|
-
title: 'Éxito',
|
|
298
|
-
backgroundColor: 'success'
|
|
299
|
-
})
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
const handleChangeQuantity = (event, productIndex) => {
|
|
304
|
-
const { value } = event.target
|
|
305
|
-
setData((prevData) => {
|
|
306
|
-
if (typeof productIndex !== 'number' || productIndex < 0 || productIndex >= prevData.length) {
|
|
307
|
-
console.warn('Invalid product index:', productIndex)
|
|
308
|
-
return prevData // Retorna el estado anterior si el índice es inválido
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
// Obtener la cantidad temporal para el producto
|
|
312
|
-
const newQuantity = value
|
|
313
|
-
if (isNaN(newQuantity) || newQuantity < 0) {
|
|
314
|
-
console.warn('Quantity must be a valid non-negative number.')
|
|
315
|
-
return prevData // Retorna sin cambios si la cantidad no es válida
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
// Actualiza el array `data` con la nueva cantidad
|
|
319
|
-
return prevData.map((product, index) =>
|
|
320
|
-
index === productIndex
|
|
321
|
-
? { ...product, CANTIDAD: newQuantity }
|
|
322
|
-
: product
|
|
323
|
-
)
|
|
324
|
-
})
|
|
325
|
-
}
|
|
326
|
-
/**
|
|
327
|
-
* Restore the 'CANTIDAD' value to 'ORIGINAL_CANTIDAD' for a specific product.
|
|
328
|
-
* Validates the product index and only updates if necessary.
|
|
329
|
-
*
|
|
330
|
-
* @param {number} productIndex - The index of the product to restore quantity for.
|
|
331
|
-
*/
|
|
332
|
-
const handleCancelUpdateQuantity = (productIndex) => {
|
|
333
|
-
setData((prevData) => {
|
|
334
|
-
// Validar que el índice es un número válido
|
|
335
|
-
if (typeof productIndex !== 'number' || productIndex < 0 || productIndex >= prevData.length) {
|
|
336
|
-
console.warn('Invalid product index:', productIndex)
|
|
337
|
-
return prevData // Retorna el estado anterior si el índice es inválido
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
// Validar que el producto existe y tiene las propiedades 'CANTIDAD' y 'ORIGINAL_CANTIDAD'
|
|
341
|
-
const product = prevData[productIndex]
|
|
342
|
-
if (!product || typeof product.ORIGINAL_CANTIDAD === 'undefined') {
|
|
343
|
-
console.warn('Product or "ORIGINAL_CANTIDAD" property not found for index:', productIndex)
|
|
344
|
-
return prevData // Retorna el estado anterior si no se encuentra el producto o propiedad
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
// Crear una nueva copia de los datos actualizando solo el producto específico
|
|
348
|
-
return prevData.map((product, index) =>
|
|
349
|
-
index === productIndex
|
|
350
|
-
? { ...product, CANTIDAD: product.ORIGINAL_CANTIDAD, editing: false }
|
|
351
|
-
: product
|
|
352
|
-
)
|
|
353
|
-
})
|
|
354
|
-
}
|
|
355
|
-
/**
|
|
356
|
-
* Filters products with a quantity of 0 or less from the data array.
|
|
357
|
-
* Sends a notification if any products are found with invalid quantities.
|
|
358
|
-
*/
|
|
359
|
-
const filterInvalidQuantityProducts = () => {
|
|
360
|
-
setData((prevData) => {
|
|
361
|
-
// Filtrar productos con `CANTIDAD` mayor a 0
|
|
362
|
-
const validProducts = prevData.filter(product => product.CANTIDAD > 0)
|
|
363
|
-
|
|
364
|
-
// Notificar si hubo productos con cantidad no válida
|
|
365
|
-
if (validProducts.length < prevData.length) {
|
|
366
|
-
sendNotification({
|
|
367
|
-
description: 'Some products had a quantity of 0 or less and were removed.',
|
|
368
|
-
title: 'Invalid Products Removed',
|
|
369
|
-
backgroundColor: 'warning'
|
|
370
|
-
})
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
return validProducts
|
|
374
|
-
})
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
/**
|
|
378
|
-
* Compares uploaded products against response data to determine which were successfully uploaded.
|
|
379
|
-
* @param {Array} data - Original array of products with their details.
|
|
380
|
-
* @param {Array} response - Array of response objects from the `updateProducts` function.
|
|
381
|
-
* @returns {Object} Object containing arrays of successfully and unsuccessfully uploaded products.
|
|
382
|
-
*/
|
|
383
|
-
const getUploadResults = (data, response) => {
|
|
384
|
-
const uploadedCodes = new Set(
|
|
385
|
-
response
|
|
386
|
-
.filter((product) => product.success)
|
|
387
|
-
.map((product) => product.data.pCode)
|
|
388
|
-
)
|
|
389
|
-
|
|
390
|
-
const successfullyUploaded = data.filter((product) =>
|
|
391
|
-
uploadedCodes.has(product.pCode)
|
|
392
|
-
)
|
|
393
|
-
|
|
394
|
-
const failedUploads = data.filter(
|
|
395
|
-
(product) => !uploadedCodes.has(product.pCode)
|
|
396
|
-
)
|
|
397
|
-
|
|
398
|
-
return {
|
|
399
|
-
successfullyUploaded,
|
|
400
|
-
failedUploads
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
return {
|
|
404
|
-
active,
|
|
405
|
-
STEPS,
|
|
406
|
-
isLoading,
|
|
407
|
-
data,
|
|
408
|
-
overActive,
|
|
409
|
-
handleOverActive,
|
|
410
|
-
handleCheckFree,
|
|
411
|
-
getUploadResults,
|
|
412
|
-
onChangeFiles,
|
|
413
|
-
handleChangeQuantity,
|
|
414
|
-
handleCancelUpdateQuantity,
|
|
415
|
-
handleToggleEditingStatus,
|
|
416
|
-
filterInvalidQuantityProducts,
|
|
417
|
-
handleSuccessUpdateQuantity,
|
|
418
|
-
updateProductQuantity,
|
|
419
|
-
handleCleanAllProducts,
|
|
420
|
-
setActive: handleSetActive
|
|
421
|
-
}
|
|
422
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { gql, useMutation } from '@apollo/client'
|
|
2
|
-
import { GET_ONE_STORE } from '../useStore/queries'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* GraphQL mutation to upsert (create or update) the daily goal.
|
|
6
|
-
*/
|
|
7
|
-
const UPSERT_GOAL = gql`
|
|
8
|
-
mutation UpsertGoal($input: CreateGoalInput!) {
|
|
9
|
-
upsertGoal(input: $input) {
|
|
10
|
-
success
|
|
11
|
-
message
|
|
12
|
-
data {
|
|
13
|
-
idStore
|
|
14
|
-
dailyGoal
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
`
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Custom hook to handle the upsert of the daily goal.
|
|
22
|
-
* @param {Object} input - The goal data (e.g. dailyGoal).
|
|
23
|
-
* @returns {{
|
|
24
|
-
* upsertGoal: (input: { dailyGoal: number }) => void,
|
|
25
|
-
* data: { success: boolean, message: string, dailyGoal: number } | undefined,
|
|
26
|
-
* loading: boolean,
|
|
27
|
-
* error: any
|
|
28
|
-
* }}
|
|
29
|
-
*/
|
|
30
|
-
export const useUpsertGoal = ({
|
|
31
|
-
sendNotification = () => {}
|
|
32
|
-
} = {}) => {
|
|
33
|
-
const [upsertGoalMutation, { data, loading, error }] = useMutation(UPSERT_GOAL, {
|
|
34
|
-
onCompleted (data) {
|
|
35
|
-
const { upsertGoal } = data || {}
|
|
36
|
-
sendNotification({
|
|
37
|
-
title: upsertGoal.success ? 'Exito' : 'Error',
|
|
38
|
-
description: upsertGoal?.message || 'Meta actualizada correctamente',
|
|
39
|
-
backgroundColor: upsertGoal.success ? 'success' : 'warning'
|
|
40
|
-
})
|
|
41
|
-
},
|
|
42
|
-
update (cache, { data: { upsertGoal } }) {
|
|
43
|
-
if (!upsertGoal?.success) return
|
|
44
|
-
|
|
45
|
-
cache.modify({
|
|
46
|
-
fields: {
|
|
47
|
-
getStore (dataOld = []) {
|
|
48
|
-
return {
|
|
49
|
-
...dataOld,
|
|
50
|
-
dailyGoal: upsertGoal.data.dailyGoal
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
})
|
|
55
|
-
}
|
|
56
|
-
})
|
|
57
|
-
const upsertGoal = (input) => {
|
|
58
|
-
upsertGoalMutation({
|
|
59
|
-
variables: { input }
|
|
60
|
-
})
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return [upsertGoal, {
|
|
64
|
-
data: data?.upsertGoal,
|
|
65
|
-
loading,
|
|
66
|
-
error
|
|
67
|
-
}]
|
|
68
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { useMutation, useQuery } from '@apollo/client'
|
|
2
|
-
import { GET_USER, GET_USER_PROFILE, SET_USER_PROFILE } from './queries'
|
|
3
|
-
|
|
4
|
-
export const useUser = (email) => {
|
|
5
|
-
const { data, loading, error } = useQuery(GET_USER, email !== ''
|
|
6
|
-
? {
|
|
7
|
-
variables: {
|
|
8
|
-
email
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
: {})
|
|
12
|
-
return [data?.getUser, { loading, error }]
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const useUserProfile = () => {
|
|
16
|
-
const { data, loading, error } = useQuery(GET_USER_PROFILE)
|
|
17
|
-
return [data, { loading, error }]
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const useSetUserProfile = () => {
|
|
21
|
-
const [setUserProfile, { loading, error }] = useMutation(SET_USER_PROFILE)
|
|
22
|
-
return [setUserProfile, { loading, error }]
|
|
23
|
-
}
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import { gql } from '@apollo/client'
|
|
2
|
-
|
|
3
|
-
export const LOGIN = gql`
|
|
4
|
-
mutation login($input: LoginInput){
|
|
5
|
-
login(input: $input){
|
|
6
|
-
token
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
`
|
|
10
|
-
export const GET_USER_PROFILE = gql`
|
|
11
|
-
query getOneUserProfile($id: ID) {
|
|
12
|
-
getOneUserProfile(id: $id){
|
|
13
|
-
upId
|
|
14
|
-
id
|
|
15
|
-
upPhone
|
|
16
|
-
upImage
|
|
17
|
-
upDateBir
|
|
18
|
-
upBloodG
|
|
19
|
-
upAddress
|
|
20
|
-
ctId
|
|
21
|
-
dId
|
|
22
|
-
upZipCode
|
|
23
|
-
cId
|
|
24
|
-
upLatitude
|
|
25
|
-
upLongitude
|
|
26
|
-
user {
|
|
27
|
-
id
|
|
28
|
-
name
|
|
29
|
-
username
|
|
30
|
-
lastName
|
|
31
|
-
email
|
|
32
|
-
avatar
|
|
33
|
-
uToken
|
|
34
|
-
uPhoNum
|
|
35
|
-
ULocation
|
|
36
|
-
upLat
|
|
37
|
-
uState
|
|
38
|
-
upLon
|
|
39
|
-
upIdeDoc
|
|
40
|
-
siteWeb
|
|
41
|
-
description
|
|
42
|
-
password
|
|
43
|
-
createAt
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
`
|
|
49
|
-
|
|
50
|
-
export const GET_USER = gql`
|
|
51
|
-
query getUser($id: ID, $email: String){
|
|
52
|
-
getUser(id: $id email: $email){
|
|
53
|
-
id
|
|
54
|
-
name
|
|
55
|
-
username
|
|
56
|
-
lastName
|
|
57
|
-
email
|
|
58
|
-
avatar
|
|
59
|
-
uToken
|
|
60
|
-
uPhoNum
|
|
61
|
-
ULocation
|
|
62
|
-
upLat
|
|
63
|
-
uState
|
|
64
|
-
idRole
|
|
65
|
-
upLon
|
|
66
|
-
upIdeDoc
|
|
67
|
-
siteWeb
|
|
68
|
-
description
|
|
69
|
-
associateStore
|
|
70
|
-
role {
|
|
71
|
-
name
|
|
72
|
-
permissions
|
|
73
|
-
description
|
|
74
|
-
createdAt
|
|
75
|
-
updatedAt
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
`
|
|
81
|
-
export const GET_ALL_USER = gql`
|
|
82
|
-
query getAllUser($search: String){
|
|
83
|
-
getAllUser(search: $search){
|
|
84
|
-
id
|
|
85
|
-
name
|
|
86
|
-
username
|
|
87
|
-
lastName
|
|
88
|
-
email
|
|
89
|
-
email
|
|
90
|
-
siteWeb
|
|
91
|
-
description
|
|
92
|
-
uPhoNum
|
|
93
|
-
upLat
|
|
94
|
-
upLon
|
|
95
|
-
createAt
|
|
96
|
-
avatar
|
|
97
|
-
latestMessage {
|
|
98
|
-
uuid
|
|
99
|
-
content
|
|
100
|
-
from
|
|
101
|
-
to
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
`
|
|
106
|
-
export const UPDATE_AVATAR = gql`
|
|
107
|
-
mutation updateAvatar($file: Upload){
|
|
108
|
-
UpdateAvatar(file: $file){
|
|
109
|
-
status
|
|
110
|
-
urlAvatar
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
`
|
|
114
|
-
|
|
115
|
-
export const SET_USER_PROFILE = gql`
|
|
116
|
-
mutation setUserProfile($data: IUserProfile!) {
|
|
117
|
-
setUserProfile(input: $data){
|
|
118
|
-
upId
|
|
119
|
-
id
|
|
120
|
-
upPhone
|
|
121
|
-
upDateBir
|
|
122
|
-
upImage
|
|
123
|
-
upBloodG
|
|
124
|
-
cId
|
|
125
|
-
ctId
|
|
126
|
-
dId
|
|
127
|
-
upAddress
|
|
128
|
-
upZipCode
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
`
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Fills missing weeks for the last 7 weeks, ensuring continuous data.
|
|
3
|
-
* If a week is missing, it fills it with totalOut: 0 and percentageChange: "N/A".
|
|
4
|
-
*
|
|
5
|
-
* @param {Array} data - Array of weekly stock movement objects.
|
|
6
|
-
* @returns {Array} - Filled data ensuring the last 7 weeks are covered.
|
|
7
|
-
*/
|
|
8
|
-
export const fillLast7Weeks = (data) => {
|
|
9
|
-
const today = new Date()
|
|
10
|
-
const last7Weeks = []
|
|
11
|
-
|
|
12
|
-
// Generar las últimas 7 semanas (cada lunes)
|
|
13
|
-
for (let i = 6; i >= 0; i--) {
|
|
14
|
-
const weekDate = new Date(today)
|
|
15
|
-
weekDate.setDate(today.getDate() - today.getDay() - (i * 7) + 1) // Ajustar para que sea lunes
|
|
16
|
-
const weekStart = weekDate.toISOString().split('T')[0] // Formato YYYY-MM-DD
|
|
17
|
-
last7Weeks.push(weekStart)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// Mapear los datos existentes para acceso rápido
|
|
21
|
-
const dataMap = new Map(data.map(item => [item.weekStart, item]))
|
|
22
|
-
|
|
23
|
-
// Construir la nueva lista asegurando que todas las semanas estén presentes
|
|
24
|
-
return last7Weeks.map(weekStart => (
|
|
25
|
-
dataMap.get(weekStart) || {
|
|
26
|
-
weekStart,
|
|
27
|
-
totalOut: 0,
|
|
28
|
-
prevTotalOut: null,
|
|
29
|
-
percentageChange: 'N/A'
|
|
30
|
-
}
|
|
31
|
-
))
|
|
32
|
-
}
|