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
|
@@ -1,2 +1,171 @@
|
|
|
1
|
+
import { useQuery } from '@apollo/client';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { SPANISH_MONTHS } from "../../utils/index";
|
|
4
|
+
import { GET_ALL_SALES } from "../useReport/queries";
|
|
1
5
|
export * from './useChartData'
|
|
2
|
-
export * from './useChartDataAllOrders'
|
|
6
|
+
export * from './useChartDataAllOrders'
|
|
7
|
+
|
|
8
|
+
export const useChartData = ({ year }) => {
|
|
9
|
+
// Construcción del nuevo array:
|
|
10
|
+
const { data, loading } = useQuery(GET_ALL_SALES)
|
|
11
|
+
const [chartType, setChartType] = useState('bar')
|
|
12
|
+
const [chartTypeYear, setChartTypeYear] = useState(new Date().getFullYear())
|
|
13
|
+
const [asFilter, setFilter] = useState(false)
|
|
14
|
+
const [newResult, setNewResult] = useState([])
|
|
15
|
+
let result = []
|
|
16
|
+
data?.getAllSalesStore?.length > 0 && data?.getAllSalesStore.reduce(function (res, value) {
|
|
17
|
+
// Creamos la posición del array para cada mes
|
|
18
|
+
let mes = new Date(value.pDatCre).getMonth()
|
|
19
|
+
let Year = new Date(value.pDatCre).getFullYear()
|
|
20
|
+
if (!res[mes]) {
|
|
21
|
+
res[mes] = { Mes: mes, Year }
|
|
22
|
+
// Inicializamos a 0 el valor de cada key
|
|
23
|
+
Object.keys(value).forEach((key) => {
|
|
24
|
+
if (key != 'pDatCre') {
|
|
25
|
+
res[mes][key] = 0
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
result.push(res[mes])
|
|
30
|
+
}
|
|
31
|
+
// Sumamos el valor de cada clave dentro de un bucle
|
|
32
|
+
Object.keys(value).forEach(function (key) {
|
|
33
|
+
if (key != 'pDatCre') {
|
|
34
|
+
res[mes]['totalProductsPrice'] += value['totalProductsPrice']
|
|
35
|
+
}
|
|
36
|
+
})
|
|
37
|
+
return res
|
|
38
|
+
}, {})
|
|
39
|
+
|
|
40
|
+
let allMonths = Array.from({ length: 12 }, (_, i) => { return i })
|
|
41
|
+
let missingMonths = allMonths.filter(month => { return !result.some(data => { return data.Mes === month }) })
|
|
42
|
+
|
|
43
|
+
for (const element of missingMonths) {
|
|
44
|
+
result.push({
|
|
45
|
+
'Mes': element,
|
|
46
|
+
'totalProductsPrice': 0,
|
|
47
|
+
'Year': ''
|
|
48
|
+
})
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
result.sort((a, b) => { return a.Mes - b.Mes })
|
|
52
|
+
|
|
53
|
+
const labelTitle = `Ventas por meses del año ${asFilter ? chartTypeYear : ''}`
|
|
54
|
+
// Resultado:
|
|
55
|
+
const dataChart = {
|
|
56
|
+
labels: asFilter ? newResult.map(data => {
|
|
57
|
+
return SPANISH_MONTHS[data.Mes]
|
|
58
|
+
}) : result.map(data => {
|
|
59
|
+
return SPANISH_MONTHS[data.Mes]
|
|
60
|
+
}),
|
|
61
|
+
datasets: [
|
|
62
|
+
{
|
|
63
|
+
label: labelTitle,
|
|
64
|
+
data: asFilter ? newResult.map(data => { return data.totalProductsPrice }) : result.map(data => { return data.totalProductsPrice }),
|
|
65
|
+
backgroundColor: [
|
|
66
|
+
'rgba(255, 99, 132, 0.2)',
|
|
67
|
+
'rgba(54, 162, 235, 0.2)',
|
|
68
|
+
'rgba(255, 206, 86, 0.2)',
|
|
69
|
+
'rgba(75, 192, 192, 0.2)',
|
|
70
|
+
'rgba(153, 102, 255, 0.2)',
|
|
71
|
+
'rgba(255, 159, 64, 0.2)'
|
|
72
|
+
],
|
|
73
|
+
borderColor: chartType === 'bar' ? [
|
|
74
|
+
'rgba(255, 99, 132, 1)',
|
|
75
|
+
'rgba(54, 162, 235, 1)',
|
|
76
|
+
'rgba(255, 206, 86, 1)',
|
|
77
|
+
'rgba(75, 192, 192, 1)',
|
|
78
|
+
'rgba(153, 102, 255, 1)',
|
|
79
|
+
'rgba(255, 159, 64, 1)'
|
|
80
|
+
] : 'rgb(255 0 0)',
|
|
81
|
+
tension: 0.6,
|
|
82
|
+
fill: false,
|
|
83
|
+
borderWidth: 1,
|
|
84
|
+
barPercentage: 1,
|
|
85
|
+
barThickness: 50,
|
|
86
|
+
minBarLength: 3,
|
|
87
|
+
}
|
|
88
|
+
]
|
|
89
|
+
}
|
|
90
|
+
const options = {
|
|
91
|
+
interaction: {
|
|
92
|
+
mode: 'index',
|
|
93
|
+
intersect: false,
|
|
94
|
+
},
|
|
95
|
+
scales: {
|
|
96
|
+
x: {
|
|
97
|
+
stacked: true
|
|
98
|
+
},
|
|
99
|
+
y: {
|
|
100
|
+
stacked: true
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
plugins: {
|
|
104
|
+
title: {
|
|
105
|
+
display: true,
|
|
106
|
+
text: labelTitle
|
|
107
|
+
},
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const groupedData = {}
|
|
111
|
+
|
|
112
|
+
data && data.getAllSalesStore.forEach((item) => {
|
|
113
|
+
const year = new Date(item.pDatCre).getFullYear()
|
|
114
|
+
if (!groupedData[year]) {
|
|
115
|
+
groupedData[year] = []
|
|
116
|
+
}
|
|
117
|
+
groupedData[year].push(item)
|
|
118
|
+
})
|
|
119
|
+
const years = []
|
|
120
|
+
data && data.getAllSalesStore.forEach((item) => {
|
|
121
|
+
const y = new Date(item.pDatCre).getFullYear()
|
|
122
|
+
if (!years.includes(y)) {
|
|
123
|
+
years.push(y)
|
|
124
|
+
}
|
|
125
|
+
})
|
|
126
|
+
const handleChangeYear = (value) => {
|
|
127
|
+
setFilter(true)
|
|
128
|
+
const currentYear = parseInt(value)
|
|
129
|
+
setChartTypeYear(currentYear || '')
|
|
130
|
+
if (result?.length > 0) {
|
|
131
|
+
const filterToYear = result.filter((elem) => {
|
|
132
|
+
return elem?.Year == currentYear
|
|
133
|
+
})
|
|
134
|
+
let missingNewMonths = allMonths.filter(month => { return !filterToYear.some(data => { return data.Mes === month }) })
|
|
135
|
+
for (const element of missingNewMonths) {
|
|
136
|
+
filterToYear.push({
|
|
137
|
+
'Mes': element,
|
|
138
|
+
'totalProductsPrice': 0,
|
|
139
|
+
'Year': ''
|
|
140
|
+
})
|
|
141
|
+
}
|
|
142
|
+
filterToYear.sort((a, b) => { return a.Mes - b.Mes })
|
|
143
|
+
setNewResult(filterToYear)
|
|
144
|
+
return filterToYear
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
const cleanFilter = () => {
|
|
148
|
+
setFilter(false)
|
|
149
|
+
setChartTypeYear(new Date().getFullYear())
|
|
150
|
+
}
|
|
151
|
+
const sortYear = () => {
|
|
152
|
+
return years.sort((a, b) => { return b - a });
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const organiceYears = sortYear()
|
|
156
|
+
return {
|
|
157
|
+
handleChangeYear,
|
|
158
|
+
setFilter,
|
|
159
|
+
cleanFilter,
|
|
160
|
+
setChartType,
|
|
161
|
+
years: organiceYears,
|
|
162
|
+
asFilter,
|
|
163
|
+
chartTypeYear,
|
|
164
|
+
options,
|
|
165
|
+
chartType,
|
|
166
|
+
labelTitle,
|
|
167
|
+
result,
|
|
168
|
+
dataChart,
|
|
169
|
+
loading
|
|
170
|
+
}
|
|
171
|
+
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { useGetAllSales } from "../../useSales/useGetAllSales"
|
|
2
2
|
|
|
3
|
-
export const useChartDataAllOrders = (
|
|
4
|
-
|
|
3
|
+
export const useChartDataAllOrders = ({
|
|
4
|
+
onScreen = false
|
|
5
|
+
} = {}) => {
|
|
6
|
+
const { data, loading } = useGetAllSales({
|
|
7
|
+
onScreen
|
|
8
|
+
})
|
|
5
9
|
|
|
6
10
|
// Objeto para mapear los códigos de estado a sus nombres
|
|
7
11
|
const statusMap = {
|
|
@@ -21,7 +25,7 @@ export const useChartDataAllOrders = () => {
|
|
|
21
25
|
}
|
|
22
26
|
|
|
23
27
|
// Procesar los datos y acumular los totales por estado
|
|
24
|
-
data
|
|
28
|
+
data?.forEach(item => {
|
|
25
29
|
const status = item.pSState;
|
|
26
30
|
const totalPrice = item.totalProductsPrice;
|
|
27
31
|
totalsByStatus[status] += totalPrice;
|
|
@@ -34,8 +38,8 @@ export const useChartDataAllOrders = () => {
|
|
|
34
38
|
// Iterar a través del statusMap para llenar los datos
|
|
35
39
|
for (const status in statusMap) {
|
|
36
40
|
const statusLabel = statusMap[status];
|
|
37
|
-
chartLabels
|
|
38
|
-
chartData
|
|
41
|
+
chartLabels?.push(statusLabel);
|
|
42
|
+
chartData?.push(totalsByStatus[status] || 0);
|
|
39
43
|
}
|
|
40
44
|
|
|
41
45
|
const chartJsData = {
|
|
@@ -72,17 +76,18 @@ export const useChartDataAllOrders = () => {
|
|
|
72
76
|
tooltips: {
|
|
73
77
|
callbacks: {
|
|
74
78
|
label: (tooltipItem, data) => {
|
|
75
|
-
const dataset = data
|
|
76
|
-
const total = dataset
|
|
77
|
-
const currentValue = dataset
|
|
79
|
+
const dataset = data?.datasets[tooltipItem.datasetIndex];
|
|
80
|
+
const total = dataset?.data?.reduce((previousValue, currentValue) => previousValue + currentValue);
|
|
81
|
+
const currentValue = dataset?.data[tooltipItem?.index];
|
|
78
82
|
const percentage = ((currentValue / total) * 100).toFixed(2);
|
|
79
|
-
return `${data
|
|
83
|
+
return `${data?.labels[tooltipItem?.index]}: ${currentValue} (${percentage}%)`;
|
|
80
84
|
},
|
|
81
85
|
},
|
|
82
86
|
},
|
|
83
87
|
};
|
|
84
88
|
|
|
85
89
|
return {
|
|
90
|
+
loading,
|
|
86
91
|
data: loading ? [] : chartJsData,
|
|
87
92
|
option: loading ? [] : defaultOptions
|
|
88
93
|
};
|
|
@@ -15,7 +15,7 @@ import { useCallback, useState } from 'react'
|
|
|
15
15
|
* - clearAll (callback)
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
export const useCheckboxState = (elem, selectedIds = [], disabledIds = []
|
|
18
|
+
export const useCheckboxState = (elem, selectedIds = [], disabledIds = []) => {
|
|
19
19
|
const numTotalItems = elem?.length
|
|
20
20
|
const [checkedItems, setCheckedItems] = useState(new Set(selectedIds))
|
|
21
21
|
const [disabledItems, setDisabledItems] = useState(new Set(disabledIds))
|
|
@@ -23,17 +23,14 @@ export const useCheckboxState = (elem, selectedIds = [], disabledIds = [], calBa
|
|
|
23
23
|
const handleChangeCheck = useCallback((event, id) => {
|
|
24
24
|
const target = event.target
|
|
25
25
|
setCheckedItems(prevState => {
|
|
26
|
-
|
|
27
26
|
const newState = new Set(prevState)
|
|
28
27
|
if (target.checked) {
|
|
29
28
|
newState.add(id)
|
|
30
29
|
} else {
|
|
31
30
|
newState.delete(id)
|
|
32
31
|
}
|
|
33
|
-
calBack([...newState])
|
|
34
32
|
return newState
|
|
35
33
|
})
|
|
36
|
-
// eslint-disable-next-line
|
|
37
34
|
}, [])
|
|
38
35
|
|
|
39
36
|
const setAll = useCallback(
|
|
@@ -109,9 +106,9 @@ export const useCheckboxState = (elem, selectedIds = [], disabledIds = [], calBa
|
|
|
109
106
|
disabledItems,
|
|
110
107
|
handleChangeCheck,
|
|
111
108
|
toggleAll,
|
|
112
|
-
setCheckedItems,
|
|
113
109
|
selectAll,
|
|
114
110
|
clearAll,
|
|
111
|
+
setCheckedItems,
|
|
115
112
|
enableCheckboxes,
|
|
116
113
|
disableCheckboxes
|
|
117
114
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useQuery, useMutation, useLazyQuery } from '@apollo/client'
|
|
2
|
+
import { useState } from 'react'
|
|
2
3
|
import {
|
|
3
4
|
CREATE_CLIENTS,
|
|
4
5
|
DELETE_ONE_CLIENTS,
|
|
@@ -10,25 +11,15 @@ import {
|
|
|
10
11
|
export const useGetClients = ({
|
|
11
12
|
max,
|
|
12
13
|
search,
|
|
13
|
-
fromDate, // Agrega las variables fromDate y toDate
|
|
14
|
-
toDate,
|
|
15
14
|
sendNotification = () => { return }
|
|
16
15
|
} = {}) => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
search: search,
|
|
25
|
-
fromDate: fromDate, // Usa las variables aquí
|
|
26
|
-
toDate: toDate
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
return [data?.getAllClients || [], { loading: called ? false : loading, error }];
|
|
31
|
-
};
|
|
16
|
+
const { loading, error, called, data } = useQuery(GET_ALL_CLIENTS, {
|
|
17
|
+
variables: {
|
|
18
|
+
search: search
|
|
19
|
+
}
|
|
20
|
+
})
|
|
21
|
+
return [data?.getAllClients || [], { loading: called ? false : loading, error }]
|
|
22
|
+
}
|
|
32
23
|
|
|
33
24
|
export const useDeleteClients = ({ sendNotification = () => { return } } = {}) => {
|
|
34
25
|
const [deleteClient, { loading, error }] = useMutation(DELETE_ONE_CLIENTS)
|
|
@@ -10,14 +10,11 @@ import {
|
|
|
10
10
|
import { useStore } from '../useStore'
|
|
11
11
|
import { useTagsProducts } from './../useProductsFood/usetagsProducts'
|
|
12
12
|
import { useEditImageProduct } from './helpers/useEditImageProduct'
|
|
13
|
-
import { errorHandler } from '../../config/client'
|
|
14
|
-
import { useLogout } from '../useLogout'
|
|
15
13
|
|
|
16
14
|
export const useCreateProduct = ({
|
|
15
|
+
setAlertBox = () => { },
|
|
17
16
|
router,
|
|
18
|
-
sendNotification = () => { }
|
|
19
|
-
handleCloseCreateProduct = () => { },
|
|
20
|
-
setAlertBox = () => { }
|
|
17
|
+
sendNotification = () => { }
|
|
21
18
|
}) => {
|
|
22
19
|
const [errors, setErrors] = useState({
|
|
23
20
|
names: ''
|
|
@@ -54,7 +51,7 @@ export const useCreateProduct = ({
|
|
|
54
51
|
|
|
55
52
|
const handleCheck = (e) => {
|
|
56
53
|
const { name, checked } = e.target
|
|
57
|
-
return setCheck((prev) =>
|
|
54
|
+
return setCheck((prev) =>({ ...prev, [name]: checked }))
|
|
58
55
|
}
|
|
59
56
|
|
|
60
57
|
const handleUpdateBanner = event => {
|
|
@@ -123,15 +120,14 @@ export const useCreateProduct = ({
|
|
|
123
120
|
alt: files[0].name
|
|
124
121
|
}
|
|
125
122
|
: initialState
|
|
126
|
-
|
|
123
|
+
)
|
|
127
124
|
}
|
|
128
125
|
const onTargetClick = () => {
|
|
129
126
|
fileInputRef.current.click()
|
|
130
127
|
}
|
|
131
128
|
const { img } = useEditImageProduct({ sendNotification, initialState })
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
const handleRegister = async ({ callBack = () => { return} } = {}) => {
|
|
129
|
+
console.log(values)
|
|
130
|
+
const handleRegister = async () => {
|
|
135
131
|
const {
|
|
136
132
|
ProPrice,
|
|
137
133
|
ProDescuento,
|
|
@@ -150,93 +146,67 @@ export const useCreateProduct = ({
|
|
|
150
146
|
const pCode = RandomCode(9)
|
|
151
147
|
const formatPrice = ProPrice ? parseFloat(ProPrice.replace(/\./g, '')) : 0
|
|
152
148
|
try {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
ProDelivery: check?.desc ? 1 : 0
|
|
173
|
-
}
|
|
174
|
-
}, update(cache) {
|
|
175
|
-
cache.modify({
|
|
176
|
-
fields: {
|
|
177
|
-
productFoodsAll(dataOld = []) {
|
|
178
|
-
return cache.writeQuery({ query: GET_ALL_FOOD_PRODUCTS, data: dataOld })
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
})
|
|
149
|
+
updateProductFoods({
|
|
150
|
+
variables: {
|
|
151
|
+
input: {
|
|
152
|
+
idStore: dataStore?.getStore?.idStore || '',
|
|
153
|
+
ProPrice: check?.desc ? 0 : formatPrice,
|
|
154
|
+
ProDescuento: check?.desc ? 0 : parseInt(ProDescuento),
|
|
155
|
+
ValueDelivery: check?.desc ? 0 : parseFloat(ValueDelivery),
|
|
156
|
+
ProDescription,
|
|
157
|
+
pName: names,
|
|
158
|
+
pCode,
|
|
159
|
+
carProId,
|
|
160
|
+
pState: 1,
|
|
161
|
+
sTateLogistic: 1,
|
|
162
|
+
ProStar: 0,
|
|
163
|
+
ProImage,
|
|
164
|
+
ProHeight: parseFloat(ProHeight),
|
|
165
|
+
ProWeight,
|
|
166
|
+
ProOutstanding: check?.desc ? 1 : 0,
|
|
167
|
+
ProDelivery: check?.desc ? 1 : 0
|
|
182
168
|
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
errors: res?.errors
|
|
191
|
-
}
|
|
192
|
-
const responseError = errorHandler(errors);
|
|
193
|
-
if (responseError) {
|
|
194
|
-
handleCloseCreateProduct()
|
|
195
|
-
return onClickLogout()
|
|
196
|
-
}
|
|
197
|
-
} else {
|
|
198
|
-
router.push(
|
|
199
|
-
{
|
|
200
|
-
query: {
|
|
201
|
-
...router.query,
|
|
202
|
-
food: pId
|
|
203
|
-
}
|
|
204
|
-
},
|
|
205
|
-
undefined,
|
|
206
|
-
{ shallow: true }
|
|
207
|
-
)
|
|
208
|
-
if (pId){
|
|
209
|
-
setPid(pId ?? null)
|
|
210
|
-
sendNotification({
|
|
211
|
-
backgroundColor: 'success',
|
|
212
|
-
title: 'Success',
|
|
213
|
-
description: `El producto ${names} subido con éxito`
|
|
214
|
-
})
|
|
215
|
-
callBack()
|
|
216
|
-
}
|
|
217
|
-
const objTag = {
|
|
218
|
-
aName: tags?.tag,
|
|
219
|
-
nameTag: tags?.tag,
|
|
220
|
-
pId
|
|
169
|
+
},
|
|
170
|
+
update (cache) {
|
|
171
|
+
cache.modify({
|
|
172
|
+
fields: {
|
|
173
|
+
productFoodsAll (dataOld = []) {
|
|
174
|
+
return cache.writeQuery({ query: GET_ALL_FOOD_PRODUCTS, data: dataOld })
|
|
175
|
+
}
|
|
221
176
|
}
|
|
222
|
-
handleRegisterTags(objTag)
|
|
223
|
-
setValues({})
|
|
224
|
-
}
|
|
225
|
-
}).catch(err => {
|
|
226
|
-
return sendNotification({
|
|
227
|
-
backgroundColor: 'error',
|
|
228
|
-
title: 'Error inesperado',
|
|
229
|
-
description: `${err}`
|
|
230
177
|
})
|
|
178
|
+
}
|
|
179
|
+
}).then((res) => {
|
|
180
|
+
const { updateProductFoods } = res?.data || {}
|
|
181
|
+
const { pId } = updateProductFoods || {}
|
|
182
|
+
setPid(pId ?? null)
|
|
183
|
+
router.push(
|
|
184
|
+
{
|
|
185
|
+
query: {
|
|
186
|
+
...router.query,
|
|
187
|
+
food: pId
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
undefined,
|
|
191
|
+
{ shallow: true }
|
|
192
|
+
)
|
|
193
|
+
sendNotification({
|
|
194
|
+
backgroundColor: 'success',
|
|
195
|
+
title: 'Success',
|
|
196
|
+
description: `El producto ${names} subido con éxito`
|
|
231
197
|
})
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
})
|
|
239
|
-
}
|
|
198
|
+
const objTag = {
|
|
199
|
+
aName: tags.tag,
|
|
200
|
+
nameTag: tags.tag,
|
|
201
|
+
pId
|
|
202
|
+
}
|
|
203
|
+
handleRegisterTags(objTag)
|
|
204
|
+
// setValues({})
|
|
205
|
+
}).catch(err => { return sendNotification({
|
|
206
|
+
backgroundColor: 'error',
|
|
207
|
+
title: `${err}`,
|
|
208
|
+
description: 'Error inesperado'
|
|
209
|
+
}) })
|
|
240
210
|
if (image !== null) {
|
|
241
211
|
setImageProducts({
|
|
242
212
|
variables: {
|
|
@@ -249,7 +219,7 @@ export const useCreateProduct = ({
|
|
|
249
219
|
}).catch((error) => {
|
|
250
220
|
sendNotification({
|
|
251
221
|
backgroundColor: 'error',
|
|
252
|
-
title: `Ocurrió un error en la imagen en el producto ${names}`,
|
|
222
|
+
title: `Ocurrió un error en la imagen en el producto ${names}`,
|
|
253
223
|
description: 'error'
|
|
254
224
|
})
|
|
255
225
|
})
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import { useQuery } from '@apollo/client'
|
|
2
|
+
import { useEffect, useState } from 'react'
|
|
2
3
|
import { GET_EMPLOYEES } from './queries'
|
|
3
4
|
|
|
4
5
|
export const useEmployee = () => {
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return [employees, {
|
|
12
|
-
loading,
|
|
13
|
-
error,
|
|
14
|
-
fetchMore
|
|
15
|
-
}]
|
|
6
|
+
const [clientes, setClients] = useState([])
|
|
7
|
+
const [more, setMore] = useState(100)
|
|
8
|
+
const { data, loading, error, fetchMore } = useQuery(GET_EMPLOYEES)
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
setClients(data)
|
|
11
|
+
}, [clientes, data])
|
|
12
|
+
return [clientes?.employees, { loading, error, fetchMore, setMore, more }]
|
|
16
13
|
}
|
|
@@ -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,10 +1,7 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
|
|
3
|
-
useRef,
|
|
4
|
-
useEffect
|
|
5
|
-
} from 'react'
|
|
1
|
+
import React, { useState, useRef, useEffect } from 'react'
|
|
2
|
+
import styled from 'styled-components'
|
|
6
3
|
|
|
7
|
-
export const
|
|
4
|
+
export const useFullscreenMode = () => {
|
|
8
5
|
const [isFullscreen, setFullscreen] = useState(false)
|
|
9
6
|
const elementRef = useRef()
|
|
10
7
|
|
|
@@ -59,7 +56,10 @@ export const useFullScreenMode = () => {
|
|
|
59
56
|
}
|
|
60
57
|
|
|
61
58
|
const ToggleIcon = (
|
|
62
|
-
<
|
|
59
|
+
<Button onDoubleClick={() => {return (!isFullscreen ? goFullscreen() : exitFullScreen())}}>{!isFullscreen ? 'FullScreen' : 'Normal'}</Button>
|
|
63
60
|
)
|
|
64
61
|
return [elementRef, ToggleIcon] //Icon, ref
|
|
65
|
-
}
|
|
62
|
+
}
|
|
63
|
+
const Button = styled.button`
|
|
64
|
+
|
|
65
|
+
`
|