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,156 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getCurrentDayAndTime,
|
|
3
|
-
getOpeningKeyFromDay,
|
|
4
|
-
getTimeString,
|
|
5
|
-
sortOpeningsByDay,
|
|
6
|
-
weekDays,
|
|
7
|
-
timeToInt,
|
|
8
|
-
days
|
|
9
|
-
} from './helpers'
|
|
10
|
-
|
|
11
|
-
export const statusOpenStores = ({
|
|
12
|
-
dataSchedules = []
|
|
13
|
-
} = {}) => {
|
|
14
|
-
const handleHourPmAM = (hour) => {
|
|
15
|
-
const hourPmAm = new Date(`1/1/1999 ${hour}`).toLocaleString('en-US', { hour: 'numeric', minute: 'numeric', hour12: true })
|
|
16
|
-
return hour ? hourPmAm : ''
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const handleState = (message, open) => {
|
|
20
|
-
return {
|
|
21
|
-
message,
|
|
22
|
-
open
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function getNextDaySchedule (dataSchedules, currentDayOfWeek) {
|
|
27
|
-
const today = new Date()
|
|
28
|
-
const tomorrow = new Date(today)
|
|
29
|
-
tomorrow.setDate(today.getDate() + 1)
|
|
30
|
-
const dayOfWeekTomorrow = tomorrow.getDay()
|
|
31
|
-
|
|
32
|
-
const findNextDay = dataSchedules?.length
|
|
33
|
-
? dataSchedules?.some((schedule) => schedule?.schDay === dayOfWeekTomorrow)
|
|
34
|
-
: false
|
|
35
|
-
|
|
36
|
-
const findDataNextDay = dataSchedules?.length
|
|
37
|
-
? dataSchedules?.find((schedule) => schedule?.schDay === dayOfWeekTomorrow)
|
|
38
|
-
: {}
|
|
39
|
-
|
|
40
|
-
return { findNextDay, findDataNextDay, dayOfWeekTomorrow }
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function getOpeningStatus (openings, currentTime, currentDayOfWeek) {
|
|
44
|
-
const weekDayLookup = [
|
|
45
|
-
'Sunday',
|
|
46
|
-
'Monday',
|
|
47
|
-
'Tuesday',
|
|
48
|
-
'Wednesday',
|
|
49
|
-
'Thursday',
|
|
50
|
-
'Friday',
|
|
51
|
-
'Saturday'
|
|
52
|
-
]
|
|
53
|
-
|
|
54
|
-
const ceroHours = '00:00 - 00:00'
|
|
55
|
-
let dayOfWeek = currentDayOfWeek
|
|
56
|
-
|
|
57
|
-
for (let i = 0; i < 7; i++) {
|
|
58
|
-
const dayName = weekDayLookup[dayOfWeek % 7]
|
|
59
|
-
const opening = openings && openings['opening' + dayName.substring(0, 3)]
|
|
60
|
-
const timeSpans = opening?.split(';').map((item) => item.trim())
|
|
61
|
-
|
|
62
|
-
for (const span of timeSpans) {
|
|
63
|
-
const hours = span.split('-').map((item) => item.trim())
|
|
64
|
-
const openTime = timeToInt(hours[0])
|
|
65
|
-
const closeTime = timeToInt(hours[1])
|
|
66
|
-
|
|
67
|
-
if (currentTime >= openTime && currentTime <= closeTime) {
|
|
68
|
-
return handleState(
|
|
69
|
-
'Abierto Ahora - Cierra a las: ' + handleHourPmAM(hours[1]),
|
|
70
|
-
true
|
|
71
|
-
)
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (currentTime < openTime && dayOfWeek === currentDayOfWeek) {
|
|
75
|
-
return handleState(
|
|
76
|
-
'Aun temprano - Abre hoy a las: ' + handleHourPmAM(hours[0]),
|
|
77
|
-
false
|
|
78
|
-
)
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (currentTime >= closeTime - 30 * 60000 && currentTime < closeTime && dayOfWeek === currentDayOfWeek) {
|
|
82
|
-
return handleState(
|
|
83
|
-
'Pronto por cerrar - Cierra hoy a las: ' + handleHourPmAM(hours[1]),
|
|
84
|
-
true
|
|
85
|
-
)
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const { findNextDay, findDataNextDay, dayOfWeekTomorrow } = getNextDaySchedule(
|
|
89
|
-
dataSchedules,
|
|
90
|
-
currentDayOfWeek
|
|
91
|
-
)
|
|
92
|
-
|
|
93
|
-
if (findNextDay && findDataNextDay?.schHoSta) {
|
|
94
|
-
const nameOfDayTomorrow = weekDays[dayOfWeekTomorrow]
|
|
95
|
-
return handleState(
|
|
96
|
-
`Cerrado abre - Mañana ${nameOfDayTomorrow} ${!!findDataNextDay?.schHoSta && 'a las'} ${
|
|
97
|
-
findDataNextDay?.schHoSta ?? ''
|
|
98
|
-
}`,
|
|
99
|
-
false
|
|
100
|
-
)
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
const nextDayName = weekDayLookup[(dayOfWeek + 1) % 7]
|
|
104
|
-
const nextOpening = openings && openings['opening' + nextDayName.substring(0, 3)]
|
|
105
|
-
const nextHours = nextOpening?.split(';')?.map((item) => item?.trim())
|
|
106
|
-
|
|
107
|
-
if (nextHours[0] !== ceroHours) {
|
|
108
|
-
return handleState(
|
|
109
|
-
'Cerrado - Abre el ' + days[nextDayName] + ' a las ' + nextHours[0],
|
|
110
|
-
false
|
|
111
|
-
)
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
dayOfWeek++
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
return handleState('Cerrado', false)
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function getIsOpening (openings) {
|
|
122
|
-
const { currentTime, currentDayOfWeek } = getCurrentDayAndTime()
|
|
123
|
-
return getOpeningStatus(openings, currentTime, currentDayOfWeek)
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
const createOpeningsObject = (dataSchedules) => {
|
|
127
|
-
const openings = {}
|
|
128
|
-
const existStoreSchedule = dataSchedules || []
|
|
129
|
-
|
|
130
|
-
existStoreSchedule?.forEach((schedule) => {
|
|
131
|
-
const day = schedule.schDay
|
|
132
|
-
const openingKey = getOpeningKeyFromDay(day)
|
|
133
|
-
const schHoSta = getTimeString(schedule?.schHoSta)
|
|
134
|
-
const schHoEnd = getTimeString(schedule?.schHoEnd)
|
|
135
|
-
openings[openingKey] = `${schHoSta} - ${schHoEnd}`
|
|
136
|
-
})
|
|
137
|
-
|
|
138
|
-
for (let i = 0; i < 7; i++) {
|
|
139
|
-
const openingKey = getOpeningKeyFromDay(i)
|
|
140
|
-
// eslint-disable-next-line no-prototype-builtins
|
|
141
|
-
if (!(openingKey in openings)) {
|
|
142
|
-
openings[openingKey] = '00:00 - 00:00' // Horario vacío para el día faltante
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
return openings
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// Luego puedes usar esta función así:
|
|
150
|
-
const openings = createOpeningsObject(dataSchedules)
|
|
151
|
-
// ...haz lo que necesites con el objeto openings
|
|
152
|
-
const sortedOpenings = sortOpeningsByDay(openings)
|
|
153
|
-
|
|
154
|
-
// Crear el array completo con objetos de tiempo
|
|
155
|
-
return getIsOpening(sortedOpenings)
|
|
156
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { useMutation } from '@apollo/client'
|
|
2
|
-
import { updateCacheMod } from '../../utils'
|
|
3
|
-
import { GET_EXTRAS_PRODUCT_FOOD_OPTIONAL, UPDATE_EXTRAS_PRODUCT_FOOD_OPTIONAL } from '../useProductsFood/queriesStore'
|
|
4
|
-
|
|
5
|
-
export const useUpdateExtProductFoodsOptional = () => {
|
|
6
|
-
const [updateExtProductOptional] = useMutation(UPDATE_EXTRAS_PRODUCT_FOOD_OPTIONAL)
|
|
7
|
-
|
|
8
|
-
const handleUpdateExtProduct = async ({
|
|
9
|
-
pId,
|
|
10
|
-
code,
|
|
11
|
-
opExPid,
|
|
12
|
-
OptionalProName,
|
|
13
|
-
required,
|
|
14
|
-
numbersOptionalOnly
|
|
15
|
-
}) => {
|
|
16
|
-
return await updateExtProductOptional({
|
|
17
|
-
variables: {
|
|
18
|
-
input: {
|
|
19
|
-
pId,
|
|
20
|
-
code,
|
|
21
|
-
opExPid,
|
|
22
|
-
OptionalProName,
|
|
23
|
-
required,
|
|
24
|
-
numbersOptionalOnly: Number(numbersOptionalOnly)
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
update: (cache, { data: { ExtProductFoodsOptionalAll } }) => {
|
|
28
|
-
return updateCacheMod({
|
|
29
|
-
cache,
|
|
30
|
-
query: GET_EXTRAS_PRODUCT_FOOD_OPTIONAL,
|
|
31
|
-
nameFun: 'ExtProductFoodsOptionalAll',
|
|
32
|
-
dataNew: ExtProductFoodsOptionalAll
|
|
33
|
-
})
|
|
34
|
-
}
|
|
35
|
-
})
|
|
36
|
-
}
|
|
37
|
-
return {
|
|
38
|
-
handleUpdateExtProduct
|
|
39
|
-
}
|
|
40
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
const data = [
|
|
2
|
-
{ x: '2021-10-17T14:38:45.540Z', y: 2 }
|
|
3
|
-
]
|
|
4
|
-
export const getDateParts = (isString) => {
|
|
5
|
-
const [year, month, day, hr, min, sec] = isString.split(/\D/g)
|
|
6
|
-
return { year, month, day, hr, min, sec }
|
|
7
|
-
}
|
|
8
|
-
export function groupDates (arr) {
|
|
9
|
-
const total = arr.reduce((a, b) => {
|
|
10
|
-
const { hr } = getDateParts(b.x)
|
|
11
|
-
return a + parseInt(hr)
|
|
12
|
-
}, 0)
|
|
13
|
-
return total
|
|
14
|
-
}
|
|
15
|
-
// eslint-disable-next-line no-unused-vars
|
|
16
|
-
const result = groupDates(data)
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { gql, useQuery } from '@apollo/client'
|
|
2
|
-
import { useEffect, useState } from 'react'
|
|
3
|
-
|
|
4
|
-
export const GET_ALL_STORES_PENDING_TO_REGISTER = gql`
|
|
5
|
-
query GetAllStoresPendingToRegister {
|
|
6
|
-
getAllStoresPendingToRegister {
|
|
7
|
-
StorePendingToRegisterId
|
|
8
|
-
UserId
|
|
9
|
-
UserEmail
|
|
10
|
-
StoreNumber
|
|
11
|
-
createAt
|
|
12
|
-
updateAt
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
`
|
|
16
|
-
|
|
17
|
-
export function useAllStoresPendingToRegister () {
|
|
18
|
-
const { loading, error, data } = useQuery(GET_ALL_STORES_PENDING_TO_REGISTER)
|
|
19
|
-
|
|
20
|
-
const [stores, setStores] = useState([])
|
|
21
|
-
const [fetchError, setFetchError] = useState(null)
|
|
22
|
-
|
|
23
|
-
useEffect(() => {
|
|
24
|
-
if (!loading && data) {
|
|
25
|
-
setStores(data.getAllStoresPendingToRegister)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (error) {
|
|
29
|
-
setFetchError(error.message)
|
|
30
|
-
}
|
|
31
|
-
}, [loading, data, error])
|
|
32
|
-
|
|
33
|
-
return { loading, stores, fetchError }
|
|
34
|
-
}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { useState } from 'react'
|
|
2
|
-
|
|
3
|
-
const formatCurrency = (
|
|
4
|
-
prefix,
|
|
5
|
-
amountValue,
|
|
6
|
-
number,
|
|
7
|
-
groupSeparator,
|
|
8
|
-
decimalSeparator,
|
|
9
|
-
allowDecimals = false,
|
|
10
|
-
decimalsLimit = 0
|
|
11
|
-
) => {
|
|
12
|
-
if (isNaN(number)) {
|
|
13
|
-
return prefix + '0'
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const amountWithoutDecimals = parseInt(number.toString())
|
|
17
|
-
const decimalIdx = amountValue.indexOf(decimalSeparator)
|
|
18
|
-
const notAllowedChars = new RegExp('[^' + decimalSeparator + '\\d]', 'g')
|
|
19
|
-
const decimalsWithSeparator =
|
|
20
|
-
decimalIdx >= 0
|
|
21
|
-
? amountValue
|
|
22
|
-
.slice(decimalIdx, amountValue.length)
|
|
23
|
-
.replace(notAllowedChars, '')
|
|
24
|
-
.slice(0, decimalsLimit + 1)
|
|
25
|
-
: ''
|
|
26
|
-
|
|
27
|
-
return (
|
|
28
|
-
prefix +
|
|
29
|
-
amountWithoutDecimals
|
|
30
|
-
.toString()
|
|
31
|
-
.replace(/\B(?=(\d{3}){1,5}(?!\d))/g, groupSeparator) +
|
|
32
|
-
decimalsWithSeparator
|
|
33
|
-
)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const processInputValue = (input, decimalSeparator) => {
|
|
37
|
-
const decimalRegex = new RegExp('[' + decimalSeparator + ']', 'g')
|
|
38
|
-
const notAllowedChars = new RegExp('[^' + decimalSeparator + '\\d¬]', 'g')
|
|
39
|
-
|
|
40
|
-
return parseFloat(
|
|
41
|
-
input
|
|
42
|
-
.replace(decimalRegex, '¬')
|
|
43
|
-
.replace(notAllowedChars, '')
|
|
44
|
-
.replace('¬', '.')
|
|
45
|
-
)
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Truncate excess decimals from a number based on a limit.
|
|
49
|
-
*
|
|
50
|
-
* @param {number} number The number to truncate.
|
|
51
|
-
* @param {number} decimalsLimit The maximum number of decimal places allowed.
|
|
52
|
-
* @returns {number} The number with truncated decimals.
|
|
53
|
-
*/
|
|
54
|
-
const truncateDecimals = (number, decimalsLimit) => {
|
|
55
|
-
if (isNaN(number)) {
|
|
56
|
-
return 0;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const multiplier = Math.pow(10, decimalsLimit);
|
|
60
|
-
return Math.floor(number * multiplier) / multiplier;
|
|
61
|
-
};
|
|
62
|
-
export const useAmountInput = props => {
|
|
63
|
-
const {
|
|
64
|
-
onChange = () => {},
|
|
65
|
-
prefix = '$',
|
|
66
|
-
groupSeparator = '.',
|
|
67
|
-
decimalSeparator = ',',
|
|
68
|
-
allowDecimals,
|
|
69
|
-
decimalsLimit,
|
|
70
|
-
defaultValue
|
|
71
|
-
} = props
|
|
72
|
-
|
|
73
|
-
const inputVal = defaultValue ?? ''
|
|
74
|
-
const [inputValue, setInputValue] = useState(inputVal)
|
|
75
|
-
|
|
76
|
-
const preProcess = amount => {
|
|
77
|
-
const amountValue = amount.trim()
|
|
78
|
-
const oldInputValue = inputValue
|
|
79
|
-
|
|
80
|
-
if (oldInputValue !== amountValue) {
|
|
81
|
-
const amountFloatValue = processInputValue(amount, decimalSeparator)
|
|
82
|
-
let inputValue = ''
|
|
83
|
-
// This allows for people to use `.` but still input decimals
|
|
84
|
-
const isAboutToIntroduceDecimals =
|
|
85
|
-
oldInputValue + decimalSeparator === amountValue ||
|
|
86
|
-
oldInputValue + '.' === amountValue
|
|
87
|
-
if (allowDecimals === true && isAboutToIntroduceDecimals) {
|
|
88
|
-
inputValue = oldInputValue + decimalSeparator
|
|
89
|
-
} else if (
|
|
90
|
-
(allowDecimals === false || allowDecimals === undefined) &&
|
|
91
|
-
isAboutToIntroduceDecimals
|
|
92
|
-
) {
|
|
93
|
-
inputValue = oldInputValue
|
|
94
|
-
} else {
|
|
95
|
-
inputValue = formatCurrency(
|
|
96
|
-
prefix,
|
|
97
|
-
amountValue,
|
|
98
|
-
amountFloatValue,
|
|
99
|
-
groupSeparator,
|
|
100
|
-
decimalSeparator,
|
|
101
|
-
allowDecimals,
|
|
102
|
-
decimalsLimit
|
|
103
|
-
)
|
|
104
|
-
}
|
|
105
|
-
setInputValue(inputValue)
|
|
106
|
-
|
|
107
|
-
const callbackValue = isNaN(amountFloatValue) ? 0 : amountFloatValue
|
|
108
|
-
if (typeof onChange === 'function') {
|
|
109
|
-
onChange(truncateDecimals(callbackValue, decimalsLimit))
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
return {
|
|
114
|
-
inputValue,
|
|
115
|
-
preProcess
|
|
116
|
-
}
|
|
117
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef } from 'react'
|
|
2
|
-
|
|
3
|
-
export const useAnimationFrame = (callback, start, end, duration = 1000) => {
|
|
4
|
-
const functionRef = useRef()
|
|
5
|
-
const delta = Math.abs(start - end)
|
|
6
|
-
const frameCount = Math.ceil(60 * (duration / 1000))
|
|
7
|
-
const iteration = useRef(frameCount)
|
|
8
|
-
useEffect(() => {
|
|
9
|
-
const animate = (rafId) => {
|
|
10
|
-
if (iteration.current <= 0) {
|
|
11
|
-
cancelAnimationFrame(rafId)
|
|
12
|
-
iteration.current = frameCount
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
callback(Math.max(delta / iteration.current, 1))
|
|
16
|
-
iteration.current--
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if (delta > 0) functionRef.current = requestAnimationFrame(animate)
|
|
20
|
-
|
|
21
|
-
return () => { return cancelAnimationFrame(functionRef.current) }
|
|
22
|
-
}, [callback, delta, frameCount, iteration])
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// const Counter = ({ numeral = 0 }) => {
|
|
26
|
-
// const [currentValue, setCurrentValue] = useState(0)
|
|
27
|
-
// const fxOperator = currentValue > numeral ? 'subtraction' : 'addition'
|
|
28
|
-
|
|
29
|
-
// useAnimationFrame(
|
|
30
|
-
// (diffValue) => {
|
|
31
|
-
// // Pass on a function to the setter of the state
|
|
32
|
-
// // to make sure we always have the latest state
|
|
33
|
-
// setCurrentValue((prevCount) => {
|
|
34
|
-
// return fxOperator === 'addition'
|
|
35
|
-
// ? prevCount + diffValue
|
|
36
|
-
// : prevCount - diffValue
|
|
37
|
-
// }
|
|
38
|
-
// )
|
|
39
|
-
// },
|
|
40
|
-
// currentValue,
|
|
41
|
-
// numeral,
|
|
42
|
-
// 300
|
|
43
|
-
// )
|
|
44
|
-
// return <>{new Intl.NumberFormat().format(Math.round(currentValue))}</>
|
|
45
|
-
// }
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef, useState } from 'react'
|
|
2
|
-
|
|
3
|
-
const fullText =
|
|
4
|
-
' this is full text it\'ll be animated again! Writing a really huge senetence here so that I can see the animation happen. I know it\'s fast but that\'s how it goes.'
|
|
5
|
-
|
|
6
|
-
export const useAnimatedText = textMessage => {
|
|
7
|
-
const fullTextRef = useRef(textMessage)
|
|
8
|
-
const [text, setText] = useState('')
|
|
9
|
-
const [index, setIndex] = useState(0)
|
|
10
|
-
|
|
11
|
-
useEffect(() => {
|
|
12
|
-
if (index < fullText.length) {
|
|
13
|
-
window.requestAnimationFrame(() => {
|
|
14
|
-
// eslint-disable-next-line
|
|
15
|
-
setText(text => text + fullTextRef.current[index]);
|
|
16
|
-
setIndex(() => {return index + 1})
|
|
17
|
-
})
|
|
18
|
-
}
|
|
19
|
-
}, [index])
|
|
20
|
-
useEffect(() => {
|
|
21
|
-
fullText.current = textMessage
|
|
22
|
-
}, [textMessage])
|
|
23
|
-
|
|
24
|
-
return text
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// export default function TextHook() {
|
|
28
|
-
// const text = useAnimatedText(fullText)
|
|
29
|
-
|
|
30
|
-
// return <span>{text} </span>
|
|
31
|
-
// }
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export const calculateTotalPrice = (shoppingCardData) => {
|
|
2
|
-
if (Array.isArray(shoppingCardData) && shoppingCardData.length) {
|
|
3
|
-
return shoppingCardData.reduce((accumulator, currentItem) => {
|
|
4
|
-
const { productFood = {}, cantProducts } = currentItem || {}
|
|
5
|
-
const { ProPrice = 0, ValueDelivery = 0 } = productFood || {}
|
|
6
|
-
|
|
7
|
-
const pricePerProduct = ProPrice * cantProducts
|
|
8
|
-
const deliveryCost = ValueDelivery || 0
|
|
9
|
-
const ExtProductFoodsAll = currentItem.ExtProductFoodsAll || []
|
|
10
|
-
|
|
11
|
-
const extraPriceSum = ExtProductFoodsAll.reduce((extraAccumulator, extraFood) => {
|
|
12
|
-
if (Number.isInteger(extraFood.newExtraPrice)) {
|
|
13
|
-
return extraAccumulator + extraFood.newExtraPrice
|
|
14
|
-
}
|
|
15
|
-
return extraAccumulator
|
|
16
|
-
}, 0)
|
|
17
|
-
|
|
18
|
-
return accumulator + pricePerProduct + deliveryCost + extraPriceSum
|
|
19
|
-
}, 0)
|
|
20
|
-
}
|
|
21
|
-
return 0
|
|
22
|
-
}
|
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useState,
|
|
3
|
-
useEffect,
|
|
4
|
-
useMemo
|
|
5
|
-
} from 'react'
|
|
6
|
-
import { useMutation } from '@apollo/client'
|
|
7
|
-
import { DELETE_ONE_ITEM_SHOPPING_PRODUCT } from './queries'
|
|
8
|
-
import { useCart, useGetCart } from '../useCart'
|
|
9
|
-
import { useManageQueryParams } from '../useManageQueryParams'
|
|
10
|
-
import { calculateTotalPrice } from './helpers'
|
|
11
|
-
import { statusOpenStores } from '../statusOpenStores'
|
|
12
|
-
|
|
13
|
-
export const useAsideCart = ({
|
|
14
|
-
openModalProduct = false,
|
|
15
|
-
location = {
|
|
16
|
-
pathname: '',
|
|
17
|
-
push: (props, state, { shallow }) => {
|
|
18
|
-
return { ...props, state, shallow }
|
|
19
|
-
},
|
|
20
|
-
query: {
|
|
21
|
-
plato: ''
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
setCountItemProduct = (number) => { return number },
|
|
25
|
-
setAlertBox = (args) => { return args },
|
|
26
|
-
setOpenModalProduct = () => { },
|
|
27
|
-
handleMenu = (boolean) => { return boolean }
|
|
28
|
-
} = {
|
|
29
|
-
openModalProduct: false,
|
|
30
|
-
location: {
|
|
31
|
-
pathname: '',
|
|
32
|
-
push: (props, state, { shallow }) => {
|
|
33
|
-
return { ...props, state, shallow }
|
|
34
|
-
},
|
|
35
|
-
query: {
|
|
36
|
-
plato: ''
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
setCountItemProduct: (number) => { return number },
|
|
40
|
-
setAlertBox: () => { },
|
|
41
|
-
setOpenModalProduct: () => { },
|
|
42
|
-
handleMenu: () => { }
|
|
43
|
-
}) => {
|
|
44
|
-
const { getOneProduct } = useCart({
|
|
45
|
-
handleMenu,
|
|
46
|
-
openModalProduct,
|
|
47
|
-
location,
|
|
48
|
-
setOpenModalProduct
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
const { handleQuery } = useManageQueryParams({
|
|
52
|
-
location
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
const [totalProductPrice, setTotalProductPrice] = useState(0)
|
|
56
|
-
|
|
57
|
-
const [dataShoppingCard, { loading }] = useGetCart({ setCountItemProduct })
|
|
58
|
-
|
|
59
|
-
// Lógica de transformación de los datos
|
|
60
|
-
const result2 = useMemo(() => {
|
|
61
|
-
if (!loading && dataShoppingCard) {
|
|
62
|
-
return dataShoppingCard.reduce((r, a) => {
|
|
63
|
-
const storeName = a.getStore?.storeName
|
|
64
|
-
if (storeName) {
|
|
65
|
-
r[storeName] = r[storeName] || []
|
|
66
|
-
r[storeName].push(a)
|
|
67
|
-
}
|
|
68
|
-
return r
|
|
69
|
-
}, {})
|
|
70
|
-
}
|
|
71
|
-
return {}
|
|
72
|
-
}, [loading, dataShoppingCard])
|
|
73
|
-
|
|
74
|
-
// Obtener dataProduct2 directamente
|
|
75
|
-
const key = useMemo(() => {
|
|
76
|
-
return Object.keys(result2)
|
|
77
|
-
}, [result2])
|
|
78
|
-
|
|
79
|
-
useEffect(() => {
|
|
80
|
-
const totalPrice = calculateTotalPrice(dataShoppingCard)
|
|
81
|
-
setTotalProductPrice(Math.abs(totalPrice))
|
|
82
|
-
}, [dataShoppingCard])
|
|
83
|
-
|
|
84
|
-
const [deleteOneItem] = useMutation(DELETE_ONE_ITEM_SHOPPING_PRODUCT, {
|
|
85
|
-
onCompleted: data => {
|
|
86
|
-
setAlertBox({ message: data?.deleteOneItem?.message })
|
|
87
|
-
|
|
88
|
-
if (dataShoppingCard?.length === 1 && data?.deleteOneItem?.success) {
|
|
89
|
-
setAlertBox({ message: 'Tu carrito está vacío' }) // Ajusta el mensaje en español
|
|
90
|
-
handleMenu(false) // Oculta el menú del carrito
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
const handleEditProduct = async (item) => {
|
|
96
|
-
const pId = item?.pId || null
|
|
97
|
-
if (pId) handleQuery('plato', pId)
|
|
98
|
-
if (pId) {
|
|
99
|
-
const product = { pId, intoCart: true }
|
|
100
|
-
getOneProduct(product)
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Handle the deletion of a shopping cart item.
|
|
105
|
-
* @param {Object} item - The item to be deleted from the shopping cart.
|
|
106
|
-
*/
|
|
107
|
-
const handleDeleteItemShopping = async (item) => {
|
|
108
|
-
if (!item) {
|
|
109
|
-
return setAlertBox({
|
|
110
|
-
message: 'Error borrando el producto. Por favor intenta nuevamente.',
|
|
111
|
-
color: 'error'
|
|
112
|
-
})
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
try {
|
|
116
|
-
const { cState, ShoppingCard } = item
|
|
117
|
-
await deleteOneItem({
|
|
118
|
-
variables: { cState, ShoppingCard },
|
|
119
|
-
update: (cache) => {
|
|
120
|
-
cache.modify({
|
|
121
|
-
fields: {
|
|
122
|
-
getAllShoppingCard (existingCart, { readField }) {
|
|
123
|
-
if (!Array.isArray(existingCart)) return []
|
|
124
|
-
|
|
125
|
-
const filteredCart = existingCart.filter(product =>
|
|
126
|
-
readField('ShoppingCard', product) !== ShoppingCard
|
|
127
|
-
)
|
|
128
|
-
|
|
129
|
-
// Actualizar el contador de productos
|
|
130
|
-
setCountItemProduct(filteredCart.length)
|
|
131
|
-
|
|
132
|
-
return filteredCart?.length > 0 ? filteredCart : []
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
})
|
|
136
|
-
}
|
|
137
|
-
})
|
|
138
|
-
} catch (error) {
|
|
139
|
-
setAlertBox({ message: 'Error borrando el producto. Por favor intenta nuevamente.', color: 'error' })
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Calculate the total price of a product.
|
|
145
|
-
* @param {number} ProPrice - The price of the product.
|
|
146
|
-
* @param {number} ProDelivery - The delivery cost of the product.
|
|
147
|
-
* @param {number} cant - The quantity of the product.
|
|
148
|
-
* @returns {number} The calculated total price.
|
|
149
|
-
*/
|
|
150
|
-
const sumProduct = (ProPrice, ProDelivery, cant) => {
|
|
151
|
-
// Convertir a números, con manejo de posibles errores
|
|
152
|
-
const price = ProPrice
|
|
153
|
-
const delivery = ProDelivery || 0
|
|
154
|
-
const quantity = cant
|
|
155
|
-
|
|
156
|
-
// Verificar si las conversiones fueron exitosas
|
|
157
|
-
if (isNaN(price) || isNaN(delivery) || isNaN(quantity)) {
|
|
158
|
-
throw new Error('Los valores proporcionados no son números válidos.')
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// Calcular el precio final
|
|
162
|
-
const priceFinal = quantity * price
|
|
163
|
-
|
|
164
|
-
// Devolver la suma total, incluyendo el costo de entrega si es aplicable
|
|
165
|
-
return delivery ? priceFinal + delivery : priceFinal
|
|
166
|
-
}
|
|
167
|
-
console.log(dataShoppingCard)
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Verifica el estado de apertura de la tienda.
|
|
171
|
-
*
|
|
172
|
-
* @returns {Object|null} Objeto con el estado de apertura de la tienda o null en caso de error.
|
|
173
|
-
* @throws {Error} Si ocurre un error durante la verificación del estado de la tienda.
|
|
174
|
-
*/
|
|
175
|
-
const handleVerifyStoreOpenStatus = () => {
|
|
176
|
-
/**
|
|
177
|
-
* @type {Array} dataShoppingCard - El array de la tarjeta de compras.
|
|
178
|
-
*/
|
|
179
|
-
if (!Array.isArray(dataShoppingCard)) {
|
|
180
|
-
return { open: false } // Retorna un objeto indicando que la tienda no está abierta
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* @type {Object} store - La primera tienda en el array de la tarjeta de compras.
|
|
185
|
-
*/
|
|
186
|
-
const store = dataShoppingCard[0] || {}
|
|
187
|
-
/**
|
|
188
|
-
* @type {Object} getStore - El objeto que contiene información de la tienda.
|
|
189
|
-
*/
|
|
190
|
-
const { getStore } = store
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* @type {Array} storeSchedules - El array de horarios de la tienda.
|
|
194
|
-
*/
|
|
195
|
-
const storeSchedules = Array.isArray(getStore?.getStoreSchedules) ? getStore?.getStoreSchedules : []
|
|
196
|
-
try {
|
|
197
|
-
const status = getStore?.scheduleOpenAll ? { open: true } : statusOpenStores({ dataSchedules: storeSchedules })
|
|
198
|
-
return status
|
|
199
|
-
} catch (error) {
|
|
200
|
-
return null
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
return {
|
|
205
|
-
key,
|
|
206
|
-
totalProductPrice,
|
|
207
|
-
result2,
|
|
208
|
-
dataShoppingCard,
|
|
209
|
-
handleDeleteItemShopping,
|
|
210
|
-
handleEditProduct,
|
|
211
|
-
handleVerifyStoreOpenStatus,
|
|
212
|
-
sumProduct
|
|
213
|
-
}
|
|
214
|
-
}
|