npm-pkg-hook 1.1.3 → 1.1.4
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/.vscode/extensions.json +6 -0
- package/.vscode/settings.json +8 -0
- package/next.config.js +1 -0
- package/package.json +43 -46
- package/src/config/client/errors.js +1 -2
- package/src/hooks/index.js +20 -25
- package/src/hooks/useAnimationText/index.jsx +13 -11
- package/src/hooks/useCatWithProduct/index.js +4 -37
- package/src/hooks/useCatWithProduct/queries.js +16 -0
- package/src/hooks/useChartData/index.js +170 -1
- package/src/hooks/useChartData/useChartDataAllOrders/index.js +14 -9
- package/src/hooks/useCheckbox/index.js +2 -5
- package/src/hooks/useClients/index.js +8 -17
- package/src/hooks/useCreateProduct/index.js +64 -94
- package/src/hooks/useDrag/index.js +1 -0
- package/src/hooks/useEmployee/index.js +8 -11
- package/src/hooks/useFormTools/index.js +1 -1
- package/src/hooks/useFullScreenMode/index.js +8 -8
- package/src/hooks/useGoogleLogin/index.js +161 -0
- package/src/hooks/useGoogleLogin/loadScript.js +15 -0
- package/src/hooks/useGoogleLogin/removeScript.js +7 -0
- package/src/hooks/useHover/index.js +1 -1
- package/src/hooks/useImagesStore/index.js +144 -176
- package/src/hooks/useImagesStore/queries.js +28 -1
- package/src/hooks/useKeypress/index.js +1 -7
- package/src/hooks/useLogout/index.js +27 -22
- package/src/hooks/useManageQueryParams/index.js +1 -1
- package/src/hooks/useProductsFood/queriesStore.js +16 -3
- package/src/hooks/useReport/index.js +30 -26
- package/src/hooks/useReport/queries.js +32 -47
- package/src/hooks/useSales/index.js +21 -52
- package/src/hooks/useSales/queries.js +38 -48
- package/src/hooks/useSales/useGetSale.js +2 -16
- package/src/hooks/useSchedule/index.jsx +23 -0
- package/src/hooks/useStoreContacts/index.js +1 -5
- package/src/hooks/useUpdateExistingOrders/index.js +8 -8
- package/src/hooks/useUser/index.js +2 -2
- package/src/hooks/useUser/queries.js +40 -40
- package/src/hooks/useWindowSize/index.js +1 -1
- package/src/index.jsx +1 -2
- package/src/security/index.js +0 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { useState, useEffect } from 'react'
|
|
2
|
+
import loadScript from './loadScript'
|
|
3
|
+
import removeScript from './removeScript'
|
|
4
|
+
|
|
5
|
+
export const useGoogleLogin = ({
|
|
6
|
+
onSuccess = () => {},
|
|
7
|
+
onAutoLoadFinished = () => {},
|
|
8
|
+
onFailure = () => {},
|
|
9
|
+
onRequest = () => {},
|
|
10
|
+
onScriptLoadFailure,
|
|
11
|
+
clientId,
|
|
12
|
+
cookiePolicy,
|
|
13
|
+
loginHint,
|
|
14
|
+
hostedDomain,
|
|
15
|
+
autoLoad,
|
|
16
|
+
isSignedIn,
|
|
17
|
+
fetchBasicProfile,
|
|
18
|
+
redirectUri,
|
|
19
|
+
discoveryDocs,
|
|
20
|
+
uxMode,
|
|
21
|
+
scope,
|
|
22
|
+
accessType,
|
|
23
|
+
responseType,
|
|
24
|
+
jsSrc = 'https://apis.google.com/js/api.js',
|
|
25
|
+
prompt
|
|
26
|
+
}) => {
|
|
27
|
+
const [loaded, setLoaded] = useState(false)
|
|
28
|
+
|
|
29
|
+
function handleSigninSuccess(res) {
|
|
30
|
+
/*
|
|
31
|
+
offer renamed response keys to names that match use
|
|
32
|
+
*/
|
|
33
|
+
const basicProfile = res.getBasicProfile()
|
|
34
|
+
const authResponse = res.getAuthResponse(true)
|
|
35
|
+
res.googleId = basicProfile.getId()
|
|
36
|
+
res.tokenObj = authResponse
|
|
37
|
+
res.tokenId = authResponse.id_token
|
|
38
|
+
res.accessToken = authResponse.access_token
|
|
39
|
+
res.profileObj = {
|
|
40
|
+
googleId: basicProfile.getId(),
|
|
41
|
+
imageUrl: basicProfile.getImageUrl(),
|
|
42
|
+
email: basicProfile.getEmail(),
|
|
43
|
+
name: basicProfile.getName(),
|
|
44
|
+
givenName: basicProfile.getGivenName(),
|
|
45
|
+
familyName: basicProfile.getFamilyName()
|
|
46
|
+
}
|
|
47
|
+
onSuccess(res)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function signIn(e) {
|
|
51
|
+
if (e) {
|
|
52
|
+
e.preventDefault() // to prevent submit if used within form
|
|
53
|
+
}
|
|
54
|
+
if (loaded) {
|
|
55
|
+
const GoogleAuth = window.gapi.auth2.getAuthInstance()
|
|
56
|
+
const options = {
|
|
57
|
+
prompt
|
|
58
|
+
}
|
|
59
|
+
onRequest()
|
|
60
|
+
if (responseType === 'code') {
|
|
61
|
+
GoogleAuth.grantOfflineAccess(options).then(
|
|
62
|
+
res => onSuccess(res),
|
|
63
|
+
err => onFailure(err)
|
|
64
|
+
)
|
|
65
|
+
} else {
|
|
66
|
+
GoogleAuth.signIn(options).then(
|
|
67
|
+
res => handleSigninSuccess(res),
|
|
68
|
+
err => onFailure(err)
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
let unmounted = false
|
|
76
|
+
const onLoadFailure = onScriptLoadFailure || onFailure
|
|
77
|
+
loadScript(
|
|
78
|
+
document,
|
|
79
|
+
'script',
|
|
80
|
+
'google-login',
|
|
81
|
+
jsSrc,
|
|
82
|
+
() => {
|
|
83
|
+
const params = {
|
|
84
|
+
client_id: clientId,
|
|
85
|
+
cookie_policy: cookiePolicy,
|
|
86
|
+
login_hint: loginHint,
|
|
87
|
+
hosted_domain: hostedDomain,
|
|
88
|
+
fetch_basic_profile: fetchBasicProfile,
|
|
89
|
+
discoveryDocs,
|
|
90
|
+
ux_mode: uxMode,
|
|
91
|
+
redirect_uri: redirectUri,
|
|
92
|
+
scope,
|
|
93
|
+
access_type: accessType
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (responseType === 'code') {
|
|
97
|
+
params.access_type = 'offline'
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
window.gapi.load('auth2', () => {
|
|
101
|
+
const GoogleAuth = window.gapi.auth2.getAuthInstance()
|
|
102
|
+
if (!GoogleAuth) {
|
|
103
|
+
window.gapi.auth2.init(params).then(
|
|
104
|
+
res => {
|
|
105
|
+
if (!unmounted) {
|
|
106
|
+
setLoaded(true)
|
|
107
|
+
const signedIn = isSignedIn && res.isSignedIn.get()
|
|
108
|
+
onAutoLoadFinished(signedIn)
|
|
109
|
+
if (signedIn) {
|
|
110
|
+
handleSigninSuccess(res.currentUser.get())
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
err => {
|
|
115
|
+
setLoaded(true)
|
|
116
|
+
onAutoLoadFinished(false)
|
|
117
|
+
onLoadFailure(err)
|
|
118
|
+
}
|
|
119
|
+
)
|
|
120
|
+
} else {
|
|
121
|
+
GoogleAuth.then(
|
|
122
|
+
() => {
|
|
123
|
+
if (unmounted) {
|
|
124
|
+
return
|
|
125
|
+
}
|
|
126
|
+
if (isSignedIn && GoogleAuth.isSignedIn.get()) {
|
|
127
|
+
setLoaded(true)
|
|
128
|
+
onAutoLoadFinished(true)
|
|
129
|
+
handleSigninSuccess(GoogleAuth.currentUser.get())
|
|
130
|
+
} else {
|
|
131
|
+
setLoaded(true)
|
|
132
|
+
onAutoLoadFinished(false)
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
err => {
|
|
136
|
+
onFailure(err)
|
|
137
|
+
}
|
|
138
|
+
)
|
|
139
|
+
}
|
|
140
|
+
})
|
|
141
|
+
},
|
|
142
|
+
err => {
|
|
143
|
+
onLoadFailure(err)
|
|
144
|
+
}
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
return () => {
|
|
148
|
+
unmounted = true
|
|
149
|
+
removeScript(document, 'google-login')
|
|
150
|
+
}
|
|
151
|
+
}, [])
|
|
152
|
+
|
|
153
|
+
useEffect(() => {
|
|
154
|
+
if (autoLoad) {
|
|
155
|
+
signIn()
|
|
156
|
+
}
|
|
157
|
+
}, [loaded])
|
|
158
|
+
|
|
159
|
+
return { signIn, loaded }
|
|
160
|
+
}
|
|
161
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export default (d, s, id, jsSrc, cb, onError) => {
|
|
2
|
+
const element = d.getElementsByTagName(s)[0]
|
|
3
|
+
const fjs = element
|
|
4
|
+
let js = element
|
|
5
|
+
js = d.createElement(s)
|
|
6
|
+
js.id = id
|
|
7
|
+
js.src = jsSrc
|
|
8
|
+
if (fjs && fjs.parentNode) {
|
|
9
|
+
fjs.parentNode.insertBefore(js, fjs)
|
|
10
|
+
} else {
|
|
11
|
+
d.head.appendChild(js)
|
|
12
|
+
}
|
|
13
|
+
js.onerror = onError
|
|
14
|
+
js.onload = cb
|
|
15
|
+
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { useMutation } from '@apollo/client';
|
|
2
2
|
import {
|
|
3
3
|
useRef,
|
|
4
|
-
useCallback,
|
|
5
4
|
useState
|
|
6
5
|
} from 'react';
|
|
7
6
|
import {
|
|
@@ -12,191 +11,159 @@ import {
|
|
|
12
11
|
GET_ONE_BANNER_STORE
|
|
13
12
|
} from '../useProductsFood/queriesStore';
|
|
14
13
|
import { GET_ONE_STORE } from '../useStore/queries';
|
|
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
|
-
},
|
|
68
|
-
},
|
|
69
|
-
});
|
|
70
|
-
},
|
|
71
|
-
});
|
|
14
|
+
export { GET_MIN_PEDIDO } from './queries'
|
|
72
15
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
16
|
+
export const useImageStore = ({ idStore, sendNotification = () => { return } } = {}) => {
|
|
17
|
+
// STATES
|
|
18
|
+
const fileInputRef = useRef(null)
|
|
19
|
+
const [{ altLogo, srcLogo }, setPreviewImgLogo] = useState({})
|
|
20
|
+
const initialState = { alt: '/images/DEFAULTBANNER.png', src: '/images/DEFAULTBANNER.png' }
|
|
21
|
+
const [{ alt, src }, setPreviewImg] = useState(initialState)
|
|
22
|
+
const fileInputRefLogo = useRef(null)
|
|
23
|
+
// HOOKS
|
|
24
|
+
const [registerBanner] = useMutation(CREATE_BANNER_STORE, {
|
|
25
|
+
onCompleted: (data) => { return console.log({ message: data?.registerBanner?.message }) },
|
|
26
|
+
context: { clientName: 'admin-server' }
|
|
27
|
+
})
|
|
28
|
+
const [setALogoStore] = useMutation(CREATE_LOGO, {
|
|
29
|
+
onCompleted: (data) => { return console.log({ message: data?.setALogoStore?.message }) },
|
|
30
|
+
context: { clientName: 'admin-server' }
|
|
31
|
+
})
|
|
32
|
+
const [DeleteOneBanner] = useMutation(DELETE_ONE_BANNER_STORE, {
|
|
33
|
+
onCompleted: (data) => { return console.log({ message: data?.DeleteOneBanner?.message }) },
|
|
34
|
+
context: { clientName: 'admin-server' }
|
|
35
|
+
})
|
|
36
|
+
const [deleteALogoStore] = useMutation(DELETE_ONE_LOGO_STORE, {
|
|
37
|
+
onCompleted: (data) => {
|
|
38
|
+
console.log({
|
|
39
|
+
message: data.deleteALogoStore.message
|
|
40
|
+
})
|
|
41
|
+
setPreviewImgLogo(initialState)
|
|
42
|
+
},
|
|
43
|
+
context: { clientName: 'admin-server' },
|
|
44
|
+
update(cache) {
|
|
45
|
+
cache.modify({
|
|
46
|
+
fields: {
|
|
47
|
+
getStore(dataOld = []) {
|
|
48
|
+
return cache.writeQuery({ query: GET_ONE_STORE, data: dataOld })
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
// HANDLESS
|
|
55
|
+
const handleDeleteLogo = () => {
|
|
56
|
+
return deleteALogoStore({
|
|
57
|
+
variables: {
|
|
58
|
+
Image: ImageName || null
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
}
|
|
81
62
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
? {
|
|
63
|
+
const handleUpdateBanner = event => {
|
|
64
|
+
try {
|
|
65
|
+
const { files } = event.target
|
|
66
|
+
setPreviewImg(
|
|
67
|
+
files.length
|
|
68
|
+
? {
|
|
89
69
|
src: URL.createObjectURL(files[0]),
|
|
90
|
-
alt: files[0].name
|
|
70
|
+
alt: files[0].name
|
|
71
|
+
}
|
|
72
|
+
: initialState
|
|
73
|
+
)
|
|
74
|
+
registerBanner({
|
|
75
|
+
variables: {
|
|
76
|
+
input: {
|
|
77
|
+
bnImage: files[0],
|
|
78
|
+
idStore: idStore
|
|
91
79
|
}
|
|
80
|
+
}, update(cache) {
|
|
81
|
+
cache.modify({
|
|
82
|
+
fields: {
|
|
83
|
+
getOneBanners(dataOld = []) {
|
|
84
|
+
return cache.writeQuery({ query: GET_ONE_BANNER_STORE, data: dataOld })
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
})
|
|
88
|
+
}
|
|
89
|
+
}).catch(() => {
|
|
90
|
+
sendNotification({
|
|
91
|
+
title: 'No pudimos cargar la imagen',
|
|
92
|
+
description: 'Error',
|
|
93
|
+
backgroundColor: 'error'
|
|
94
|
+
})
|
|
95
|
+
setPreviewImg(initialState)
|
|
96
|
+
})
|
|
97
|
+
} catch {
|
|
98
|
+
setPreviewImg(initialState)
|
|
99
|
+
sendNotification({
|
|
100
|
+
title: 'No pudimos cargar la imagen',
|
|
101
|
+
description: 'Error',
|
|
102
|
+
backgroundColor: 'error'
|
|
103
|
+
})
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
const handleInputChangeLogo = event => {
|
|
107
|
+
const { files } = event.target
|
|
108
|
+
setPreviewImgLogo(
|
|
109
|
+
files.length
|
|
110
|
+
? {
|
|
111
|
+
srcLogo: URL.createObjectURL(files[0]),
|
|
112
|
+
altLogo: files[0].name
|
|
113
|
+
}
|
|
92
114
|
: initialState
|
|
93
|
-
)
|
|
94
|
-
|
|
115
|
+
)
|
|
116
|
+
setALogoStore({
|
|
95
117
|
variables: {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
update(cache) {
|
|
118
|
+
logo: files[0],
|
|
119
|
+
idStore: idStore
|
|
120
|
+
}, update(cache) {
|
|
102
121
|
cache.modify({
|
|
103
122
|
fields: {
|
|
104
|
-
|
|
105
|
-
return cache.writeQuery({ query:
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
})
|
|
109
|
-
}
|
|
123
|
+
getStore(dataOld = []) {
|
|
124
|
+
return cache.writeQuery({ query: GET_ONE_STORE, data: dataOld })
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
})
|
|
128
|
+
}
|
|
110
129
|
}).catch(() => {
|
|
111
130
|
sendNotification({
|
|
112
131
|
title: 'No pudimos cargar la imagen',
|
|
113
132
|
description: 'Error',
|
|
114
|
-
backgroundColor: 'error'
|
|
115
|
-
})
|
|
116
|
-
|
|
117
|
-
})
|
|
118
|
-
} catch {
|
|
119
|
-
setPreviewImg(initialState);
|
|
120
|
-
sendNotification({
|
|
121
|
-
title: 'No pudimos cargar la imagen',
|
|
122
|
-
description: 'Error',
|
|
123
|
-
backgroundColor: 'error',
|
|
124
|
-
});
|
|
133
|
+
backgroundColor: 'error'
|
|
134
|
+
})
|
|
135
|
+
setPreviewImgLogo(initialState)
|
|
136
|
+
})
|
|
125
137
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
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
|
-
|
|
138
|
+
const HandleDeleteBanner = async () => {
|
|
139
|
+
setPreviewImg(initialState)
|
|
140
|
+
DeleteOneBanner({
|
|
141
|
+
variables: {
|
|
142
|
+
bnState: bnState,
|
|
143
|
+
bnImageFileName: bnImageFileName,
|
|
144
|
+
idStore,
|
|
145
|
+
bnId
|
|
146
|
+
}, update(cache) {
|
|
147
|
+
cache.modify({
|
|
148
|
+
fields: {
|
|
149
|
+
getOneBanners(dataOld = []) {
|
|
150
|
+
return cache.writeQuery({ query: GET_ONE_BANNER_STORE, data: dataOld })
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
})
|
|
154
|
+
}
|
|
155
|
+
}).then(() => {
|
|
156
|
+
setPreviewImg(initialState)
|
|
157
|
+
})
|
|
158
|
+
}
|
|
159
|
+
const onTargetClickLogo = e => {
|
|
160
|
+
e.preventDefault()
|
|
161
|
+
fileInputRefLogo.current.click()
|
|
162
|
+
}
|
|
163
|
+
const onTargetClick = e => {
|
|
164
|
+
e.preventDefault()
|
|
165
|
+
fileInputRef.current.click()
|
|
166
|
+
}
|
|
200
167
|
return {
|
|
201
168
|
fileInputRefLogo,
|
|
202
169
|
src,
|
|
@@ -210,6 +177,7 @@ export const useImageStore = ({ idStore, sendNotification = () => {} } = {}) =>
|
|
|
210
177
|
onTargetClickLogo,
|
|
211
178
|
HandleDeleteBanner,
|
|
212
179
|
handleInputChangeLogo,
|
|
213
|
-
handleUpdateBanner
|
|
214
|
-
}
|
|
215
|
-
}
|
|
180
|
+
handleUpdateBanner
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
@@ -8,7 +8,29 @@ export const CREATE_SCHEDULE_STORE = gql`
|
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
`;
|
|
11
|
-
|
|
11
|
+
export const GET_SCHEDULE_STORE = gql`
|
|
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
|
+
`;
|
|
12
34
|
export const GET_CAT_OF_PRODUCTS = gql`
|
|
13
35
|
query getAllCatOfProducts($idStore: ID) {
|
|
14
36
|
getAllCatOfProducts(idStore: $idStore) {
|
|
@@ -152,6 +174,11 @@ export const GET_ALL_VISITOR_STORE = gql`
|
|
|
152
174
|
}
|
|
153
175
|
}
|
|
154
176
|
`;
|
|
177
|
+
export const GET_MIN_PEDIDO = gql`
|
|
178
|
+
query getMinPrice($idStore: ID) {
|
|
179
|
+
getMinPrice(idStore: $idStore)
|
|
180
|
+
}
|
|
181
|
+
`;
|
|
155
182
|
|
|
156
183
|
export const GET_All_RATING_STORE = gql`
|
|
157
184
|
query getAllRating($idStore: ID) {
|
|
@@ -25,10 +25,4 @@ export const useKeyPress = (targetKey) => {
|
|
|
25
25
|
}, [targetKey])
|
|
26
26
|
|
|
27
27
|
return keyPressed
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export function useMultiKeyPress(targetKeyA, targetKeyB) {
|
|
31
|
-
const keyPressedA = useKeyPress(targetKeyA)
|
|
32
|
-
const keyPressedB = useKeyPress(targetKeyB)
|
|
33
|
-
return keyPressedA && keyPressedB
|
|
34
|
-
}
|
|
28
|
+
}
|
|
@@ -1,33 +1,38 @@
|
|
|
1
|
-
import { useApolloClient } from '@apollo/client'
|
|
1
|
+
import { useApolloClient } from '@apollo/client';
|
|
2
2
|
import { useState, useCallback } from 'react'
|
|
3
|
-
import { useRouter } from 'next/router'
|
|
4
|
-
import { Cookies } from '../../cookies'
|
|
5
|
-
import { fetchJson } from '../../hooks/useFetchJson'
|
|
3
|
+
import { useRouter } from 'next/router';
|
|
4
|
+
import { Cookies } from '../../cookies';
|
|
6
5
|
|
|
7
6
|
export const useLogout = ({ setAlertBox = () => { } } = {}) => {
|
|
8
7
|
const [loading, setLoading] = useState(false)
|
|
9
8
|
const [error, setError] = useState(false)
|
|
10
|
-
const router = useRouter()
|
|
11
|
-
const client = useApolloClient()
|
|
9
|
+
const router = useRouter();
|
|
10
|
+
const client = useApolloClient();
|
|
12
11
|
|
|
13
12
|
const onClickLogout = async () => {
|
|
14
13
|
setLoading(true)
|
|
15
|
-
await
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
14
|
+
await window
|
|
15
|
+
.fetch(`${process.env.URL_BASE}api/auth/logout/`, {})
|
|
16
|
+
.then(res => {
|
|
17
|
+
if (res) {
|
|
18
|
+
localStorage.removeItem('session');
|
|
19
|
+
localStorage.removeItem('usuario');
|
|
20
|
+
localStorage.removeItem('location');
|
|
21
|
+
localStorage.removeItem('sessionGoogle');
|
|
22
|
+
localStorage.removeItem('namefood');
|
|
23
|
+
localStorage.removeItem('longitude');
|
|
24
|
+
localStorage.removeItem('latitude');
|
|
25
|
+
localStorage.removeItem('userlogin');
|
|
26
|
+
localStorage.removeItem('restaurant');
|
|
27
|
+
Cookies.remove('vp.store');
|
|
28
|
+
Cookies.remove('app.cart.sales');
|
|
29
|
+
Cookies.remove('restaurant');
|
|
30
|
+
client?.clearStore();
|
|
31
|
+
router.replace('/entrar');
|
|
32
|
+
setLoading(false);
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
.catch(() => {
|
|
31
36
|
setError(true)
|
|
32
37
|
setAlertBox({ message: 'Ocurrió un error al cerrar session' })
|
|
33
38
|
})
|