npm-pkg-hook 1.10.1 → 1.10.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/package.json +1 -1
- package/src/hooks/handleLogin/index.js +0 -1
- package/src/hooks/index.js +2 -0
- package/src/hooks/useCatWithProduct/queries.js +3 -2
- package/src/hooks/useCatWithProductClient/queries.js +1 -0
- package/src/hooks/useChartData/useChartDataAllOrders/index.js +2 -2
- package/src/hooks/useClients/queries.js +2 -2
- package/src/hooks/useCreateProduct/index.js +49 -12
- package/src/hooks/useDepartments/queries.js +5 -4
- package/src/hooks/useDevices/index.js +2 -35
- package/src/hooks/useDevices/useGetDevices.js +35 -0
- package/src/hooks/useDevices/useRegisterDevices.js +75 -0
- package/src/hooks/useImagesStore/queries.js +2 -0
- 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/useLogout/helpers/index.js +0 -1
- package/src/hooks/useModules/helpers/index.js +1 -0
- package/src/hooks/useModules/helpers/validateModules.js +29 -0
- package/src/hooks/useModules/index.js +19 -3
- package/src/hooks/useOrders/queries.js +2 -2
- package/src/hooks/useProductsFood/index.js +8 -1
- package/src/hooks/useProductsFood/queriesStore.js +7 -8
- package/src/hooks/useSales/index.js +138 -52
- package/src/hooks/useSales/queries.js +2 -0
- package/src/hooks/useSetImageProducts/index.js +30 -0
- package/src/hooks/useSetImageProducts/queries.js +13 -0
- package/src/hooks/useStoreTable/index.js +2 -0
- package/src/hooks/useStoreTable/queries.js +47 -0
- package/src/hooks/useStoreTable/useStoreTableCreate.js +76 -0
- package/src/hooks/useStoreTable/useStoreTables.js +14 -0
- package/src/hooks/useSubscriptionValidation/index.js +0 -1
- package/src/hooks/useUpdateExistingOrders/index.js +2 -2
- package/src/hooks/useUpdateMultipleProducts/index.js +28 -7
- package/src/hooks/useUpdateMultipleProducts/queries.js +1 -1
- package/src/hooks/useUploadProducts/helpers/validateProductDataExcel.js +24 -16
- package/src/hooks/useUploadProducts/index.js +7 -4
- package/src/hooks/useUser/queries.js +6 -0
- package/src/index.jsx +3 -1
- package/src/utils/index.js +6 -6
|
@@ -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()
|
|
@@ -117,8 +119,9 @@ export const useUploadProducts = ({
|
|
|
117
119
|
})
|
|
118
120
|
return
|
|
119
121
|
}
|
|
120
|
-
if (active === STEPS.UPLOAD_FILE
|
|
121
|
-
|
|
122
|
+
if (active === STEPS.UPLOAD_FILE) {
|
|
123
|
+
setActive(data.length ? STEPS.UPLOAD_PRODUCTS : 0)
|
|
124
|
+
}
|
|
122
125
|
}
|
|
123
126
|
|
|
124
127
|
const updateProductQuantity = (index, quantityChange) => {
|
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
|
@@ -19,7 +19,7 @@ export const statusOrder = {
|
|
|
19
19
|
2: 'PROCESO',
|
|
20
20
|
3: 'LISTOS',
|
|
21
21
|
4: 'CONCLUIDOS',
|
|
22
|
-
5: '
|
|
22
|
+
5: 'REJECTED'
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export const statusProduct = {
|
|
@@ -28,6 +28,9 @@ export const statusProduct = {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
export const validationSubmitHooks = elements => {
|
|
31
|
+
if (!elements || elements.length === 0) {
|
|
32
|
+
return {}
|
|
33
|
+
}
|
|
31
34
|
let errorForm = {}
|
|
32
35
|
|
|
33
36
|
for (const element of elements) {
|
|
@@ -81,9 +84,6 @@ export const updateCacheMod = async ({ cache, query, nameFun, dataNew, type, id
|
|
|
81
84
|
}
|
|
82
85
|
})
|
|
83
86
|
}
|
|
84
|
-
const initialState = {}
|
|
85
|
-
export const initializer = (initialValue = initialState) => { return JSON.parse(localStorage.getItem(process.env.LOCAL_SALES_STORE)) || initialValue }
|
|
86
|
-
|
|
87
87
|
/**
|
|
88
88
|
* Formatea un valor como un número siguiendo el formato de Colombia.
|
|
89
89
|
* Si el valor no es un número válido, lo devuelve tal como está.
|
|
@@ -104,9 +104,9 @@ export const numberFormat = value => {
|
|
|
104
104
|
const numberValue = parseFloat(stringValue)
|
|
105
105
|
if (!isNaN(numberValue)) {
|
|
106
106
|
return new Intl.NumberFormat('es-CO', {
|
|
107
|
-
minimumFractionDigits:
|
|
107
|
+
minimumFractionDigits: 2,
|
|
108
108
|
style: 'decimal',
|
|
109
|
-
maximumFractionDigits:
|
|
109
|
+
maximumFractionDigits: 2
|
|
110
110
|
}).format(numberValue)
|
|
111
111
|
}
|
|
112
112
|
|