npm-pkg-hook 1.10.2 → 1.10.6
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/package.json +1 -1
- package/src/hooks/index.js +7 -0
- package/src/hooks/useCatWithProduct/queries.js +3 -2
- package/src/hooks/useCatWithProductClient/queries.js +1 -0
- package/src/hooks/useChartData/useChartDataAllOrders/index.js +1 -1
- package/src/hooks/useCreateProduct/index.js +35 -13
- package/src/hooks/useDepartments/queries.js +5 -4
- package/src/hooks/useImagesStore/queries.js +1 -65
- package/src/hooks/useInventory/index.js +2 -0
- package/src/hooks/useInventory/queries.js +58 -0
- package/src/hooks/useInventory/useGetProductsInStock.js +15 -0
- package/src/hooks/useInventory/useUpdateManageStock.js +41 -0
- package/src/hooks/useLocationManager/index.js +2 -2
- package/src/hooks/useModules/helpers/validateModules.js +15 -15
- package/src/hooks/useOrders/queries.js +1 -1
- package/src/hooks/useProductsFood/index.js +13 -5
- package/src/hooks/useProductsFood/queriesStore.js +20 -9
- package/src/hooks/useReport/index.js +1 -1
- package/src/hooks/useSales/index.js +130 -41
- package/src/hooks/useSetImageProducts/index.js +30 -0
- package/src/hooks/useSetImageProducts/queries.js +13 -0
- package/src/hooks/useStockMovements/helpers/index.js +16 -0
- package/src/hooks/useStockMovements/index.js +36 -0
- package/src/hooks/useTopProductsMovements/index.js +27 -0
- package/src/hooks/useTotalAllSales/index.js +25 -0
- package/src/hooks/useTotalProductsInStock/index.js +23 -0
- package/src/hooks/useTotalProductsSold/index.js +23 -0
- package/src/hooks/useTotalProductsSolded/index.js +20 -0
- package/src/hooks/useUpdateExistingOrders/index.js +1 -1
- package/src/hooks/useUpdateMultipleProducts/index.js +29 -8
- package/src/hooks/useUpdateMultipleProducts/queries.js +1 -1
- package/src/hooks/useUploadProducts/helpers/validateProductDataExcel.js +24 -16
- package/src/hooks/useUploadProducts/index.js +9 -4
- package/src/hooks/useUser/queries.js +1 -2
- package/src/index.jsx +3 -1
- package/src/utils/index.js +2 -5
|
@@ -3,60 +3,68 @@ export const validateProductDataExcel = (product, productIndex) => {
|
|
|
3
3
|
{
|
|
4
4
|
name: 'NOMBRE',
|
|
5
5
|
required: true,
|
|
6
|
-
|
|
6
|
+
types: ['string']
|
|
7
7
|
},
|
|
8
8
|
{
|
|
9
9
|
name: 'PRECIO_AL_PUBLICO',
|
|
10
10
|
required: false,
|
|
11
|
-
|
|
11
|
+
types: ['number', 'string']
|
|
12
12
|
},
|
|
13
13
|
{
|
|
14
14
|
name: 'VALOR_DE_COMPRA',
|
|
15
15
|
required: false,
|
|
16
|
-
|
|
16
|
+
types: ['number', 'string']
|
|
17
17
|
},
|
|
18
18
|
{
|
|
19
19
|
name: 'CANTIDAD',
|
|
20
20
|
required: true,
|
|
21
|
-
|
|
21
|
+
types: ['number']
|
|
22
22
|
},
|
|
23
23
|
{
|
|
24
24
|
name: 'DESCRIPCION',
|
|
25
25
|
required: true,
|
|
26
|
-
|
|
26
|
+
types: ['string']
|
|
27
27
|
},
|
|
28
28
|
{
|
|
29
29
|
name: 'DESCUENTO',
|
|
30
30
|
required: false,
|
|
31
|
-
|
|
31
|
+
types: ['number', 'string']
|
|
32
32
|
},
|
|
33
33
|
{
|
|
34
34
|
name: 'CATEGORIA',
|
|
35
35
|
required: false,
|
|
36
|
-
|
|
36
|
+
types: ['string']
|
|
37
37
|
},
|
|
38
38
|
{
|
|
39
39
|
name: 'CODIGO_DE_BARRAS',
|
|
40
40
|
required: false,
|
|
41
|
-
|
|
41
|
+
types: ['string', 'number']
|
|
42
42
|
},
|
|
43
43
|
{
|
|
44
44
|
name: 'IMPUESTO (%)',
|
|
45
45
|
required: false,
|
|
46
|
-
|
|
46
|
+
types: ['number', 'string']
|
|
47
47
|
}
|
|
48
48
|
]
|
|
49
49
|
|
|
50
50
|
const errors = []
|
|
51
51
|
|
|
52
|
-
// Validar encabezados requeridos
|
|
53
|
-
expectedHeaders.forEach(({ name, required,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
52
|
+
// Validar encabezados requeridos y tipos
|
|
53
|
+
expectedHeaders.forEach(({ name, required, types }) => {
|
|
54
|
+
const value = product[name]
|
|
55
|
+
|
|
56
|
+
if (required && (value === undefined || value === null)) {
|
|
57
|
+
errors.push(`Producto ${productIndex + 1}: Falta la columna requerida: ${name}.`)
|
|
58
|
+
} else if (value !== undefined && value !== null) {
|
|
59
|
+
const isValidType = types.some(type => {
|
|
60
|
+
if (type === 'number') {
|
|
61
|
+
return typeof value === 'number' && !isNaN(value)
|
|
62
|
+
}
|
|
63
|
+
return typeof value === type
|
|
64
|
+
})
|
|
65
|
+
|
|
58
66
|
if (!isValidType) {
|
|
59
|
-
errors.push(`Producto ${productIndex + 1}: El campo ${name} debe ser de tipo ${
|
|
67
|
+
errors.push(`Producto ${productIndex + 1}: El campo ${name} debe ser de tipo ${types.join(' o ')}.`)
|
|
60
68
|
}
|
|
61
69
|
}
|
|
62
70
|
})
|
|
@@ -10,8 +10,11 @@ const STEPS = {
|
|
|
10
10
|
|
|
11
11
|
export const useUploadProducts = ({
|
|
12
12
|
sendNotification = () => { return null }
|
|
13
|
-
} = {
|
|
13
|
+
} = {
|
|
14
|
+
sendNotification: () => { return null }
|
|
15
|
+
}) => {
|
|
14
16
|
const [data, setData] = useState([])
|
|
17
|
+
console.log("🚀 ~ data:", data)
|
|
15
18
|
const [isLoading, setIsLoading] = useState(false)
|
|
16
19
|
const [active, setActive] = useState(STEPS.UPLOAD_FILE)
|
|
17
20
|
const [overActive, setOverActive] = useState(STEPS.UPLOAD_FILE)
|
|
@@ -19,7 +22,6 @@ export const useUploadProducts = ({
|
|
|
19
22
|
const handleOverActive = (index) => {
|
|
20
23
|
setOverActive(index)
|
|
21
24
|
}
|
|
22
|
-
|
|
23
25
|
const readExcelFile = (file) => {
|
|
24
26
|
return new Promise((resolve, reject) => {
|
|
25
27
|
const reader = new FileReader()
|
|
@@ -57,7 +59,9 @@ export const useUploadProducts = ({
|
|
|
57
59
|
pCode: code,
|
|
58
60
|
editing: false,
|
|
59
61
|
PRECIO_AL_PUBLICO,
|
|
62
|
+
ProImage: '/images/placeholder-image.webp',
|
|
60
63
|
VALOR_DE_COMPRA,
|
|
64
|
+
manageStock: true,
|
|
61
65
|
errors: validationErrors.length > 0 ? validationErrors : null
|
|
62
66
|
}
|
|
63
67
|
})
|
|
@@ -117,8 +121,9 @@ export const useUploadProducts = ({
|
|
|
117
121
|
})
|
|
118
122
|
return
|
|
119
123
|
}
|
|
120
|
-
if (active === STEPS.UPLOAD_FILE
|
|
121
|
-
|
|
124
|
+
if (active === STEPS.UPLOAD_FILE) {
|
|
125
|
+
setActive(data.length ? STEPS.UPLOAD_PRODUCTS : 0)
|
|
126
|
+
}
|
|
122
127
|
}
|
|
123
128
|
|
|
124
129
|
const updateProductQuantity = (index, quantityChange) => {
|
|
@@ -56,12 +56,12 @@ username
|
|
|
56
56
|
lastName
|
|
57
57
|
email
|
|
58
58
|
avatar
|
|
59
|
-
idRole
|
|
60
59
|
uToken
|
|
61
60
|
uPhoNum
|
|
62
61
|
ULocation
|
|
63
62
|
upLat
|
|
64
63
|
uState
|
|
64
|
+
idRole
|
|
65
65
|
upLon
|
|
66
66
|
upIdeDoc
|
|
67
67
|
siteWeb
|
|
@@ -70,7 +70,6 @@ associateStore
|
|
|
70
70
|
createAt
|
|
71
71
|
role {
|
|
72
72
|
name
|
|
73
|
-
idRole,
|
|
74
73
|
permissions
|
|
75
74
|
description
|
|
76
75
|
createdAt
|
package/src/index.jsx
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import packageJson from '../package.json'
|
|
2
|
+
|
|
1
3
|
export * from './hooks/index'
|
|
2
4
|
export * from './utils'
|
|
3
5
|
export * from './cookies'
|
|
4
6
|
export * from './security/index'
|
|
5
7
|
|
|
6
8
|
// version
|
|
7
|
-
export
|
|
9
|
+
export const version = packageJson.version
|
package/src/utils/index.js
CHANGED
|
@@ -84,9 +84,6 @@ export const updateCacheMod = async ({ cache, query, nameFun, dataNew, type, id
|
|
|
84
84
|
}
|
|
85
85
|
})
|
|
86
86
|
}
|
|
87
|
-
const initialState = {}
|
|
88
|
-
export const initializer = (initialValue = initialState) => { return JSON.parse(localStorage.getItem(process.env.LOCAL_SALES_STORE)) || initialValue }
|
|
89
|
-
|
|
90
87
|
/**
|
|
91
88
|
* Formatea un valor como un número siguiendo el formato de Colombia.
|
|
92
89
|
* Si el valor no es un número válido, lo devuelve tal como está.
|
|
@@ -107,9 +104,9 @@ export const numberFormat = value => {
|
|
|
107
104
|
const numberValue = parseFloat(stringValue)
|
|
108
105
|
if (!isNaN(numberValue)) {
|
|
109
106
|
return new Intl.NumberFormat('es-CO', {
|
|
110
|
-
minimumFractionDigits:
|
|
107
|
+
minimumFractionDigits: 2,
|
|
111
108
|
style: 'decimal',
|
|
112
|
-
maximumFractionDigits:
|
|
109
|
+
maximumFractionDigits: 2
|
|
113
110
|
}).format(numberValue)
|
|
114
111
|
}
|
|
115
112
|
|