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
|
@@ -1,36 +1,33 @@
|
|
|
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'
|
|
3
|
+
import { useRouter } from 'next/router'
|
|
4
|
+
import { Cookies } from '../../cookies'
|
|
5
|
+
import { fetchJson } from '../../hooks/useFetchJson'
|
|
5
6
|
|
|
6
7
|
export const useLogout = ({ setAlertBox = () => { } } = {}) => {
|
|
7
8
|
const [loading, setLoading] = useState(false)
|
|
8
9
|
const [error, setError] = useState(false)
|
|
9
|
-
const router = useRouter()
|
|
10
|
-
const client = useApolloClient()
|
|
10
|
+
const router = useRouter()
|
|
11
|
+
const client = useApolloClient()
|
|
11
12
|
|
|
12
13
|
const onClickLogout = async () => {
|
|
13
14
|
setLoading(true)
|
|
14
|
-
await
|
|
15
|
-
|
|
16
|
-
.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
setLoading(false);
|
|
31
|
-
}
|
|
32
|
-
})
|
|
33
|
-
.catch(() => {
|
|
15
|
+
await fetchJson(`${process.env.URL_BASE}api/auth/logout`, {
|
|
16
|
+
}).then(res => {
|
|
17
|
+
localStorage.removeItem('session')
|
|
18
|
+
localStorage.removeItem('usuario')
|
|
19
|
+
localStorage.removeItem('location')
|
|
20
|
+
localStorage.removeItem('sessionGoogle')
|
|
21
|
+
localStorage.removeItem('longitude')
|
|
22
|
+
localStorage.removeItem('latitude')
|
|
23
|
+
localStorage.removeItem('restaurant')
|
|
24
|
+
Cookies.remove(process.env.SESSION_NAME)
|
|
25
|
+
Cookies.remove(process.env.LOCAL_SALES_STORE)
|
|
26
|
+
Cookies.remove('restaurant')
|
|
27
|
+
client?.clearStore()
|
|
28
|
+
router.replace('/entrar')
|
|
29
|
+
setLoading(false)
|
|
30
|
+
}).catch(() => {
|
|
34
31
|
setError(true)
|
|
35
32
|
setAlertBox({ message: 'Ocurrió un error al cerrar session' })
|
|
36
33
|
})
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { useRouter } from 'next/router'
|
|
2
|
+
|
|
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
|
+
router.push(
|
|
21
|
+
{
|
|
22
|
+
query: {
|
|
23
|
+
...router.query,
|
|
24
|
+
[name]: value || ''
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
undefined,
|
|
28
|
+
{ shallow: true }
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
handleQuery,
|
|
35
|
+
handleCleanQuery
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -420,6 +420,7 @@ export const GET_EXTRAS_PRODUCT_FOOD_OPTIONAL = gql`
|
|
|
420
420
|
}
|
|
421
421
|
}
|
|
422
422
|
`;
|
|
423
|
+
|
|
423
424
|
export const GET_EXTRAS_PRODUCT_FOOD_SUB_OPTIONAL = gql`
|
|
424
425
|
mutation updateExtProductFoodsSubOptional(
|
|
425
426
|
$input: InputExtProductFoodSubOptional
|
|
@@ -701,14 +702,6 @@ export const GET_BANNER_PROMO_DASHBOARD = gql`
|
|
|
701
702
|
}
|
|
702
703
|
`;
|
|
703
704
|
|
|
704
|
-
export const CREATE_STORE_CALENDAR = gql`
|
|
705
|
-
mutation setStoreSchedule($input: ITstoreSchedule!) {
|
|
706
|
-
setStoreSchedule(input: $input) {
|
|
707
|
-
message
|
|
708
|
-
success
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
|
-
`;
|
|
712
705
|
export const DELETE_ONE_CAT_PRODUCTS = gql`
|
|
713
706
|
mutation deleteCatOfProducts($idPc: ID!, $pState: Int) {
|
|
714
707
|
deleteCatOfProducts(idPc: $idPc, pState: $pState) {
|
|
@@ -741,14 +734,8 @@ export const EDIT_EXTRA_PRODUCTS = gql`
|
|
|
741
734
|
}
|
|
742
735
|
}
|
|
743
736
|
`;
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
DeleteExtProductFoodsOptional(opExPid: $opExPid, state: $state) {
|
|
747
|
-
success
|
|
748
|
-
message
|
|
749
|
-
}
|
|
750
|
-
}
|
|
751
|
-
`;
|
|
737
|
+
|
|
738
|
+
|
|
752
739
|
export const DELETE_CAT_EXTRA_SUB_OPTIONAL_PRODUCTS = gql`
|
|
753
740
|
mutation DeleteExtFoodSubsOptional($opSubExPid: ID, $state: Int) {
|
|
754
741
|
DeleteExtFoodSubsOptional(opSubExPid: $opSubExPid, state: $state) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { REGISTER_TAGS_PRODUCT } from
|
|
1
|
+
import { useState } from 'react'
|
|
2
|
+
import { useMutation } from '@apollo/client'
|
|
3
|
+
import { REGISTER_TAGS_PRODUCT } from './queriesStore'
|
|
4
4
|
|
|
5
5
|
export const useTagsProducts = () => {
|
|
6
6
|
const [registerTag] = useMutation(REGISTER_TAGS_PRODUCT)
|
|
@@ -20,8 +20,33 @@ export const useTagsProducts = () => {
|
|
|
20
20
|
{
|
|
21
21
|
id: 4,
|
|
22
22
|
tag: 'Bebida sin alcohol'
|
|
23
|
-
}
|
|
24
|
-
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
id: 5,
|
|
26
|
+
tag: 'Entrante'
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
id: 6,
|
|
30
|
+
tag: 'Plato principal'
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
id: 7,
|
|
34
|
+
tag: 'Postre'
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: 8,
|
|
38
|
+
tag: 'Sopa'
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: 9,
|
|
42
|
+
tag: 'Ensalada'
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: 10,
|
|
46
|
+
tag: 'Mariscos'
|
|
47
|
+
},
|
|
48
|
+
];
|
|
49
|
+
|
|
25
50
|
const [tags, setTags] = useState({
|
|
26
51
|
id: '',
|
|
27
52
|
tag: ''
|
|
@@ -0,0 +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
|
+
`
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useMutation } from "@apollo/client"
|
|
2
|
+
import { CREATE_PROVIDERS } from "../queries"
|
|
3
|
+
|
|
4
|
+
export const useProvidersCreateStore = ({ setAlertBox = () => { return } } = {}) => {
|
|
5
|
+
|
|
6
|
+
const [registerProviders, { loading, error }] = useMutation(CREATE_PROVIDERS, {
|
|
7
|
+
onCompleted: (data) => {
|
|
8
|
+
setAlertBox({ message: `${data.registerProviders.message}` })
|
|
9
|
+
}
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
return [registerProviders, { loading, error }]
|
|
13
|
+
}
|
|
@@ -0,0 +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
|
+
}
|
|
@@ -0,0 +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
|
+
}
|
|
@@ -0,0 +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
|
+
`
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { useState, useEffect } from 'react';
|
|
2
|
+
import { useQuery } from '@apollo/client';
|
|
3
|
+
import { GET_All_RATING_STORE } from './queries';
|
|
4
|
+
|
|
5
|
+
export const useRatingData = () => {
|
|
6
|
+
const { data: dataRating } = useQuery(GET_All_RATING_STORE);
|
|
7
|
+
|
|
8
|
+
const calculateTotalRatings = (ratings = []) => {
|
|
9
|
+
return ratings.reduce(
|
|
10
|
+
(total, rating) => ({
|
|
11
|
+
rAppearance: total?.rAppearance + rating.rAppearance,
|
|
12
|
+
rTasty: total?.rTasty + rating.rTasty,
|
|
13
|
+
rGoodCondition: total?.rGoodCondition + rating.rGoodCondition,
|
|
14
|
+
rGoodTemperature: total?.rGoodTemperature + rating.rGoodTemperature,
|
|
15
|
+
}),
|
|
16
|
+
{
|
|
17
|
+
rAppearance: 0,
|
|
18
|
+
rTasty: 0,
|
|
19
|
+
rGoodCondition: 0,
|
|
20
|
+
rGoodTemperature: 0,
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const [totalRatings, setTotalRatings] = useState(
|
|
26
|
+
calculateTotalRatings(dataRating?.getAllRating || [])
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
setTotalRatings(calculateTotalRatings(dataRating?.getAllRating || []));
|
|
31
|
+
}, [dataRating]);
|
|
32
|
+
|
|
33
|
+
const dataArr = [
|
|
34
|
+
{
|
|
35
|
+
name: 'Buena apariencia',
|
|
36
|
+
value: totalRatings.rAppearance || 0,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: 'Es deliciosa',
|
|
40
|
+
value: totalRatings.rTasty || 0,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: 'Buenas condiciones',
|
|
44
|
+
value: totalRatings.rGoodCondition || 0,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: 'Buena temperatura',
|
|
48
|
+
value: totalRatings.rGoodTemperature || 0,
|
|
49
|
+
},
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
return dataArr;
|
|
53
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { gql } from '@apollo/client'
|
|
2
|
+
|
|
3
|
+
export const GET_All_RATING_STORE = gql`
|
|
4
|
+
query getAllRating($idStore: ID){
|
|
5
|
+
getAllRating(idStore: $idStore){
|
|
6
|
+
idStore
|
|
7
|
+
rId
|
|
8
|
+
id
|
|
9
|
+
rAppearance
|
|
10
|
+
rTasty
|
|
11
|
+
rGoodTemperature
|
|
12
|
+
rGoodCondition
|
|
13
|
+
rState
|
|
14
|
+
createAt
|
|
15
|
+
updateAt
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
`
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useMutation } from '@apollo/client'
|
|
2
|
+
import { DELETE_CAT_EXTRA_PRODUCTS } from './queries'
|
|
3
|
+
|
|
4
|
+
export const useRemoveExtraProductFoodsOptional = () => {
|
|
5
|
+
const [DeleteExtProductFoodsOptional, { loading, error }] = useMutation(DELETE_CAT_EXTRA_PRODUCTS)
|
|
6
|
+
|
|
7
|
+
const handleDeleteOptional = async elem => {
|
|
8
|
+
const { state, opExPid } = elem || {}
|
|
9
|
+
DeleteExtProductFoodsOptional({
|
|
10
|
+
variables: {
|
|
11
|
+
state: state,
|
|
12
|
+
opExPid: opExPid,
|
|
13
|
+
isCustomOpExPid: true
|
|
14
|
+
}
|
|
15
|
+
})
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
handleDeleteOptional,
|
|
19
|
+
DeleteExtProductFoodsOptional,
|
|
20
|
+
loading,
|
|
21
|
+
error
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { gql } from "@apollo/client";
|
|
2
|
+
|
|
3
|
+
export const DELETE_CAT_EXTRA_PRODUCTS = gql`
|
|
4
|
+
mutation DeleteExtProductFoodsOptional($opExPid: ID, $state: Int, $isCustomOpExPid: Boolean) {
|
|
5
|
+
DeleteExtProductFoodsOptional(opExPid: $opExPid, state: $state, isCustomOpExPid: $isCustomOpExPid) {
|
|
6
|
+
success
|
|
7
|
+
message
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
`;
|
|
11
|
+
|
|
12
|
+
export const GET_EXTRAS_PRODUCT_FOOD_OPTIONAL = gql`
|
|
13
|
+
query ExtProductFoodsOptionalAll(
|
|
14
|
+
$search: String
|
|
15
|
+
$min: Int
|
|
16
|
+
$max: Int
|
|
17
|
+
$pId: ID
|
|
18
|
+
) {
|
|
19
|
+
ExtProductFoodsOptionalAll(
|
|
20
|
+
search: $search
|
|
21
|
+
min: $min
|
|
22
|
+
max: $max
|
|
23
|
+
pId: $pId
|
|
24
|
+
) {
|
|
25
|
+
pId
|
|
26
|
+
opExPid
|
|
27
|
+
OptionalProName
|
|
28
|
+
state
|
|
29
|
+
code
|
|
30
|
+
numbersOptionalOnly
|
|
31
|
+
pDatCre
|
|
32
|
+
required
|
|
33
|
+
pDatMod
|
|
34
|
+
ExtProductFoodsSubOptionalAll {
|
|
35
|
+
pId
|
|
36
|
+
opExPid
|
|
37
|
+
idStore
|
|
38
|
+
opSubExPid
|
|
39
|
+
OptionalSubProName
|
|
40
|
+
exCodeOptionExtra
|
|
41
|
+
exCode
|
|
42
|
+
state
|
|
43
|
+
pDatCre
|
|
44
|
+
pDatMod
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
`;
|
|
@@ -1,16 +1,24 @@
|
|
|
1
|
-
import { useQuery } from '@apollo/client'
|
|
1
|
+
import { useQuery, useLazyQuery } from '@apollo/client'
|
|
2
2
|
import { GET_ALL_SALES, GET_ALL_TOTAL_SALES } from './queries'
|
|
3
3
|
|
|
4
4
|
export const useReport = ({
|
|
5
|
+
fromDate = '',
|
|
5
6
|
more,
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
search = '',
|
|
8
|
+
channel = null,
|
|
9
|
+
toDate = '',
|
|
10
|
+
lazyQuery = false
|
|
8
11
|
}) => {
|
|
9
|
-
const { data
|
|
12
|
+
const [getAllSalesStore, { data: lazyDataSales, loading: lazyLoading }] = useLazyQuery(GET_ALL_SALES)
|
|
13
|
+
|
|
14
|
+
const { data: dataSales, fetchMore, loading } = useQuery(GET_ALL_SALES,{
|
|
10
15
|
fetchPolicy: 'network-only',
|
|
16
|
+
skip: lazyQuery,
|
|
11
17
|
variables: {
|
|
12
18
|
min: 0,
|
|
13
19
|
fromDate,
|
|
20
|
+
channel: channel,
|
|
21
|
+
search,
|
|
14
22
|
toDate,
|
|
15
23
|
max: more
|
|
16
24
|
}
|
|
@@ -22,11 +30,12 @@ export const useReport = ({
|
|
|
22
30
|
toDate,
|
|
23
31
|
}
|
|
24
32
|
})
|
|
25
|
-
|
|
33
|
+
const data = lazyQuery ? lazyDataSales : dataSales
|
|
26
34
|
|
|
27
35
|
return {
|
|
28
|
-
|
|
29
|
-
|
|
36
|
+
getAllSalesStore,
|
|
37
|
+
data: data,
|
|
38
|
+
loading: lazyLoading || loading,
|
|
30
39
|
totalSales: totalSales?.getAllSalesStoreTotal.TOTAL ?? 0,
|
|
31
40
|
restaurant: totalSales?.getAllSalesStoreTotal.restaurant ?? 0,
|
|
32
41
|
delivery: totalSales?.getAllSalesStoreTotal.delivery ?? 0,
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { gql } from '@apollo/client'
|
|
2
2
|
|
|
3
3
|
export const GET_ALL_SALES = gql`
|
|
4
|
-
query getAllSalesStore($idStore: ID,$search: String, $min: Int, $max: Int $fromDate: DateTime, $toDate: DateTime ) {
|
|
5
|
-
getAllSalesStore(idStore: $idStore, search: $search, min: $min, max: $max, toDate: $toDate, fromDate: $fromDate) {
|
|
4
|
+
query getAllSalesStore($idStore: ID,$search: String, $min: Int, $max: Int $fromDate: DateTime, $toDate: DateTime, $channel: Int) {
|
|
5
|
+
getAllSalesStore(idStore: $idStore, search: $search, min: $min, max: $max, toDate: $toDate, fromDate: $fromDate, channel: $channel) {
|
|
6
6
|
totalProductsPrice
|
|
7
|
-
channel
|
|
8
7
|
pDatCre
|
|
9
8
|
pCodeRef
|
|
9
|
+
change
|
|
10
|
+
channel
|
|
10
11
|
}
|
|
11
12
|
}
|
|
12
13
|
`
|
|
@@ -21,19 +22,33 @@ query getAllSalesStoreTotal($idStore: ID,$search: String, $min: Int, $max: Int $
|
|
|
21
22
|
}
|
|
22
23
|
`
|
|
23
24
|
export const GET_ALL_SALES_STATISTICS = gql`
|
|
24
|
-
query getAllSalesStoreStatistic(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
25
|
+
query getAllSalesStoreStatistic(
|
|
26
|
+
$idStore: ID
|
|
27
|
+
$search: String
|
|
28
|
+
$min: Int
|
|
29
|
+
$max: Int
|
|
30
|
+
$fromDate: DateTime
|
|
31
|
+
$toDate: DateTime
|
|
32
|
+
) {
|
|
33
|
+
getAllSalesStoreStatistic(
|
|
34
|
+
idStore: $idStore
|
|
35
|
+
search: $search
|
|
36
|
+
min: $min
|
|
37
|
+
max: $max
|
|
38
|
+
toDate: $toDate
|
|
39
|
+
fromDate: $fromDate
|
|
40
|
+
) {
|
|
41
|
+
pdpId
|
|
42
|
+
idStore
|
|
43
|
+
pCodeRef
|
|
44
|
+
payMethodPState
|
|
45
|
+
pPRecoger
|
|
46
|
+
totalProductsPrice
|
|
47
|
+
pSState
|
|
48
|
+
pDatCre
|
|
49
|
+
locationUser
|
|
50
|
+
pDatMod
|
|
51
|
+
getAllPedidoStore {
|
|
37
52
|
pdpId
|
|
38
53
|
pId
|
|
39
54
|
idStore
|
|
@@ -49,26 +64,26 @@ query getAllSalesStoreStatistic($idStore: ID,$search: String, $min: Int, $max: I
|
|
|
49
64
|
comments
|
|
50
65
|
cantProducts
|
|
51
66
|
pId
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
+
productFood {
|
|
68
|
+
pId
|
|
69
|
+
carProId
|
|
70
|
+
colorId
|
|
71
|
+
idStore
|
|
72
|
+
pName
|
|
73
|
+
ProPrice
|
|
74
|
+
ProDescuento
|
|
75
|
+
ProDescription
|
|
76
|
+
ValueDelivery
|
|
77
|
+
ProImage
|
|
78
|
+
ProStar
|
|
79
|
+
pState
|
|
80
|
+
pDatCre
|
|
81
|
+
pDatMod
|
|
82
|
+
}
|
|
67
83
|
}
|
|
68
84
|
}
|
|
69
85
|
}
|
|
70
86
|
}
|
|
71
|
-
}
|
|
72
87
|
`
|
|
73
88
|
|
|
74
89
|
export const GET_ONE_SALES = gql`
|