npm-pkg-hook 1.1.0 → 1.1.3
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/.eslintrc.js +132 -132
- package/next.config.js +0 -1
- package/package.json +46 -43
- package/src/config/client/errors.js +2 -1
- package/src/hooks/getSession/index.js +18 -0
- package/src/hooks/index.js +27 -7
- package/src/hooks/useAnimationFrame/index.js +45 -0
- package/src/hooks/useAnimationText/index.jsx +11 -13
- package/src/hooks/useCatWithProduct/index.js +37 -4
- package/src/hooks/useCatWithProduct/queries.js +0 -16
- package/src/hooks/useCategoriesProduct/index.js +12 -0
- package/src/hooks/useCategoriesProduct/queries.js +16 -0
- package/src/hooks/useChartData/index.js +2 -169
- package/src/hooks/useChartData/useChartData/index.js +197 -0
- package/src/hooks/useChartData/useChartDataAllOrders/index.js +89 -0
- package/src/hooks/useCheckbox/index.js +5 -1
- package/src/hooks/useClients/index.js +17 -8
- package/src/hooks/useCreateProduct/index.js +95 -65
- package/src/hooks/useDeleteSubProductOptional/index.js +30 -0
- package/src/hooks/useDeleteSubProductOptional/queries.js +10 -0
- package/src/hooks/useDessert/helpers/index.js +51 -0
- package/src/hooks/useDessert/index.js +319 -121
- package/src/hooks/useDevices/index.js +36 -0
- package/src/hooks/useDevices/queries.js +19 -0
- package/src/hooks/useDrag/index.js +1 -1
- package/src/hooks/useDropzone/index.js +79 -0
- package/src/hooks/useDynamicAuth/index.js +13 -0
- package/src/hooks/useDynamicAuth/queries.js +24 -0
- package/src/hooks/useEmployee/index.js +11 -8
- package/src/hooks/useFingerprintjs/index.js +176 -0
- package/src/hooks/useFormTools/index.js +1 -1
- package/src/hooks/useFullScreenMode/index.js +8 -9
- package/src/hooks/useGenerateNumberArray/index.js +17 -0
- package/src/hooks/useImagesStore/index.js +176 -143
- package/src/hooks/useImagesStore/queries.js +1 -28
- package/src/hooks/useKeypress/index.js +7 -1
- package/src/hooks/useLocalSorage/index.js +1 -1
- package/src/hooks/useLogout/index.js +22 -25
- package/src/hooks/useManageQueryParams/index.js +37 -0
- package/src/hooks/useProductsFood/queriesStore.js +3 -16
- package/src/hooks/useProductsFood/usetagsProducts.js +30 -5
- package/src/hooks/useProviders/index.js +3 -0
- package/src/hooks/useProviders/queries.js +31 -0
- package/src/hooks/useProviders/useProvidersCreateStore/index.js +13 -0
- package/src/hooks/useProviders/useProvidersDataStore/index.js +24 -0
- package/src/hooks/useProvidersStore/index.js +24 -0
- package/src/hooks/useProvidersStore/queries.js +31 -0
- package/src/hooks/useRatingData/index.js +53 -0
- package/src/hooks/useRatingData/queries.js +18 -0
- package/src/hooks/useRemoveExtraProductFoodsOptional/index.js +23 -0
- package/src/hooks/useRemoveExtraProductFoodsOptional/queries.js +48 -0
- package/src/hooks/useReport/index.js +16 -7
- package/src/hooks/useReport/queries.js +47 -32
- package/src/hooks/useSales/index.js +53 -22
- package/src/hooks/useSales/queries.js +48 -38
- package/src/hooks/useSales/useGetAllSales/index.js +25 -0
- package/src/hooks/useSales/useGetSale.js +16 -2
- package/src/hooks/useSchedule/index.js +36 -0
- package/src/hooks/useSchedule/queries.js +35 -0
- package/src/hooks/useScheduleData/index.js +171 -0
- package/src/hooks/useScroll/index.js +57 -0
- package/src/hooks/useScrollRotate/index.js +14 -0
- package/src/hooks/useStatusOpenStore/helpers/index.js +102 -0
- package/src/hooks/useStatusOpenStore/index.js +173 -0
- package/src/hooks/useStoreContacts/index.js +5 -1
- package/src/hooks/useUpdateExistingOrders/index.js +8 -8
- package/src/hooks/useUser/index.js +7 -2
- package/src/hooks/useUser/queries.js +40 -0
- package/src/index.jsx +3 -1
- package/.vscode/extensions.json +0 -6
- package/.vscode/settings.json +0 -8
- package/src/hooks/useSchedule/index.jsx +0 -23
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import md5 from 'md5'
|
|
2
|
+
|
|
3
|
+
async function getCPUInfo() {
|
|
4
|
+
if (navigator.hardwareConcurrency) {
|
|
5
|
+
try {
|
|
6
|
+
const logicalCores = navigator.hardwareConcurrency;
|
|
7
|
+
const agent = window.navigator.userAgent;
|
|
8
|
+
const hyperThreaded = /Intel|Apple/.test(agent) && /Win64|Linux x86_64|MacIntel/.test(agent);
|
|
9
|
+
|
|
10
|
+
// Ajustar el número de núcleos lógicos si se sospecha hiperprocesamiento
|
|
11
|
+
const physicalCores = hyperThreaded ? logicalCores / 2 : logicalCores;
|
|
12
|
+
|
|
13
|
+
const cpuInfo = {
|
|
14
|
+
logicalCores: logicalCores,
|
|
15
|
+
physicalCores: physicalCores,
|
|
16
|
+
hyperThreaded: hyperThreaded
|
|
17
|
+
};
|
|
18
|
+
return JSON.stringify(cpuInfo);
|
|
19
|
+
} catch (error) {
|
|
20
|
+
console.error('Error al obtener información de la CPU:', error);
|
|
21
|
+
return 'cpu-info-error';
|
|
22
|
+
}
|
|
23
|
+
} else {
|
|
24
|
+
return 'cpu-info-not-available';
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async function generateFingerprint() {
|
|
29
|
+
const canvas = document.createElement('canvas');
|
|
30
|
+
const context = canvas.getContext('2d');
|
|
31
|
+
const audioContext = new (window.AudioContext || window.webkitAudioContext)();
|
|
32
|
+
|
|
33
|
+
const userAgent = navigator.userAgent;
|
|
34
|
+
const language = navigator.language;
|
|
35
|
+
const colorDepth = window.screen.colorDepth;
|
|
36
|
+
const availableScreenHeight = window.screen.availHeight;
|
|
37
|
+
const platform = navigator.platform;
|
|
38
|
+
const cpuClass = navigator.cpuClass || 'unknown';
|
|
39
|
+
|
|
40
|
+
const canvasFingerprint = await generateCanvasFingerprint(canvas);
|
|
41
|
+
const audioFingerprint = await generateAudioFingerprint(audioContext);
|
|
42
|
+
|
|
43
|
+
const cpuInfo = await getCPUInfo();
|
|
44
|
+
const webGLInfo = await getWebGLInfo();
|
|
45
|
+
const fonts = getInstalledFonts();
|
|
46
|
+
const touchscreenInfo = getTouchscreenInfo();
|
|
47
|
+
|
|
48
|
+
const fingerprintData = {
|
|
49
|
+
browser: {
|
|
50
|
+
userAgent,
|
|
51
|
+
language,
|
|
52
|
+
colorDepth,
|
|
53
|
+
availableScreenHeight,
|
|
54
|
+
plugins: Array.from(navigator.plugins).map(plugin => plugin.name).join(','),
|
|
55
|
+
timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
56
|
+
hardwareConcurrency: cpuInfo.logicalCores || 'unknown',
|
|
57
|
+
platformVersion: navigator.platformVersion || 'unknown',
|
|
58
|
+
},
|
|
59
|
+
device: {
|
|
60
|
+
platform,
|
|
61
|
+
cpuClass,
|
|
62
|
+
},
|
|
63
|
+
canvas: canvasFingerprint,
|
|
64
|
+
audio: audioFingerprint,
|
|
65
|
+
cpu: cpuInfo,
|
|
66
|
+
webgl: webGLInfo,
|
|
67
|
+
fonts,
|
|
68
|
+
touchscreen: touchscreenInfo,
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const fingerprint = JSON.stringify(fingerprintData);
|
|
72
|
+
const uniqueID = md5(fingerprint);
|
|
73
|
+
|
|
74
|
+
return uniqueID;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Función para generar huella digital del audio
|
|
78
|
+
async function generateAudioFingerprint(audioContext) {
|
|
79
|
+
if (audioContext) {
|
|
80
|
+
try {
|
|
81
|
+
await audioContext.resume();
|
|
82
|
+
|
|
83
|
+
// Obtén propiedades del audio que puedas obtener en modo incógnito
|
|
84
|
+
const audioProperties = {
|
|
85
|
+
isAudioContextAvailable: true,
|
|
86
|
+
// Agrega más propiedades relevantes aquí
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
return audioProperties;
|
|
90
|
+
} catch (error) {
|
|
91
|
+
console.error('Error al generar huella digital de audio:', error);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return { isAudioContextAvailable: false };
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Función para generar huella digital del canvas
|
|
99
|
+
async function generateCanvasFingerprint(canvas) {
|
|
100
|
+
if (canvas) {
|
|
101
|
+
try {
|
|
102
|
+
canvas.width = 200;
|
|
103
|
+
canvas.height = 200;
|
|
104
|
+
const context = canvas.getContext('2d');
|
|
105
|
+
context.clearRect(0, 0, canvas.width, canvas.height);
|
|
106
|
+
context.fillStyle = '#f60';
|
|
107
|
+
context.fillRect(125, 1, 62, 20);
|
|
108
|
+
context.fillStyle = '#069';
|
|
109
|
+
context.font = '16pt Arial';
|
|
110
|
+
context.fillText('Cwm fjordbank glyphs vext quiz', 125, 20);
|
|
111
|
+
|
|
112
|
+
// Obtén más propiedades del canvas que puedas obtener en modo incógnito
|
|
113
|
+
const canvasProperties = {
|
|
114
|
+
width: canvas.width,
|
|
115
|
+
height: canvas.height,
|
|
116
|
+
// Agrega más propiedades relevantes aquí
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
return canvasProperties;
|
|
120
|
+
} catch (error) {
|
|
121
|
+
console.error('Error al generar huella digital del canvas:', error);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return { width: 0, height: 0 };
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
async function getWebGLInfo() {
|
|
131
|
+
if ('WebGLRenderingContext' in window) {
|
|
132
|
+
const canvas = document.createElement('canvas');
|
|
133
|
+
const gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl');
|
|
134
|
+
|
|
135
|
+
if (gl) {
|
|
136
|
+
const renderer = gl.getParameter(gl.RENDERER);
|
|
137
|
+
const version = gl.getParameter(gl.VERSION);
|
|
138
|
+
|
|
139
|
+
// Obtener más información sobre las capacidades WebGL si es necesario
|
|
140
|
+
|
|
141
|
+
return `${renderer}-${version}`;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return 'webgl-info-not-supported';
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function getInstalledFonts() {
|
|
149
|
+
const fonts = [];
|
|
150
|
+
|
|
151
|
+
if ('fonts' in document) {
|
|
152
|
+
document.fonts.forEach(font => {
|
|
153
|
+
fonts.push(font.family);
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return fonts.join(',');
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function getTouchscreenInfo() {
|
|
161
|
+
if ('maxTouchPoints' in navigator) {
|
|
162
|
+
const maxTouchPoints = navigator.maxTouchPoints;
|
|
163
|
+
const touchEvent = 'ontouchstart' in window ? 'true' : 'false';
|
|
164
|
+
|
|
165
|
+
return `${maxTouchPoints}-${touchEvent}`;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return 'touchscreen-info-not-supported';
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
export async function fingerprintJs() {
|
|
173
|
+
const fingerprint = await generateFingerprint();
|
|
174
|
+
const uniqueID = md5(fingerprint)
|
|
175
|
+
return uniqueID;
|
|
176
|
+
}
|
|
@@ -75,7 +75,7 @@ export const useFormTools = ({ sendNotification = () => { } } = {}) => {
|
|
|
75
75
|
|
|
76
76
|
// Ejecuta la accion si es válido
|
|
77
77
|
if (!errSub && action) {
|
|
78
|
-
action()
|
|
78
|
+
action()?.then(res => {
|
|
79
79
|
if (res) {
|
|
80
80
|
sendNotification({
|
|
81
81
|
message: msgSuccess || 'Operación exitosa',
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
|
|
1
|
+
import React, {
|
|
2
|
+
useState,
|
|
3
|
+
useRef,
|
|
4
|
+
useEffect
|
|
5
|
+
} from 'react'
|
|
3
6
|
|
|
4
|
-
const
|
|
7
|
+
export const useFullScreenMode = () => {
|
|
5
8
|
const [isFullscreen, setFullscreen] = useState(false)
|
|
6
9
|
const elementRef = useRef()
|
|
7
10
|
|
|
@@ -56,11 +59,7 @@ const useFullscreenMode = () => {
|
|
|
56
59
|
}
|
|
57
60
|
|
|
58
61
|
const ToggleIcon = (
|
|
59
|
-
<
|
|
62
|
+
<button onDoubleClick={() => {return (!isFullscreen ? goFullscreen() : exitFullScreen())}}>{!isFullscreen ? 'FullScreen' : 'Normal'}</button>
|
|
60
63
|
)
|
|
61
64
|
return [elementRef, ToggleIcon] //Icon, ref
|
|
62
|
-
}
|
|
63
|
-
const Button = styled.button`
|
|
64
|
-
|
|
65
|
-
`
|
|
66
|
-
export default useFullscreenMode
|
|
65
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const addButtonValues = (values, max) => {
|
|
2
|
+
const value1 = values.splice(Math.floor(Math.random() * (max - 0)) + 0, 1)
|
|
3
|
+
return { max: max - 2, values: [value1] }
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export const useGenerateNumberArray = () => {
|
|
7
|
+
const values = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
|
8
|
+
let max = 9
|
|
9
|
+
const buttons = Array.from(Array(10)).map(() => {
|
|
10
|
+
return Array.from(Array(1)).map(() => {
|
|
11
|
+
const buttonValues = addButtonValues(values, max)
|
|
12
|
+
max = buttonValues.max
|
|
13
|
+
return buttonValues.values
|
|
14
|
+
})
|
|
15
|
+
})
|
|
16
|
+
return buttons
|
|
17
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useMutation } from '@apollo/client';
|
|
2
2
|
import {
|
|
3
3
|
useRef,
|
|
4
|
+
useCallback,
|
|
4
5
|
useState
|
|
5
6
|
} from 'react';
|
|
6
7
|
import {
|
|
@@ -11,158 +12,191 @@ import {
|
|
|
11
12
|
GET_ONE_BANNER_STORE
|
|
12
13
|
} from '../useProductsFood/queriesStore';
|
|
13
14
|
import { GET_ONE_STORE } from '../useStore/queries';
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Custom hook to handle image upload and management for a store's banner and logo.
|
|
17
|
+
* @typedef {Object} ImageStoreHookResult
|
|
18
|
+
* @property {React.RefObject} fileInputRefLogo - Reference to the logo file input element.
|
|
19
|
+
* @property {string} src - Source URL of the store's banner image.
|
|
20
|
+
* @property {string} alt - Alternate text for the store's banner image.
|
|
21
|
+
* @property {Object} initialState - Initial state for the store's banner image.
|
|
22
|
+
* @property {string} srcLogo - Source URL of the store's logo image.
|
|
23
|
+
* @property {string} altLogo - Alternate text for the store's logo image.
|
|
24
|
+
* @property {React.RefObject} fileInputRef - Reference to the banner file input element.
|
|
25
|
+
* @property {function} handleDeleteLogo - Callback function to handle logo deletion.
|
|
26
|
+
* @property {function} onTargetClick - Callback function to trigger banner file input click.
|
|
27
|
+
* @property {function} onTargetClickLogo - Callback function to trigger logo file input click.
|
|
28
|
+
* @property {function} HandleDeleteBanner - Callback function to handle banner deletion.
|
|
29
|
+
* @property {function} handleInputChangeLogo - Callback function to handle logo file input change.
|
|
30
|
+
* @property {function} handleUpdateBanner - Callback function to handle banner file input change.
|
|
31
|
+
* @param {Object} options - Options for the hook.
|
|
32
|
+
* @param {string} options.idStore - ID of the store.
|
|
33
|
+
* @param {Function} options.sendNotification - Function to send a notification (optional).
|
|
34
|
+
* @returns {ImageStoreHookResult} Object containing image handling functions and state.
|
|
35
|
+
*/
|
|
36
|
+
export const useImageStore = ({ idStore, sendNotification = () => {} } = {}) => {
|
|
37
|
+
// STATES
|
|
38
|
+
const fileInputRef = useRef(null);
|
|
39
|
+
const [{ altLogo, srcLogo }, setPreviewImgLogo] = useState({});
|
|
40
|
+
const initialState = { alt: '/images/DEFAULTBANNER.png', src: '/images/DEFAULTBANNER.png' };
|
|
41
|
+
const [{ alt, src }, setPreviewImg] = useState(initialState);
|
|
42
|
+
const fileInputRefLogo = useRef(null);
|
|
43
|
+
// HOOKS
|
|
44
|
+
const [registerBanner] = useMutation(CREATE_BANNER_STORE, {
|
|
45
|
+
onCompleted: (data) => console.log({ message: data?.registerBanner?.message }),
|
|
46
|
+
context: { clientName: 'admin-server' },
|
|
47
|
+
});
|
|
48
|
+
const [setALogoStore] = useMutation(CREATE_LOGO, {
|
|
49
|
+
onCompleted: (data) => console.log({ message: data?.setALogoStore?.message }),
|
|
50
|
+
context: { clientName: 'admin-server' },
|
|
51
|
+
});
|
|
52
|
+
const [DeleteOneBanner] = useMutation(DELETE_ONE_BANNER_STORE, {
|
|
53
|
+
onCompleted: (data) => console.log({ message: data?.DeleteOneBanner?.message }),
|
|
54
|
+
context: { clientName: 'admin-server' },
|
|
55
|
+
});
|
|
56
|
+
const [deleteALogoStore] = useMutation(DELETE_ONE_LOGO_STORE, {
|
|
57
|
+
onCompleted: (data) => {
|
|
58
|
+
console.log({ message: data.deleteALogoStore.message });
|
|
59
|
+
setPreviewImgLogo(initialState);
|
|
60
|
+
},
|
|
61
|
+
context: { clientName: 'admin-server' },
|
|
62
|
+
update(cache) {
|
|
63
|
+
cache.modify({
|
|
64
|
+
fields: {
|
|
65
|
+
getStore(dataOld = []) {
|
|
66
|
+
return cache.writeQuery({ query: GET_ONE_STORE, data: dataOld });
|
|
67
|
+
},
|
|
41
68
|
},
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
fields: {
|
|
46
|
-
getStore(dataOld = []) {
|
|
47
|
-
return cache.writeQuery({ query: GET_ONE_STORE, data: dataOld })
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
})
|
|
51
|
-
}
|
|
52
|
-
})
|
|
53
|
-
// HANDLESS
|
|
54
|
-
const handleDeleteLogo = () => {
|
|
55
|
-
return deleteALogoStore({
|
|
56
|
-
variables: {
|
|
57
|
-
Image: ImageName || null
|
|
58
|
-
}
|
|
59
|
-
})
|
|
60
|
-
}
|
|
69
|
+
});
|
|
70
|
+
},
|
|
71
|
+
});
|
|
61
72
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
bnImage: files[0],
|
|
77
|
-
idStore: idStore
|
|
78
|
-
}
|
|
79
|
-
}, update(cache) {
|
|
80
|
-
cache.modify({
|
|
81
|
-
fields: {
|
|
82
|
-
getOneBanners(dataOld = []) {
|
|
83
|
-
return cache.writeQuery({ query: GET_ONE_BANNER_STORE, data: dataOld })
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
})
|
|
87
|
-
}
|
|
88
|
-
}).catch(() => {
|
|
89
|
-
sendNotification({
|
|
90
|
-
title: 'No pudimos cargar la imagen',
|
|
91
|
-
description: 'Error',
|
|
92
|
-
backgroundColor: 'error'
|
|
93
|
-
})
|
|
94
|
-
setPreviewImg(initialState)
|
|
95
|
-
})
|
|
96
|
-
} catch {
|
|
97
|
-
setPreviewImg(initialState)
|
|
98
|
-
sendNotification({
|
|
99
|
-
title: 'No pudimos cargar la imagen',
|
|
100
|
-
description: 'Error',
|
|
101
|
-
backgroundColor: 'error'
|
|
102
|
-
})
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
const handleInputChangeLogo = event => {
|
|
106
|
-
const { files } = event.target
|
|
107
|
-
setPreviewImgLogo(
|
|
73
|
+
// HANDLESS
|
|
74
|
+
const handleDeleteLogo = useCallback(() => {
|
|
75
|
+
return deleteALogoStore({
|
|
76
|
+
variables: {
|
|
77
|
+
Image: ImageName || null,
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
}, [deleteALogoStore]);
|
|
81
|
+
|
|
82
|
+
const handleUpdateBanner = useCallback(
|
|
83
|
+
(event) => {
|
|
84
|
+
try {
|
|
85
|
+
const { files } = event.target;
|
|
86
|
+
setPreviewImg(
|
|
108
87
|
files.length
|
|
109
88
|
? {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
89
|
+
src: URL.createObjectURL(files[0]),
|
|
90
|
+
alt: files[0].name,
|
|
91
|
+
}
|
|
113
92
|
: initialState
|
|
114
|
-
)
|
|
115
|
-
|
|
93
|
+
);
|
|
94
|
+
registerBanner({
|
|
116
95
|
variables: {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
96
|
+
input: {
|
|
97
|
+
bnImage: files[0],
|
|
98
|
+
idStore: idStore,
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
update(cache) {
|
|
120
102
|
cache.modify({
|
|
121
103
|
fields: {
|
|
122
|
-
|
|
123
|
-
return cache.writeQuery({ query:
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
})
|
|
127
|
-
}
|
|
104
|
+
getOneBanners(dataOld = []) {
|
|
105
|
+
return cache.writeQuery({ query: GET_ONE_BANNER_STORE, data: dataOld });
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
},
|
|
128
110
|
}).catch(() => {
|
|
129
111
|
sendNotification({
|
|
130
112
|
title: 'No pudimos cargar la imagen',
|
|
131
113
|
description: 'Error',
|
|
132
|
-
backgroundColor: 'error'
|
|
133
|
-
})
|
|
134
|
-
|
|
135
|
-
})
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
idStore,
|
|
144
|
-
bnId
|
|
145
|
-
}, update(cache) {
|
|
146
|
-
cache.modify({
|
|
147
|
-
fields: {
|
|
148
|
-
getOneBanners(dataOld = []) {
|
|
149
|
-
return cache.writeQuery({ query: GET_ONE_BANNER_STORE, data: dataOld })
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
})
|
|
153
|
-
}
|
|
154
|
-
}).then(() => {
|
|
155
|
-
setPreviewImg(initialState)
|
|
156
|
-
})
|
|
114
|
+
backgroundColor: 'error',
|
|
115
|
+
});
|
|
116
|
+
setPreviewImg(initialState);
|
|
117
|
+
});
|
|
118
|
+
} catch {
|
|
119
|
+
setPreviewImg(initialState);
|
|
120
|
+
sendNotification({
|
|
121
|
+
title: 'No pudimos cargar la imagen',
|
|
122
|
+
description: 'Error',
|
|
123
|
+
backgroundColor: 'error',
|
|
124
|
+
});
|
|
157
125
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
126
|
+
},
|
|
127
|
+
[setPreviewImg, initialState, sendNotification, idStore, registerBanner]
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
const handleInputChangeLogo = useCallback(
|
|
131
|
+
(event) => {
|
|
132
|
+
const { files } = event.target;
|
|
133
|
+
setPreviewImgLogo(
|
|
134
|
+
files.length
|
|
135
|
+
? {
|
|
136
|
+
srcLogo: URL.createObjectURL(files[0]),
|
|
137
|
+
altLogo: files[0].name,
|
|
138
|
+
}
|
|
139
|
+
: initialState
|
|
140
|
+
);
|
|
141
|
+
setALogoStore({
|
|
142
|
+
variables: {
|
|
143
|
+
logo: files[0],
|
|
144
|
+
idStore: idStore,
|
|
145
|
+
},
|
|
146
|
+
update(cache) {
|
|
147
|
+
cache.modify({
|
|
148
|
+
fields: {
|
|
149
|
+
getStore(dataOld = []) {
|
|
150
|
+
return cache.writeQuery({ query: GET_ONE_STORE, data: dataOld });
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
});
|
|
154
|
+
},
|
|
155
|
+
}).catch(() => {
|
|
156
|
+
sendNotification({
|
|
157
|
+
title: 'No pudimos cargar la imagen',
|
|
158
|
+
description: 'Error',
|
|
159
|
+
backgroundColor: 'error',
|
|
160
|
+
});
|
|
161
|
+
setPreviewImgLogo(initialState);
|
|
162
|
+
});
|
|
163
|
+
},
|
|
164
|
+
[setPreviewImgLogo, initialState, idStore, setALogoStore]
|
|
165
|
+
);
|
|
166
|
+
|
|
167
|
+
const HandleDeleteBanner = useCallback(async () => {
|
|
168
|
+
setPreviewImg(initialState);
|
|
169
|
+
DeleteOneBanner({
|
|
170
|
+
variables: {
|
|
171
|
+
bnState: bnState, // You should provide bnState and bnImageFileName
|
|
172
|
+
bnImageFileName: bnImageFileName,
|
|
173
|
+
idStore,
|
|
174
|
+
bnId,
|
|
175
|
+
},
|
|
176
|
+
update(cache) {
|
|
177
|
+
cache.modify({
|
|
178
|
+
fields: {
|
|
179
|
+
getOneBanners(dataOld = []) {
|
|
180
|
+
return cache.writeQuery({ query: GET_ONE_BANNER_STORE, data: dataOld });
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
});
|
|
184
|
+
},
|
|
185
|
+
}).then(() => {
|
|
186
|
+
setPreviewImg(initialState);
|
|
187
|
+
});
|
|
188
|
+
}, [setPreviewImg, initialState, DeleteOneBanner]);
|
|
189
|
+
|
|
190
|
+
const onTargetClickLogo = useCallback((e) => {
|
|
191
|
+
e.preventDefault();
|
|
192
|
+
fileInputRefLogo.current.click();
|
|
193
|
+
}, []);
|
|
194
|
+
|
|
195
|
+
const onTargetClick = useCallback((e) => {
|
|
196
|
+
e.preventDefault();
|
|
197
|
+
fileInputRef.current.click();
|
|
198
|
+
}, []);
|
|
199
|
+
|
|
166
200
|
return {
|
|
167
201
|
fileInputRefLogo,
|
|
168
202
|
src,
|
|
@@ -176,7 +210,6 @@ export const useImageStore = ({ idStore, sendNotification = () => { return } } =
|
|
|
176
210
|
onTargetClickLogo,
|
|
177
211
|
HandleDeleteBanner,
|
|
178
212
|
handleInputChangeLogo,
|
|
179
|
-
handleUpdateBanner
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
213
|
+
handleUpdateBanner,
|
|
214
|
+
};
|
|
215
|
+
};
|
|
@@ -8,29 +8,7 @@ export const CREATE_SCHEDULE_STORE = gql`
|
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
`;
|
|
11
|
-
|
|
12
|
-
query getStoreSchedules($schDay: Int, $idStore: ID) {
|
|
13
|
-
getStoreSchedules(schDay: $schDay, idStore: $idStore) {
|
|
14
|
-
schId
|
|
15
|
-
idStore
|
|
16
|
-
schDay
|
|
17
|
-
schHoSta
|
|
18
|
-
schHoEnd
|
|
19
|
-
schState
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
`;
|
|
23
|
-
export const GET_ONE_SCHEDULE_STORE = gql`
|
|
24
|
-
query getOneStoreSchedules($schDay: Int, $idStore: ID) {
|
|
25
|
-
getOneStoreSchedules(schDay: $schDay, idStore: $idStore) {
|
|
26
|
-
schId
|
|
27
|
-
schDay
|
|
28
|
-
schHoSta
|
|
29
|
-
schHoEnd
|
|
30
|
-
schState
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
`;
|
|
11
|
+
|
|
34
12
|
export const GET_CAT_OF_PRODUCTS = gql`
|
|
35
13
|
query getAllCatOfProducts($idStore: ID) {
|
|
36
14
|
getAllCatOfProducts(idStore: $idStore) {
|
|
@@ -174,11 +152,6 @@ export const GET_ALL_VISITOR_STORE = gql`
|
|
|
174
152
|
}
|
|
175
153
|
}
|
|
176
154
|
`;
|
|
177
|
-
export const GET_MIN_PEDIDO = gql`
|
|
178
|
-
query getMinPrice($idStore: ID) {
|
|
179
|
-
getMinPrice(idStore: $idStore)
|
|
180
|
-
}
|
|
181
|
-
`;
|
|
182
155
|
|
|
183
156
|
export const GET_All_RATING_STORE = gql`
|
|
184
157
|
query getAllRating($idStore: ID) {
|
|
@@ -25,4 +25,10 @@ export const useKeyPress = (targetKey) => {
|
|
|
25
25
|
}, [targetKey])
|
|
26
26
|
|
|
27
27
|
return keyPressed
|
|
28
|
-
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function useMultiKeyPress(targetKeyA, targetKeyB) {
|
|
31
|
+
const keyPressedA = useKeyPress(targetKeyA)
|
|
32
|
+
const keyPressedB = useKeyPress(targetKeyB)
|
|
33
|
+
return keyPressedA && keyPressedB
|
|
34
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useState } from 'react'
|
|
2
2
|
|
|
3
|
-
export
|
|
3
|
+
export const useLocalStorage= (key, initialValue) => {
|
|
4
4
|
// const { setAlertBox } = useContext(Context)
|
|
5
5
|
// State to store our value
|
|
6
6
|
// Pass initial state function to useState so logic is only executed once
|