npm-pkg-hook 1.0.5 → 1.0.7
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/.vscode/settings.json +1 -5
- package/package.json +1 -1
- package/src/hooks/index.js +2 -1
- package/src/hooks/useBanner/index.js +1 -1
- package/src/hooks/useCatWithProduct/index.js +2 -0
- package/src/hooks/useCatWithProduct/queries.js +3 -2
- package/src/hooks/useChartData/index.js +0 -1
- package/src/hooks/useClients/index.js +10 -0
- package/src/hooks/useFormTools/index.js +7 -6
- package/src/hooks/useFormatDate/index.js +1 -1
- package/src/hooks/useFormatNumberPhone/index.js +23 -0
- package/src/hooks/useProductsFood/index.js +7 -5
- package/src/hooks/useProductsFood/queriesStore.js +0 -1
- package/src/hooks/useReactToPrint/index.js +1 -1
- package/src/hooks/useSales/helpers/index.js +0 -0
- package/src/hooks/useSales/index.js +719 -358
- package/src/hooks/useSales/queries.js +348 -196
- package/src/hooks/useSales/useGetSale.js +9 -8
- package/src/hooks/useSales/useTotalSales.js +10 -3
package/.vscode/settings.json
CHANGED
package/package.json
CHANGED
package/src/hooks/index.js
CHANGED
|
@@ -15,6 +15,7 @@ export * from './useDrag'
|
|
|
15
15
|
export * from './useEvent'
|
|
16
16
|
export * from './useFetchJson'
|
|
17
17
|
export * from './useFormatDate'
|
|
18
|
+
export * from './useFormatNumberPhone'
|
|
18
19
|
export * from './useFormTools/index'
|
|
19
20
|
export * from './useHover'
|
|
20
21
|
export * from './useImageOptimization'
|
|
@@ -29,6 +30,7 @@ export * from './useMobile'
|
|
|
29
30
|
export * from './useMutateHeight'
|
|
30
31
|
export * from './useProductsFood'
|
|
31
32
|
export * from './useProductsFood/usetagsProducts'
|
|
33
|
+
export * from './useReactToPrint'
|
|
32
34
|
export * from './useReport'
|
|
33
35
|
export * from './useRestaurant'
|
|
34
36
|
export * from './useSales'
|
|
@@ -43,5 +45,4 @@ export * from './useTimeAgo/useTimeAgo'
|
|
|
43
45
|
export * from './useUpdateCart'
|
|
44
46
|
export * from './useUpdateExtProductFoodsSubOptional'
|
|
45
47
|
export * from './useUser'
|
|
46
|
-
export * from './useReactToPrint'
|
|
47
48
|
|
|
@@ -12,7 +12,7 @@ export const useBanner = () => {
|
|
|
12
12
|
} = useQuery(GET_ONE_BANNER_STORE, {
|
|
13
13
|
context: { clientName: 'admin-server' },
|
|
14
14
|
variables: {
|
|
15
|
-
idStore: !loaStore &&
|
|
15
|
+
idStore: !loaStore && ''
|
|
16
16
|
}
|
|
17
17
|
})
|
|
18
18
|
return [data?.getOneBanners, { loading, error }]
|
|
@@ -5,6 +5,7 @@ export const useCatWithProduct = ({
|
|
|
5
5
|
max = 1,
|
|
6
6
|
min = 0,
|
|
7
7
|
search = null,
|
|
8
|
+
productName = null,
|
|
8
9
|
searchFilter= {}
|
|
9
10
|
}) => {
|
|
10
11
|
const {
|
|
@@ -22,6 +23,7 @@ export const useCatWithProduct = ({
|
|
|
22
23
|
variables:
|
|
23
24
|
{
|
|
24
25
|
search,
|
|
26
|
+
productName,
|
|
25
27
|
gender: gender,
|
|
26
28
|
min,
|
|
27
29
|
max: 400,
|
|
@@ -117,8 +117,8 @@ query ExtProductFoodsAll($search: String, $min: Int, $max: Int, $pId: ID) {
|
|
|
117
117
|
}
|
|
118
118
|
`
|
|
119
119
|
export const GET_ALL_CATEGORIES_WITH_PRODUCT = gql`
|
|
120
|
-
query getCatProductsWithProduct($search: String, $min: Int, $max: Int, $gender: [String], $desc: [String], $categories: [ID], ) {
|
|
121
|
-
getCatProductsWithProduct(search: $search, min: $min, max: $max, gender: $gender, desc: $desc, categories: $categories,) {
|
|
120
|
+
query getCatProductsWithProduct($search: String, $productName: String, $min: Int, $max: Int, $gender: [String], $desc: [String], $categories: [ID], ) {
|
|
121
|
+
getCatProductsWithProduct(search: $search, min: $min, productName:$productName, max: $max, gender: $gender, desc: $desc, categories: $categories,) {
|
|
122
122
|
totalCount,
|
|
123
123
|
catProductsWithProduct {
|
|
124
124
|
carProId
|
|
@@ -136,6 +136,7 @@ query getCatProductsWithProduct($search: String, $min: Int, $max: Int, $gender:
|
|
|
136
136
|
productFoodsAll {
|
|
137
137
|
pId
|
|
138
138
|
sizeId
|
|
139
|
+
|
|
139
140
|
colorId
|
|
140
141
|
carProId
|
|
141
142
|
cId
|
|
@@ -50,7 +50,6 @@ export const useChartData = ({ year }) => {
|
|
|
50
50
|
|
|
51
51
|
const labelTitle = `Ventas por meses del año ${asFilter ? chartTypeYear : ''}`
|
|
52
52
|
// Resultado:
|
|
53
|
-
console.log(chartTypeYear)
|
|
54
53
|
const dataChart = {
|
|
55
54
|
labels: asFilter ? newResult.map(data => {
|
|
56
55
|
return SPANISH_MONTHS[data.Mes]
|
|
@@ -11,3 +11,13 @@ export const useGetClients = () => {
|
|
|
11
11
|
})
|
|
12
12
|
return [clientes?.getAllClients || [], { loading, error }]
|
|
13
13
|
}
|
|
14
|
+
|
|
15
|
+
export const useDeleteClients = () => {
|
|
16
|
+
const [clientes, setClients] = useState([])
|
|
17
|
+
const { loading, error } = useQuery(GET_ALL_CLIENTS, {
|
|
18
|
+
onCompleted: (data) => {
|
|
19
|
+
setClients(data)
|
|
20
|
+
}
|
|
21
|
+
})
|
|
22
|
+
return [clientes?.getAllClients || [], { loading, error }]
|
|
23
|
+
}
|
|
@@ -9,7 +9,7 @@ import { validationSubmitHooks } from '../../utils'
|
|
|
9
9
|
* @description Hook con herramientas de validación y eventos de cambio
|
|
10
10
|
* @return {Array} devuelve la función onChange a ejecutar y el estado de error de cada input
|
|
11
11
|
*/
|
|
12
|
-
export const useFormTools = () => {
|
|
12
|
+
export const useFormTools = ({ sendNotification = () => { } } = {}) => {
|
|
13
13
|
const [dataForm, setDataForm] = useState({})
|
|
14
14
|
const [errorForm, setErrorForm] = useState({})
|
|
15
15
|
const [errorSubmit, setErrorSubmit] = useState(false)
|
|
@@ -33,11 +33,12 @@ export const useFormTools = () => {
|
|
|
33
33
|
// Handle submit, al enviar formulario
|
|
34
34
|
const listErrors = Object.values(errorForm)
|
|
35
35
|
const errors = listErrors.find((error) => {
|
|
36
|
-
return error ===true
|
|
36
|
+
return error === true
|
|
37
37
|
})
|
|
38
38
|
|
|
39
39
|
const handleSubmit = useCallback(({ event, action, msgSuccess, msgError, actionAfterSuccess }) => {
|
|
40
|
-
|
|
40
|
+
event.preventDefault()
|
|
41
|
+
console.log(event)
|
|
41
42
|
setCalledSubmit(true)
|
|
42
43
|
let errSub = false
|
|
43
44
|
|
|
@@ -55,8 +56,8 @@ export const useFormTools = () => {
|
|
|
55
56
|
|
|
56
57
|
// Valida los errores desde el evento
|
|
57
58
|
const errores = validationSubmitHooks(event.target.elements)
|
|
59
|
+
console.log({errores})
|
|
58
60
|
setErrorForm(errores)
|
|
59
|
-
console.log("🚀 ~ file: index.js ~ line 50 ~ handleSubmit ~ errores", errores)
|
|
60
61
|
for (const x in errores) {
|
|
61
62
|
if (errores[x]) errSub = true
|
|
62
63
|
}
|
|
@@ -65,11 +66,11 @@ export const useFormTools = () => {
|
|
|
65
66
|
if (!errSub && action) {
|
|
66
67
|
action().then(res => {
|
|
67
68
|
if (res) {
|
|
68
|
-
|
|
69
|
+
sendNotification({ message: msgSuccess || 'Operación exitosa', description: 'Operación exitosa', color: PColor })
|
|
69
70
|
!!actionAfterSuccess && actionAfterSuccess()
|
|
70
71
|
}
|
|
71
72
|
|
|
72
|
-
}).catch(e => {return
|
|
73
|
+
}).catch(e => {return sendNotification({ title: msgError || e?.message || 'Ha ocurrido un error', color: WColor })})
|
|
73
74
|
}
|
|
74
75
|
|
|
75
76
|
setErrorSubmit(errSub)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export const useFormatDate = ({
|
|
2
2
|
date,
|
|
3
3
|
local = 'ES'
|
|
4
|
-
}) => {
|
|
4
|
+
} = {}) => {
|
|
5
5
|
const dateToFormat = new Date(date ?? Date.now())
|
|
6
6
|
const fullDate = dateToFormat.toLocaleDateString(local, { year: 'numeric', month: '2-digit', day: '2-digit' })
|
|
7
7
|
const day = fullDate.split('/')[0]
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Description
|
|
3
|
+
* @param {any} phoneNumber type number or string
|
|
4
|
+
* @returns {any}
|
|
5
|
+
*/
|
|
6
|
+
export const formatPhoneNumber = (phoneNumber) => {
|
|
7
|
+
const cleaned = ('' + phoneNumber).replace(/\D/g, '');
|
|
8
|
+
const match = cleaned.match(/^(\d{3})(\d{3})(\d{4})$/);
|
|
9
|
+
if (match) {
|
|
10
|
+
return `(${match[1]}) ${match[2]}-${match[3]}`;
|
|
11
|
+
}
|
|
12
|
+
return phoneNumber;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Description
|
|
17
|
+
* @param {any} phoneNumber type number or string
|
|
18
|
+
* @returns {any}
|
|
19
|
+
*/
|
|
20
|
+
export const validatePhoneNumber = (phoneNumber) => {
|
|
21
|
+
const regex = /^\(\d{3}\) \d{3}-\d{4}$/;
|
|
22
|
+
return regex.test(phoneNumber);
|
|
23
|
+
};
|
|
@@ -38,10 +38,13 @@ export const useProductsFood = ({
|
|
|
38
38
|
search = null,
|
|
39
39
|
toDate
|
|
40
40
|
}) => {
|
|
41
|
-
const [productsFood, setProductsFood] = useState([])
|
|
41
|
+
// const [productsFood, setProductsFood] = useState([])
|
|
42
42
|
const [showMore, setShowMore] = useState(50)
|
|
43
43
|
const { data, loading, fetchMore, error } = useQuery(GET_ALL_PRODUCT_STORE, {
|
|
44
|
-
fetchPolicy: fetchPolicy,
|
|
44
|
+
fetchPolicy: fetchPolicy ?? 'cache-and-network',
|
|
45
|
+
notifyOnNetworkStatusChange: true,
|
|
46
|
+
nextFetchPolicy: 'cache-first',
|
|
47
|
+
refetchWritePolicy: 'merge',
|
|
45
48
|
variables:
|
|
46
49
|
{
|
|
47
50
|
categories: categories || [],
|
|
@@ -55,9 +58,8 @@ export const useProductsFood = ({
|
|
|
55
58
|
toDate: toDate || null
|
|
56
59
|
}
|
|
57
60
|
})
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}, [data, productsFood])
|
|
61
|
+
|
|
62
|
+
const productsFood = data?.productFoodsAll
|
|
61
63
|
return [
|
|
62
64
|
productsFood, {
|
|
63
65
|
error,
|
|
@@ -690,7 +690,7 @@
|
|
|
690
690
|
var u = {
|
|
691
691
|
copyStyles: !0,
|
|
692
692
|
pageStyle:
|
|
693
|
-
"\n @page {\n /* Remove browser default header (title) and footer (url) */\n
|
|
693
|
+
"\n @page {\n /* Remove browser default header (title) and footer (url) */\n padding: 10px;\n }\n @media print {\n body {\n /* Tell browsers to print background colors */\n -webkit-print-color-adjust: exact; /* Chrome/Safari/Edge/Opera */\n color-adjust: exact; /* Firefox */\n }\n }\n ",
|
|
694
694
|
removeAfterPrint: !1,
|
|
695
695
|
suppressErrors: !1,
|
|
696
696
|
},
|
|
File without changes
|