npm-pkg-hook 1.3.6 → 1.3.8
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 +38 -38
- package/.eslintrc.json +127 -127
- package/.github/pull_request_template.md +17 -17
- package/.github/workflows/pepeline.yaml +29 -29
- package/package.json +46 -46
- package/script.txt +6 -6
- package/src/config/client/index.js +1 -1
- package/src/hooks/getCategoriesWithProduct/helpers/index.js +7 -7
- package/src/hooks/getCategoriesWithProduct/index.js +62 -62
- package/src/hooks/getSession/index.js +18 -18
- package/src/hooks/handleLogin/index.js +10 -0
- package/src/hooks/index.js +1 -0
- package/src/hooks/useAnimationFrame/index.js +45 -45
- package/src/hooks/useAsideCart/index.js +155 -155
- package/src/hooks/useAsideCart/queries.js +10 -10
- package/src/hooks/useCart/index.js +2 -2
- package/src/hooks/useCart/queries.js +164 -164
- package/src/hooks/useCart/useCart/helpers/index.js +75 -75
- package/src/hooks/useCart/useCart/index.js +410 -410
- package/src/hooks/useCart/useGetCart/index.js +31 -31
- package/src/hooks/useCatWithProductClient/index.js +56 -56
- package/src/hooks/useCatWithProductClient/queries.js +55 -55
- package/src/hooks/useCategoriesProduct/index.js +12 -12
- package/src/hooks/useCategoriesProduct/queries.js +16 -16
- package/src/hooks/useCategoryInStore/queries.js +78 -78
- package/src/hooks/useChartData/useChartData/index.js +199 -199
- package/src/hooks/useChartData/useChartDataAllOrders/index.js +94 -94
- package/src/hooks/useCheckbox/index.js +115 -115
- package/src/hooks/useCreateProduct/helpers/manageCacheDataCatProduct/index.js +52 -0
- package/src/hooks/useCreateProduct/index.js +8 -3
- package/src/hooks/useDeleteSubProductOptional/index.js +30 -30
- package/src/hooks/useDeleteSubProductOptional/queries.js +10 -10
- package/src/hooks/useDessert/helpers/index.js +51 -51
- package/src/hooks/useDevices/index.js +35 -35
- package/src/hooks/useDevices/queries.js +19 -19
- package/src/hooks/useDropzone/index.js +94 -94
- package/src/hooks/useDynamicAuth/index.js +13 -13
- package/src/hooks/useDynamicAuth/queries.js +24 -24
- package/src/hooks/useEditSubProductOptional/queries.js +10 -10
- package/src/hooks/useEvent/index.js +33 -33
- package/src/hooks/useFavoriteStores/index.js +19 -19
- package/src/hooks/useFavoriteStores/queries.js +47 -47
- package/src/hooks/useFetchJson/index.js +25 -25
- package/src/hooks/useFingerprintjs/index.js +172 -172
- package/src/hooks/useFullScreenMode/index.js +65 -65
- package/src/hooks/useGenerateNumberArray/index.js +17 -17
- package/src/hooks/useGetExtProductFoodsSubOptionalAll/index.js +14 -14
- package/src/hooks/useGetFoodRecomended/index.js +32 -33
- package/src/hooks/useGetFoodRecomended/queries.js +47 -47
- package/src/hooks/useGetMinPrice/index.js +12 -12
- package/src/hooks/useGetMinPrice/queries.js +7 -7
- package/src/hooks/useGetOneStoreRating/index.js +40 -40
- package/src/hooks/useGetOneStoreRating/queries.js +18 -18
- package/src/hooks/useGoogleLogin/index.js +160 -160
- package/src/hooks/useGoogleLogin/loadScript.js +15 -15
- package/src/hooks/useGoogleLogin/removeScript.js +7 -7
- package/src/hooks/useHover/index.js +29 -29
- package/src/hooks/useImagesStore/index.js +5 -4
- package/src/hooks/useInnerHtml/index.js +39 -39
- package/src/hooks/useKeypress/index.js +28 -28
- package/src/hooks/useLocationNavigate/index.js +54 -54
- package/src/hooks/useLogout/index.js +29 -21
- package/src/hooks/useManageQueryParams/index.js +37 -36
- package/src/hooks/useMobile/index.js +39 -39
- package/src/hooks/useOrderClient/index.js +5 -5
- package/src/hooks/useProviders/index.js +3 -3
- package/src/hooks/useProviders/queries.js +31 -31
- package/src/hooks/useProviders/useProvidersCreateStore/index.js +12 -12
- package/src/hooks/useProviders/useProvidersDataStore/index.js +24 -24
- package/src/hooks/useProvidersStore/index.js +24 -24
- package/src/hooks/useProvidersStore/queries.js +31 -31
- package/src/hooks/useRatingArrayData/index.js +54 -54
- package/src/hooks/useRatingArrayData/queries.js +19 -19
- package/src/hooks/useRemoveExtraProductFoodsOptional/index.js +23 -23
- package/src/hooks/useRemoveExtraProductFoodsOptional/queries.js +48 -48
- package/src/hooks/useRestaurant/index.js +19 -19
- package/src/hooks/useRestaurant/queries.js +80 -80
- package/src/hooks/useSales/useGetAllSales/index.js +25 -25
- package/src/hooks/useSchedule/index.js +72 -72
- package/src/hooks/useSchedule/index.jsx +22 -22
- package/src/hooks/useSchedule/queries.js +43 -43
- package/src/hooks/useScheduleData/index.js +123 -123
- package/src/hooks/useScroll/index.js +56 -56
- package/src/hooks/useScrollRotate/index.js +16 -16
- package/src/hooks/useStatusOpenStore/helpers/index.js +101 -101
- package/src/hooks/useStatusOpenStore/index.js +172 -172
- package/src/hooks/useStatusOrdersClient/queries.js +80 -80
- package/src/hooks/useStore/queries.js +163 -163
- package/src/hooks/useStoreCalendar/index.js +5 -5
- package/src/hooks/useStoreContacts/queries.js +1 -1
- package/src/hooks/useTimeAgo/useTimeAgo.js +39 -39
- package/src/hooks/useUpdateExtProductFoodsSubOptional/index.js +38 -38
- package/src/hooks/useWindowSize/index.js +38 -38
- package/src/mock/dessert/index.js +16 -16
- package/src/mock/index.js +1 -1
- package/.vscode/extensions.json +0 -6
- package/.vscode/settings.json +0 -8
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
import { GET_ONE_STORE } from '../useStore/queries'
|
|
14
14
|
export { GET_MIN_PEDIDO } from './queries'
|
|
15
15
|
export * from './queries'
|
|
16
|
+
|
|
16
17
|
export const useImageStore = ({ idStore, sendNotification = () => { } } = {}) => {
|
|
17
18
|
// STATES
|
|
18
19
|
const fileInputRef = useRef(null)
|
|
@@ -22,20 +23,20 @@ export const useImageStore = ({ idStore, sendNotification = () => { } } = {}) =>
|
|
|
22
23
|
const fileInputRefLogo = useRef(null)
|
|
23
24
|
// HOOKS
|
|
24
25
|
const [registerBanner] = useMutation(CREATE_BANNER_STORE, {
|
|
25
|
-
onCompleted: (data) => { return
|
|
26
|
+
onCompleted: (data) => { return sendNotification({ message: data?.registerBanner?.message }) },
|
|
26
27
|
context: { clientName: 'admin-server' }
|
|
27
28
|
})
|
|
28
29
|
const [setALogoStore] = useMutation(CREATE_LOGO, {
|
|
29
|
-
onCompleted: (data) => { return
|
|
30
|
+
onCompleted: (data) => { return sendNotification({ message: data?.setALogoStore?.message }) },
|
|
30
31
|
context: { clientName: 'admin-server' }
|
|
31
32
|
})
|
|
32
33
|
const [DeleteOneBanner] = useMutation(DELETE_ONE_BANNER_STORE, {
|
|
33
|
-
onCompleted: (data) => { return
|
|
34
|
+
onCompleted: (data) => { return sendNotification({ message: data?.DeleteOneBanner?.message }) },
|
|
34
35
|
context: { clientName: 'admin-server' }
|
|
35
36
|
})
|
|
36
37
|
const [deleteALogoStore] = useMutation(DELETE_ONE_LOGO_STORE, {
|
|
37
38
|
onCompleted: (data) => {
|
|
38
|
-
|
|
39
|
+
sendNotification({
|
|
39
40
|
message: data.deleteALogoStore.message
|
|
40
41
|
})
|
|
41
42
|
setPreviewImgLogo(initialState)
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { createRoot } from 'react-dom' // Import createRoot from react-dom
|
|
3
|
-
import './styles.css'
|
|
4
|
-
|
|
5
|
-
const htmlText =
|
|
6
|
-
'<p style=\'display:inline;\'>Lorem ipsum</p> dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.'
|
|
7
|
-
|
|
8
|
-
function App () {
|
|
9
|
-
const [state, setState] = React.useState({
|
|
10
|
-
showOriginalHTML: false,
|
|
11
|
-
originalHTML: htmlText
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
const handleShowText = React.useCallback(() => {
|
|
15
|
-
setState((prevState) => {
|
|
16
|
-
return {
|
|
17
|
-
...prevState,
|
|
18
|
-
showOriginalHTML: !prevState.showOriginalHTML
|
|
19
|
-
}
|
|
20
|
-
})
|
|
21
|
-
}, [setState])
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
<div className='container'>
|
|
25
|
-
<div
|
|
26
|
-
className='text'
|
|
27
|
-
dangerouslySetInnerHTML={{
|
|
28
|
-
__html: `${state.originalHTML}`
|
|
29
|
-
}}
|
|
30
|
-
/>
|
|
31
|
-
<button className='read-more' onClick={handleShowText}>
|
|
32
|
-
{!state.showOriginalHTML ? 'read more' : 'show less'}
|
|
33
|
-
</button>
|
|
34
|
-
</div>
|
|
35
|
-
)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const root = document.getElementById('root')
|
|
39
|
-
createRoot(root).render(<App />) // Use createRoot to render your React app
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { createRoot } from 'react-dom' // Import createRoot from react-dom
|
|
3
|
+
import './styles.css'
|
|
4
|
+
|
|
5
|
+
const htmlText =
|
|
6
|
+
'<p style=\'display:inline;\'>Lorem ipsum</p> dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.'
|
|
7
|
+
|
|
8
|
+
function App () {
|
|
9
|
+
const [state, setState] = React.useState({
|
|
10
|
+
showOriginalHTML: false,
|
|
11
|
+
originalHTML: htmlText
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
const handleShowText = React.useCallback(() => {
|
|
15
|
+
setState((prevState) => {
|
|
16
|
+
return {
|
|
17
|
+
...prevState,
|
|
18
|
+
showOriginalHTML: !prevState.showOriginalHTML
|
|
19
|
+
}
|
|
20
|
+
})
|
|
21
|
+
}, [setState])
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<div className='container'>
|
|
25
|
+
<div
|
|
26
|
+
className='text'
|
|
27
|
+
dangerouslySetInnerHTML={{
|
|
28
|
+
__html: `${state.originalHTML}`
|
|
29
|
+
}}
|
|
30
|
+
/>
|
|
31
|
+
<button className='read-more' onClick={handleShowText}>
|
|
32
|
+
{!state.showOriginalHTML ? 'read more' : 'show less'}
|
|
33
|
+
</button>
|
|
34
|
+
</div>
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const root = document.getElementById('root')
|
|
39
|
+
createRoot(root).render(<App />) // Use createRoot to render your React app
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react'
|
|
2
|
-
|
|
3
|
-
export const useKeyPress = (targetKey) => {
|
|
4
|
-
const [keyPressed, setKeyPressed] = useState(false)
|
|
5
|
-
|
|
6
|
-
useEffect(() => {
|
|
7
|
-
const downHandler = ({ key }) => {
|
|
8
|
-
if (key === targetKey) {
|
|
9
|
-
setKeyPressed(true)
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
const upHandler = ({ key }) => {
|
|
13
|
-
if (key === targetKey) {
|
|
14
|
-
setKeyPressed(false)
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
window.addEventListener('keydown', downHandler)
|
|
19
|
-
window.addEventListener('keyup', upHandler)
|
|
20
|
-
|
|
21
|
-
return () => {
|
|
22
|
-
window.removeEventListener('keydown', downHandler)
|
|
23
|
-
window.removeEventListener('keyup', upHandler)
|
|
24
|
-
}
|
|
25
|
-
}, [targetKey])
|
|
26
|
-
|
|
27
|
-
return keyPressed
|
|
28
|
-
}
|
|
1
|
+
import { useEffect, useState } from 'react'
|
|
2
|
+
|
|
3
|
+
export const useKeyPress = (targetKey) => {
|
|
4
|
+
const [keyPressed, setKeyPressed] = useState(false)
|
|
5
|
+
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
const downHandler = ({ key }) => {
|
|
8
|
+
if (key === targetKey) {
|
|
9
|
+
setKeyPressed(true)
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
const upHandler = ({ key }) => {
|
|
13
|
+
if (key === targetKey) {
|
|
14
|
+
setKeyPressed(false)
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
window.addEventListener('keydown', downHandler)
|
|
19
|
+
window.addEventListener('keyup', upHandler)
|
|
20
|
+
|
|
21
|
+
return () => {
|
|
22
|
+
window.removeEventListener('keydown', downHandler)
|
|
23
|
+
window.removeEventListener('keyup', upHandler)
|
|
24
|
+
}
|
|
25
|
+
}, [targetKey])
|
|
26
|
+
|
|
27
|
+
return keyPressed
|
|
28
|
+
}
|
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react'
|
|
2
|
-
|
|
3
|
-
const defaultSettings = {
|
|
4
|
-
enableHighAccuracy: false,
|
|
5
|
-
timeout: Infinity,
|
|
6
|
-
maximumAge: 0
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export const usePosition = (watch = false, settings = defaultSettings) => {
|
|
10
|
-
const [position, setPosition] = useState({})
|
|
11
|
-
const [error, setError] = useState(null)
|
|
12
|
-
|
|
13
|
-
const onChange = ({ coords, timestamp }) => {
|
|
14
|
-
setPosition({
|
|
15
|
-
latitude: coords.latitude,
|
|
16
|
-
longitude: coords.longitude,
|
|
17
|
-
accuracy: coords.accuracy,
|
|
18
|
-
speed: coords.speed,
|
|
19
|
-
timestamp
|
|
20
|
-
})
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const onError = () => {
|
|
24
|
-
setError(error?.message)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
if (!navigator || !navigator.geolocation) {
|
|
29
|
-
setError('Geolocation is not supported')
|
|
30
|
-
return
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
let watcher = null
|
|
34
|
-
if (watch) {
|
|
35
|
-
watcher = navigator.geolocation.watchPosition(
|
|
36
|
-
onChange,
|
|
37
|
-
onError,
|
|
38
|
-
settings
|
|
39
|
-
)
|
|
40
|
-
} else {
|
|
41
|
-
navigator.geolocation.getCurrentPosition(onChange, onError, settings)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return () => { return watcher && navigator.geolocation.clearWatch(watcher) }
|
|
45
|
-
}, [
|
|
46
|
-
settings,
|
|
47
|
-
settings.enableHighAccuracy,
|
|
48
|
-
settings.timeout,
|
|
49
|
-
settings.maximumAge,
|
|
50
|
-
watch
|
|
51
|
-
])
|
|
52
|
-
|
|
53
|
-
return { ...position, error }
|
|
54
|
-
}
|
|
1
|
+
import { useEffect, useState } from 'react'
|
|
2
|
+
|
|
3
|
+
const defaultSettings = {
|
|
4
|
+
enableHighAccuracy: false,
|
|
5
|
+
timeout: Infinity,
|
|
6
|
+
maximumAge: 0
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const usePosition = (watch = false, settings = defaultSettings) => {
|
|
10
|
+
const [position, setPosition] = useState({})
|
|
11
|
+
const [error, setError] = useState(null)
|
|
12
|
+
|
|
13
|
+
const onChange = ({ coords, timestamp }) => {
|
|
14
|
+
setPosition({
|
|
15
|
+
latitude: coords.latitude,
|
|
16
|
+
longitude: coords.longitude,
|
|
17
|
+
accuracy: coords.accuracy,
|
|
18
|
+
speed: coords.speed,
|
|
19
|
+
timestamp
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const onError = () => {
|
|
24
|
+
setError(error?.message)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
if (!navigator || !navigator.geolocation) {
|
|
29
|
+
setError('Geolocation is not supported')
|
|
30
|
+
return
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
let watcher = null
|
|
34
|
+
if (watch) {
|
|
35
|
+
watcher = navigator.geolocation.watchPosition(
|
|
36
|
+
onChange,
|
|
37
|
+
onError,
|
|
38
|
+
settings
|
|
39
|
+
)
|
|
40
|
+
} else {
|
|
41
|
+
navigator.geolocation.getCurrentPosition(onChange, onError, settings)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return () => { return watcher && navigator.geolocation.clearWatch(watcher) }
|
|
45
|
+
}, [
|
|
46
|
+
settings,
|
|
47
|
+
settings.enableHighAccuracy,
|
|
48
|
+
settings.timeout,
|
|
49
|
+
settings.maximumAge,
|
|
50
|
+
watch
|
|
51
|
+
])
|
|
52
|
+
|
|
53
|
+
return { ...position, error }
|
|
54
|
+
}
|
|
@@ -10,28 +10,36 @@ export const useLogout = ({ setAlertBox = () => { } } = {}) => {
|
|
|
10
10
|
const client = useApolloClient()
|
|
11
11
|
|
|
12
12
|
const onClickLogout = async () => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
13
|
+
try {
|
|
14
|
+
setLoading(true)
|
|
15
|
+
// Logout from the server
|
|
16
|
+
const logoutResponse = await window.fetch(`${process.env.URL_BASE}/api/auth/logout/`, {})
|
|
17
|
+
if (!logoutResponse.ok) return
|
|
18
|
+
await window
|
|
19
|
+
.fetch(`${process.env.URL_BASE}/api/auth/logout/`, {})
|
|
20
|
+
.then(res => {
|
|
21
|
+
if (res) {
|
|
22
|
+
Cookies.remove(process.env.SESSION_NAME)
|
|
23
|
+
Cookies.remove(process.env.LOCAL_SALES_STORE)
|
|
24
|
+
Cookies.remove('restaurant')
|
|
25
|
+
Cookies.remove('usuario')
|
|
26
|
+
Cookies.remove('session')
|
|
27
|
+
client?.clearStore()
|
|
28
|
+
setLoading(false)
|
|
29
|
+
console.log('Borrado todo')
|
|
30
|
+
}
|
|
31
|
+
})
|
|
29
32
|
signOutAuth({ redirect: true, callbackUrl: '/' })
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
.catch(() => {
|
|
34
|
+
setError(true)
|
|
35
|
+
setAlertBox({ message: 'Ocurrió un error al cerrar session' })
|
|
36
|
+
})
|
|
37
|
+
setLoading(false)
|
|
38
|
+
} catch (error) {
|
|
39
|
+
setLoading(false)
|
|
40
|
+
setError(true)
|
|
41
|
+
setAlertBox({ message: 'Ocurrió un error al cerrar session' })
|
|
42
|
+
}
|
|
35
43
|
}
|
|
36
44
|
|
|
37
45
|
return [onClickLogout, { loading, error }]
|
|
@@ -1,36 +1,37 @@
|
|
|
1
|
-
import { useRouter } from 'next/router'
|
|
2
|
-
// Hola mundo
|
|
3
|
-
export const useManageQueryParams = () => {
|
|
4
|
-
const router = useRouter()
|
|
5
|
-
|
|
6
|
-
const handleQuery = (name, value = '') => {
|
|
7
|
-
router.push(
|
|
8
|
-
{
|
|
9
|
-
query: {
|
|
10
|
-
...router.query,
|
|
11
|
-
[name]: value
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
undefined,
|
|
15
|
-
{ shallow: true }
|
|
16
|
-
)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const handleCleanQuery = (name, value = '') => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
1
|
+
import { useRouter } from 'next/router'
|
|
2
|
+
// Hola mundo
|
|
3
|
+
export const useManageQueryParams = () => {
|
|
4
|
+
const router = useRouter()
|
|
5
|
+
|
|
6
|
+
const handleQuery = (name, value = '') => {
|
|
7
|
+
router.push(
|
|
8
|
+
{
|
|
9
|
+
query: {
|
|
10
|
+
...router.query,
|
|
11
|
+
[name]: value
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
undefined,
|
|
15
|
+
{ shallow: true }
|
|
16
|
+
)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const handleCleanQuery = (name, value = '') => {
|
|
20
|
+
const updatedQuery = {
|
|
21
|
+
...router.query,
|
|
22
|
+
[name]: value || ''
|
|
23
|
+
}
|
|
24
|
+
router.push(
|
|
25
|
+
{
|
|
26
|
+
query: updatedQuery
|
|
27
|
+
},
|
|
28
|
+
undefined,
|
|
29
|
+
{ shallow: true }
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
handleQuery,
|
|
35
|
+
handleCleanQuery
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
/* eslint-disable no-void */
|
|
2
|
-
import { useEffect, useState } from 'react'
|
|
3
|
-
|
|
4
|
-
export const useMobile = (props) => {
|
|
5
|
-
const { callBack = () => { return null } } = props || {}
|
|
6
|
-
const [innerHeight, setInnerHeight] = useState()
|
|
7
|
-
const [innerWidth, setInnerWidth] = useState()
|
|
8
|
-
let isMobile = false
|
|
9
|
-
useEffect(() => {
|
|
10
|
-
setInnerHeight(window.innerHeight)
|
|
11
|
-
setInnerWidth(window.innerWidth)
|
|
12
|
-
callBack()
|
|
13
|
-
}, [])
|
|
14
|
-
useEffect(() => {
|
|
15
|
-
const handleResize = () => {
|
|
16
|
-
if (!isNaN(window === null || window === void 0 ? void 0 : window.innerHeight) && (window === null || window === void 0 ? void 0 : window.innerHeight) !== innerHeight) {
|
|
17
|
-
setInnerHeight(window.innerHeight)
|
|
18
|
-
}
|
|
19
|
-
if (!isNaN(window.innerWidth) && window.innerWidth !== innerWidth) {
|
|
20
|
-
setInnerWidth(window.innerWidth)
|
|
21
|
-
}
|
|
22
|
-
callBack()
|
|
23
|
-
}
|
|
24
|
-
if (typeof window !== 'undefined') {
|
|
25
|
-
window.addEventListener('resize', handleResize)
|
|
26
|
-
}
|
|
27
|
-
return () => {
|
|
28
|
-
window.removeEventListener('resize', handleResize)
|
|
29
|
-
}
|
|
30
|
-
})
|
|
31
|
-
if (typeof window !== 'undefined' && /Mobile/i.test((navigator === null || navigator === void 0 ? void 0 : navigator.userAgent) || (navigator === null || navigator === void 0 ? void 0 : navigator.vendor))) {
|
|
32
|
-
isMobile = true
|
|
33
|
-
}
|
|
34
|
-
return {
|
|
35
|
-
isMobile,
|
|
36
|
-
innerHeight,
|
|
37
|
-
innerWidth
|
|
38
|
-
}
|
|
39
|
-
}
|
|
1
|
+
/* eslint-disable no-void */
|
|
2
|
+
import { useEffect, useState } from 'react'
|
|
3
|
+
|
|
4
|
+
export const useMobile = (props) => {
|
|
5
|
+
const { callBack = () => { return null } } = props || {}
|
|
6
|
+
const [innerHeight, setInnerHeight] = useState()
|
|
7
|
+
const [innerWidth, setInnerWidth] = useState()
|
|
8
|
+
let isMobile = false
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
setInnerHeight(window.innerHeight)
|
|
11
|
+
setInnerWidth(window.innerWidth)
|
|
12
|
+
callBack()
|
|
13
|
+
}, [])
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
const handleResize = () => {
|
|
16
|
+
if (!isNaN(window === null || window === void 0 ? void 0 : window.innerHeight) && (window === null || window === void 0 ? void 0 : window.innerHeight) !== innerHeight) {
|
|
17
|
+
setInnerHeight(window.innerHeight)
|
|
18
|
+
}
|
|
19
|
+
if (!isNaN(window.innerWidth) && window.innerWidth !== innerWidth) {
|
|
20
|
+
setInnerWidth(window.innerWidth)
|
|
21
|
+
}
|
|
22
|
+
callBack()
|
|
23
|
+
}
|
|
24
|
+
if (typeof window !== 'undefined') {
|
|
25
|
+
window.addEventListener('resize', handleResize)
|
|
26
|
+
}
|
|
27
|
+
return () => {
|
|
28
|
+
window.removeEventListener('resize', handleResize)
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
if (typeof window !== 'undefined' && /Mobile/i.test((navigator === null || navigator === void 0 ? void 0 : navigator.userAgent) || (navigator === null || navigator === void 0 ? void 0 : navigator.vendor))) {
|
|
32
|
+
isMobile = true
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
isMobile,
|
|
36
|
+
innerHeight,
|
|
37
|
+
innerWidth
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export const useOrderClient = () => {
|
|
2
|
-
return {
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
}
|
|
1
|
+
export const useOrderClient = () => {
|
|
2
|
+
return {
|
|
3
|
+
|
|
4
|
+
}
|
|
5
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './useProvidersCreateStore'
|
|
2
|
-
export * from './useProvidersDataStore'
|
|
3
|
-
export * from './queries'
|
|
1
|
+
export * from './useProvidersCreateStore'
|
|
2
|
+
export * from './useProvidersDataStore'
|
|
3
|
+
export * from './queries'
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import { gql } from '@apollo/client'
|
|
2
|
-
|
|
3
|
-
export const CREATE_PROVIDERS = gql`
|
|
4
|
-
mutation registerProviders($input: IProviders) {
|
|
5
|
-
registerProviders(input: $input) {
|
|
6
|
-
success
|
|
7
|
-
message
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
`
|
|
11
|
-
export const GET_ALL_PROVIDERS = gql`
|
|
12
|
-
query getAllProviders($idStore: ID,$search: String, $min: Int, $max: Int $fromDate: DateTime, $toDate: DateTime ) {
|
|
13
|
-
getAllProviders(idStore: $idStore, search: $search, min: $min, max: $max, toDate: $toDate, fromDate: $fromDate) {
|
|
14
|
-
idProvider
|
|
15
|
-
idStore
|
|
16
|
-
prImage
|
|
17
|
-
prPathImage
|
|
18
|
-
PrNit
|
|
19
|
-
prName
|
|
20
|
-
PrNumberPhone
|
|
21
|
-
PrNumberIdentity
|
|
22
|
-
PrAdres
|
|
23
|
-
PrMail
|
|
24
|
-
TotalBysPr
|
|
25
|
-
TotalDeuda
|
|
26
|
-
prState
|
|
27
|
-
DatCre
|
|
28
|
-
DatMod
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
`
|
|
1
|
+
import { gql } from '@apollo/client'
|
|
2
|
+
|
|
3
|
+
export const CREATE_PROVIDERS = gql`
|
|
4
|
+
mutation registerProviders($input: IProviders) {
|
|
5
|
+
registerProviders(input: $input) {
|
|
6
|
+
success
|
|
7
|
+
message
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
`
|
|
11
|
+
export const GET_ALL_PROVIDERS = gql`
|
|
12
|
+
query getAllProviders($idStore: ID,$search: String, $min: Int, $max: Int $fromDate: DateTime, $toDate: DateTime ) {
|
|
13
|
+
getAllProviders(idStore: $idStore, search: $search, min: $min, max: $max, toDate: $toDate, fromDate: $fromDate) {
|
|
14
|
+
idProvider
|
|
15
|
+
idStore
|
|
16
|
+
prImage
|
|
17
|
+
prPathImage
|
|
18
|
+
PrNit
|
|
19
|
+
prName
|
|
20
|
+
PrNumberPhone
|
|
21
|
+
PrNumberIdentity
|
|
22
|
+
PrAdres
|
|
23
|
+
PrMail
|
|
24
|
+
TotalBysPr
|
|
25
|
+
TotalDeuda
|
|
26
|
+
prState
|
|
27
|
+
DatCre
|
|
28
|
+
DatMod
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
`
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { useMutation } from '@apollo/client'
|
|
2
|
-
import { CREATE_PROVIDERS } from '../queries'
|
|
3
|
-
|
|
4
|
-
export const useProvidersCreateStore = ({ setAlertBox = () => { } } = {}) => {
|
|
5
|
-
const [registerProviders, { loading, error }] = useMutation(CREATE_PROVIDERS, {
|
|
6
|
-
onCompleted: (data) => {
|
|
7
|
-
setAlertBox({ message: `${data.registerProviders.message}` })
|
|
8
|
-
}
|
|
9
|
-
})
|
|
10
|
-
|
|
11
|
-
return [registerProviders, { loading, error }]
|
|
12
|
-
}
|
|
1
|
+
import { useMutation } from '@apollo/client'
|
|
2
|
+
import { CREATE_PROVIDERS } from '../queries'
|
|
3
|
+
|
|
4
|
+
export const useProvidersCreateStore = ({ setAlertBox = () => { } } = {}) => {
|
|
5
|
+
const [registerProviders, { loading, error }] = useMutation(CREATE_PROVIDERS, {
|
|
6
|
+
onCompleted: (data) => {
|
|
7
|
+
setAlertBox({ message: `${data.registerProviders.message}` })
|
|
8
|
+
}
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
return [registerProviders, { loading, error }]
|
|
12
|
+
}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { useQuery } from '@apollo/client'
|
|
2
|
-
import { GET_ALL_PROVIDERS } from '../queries'
|
|
3
|
-
|
|
4
|
-
export const useProvidersStore = () => {
|
|
5
|
-
const {
|
|
6
|
-
data,
|
|
7
|
-
fetchMore,
|
|
8
|
-
loading,
|
|
9
|
-
error,
|
|
10
|
-
called
|
|
11
|
-
} = useQuery(GET_ALL_PROVIDERS, {
|
|
12
|
-
fetchPolicy: 'cache-and-network',
|
|
13
|
-
notifyOnNetworkStatusChange: true,
|
|
14
|
-
nextFetchPolicy: 'cache-first',
|
|
15
|
-
refetchWritePolicy: 'merge'
|
|
16
|
-
})
|
|
17
|
-
const providerData = data?.getAllProviders || []
|
|
18
|
-
return [providerData, {
|
|
19
|
-
fetchMore,
|
|
20
|
-
called,
|
|
21
|
-
error,
|
|
22
|
-
loading
|
|
23
|
-
}]
|
|
24
|
-
}
|
|
1
|
+
import { useQuery } from '@apollo/client'
|
|
2
|
+
import { GET_ALL_PROVIDERS } from '../queries'
|
|
3
|
+
|
|
4
|
+
export const useProvidersStore = () => {
|
|
5
|
+
const {
|
|
6
|
+
data,
|
|
7
|
+
fetchMore,
|
|
8
|
+
loading,
|
|
9
|
+
error,
|
|
10
|
+
called
|
|
11
|
+
} = useQuery(GET_ALL_PROVIDERS, {
|
|
12
|
+
fetchPolicy: 'cache-and-network',
|
|
13
|
+
notifyOnNetworkStatusChange: true,
|
|
14
|
+
nextFetchPolicy: 'cache-first',
|
|
15
|
+
refetchWritePolicy: 'merge'
|
|
16
|
+
})
|
|
17
|
+
const providerData = data?.getAllProviders || []
|
|
18
|
+
return [providerData, {
|
|
19
|
+
fetchMore,
|
|
20
|
+
called,
|
|
21
|
+
error,
|
|
22
|
+
loading
|
|
23
|
+
}]
|
|
24
|
+
}
|