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,62 +0,0 @@
|
|
|
1
|
-
import { jaccardSimilarity } from './helpers'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Get categories that contain products with names similar to the given product name.
|
|
5
|
-
* Uses the Jaccard similarity coefficient for string comparison.
|
|
6
|
-
* @param {Array} data - The array of categories with product information.
|
|
7
|
-
* @param {string} productName - The name of the product to search for.
|
|
8
|
-
* @param {number} similarityThreshold - The minimum similarity threshold for products (0.0 to 1.0).
|
|
9
|
-
* @returns {Array} - An array of categories containing similar products.
|
|
10
|
-
*/
|
|
11
|
-
export const getCategoriesWithProduct = (
|
|
12
|
-
data = [],
|
|
13
|
-
productName = '',
|
|
14
|
-
similarityThreshold = 0.0) => {
|
|
15
|
-
// Validate input data
|
|
16
|
-
if (!data || !Array.isArray(data)) {
|
|
17
|
-
return data || []
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (typeof productName !== 'string' || productName.trim() === '') {
|
|
21
|
-
return data
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// Convert product name to lowercase for case-insensitive comparison
|
|
25
|
-
const productNameLower = productName.toLowerCase()
|
|
26
|
-
|
|
27
|
-
// Use a Set to store unique product names for better performance
|
|
28
|
-
const uniqueProductNames = new Set()
|
|
29
|
-
|
|
30
|
-
// Store unique product names in the Set
|
|
31
|
-
data.forEach(category => {
|
|
32
|
-
if (category?.productFoodsAll && Array.isArray(category.productFoodsAll)) {
|
|
33
|
-
category.productFoodsAll.forEach(product => {
|
|
34
|
-
const productLower = product.pName.toLowerCase()
|
|
35
|
-
uniqueProductNames.add(productLower)
|
|
36
|
-
})
|
|
37
|
-
}
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
// Filter categories that contain products with names similar to the given product name
|
|
41
|
-
const matchingCategories = data.filter(category => {
|
|
42
|
-
if (category?.productFoodsAll && Array.isArray(category.productFoodsAll)) {
|
|
43
|
-
const products = category.productFoodsAll.some(product => {
|
|
44
|
-
const productLower = product?.pName?.toLowerCase()
|
|
45
|
-
return jaccardSimilarity(productNameLower, productLower) >= similarityThreshold
|
|
46
|
-
})
|
|
47
|
-
return products
|
|
48
|
-
}
|
|
49
|
-
return false
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
// Find similar products in each matching category
|
|
53
|
-
const findProduct = matchingCategories?.map(categories => {
|
|
54
|
-
const similarProducts = categories.productFoodsAll.filter(product => {
|
|
55
|
-
const productLower = product?.pName?.toLowerCase()
|
|
56
|
-
return productLower.includes(productNameLower)
|
|
57
|
-
})
|
|
58
|
-
return similarProducts.length > 0 ? { ...categories, productFoodsAll: similarProducts } : null
|
|
59
|
-
}).filter(Boolean)
|
|
60
|
-
|
|
61
|
-
return findProduct
|
|
62
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import crypto from 'crypto'
|
|
2
|
-
|
|
3
|
-
function generateEncryptionKey (password, salt) {
|
|
4
|
-
return crypto
|
|
5
|
-
.pbkdf2Sync(password, salt, 100000, 32, 'sha256')
|
|
6
|
-
.toString('hex')
|
|
7
|
-
.slice(0, 32)
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const ENCRYPTION_KEY = generateEncryptionKey(
|
|
11
|
-
'tu-contraseña',
|
|
12
|
-
'alguna-sal-segura'
|
|
13
|
-
)
|
|
14
|
-
const IV_LENGTH = 16 // Para AES, este siempre debe ser 16
|
|
15
|
-
|
|
16
|
-
export const encryptSession = (text) => {
|
|
17
|
-
try {
|
|
18
|
-
const iv = crypto.randomBytes(IV_LENGTH)
|
|
19
|
-
const cipher = crypto.createCipheriv(
|
|
20
|
-
'aes-256-cbc',
|
|
21
|
-
Buffer.from(ENCRYPTION_KEY),
|
|
22
|
-
iv
|
|
23
|
-
)
|
|
24
|
-
let encrypted = cipher.update(text)
|
|
25
|
-
encrypted = Buffer.concat([encrypted, cipher.final()])
|
|
26
|
-
return iv.toString('hex') + ':' + encrypted.toString('hex')
|
|
27
|
-
} catch (error) {
|
|
28
|
-
return null
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export const decryptSession = (text) => {
|
|
33
|
-
try {
|
|
34
|
-
if (!text) return
|
|
35
|
-
const textParts = text.split(':')
|
|
36
|
-
const iv = Buffer.from(textParts.shift(), 'hex')
|
|
37
|
-
const encryptedText = Buffer.from(textParts.join(':'), 'hex')
|
|
38
|
-
const decipher = crypto.createDecipheriv(
|
|
39
|
-
'aes-256-cbc',
|
|
40
|
-
Buffer.from(ENCRYPTION_KEY),
|
|
41
|
-
iv
|
|
42
|
-
)
|
|
43
|
-
let decrypted = decipher.update(encryptedText)
|
|
44
|
-
decrypted = Buffer.concat([decrypted, decipher.final()])
|
|
45
|
-
return decrypted.toString()
|
|
46
|
-
} catch (error) {
|
|
47
|
-
return null
|
|
48
|
-
}
|
|
49
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export const getSession = async () => {
|
|
2
|
-
try {
|
|
3
|
-
const res = await fetch(`${process.env.URL_BASE}/api/auth/getAuth`,
|
|
4
|
-
{ method: 'GET', headers: { 'Content-Type': 'application/json' } })
|
|
5
|
-
const data = await res.json()
|
|
6
|
-
const { ok, ok: { user }, isSession } = data || {}
|
|
7
|
-
const { deviceid, token } = user || {}
|
|
8
|
-
return {
|
|
9
|
-
user,
|
|
10
|
-
ok,
|
|
11
|
-
isSession,
|
|
12
|
-
deviceid,
|
|
13
|
-
token
|
|
14
|
-
}
|
|
15
|
-
} catch (e) {
|
|
16
|
-
return e
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Get the start timestamp for the current day.
|
|
3
|
-
* @returns {string} The start timestamp for the current day.
|
|
4
|
-
*/
|
|
5
|
-
export const getStartOfDayTimestamp = () => {
|
|
6
|
-
const start = new Date()
|
|
7
|
-
start.setHours(0, 0, 0, 0)
|
|
8
|
-
return start.toISOString()
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Get the end timestamp for the current day.
|
|
13
|
-
* @returns {string} The end timestamp for the current day.
|
|
14
|
-
*/
|
|
15
|
-
export const getEndOfDayTimestamp = () => {
|
|
16
|
-
const end = new Date()
|
|
17
|
-
end.setHours(23, 59, 59, 999)
|
|
18
|
-
return end.toISOString()
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Get start and end timestamps for the current day.
|
|
23
|
-
* @returns {Object} An object containing start and end timestamps.
|
|
24
|
-
*/
|
|
25
|
-
export const getTodayTimestamps = () => {
|
|
26
|
-
return {
|
|
27
|
-
startTimestamp: getStartOfDayTimestamp(),
|
|
28
|
-
endTimestamp: getEndOfDayTimestamp()
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Get start timestamp for a specific number of days ago.
|
|
34
|
-
* @param {number} daysAgo - The number of days ago.
|
|
35
|
-
* @returns {string} The start timestamp for the specified number of days ago.
|
|
36
|
-
*/
|
|
37
|
-
export const getStartTimestampDaysAgo = (daysAgo) => {
|
|
38
|
-
if (isNaN(daysAgo) || daysAgo < 0) {
|
|
39
|
-
throw new Error('Invalid input. Provide a valid number of days.')
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const start = new Date()
|
|
43
|
-
start.setDate(start.getDate() - daysAgo)
|
|
44
|
-
start.setHours(0, 0, 0, 0)
|
|
45
|
-
|
|
46
|
-
return start.toISOString()
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export function convertDateFormat ({ dateString, start }) {
|
|
50
|
-
const parsedDate = dateString ? new Date(dateString) : new Date()
|
|
51
|
-
const year = parsedDate.getFullYear()
|
|
52
|
-
const month = `0${parsedDate.getMonth() + 1}`.slice(-2)
|
|
53
|
-
const day = `0${parsedDate.getDate()}`.slice(-2)
|
|
54
|
-
|
|
55
|
-
if (start) {
|
|
56
|
-
// Inicio del día (00:00:00)
|
|
57
|
-
return `${year}-${month}-${day}T00:00:00.000Z`
|
|
58
|
-
} else {
|
|
59
|
-
// Final del día (23:59:59.999)
|
|
60
|
-
const endOfDay = new Date(parsedDate)
|
|
61
|
-
endOfDay.setHours(23, 59, 59, 999)
|
|
62
|
-
return endOfDay.toISOString()
|
|
63
|
-
}
|
|
64
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
export const getTotalHours = (days = []) => {
|
|
2
|
-
const totalMinutesArray = days?.map((day) => {
|
|
3
|
-
const { schHoSta, schHoEnd } = day
|
|
4
|
-
|
|
5
|
-
// Handle potential invalid time strings
|
|
6
|
-
if (!isValidTimeString(schHoSta) || !isValidTimeString(schHoEnd)) {
|
|
7
|
-
return 0 // Ignore invalid time strings and return 0
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const [startHours, startMinutes] = schHoSta.split(':')
|
|
11
|
-
const [endHours, endMinutes] = schHoEnd.split(':')
|
|
12
|
-
|
|
13
|
-
// Convert hours and minutes to integers for calculations
|
|
14
|
-
let totalHoursInt = parseInt(endHours, 10) - parseInt(startHours, 10)
|
|
15
|
-
const totalMinutesInt = parseInt(endMinutes, 10) - parseInt(startMinutes, 10)
|
|
16
|
-
|
|
17
|
-
// Handle negative total minutes (occurs when endMinutes < startMinutes)
|
|
18
|
-
let totalMinutes = totalMinutesInt
|
|
19
|
-
if (totalMinutes < 0) {
|
|
20
|
-
totalHoursInt-- // Decrement total hours for negative minutes
|
|
21
|
-
totalMinutes += 60 // Add 60 minutes to account for borrowing from previous hour
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// Calculate total time in minutes
|
|
25
|
-
const totalTimeMinutes = totalHoursInt * 60 + totalMinutes
|
|
26
|
-
|
|
27
|
-
return totalTimeMinutes
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
// Calculate the sum of total minutes for all days
|
|
31
|
-
const totalMinutes = totalMinutesArray.reduce((acc, curr) => acc + curr, 0)
|
|
32
|
-
|
|
33
|
-
// Convert total minutes to hours and minutes format
|
|
34
|
-
const totalHours = Math.floor(totalMinutes / 60)
|
|
35
|
-
const remainingMinutes = totalMinutes % 60
|
|
36
|
-
|
|
37
|
-
// Format the total time as "00:00"
|
|
38
|
-
const formattedHours = totalHours.toString().padStart(2, '0')
|
|
39
|
-
const formattedMinutes = remainingMinutes.toString().padStart(2, '0')
|
|
40
|
-
|
|
41
|
-
return `${formattedHours}:${formattedMinutes}`
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// Function to validate time string format (HH:MM)
|
|
45
|
-
export const isValidTimeString = (timeString) => {
|
|
46
|
-
const timeRegex = /^([0-1][0-9]|2[0-3]):([0-5][0-9])$/
|
|
47
|
-
return timeRegex.test(timeString)
|
|
48
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export async function handleLogin (body) {
|
|
2
|
-
const response = await fetch(`${process.env.URL_BASE}/api/auth/login`, {
|
|
3
|
-
method: 'POST',
|
|
4
|
-
headers: { 'Content-Type': 'application/json' },
|
|
5
|
-
body: JSON.stringify(body),
|
|
6
|
-
credentials: 'include'
|
|
7
|
-
})
|
|
8
|
-
|
|
9
|
-
return response.json()
|
|
10
|
-
}
|
package/src/hooks/index.ts
DELETED
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
export * from './updateExtProductFoodsOptional'
|
|
2
|
-
export * from './useAcumulateDate'
|
|
3
|
-
export * from './useBanner'
|
|
4
|
-
export * from './useCategoryInStore'
|
|
5
|
-
export * from './useCategoryStore'
|
|
6
|
-
export * from './useCatWithProduct'
|
|
7
|
-
export * from './useManageQueryParams'
|
|
8
|
-
export * from './useDeliveryTime'
|
|
9
|
-
export * from './useModules'
|
|
10
|
-
export * from './getTotalHours'
|
|
11
|
-
export * from './useUpdateMultipleProducts'
|
|
12
|
-
export * from './useTokenCards'
|
|
13
|
-
export * from './useStoreTable/index'
|
|
14
|
-
export * from './useSubscriptionValidation'
|
|
15
|
-
export * from './convertToMilitaryTime'
|
|
16
|
-
export * from './useRoles'
|
|
17
|
-
export * from './useLocalBackendIp'
|
|
18
|
-
export * from './statusOpenStores'
|
|
19
|
-
export * from './completeSchedules'
|
|
20
|
-
export * from './useLogout/helpers/BroadcastChannel'
|
|
21
|
-
export * from './getCardType'
|
|
22
|
-
export * from './useLoginEmployeeInStore'
|
|
23
|
-
export * from './useUploadProducts'
|
|
24
|
-
export * from './useAmountInput'
|
|
25
|
-
export * from './useColorByLetters'
|
|
26
|
-
export * from './newMessageSubscription'
|
|
27
|
-
export * from './usePWAInstall'
|
|
28
|
-
export * from './useGetCookies'
|
|
29
|
-
export * from './generateTemplate'
|
|
30
|
-
export * from './isTokenExpired'
|
|
31
|
-
export * from './useCreateDeliveryTime'
|
|
32
|
-
export * from './addTenMinutes'
|
|
33
|
-
export * from './useUpdateCartCookie'
|
|
34
|
-
export * from './useCategoriesProduct'
|
|
35
|
-
export * from './useLogout'
|
|
36
|
-
export * from './useSetupSchedule'
|
|
37
|
-
export * from './useMouse'
|
|
38
|
-
export * from './useStatusOpenStore'
|
|
39
|
-
export * from './usePushNotificationOrder'
|
|
40
|
-
export * from './newStoreOrderSubscription'
|
|
41
|
-
export * from './useChatRoomSubscription'
|
|
42
|
-
export * from './useScheduleData'
|
|
43
|
-
export * from './useGetMessagesToRoom'
|
|
44
|
-
export * from './useOrders'
|
|
45
|
-
export * from './usePushNotifications'
|
|
46
|
-
export * from './useLocationManager'
|
|
47
|
-
export * from './useQueryLocationsMap'
|
|
48
|
-
export * from './useGetAllLocationUser'
|
|
49
|
-
export * from './useFingerprintjs'
|
|
50
|
-
export * from './useCountries'
|
|
51
|
-
export * from './useDessertWithPrice'
|
|
52
|
-
export * from './generateStoreURL'
|
|
53
|
-
export * from './useCreateStorePendingToRegister'
|
|
54
|
-
export * from './useDepartments'
|
|
55
|
-
export * from './useSaveLocation'
|
|
56
|
-
export * from './useRoads'
|
|
57
|
-
export * from './useCities'
|
|
58
|
-
export * from './useEditCategory'
|
|
59
|
-
export * from './useEmployee'
|
|
60
|
-
export * from './useEmployee/useCreateEmployee'
|
|
61
|
-
export * from './useCheckbox'
|
|
62
|
-
export * from './useRemoveExtraProductFoodsOptional'
|
|
63
|
-
export * from './useDeleteSubProductOptional'
|
|
64
|
-
export * from './useGetOneStoreRating'
|
|
65
|
-
export * from './useFavoriteStores'
|
|
66
|
-
export * from './useAsideCart'
|
|
67
|
-
export * from './useRatingArrayData'
|
|
68
|
-
export * from './useChartData'
|
|
69
|
-
export * from './useDevices'
|
|
70
|
-
export * from './useClients'
|
|
71
|
-
export * from './useScroll'
|
|
72
|
-
export * from './useStatusOrdersClient'
|
|
73
|
-
export * from './useUpdateExistingOrders'
|
|
74
|
-
export * from './useConnection'
|
|
75
|
-
export * from './useManageNewOrder'
|
|
76
|
-
export * from './useCreateProduct'
|
|
77
|
-
export * from './useCreateProduct/helpers/useEditImageProduct'
|
|
78
|
-
export * from './useDessert'
|
|
79
|
-
export * from './useDrag'
|
|
80
|
-
export * from './useEvent'
|
|
81
|
-
export * from './useFetchJson'
|
|
82
|
-
export * from './useFormatDate'
|
|
83
|
-
export * from './getTodayTimestamps'
|
|
84
|
-
export * from './useFormatNumberPhone'
|
|
85
|
-
export * from './useFormTools/index'
|
|
86
|
-
export * from './useHover'
|
|
87
|
-
export * from './useImageOptimization'
|
|
88
|
-
export * from './useImagesStore'
|
|
89
|
-
export * from './useImageWeight'
|
|
90
|
-
export * from './useIntersection'
|
|
91
|
-
export * from './useKeypress'
|
|
92
|
-
export * from './useLazyScript'
|
|
93
|
-
export * from './useLocalSorage'
|
|
94
|
-
export * from './useLocationNavigate'
|
|
95
|
-
export * from './useSetSession'
|
|
96
|
-
export * from './useMobile'
|
|
97
|
-
export * from './useMutateHeight'
|
|
98
|
-
export * from './useProductsFood'
|
|
99
|
-
export * from './useProductsFood/usetagsProducts'
|
|
100
|
-
export * from './useReactToPrint'
|
|
101
|
-
export * from './useReport'
|
|
102
|
-
export * from './useSales/useTotalSales'
|
|
103
|
-
export * from './useOrderClient'
|
|
104
|
-
export * from './useStoreContacts'
|
|
105
|
-
export * from './useRestaurant'
|
|
106
|
-
export * from './useSales'
|
|
107
|
-
export * from './useSales/useGetSale'
|
|
108
|
-
export * from './useGetMinPrice'
|
|
109
|
-
export * from './useCatWithProductClient'
|
|
110
|
-
export * from './useGetFoodRecomended'
|
|
111
|
-
export * from './useSaveAvailableProduct'
|
|
112
|
-
export * from './useSchedule'
|
|
113
|
-
export * from './useSetState'
|
|
114
|
-
export * from './useStore'
|
|
115
|
-
export * from './useStoreCalendar'
|
|
116
|
-
export * from './getCategoriesWithProduct'
|
|
117
|
-
export * from './useIncomingOrders'
|
|
118
|
-
export * from './useTimeAgo/useTimeAgo'
|
|
119
|
-
export * from './useUpdateCart'
|
|
120
|
-
export * from './useUpdateExtProductFoodsSubOptional'
|
|
121
|
-
export * from './useUser'
|
|
122
|
-
export * from './useCart'
|
|
123
|
-
export * from './useGetStoreCookie'
|
|
124
|
-
export * from './getGlobalSession'
|
|
125
|
-
export * from './handleLogin'
|
|
126
|
-
export * from './useInventory'
|
|
127
|
-
export * from './useStockMovements'
|
|
128
|
-
export * from './useTopProductsMovements'
|
|
129
|
-
export * from './useTotalProductsSold'
|
|
130
|
-
export * from './useTotalProductsInStock/index'
|
|
131
|
-
export * from './useTotalAllSales/index'
|
|
132
|
-
export * from './useTotalProductsSolded'
|
|
133
|
-
export * from './useWeeklyStockMovement'
|
|
134
|
-
export * from './useSetImageProducts'
|
|
135
|
-
export * from './useGetSalesAmountToday'
|
|
136
|
-
export * from './useUpsertGoal'
|
|
137
|
-
export * from './useDashboardComponents'
|
|
138
|
-
export * from './useUpdateDashboardComponent'
|
|
139
|
-
export * from './useUpdateModuleOrder'
|
|
140
|
-
export * from './useDownloadReports'
|
|
141
|
-
export * from './usePortFetcher'
|
|
142
|
-
export * from './useImageUploaderProduct'
|
|
143
|
-
export * from './useTagProducts'
|
|
144
|
-
export * from './useOrderStatusTypes'
|
|
145
|
-
export * from './useCreateOrderStatusType'
|
|
146
|
-
export * from './useDevWS'
|
|
147
|
-
export * from './usePrintSaleTicket'
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Verifica si un token JWT ha expirado.
|
|
3
|
-
* @param {string} token El token JWT a verificar.
|
|
4
|
-
* @param {string} [expField='exp'] El nombre del campo que contiene la fecha de expiración en el token.
|
|
5
|
-
* @returns {boolean} True si el token ha expirado, false de lo contrario.
|
|
6
|
-
*/
|
|
7
|
-
export const isTokenExpired = (token, expField = 'exp') => {
|
|
8
|
-
try {
|
|
9
|
-
const [, payloadBase64] = token.split('.')
|
|
10
|
-
const decodedJson = Buffer.from(payloadBase64, 'base64').toString()
|
|
11
|
-
const decoded = JSON.parse(decodedJson)
|
|
12
|
-
const exp = decoded[expField] * 1000 // Convertir segundos a milisegundos
|
|
13
|
-
return Date.now() >= exp
|
|
14
|
-
} catch (error) {
|
|
15
|
-
return true
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { useSubscription, gql } from '@apollo/client'
|
|
2
|
-
|
|
3
|
-
const NEW_MESSAGE_SUBSCRIPTION = gql`
|
|
4
|
-
subscription NewMessage($idStore: String!) {
|
|
5
|
-
newMessage(idStore: $idStore) {
|
|
6
|
-
uuid
|
|
7
|
-
content
|
|
8
|
-
aDatCre
|
|
9
|
-
from
|
|
10
|
-
to
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
`
|
|
14
|
-
|
|
15
|
-
export const newMessageSubscription = (idStore, onMessageReceived) => {
|
|
16
|
-
const subscription = useSubscription(NEW_MESSAGE_SUBSCRIPTION, {
|
|
17
|
-
variables: { idStore },
|
|
18
|
-
onSubscriptionData: ({ client, subscriptionData }) => {
|
|
19
|
-
if (subscriptionData.data && subscriptionData.data.newMessage) {
|
|
20
|
-
// Llama a la función proporcionada cuando se recibe un nuevo mensaje
|
|
21
|
-
onMessageReceived(subscriptionData.data.newMessage)
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
// Puedes ajustar lo que devuelve el hook según tus necesidades
|
|
27
|
-
return subscription
|
|
28
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { useSubscription, gql } from '@apollo/client'
|
|
2
|
-
|
|
3
|
-
const NEW_STORE_ORDER_SUBSCRIPTION = gql`
|
|
4
|
-
subscription NewStoreOrder($idStore: String!) {
|
|
5
|
-
newStoreOrder(idStore: $idStore) {
|
|
6
|
-
id
|
|
7
|
-
idStore
|
|
8
|
-
pCodeRef
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
`
|
|
12
|
-
|
|
13
|
-
export const newStoreOrderSubscription = (idStore, onOrderReceived) => {
|
|
14
|
-
const subscription = useSubscription(NEW_STORE_ORDER_SUBSCRIPTION, {
|
|
15
|
-
variables: { idStore },
|
|
16
|
-
onSubscriptionData: ({ client, subscriptionData }) => {
|
|
17
|
-
if (subscriptionData.data && subscriptionData.data.newStoreOrder) {
|
|
18
|
-
// Llama a la función proporcionada cuando se recibe una nueva orden
|
|
19
|
-
onOrderReceived(subscriptionData.data.newStoreOrder)
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
// Puedes ajustar lo que devuelve el hook según tus necesidades
|
|
25
|
-
return subscription
|
|
26
|
-
}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
export const getDayFromOpeningKey = (key) => {
|
|
2
|
-
const days = {
|
|
3
|
-
openingSun: 0,
|
|
4
|
-
openingMon: 1,
|
|
5
|
-
openingTue: 2,
|
|
6
|
-
openingWed: 3,
|
|
7
|
-
openingThu: 4,
|
|
8
|
-
openingFri: 5,
|
|
9
|
-
openingSat: 6
|
|
10
|
-
}
|
|
11
|
-
return days[key] !== undefined ? days[key] : -1
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
// Función para convertir el objeto de tiempo en una cadena de tiempo
|
|
15
|
-
export function getTimeString (timeStr) {
|
|
16
|
-
return timeStr || '00:00' // Return '00:00' for empty time strings
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function getCurrentDayAndTime () {
|
|
20
|
-
try {
|
|
21
|
-
const date = new Date()
|
|
22
|
-
const currentTime = date.getHours() * 60 + date.getMinutes()
|
|
23
|
-
const currentDayOfWeek = date.getDay()
|
|
24
|
-
return { currentTime, currentDayOfWeek }
|
|
25
|
-
} catch (error) {
|
|
26
|
-
return {
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function getTimeObject (timeStr) {
|
|
33
|
-
try {
|
|
34
|
-
if (!timeStr || !/\d{2}:\d{2}/.test(timeStr)) {
|
|
35
|
-
return { hours: 0, minutes: 0 } // Return default values for invalid input
|
|
36
|
-
}
|
|
37
|
-
const [hours, minutes] = timeStr.split(':').map(str => parseInt(str))
|
|
38
|
-
return { hours, minutes }
|
|
39
|
-
} catch (e) {
|
|
40
|
-
return { hours: 0, minutes: 0 } // Return default values on error
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function sortOpeningsByDay (openings) {
|
|
45
|
-
const days = [
|
|
46
|
-
'openingSun',
|
|
47
|
-
'openingMon',
|
|
48
|
-
'openingTue',
|
|
49
|
-
'openingWed',
|
|
50
|
-
'openingThu',
|
|
51
|
-
'openingFri',
|
|
52
|
-
'openingSat'
|
|
53
|
-
]
|
|
54
|
-
const sortedOpenings = {}
|
|
55
|
-
|
|
56
|
-
days.forEach((day) => {
|
|
57
|
-
sortedOpenings[day] = openings[day] || '00:00 - 00:00' // Agregar horario vacío para los días faltantes
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
return sortedOpenings
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Función para obtener la clave de openings a partir del día de la semana
|
|
64
|
-
export function getOpeningKeyFromDay (day) {
|
|
65
|
-
const days = {
|
|
66
|
-
0: 'openingSun',
|
|
67
|
-
1: 'openingMon',
|
|
68
|
-
2: 'openingTue',
|
|
69
|
-
3: 'openingWed',
|
|
70
|
-
4: 'openingThu',
|
|
71
|
-
5: 'openingFri',
|
|
72
|
-
6: 'openingSat'
|
|
73
|
-
}
|
|
74
|
-
return days[day]
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export const weekDays = [
|
|
78
|
-
'Domingo',
|
|
79
|
-
'Lunes',
|
|
80
|
-
'Martes',
|
|
81
|
-
'Miércoles',
|
|
82
|
-
'Jueves',
|
|
83
|
-
'Viernes',
|
|
84
|
-
'Sábado'
|
|
85
|
-
]
|
|
86
|
-
|
|
87
|
-
export function timeToInt (text) {
|
|
88
|
-
const hour = parseInt(text.substring(0, 2))
|
|
89
|
-
const minute = parseInt(text.substring(3))
|
|
90
|
-
return hour * 60 + minute
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export const days = {
|
|
94
|
-
Monday: 'Lunes',
|
|
95
|
-
Tuesday: 'Martes',
|
|
96
|
-
Wednesday: 'Miércoles',
|
|
97
|
-
Thursday: 'Jueves',
|
|
98
|
-
Friday: 'Viernes',
|
|
99
|
-
Saturday: 'Sábado',
|
|
100
|
-
Sunday: 'Domingo'
|
|
101
|
-
}
|