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.
Files changed (42) hide show
  1. package/package.json +1 -1
  2. package/src/hooks/handleLogin/index.js +0 -1
  3. package/src/hooks/index.js +2 -0
  4. package/src/hooks/useCatWithProduct/queries.js +3 -2
  5. package/src/hooks/useCatWithProductClient/queries.js +1 -0
  6. package/src/hooks/useChartData/useChartDataAllOrders/index.js +2 -2
  7. package/src/hooks/useClients/queries.js +2 -2
  8. package/src/hooks/useCreateProduct/index.js +49 -12
  9. package/src/hooks/useDepartments/queries.js +5 -4
  10. package/src/hooks/useDevices/index.js +2 -35
  11. package/src/hooks/useDevices/useGetDevices.js +35 -0
  12. package/src/hooks/useDevices/useRegisterDevices.js +75 -0
  13. package/src/hooks/useImagesStore/queries.js +2 -0
  14. package/src/hooks/useInventory/index.js +2 -0
  15. package/src/hooks/useInventory/queries.js +58 -0
  16. package/src/hooks/useInventory/useGetProductsInStock.js +15 -0
  17. package/src/hooks/useInventory/useUpdateManageStock.js +41 -0
  18. package/src/hooks/useLocationManager/index.js +2 -2
  19. package/src/hooks/useLogout/helpers/index.js +0 -1
  20. package/src/hooks/useModules/helpers/index.js +1 -0
  21. package/src/hooks/useModules/helpers/validateModules.js +29 -0
  22. package/src/hooks/useModules/index.js +19 -3
  23. package/src/hooks/useOrders/queries.js +2 -2
  24. package/src/hooks/useProductsFood/index.js +8 -1
  25. package/src/hooks/useProductsFood/queriesStore.js +7 -8
  26. package/src/hooks/useSales/index.js +138 -52
  27. package/src/hooks/useSales/queries.js +2 -0
  28. package/src/hooks/useSetImageProducts/index.js +30 -0
  29. package/src/hooks/useSetImageProducts/queries.js +13 -0
  30. package/src/hooks/useStoreTable/index.js +2 -0
  31. package/src/hooks/useStoreTable/queries.js +47 -0
  32. package/src/hooks/useStoreTable/useStoreTableCreate.js +76 -0
  33. package/src/hooks/useStoreTable/useStoreTables.js +14 -0
  34. package/src/hooks/useSubscriptionValidation/index.js +0 -1
  35. package/src/hooks/useUpdateExistingOrders/index.js +2 -2
  36. package/src/hooks/useUpdateMultipleProducts/index.js +28 -7
  37. package/src/hooks/useUpdateMultipleProducts/queries.js +1 -1
  38. package/src/hooks/useUploadProducts/helpers/validateProductDataExcel.js +24 -16
  39. package/src/hooks/useUploadProducts/index.js +7 -4
  40. package/src/hooks/useUser/queries.js +6 -0
  41. package/src/index.jsx +3 -1
  42. 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
- type: 'string'
6
+ types: ['string']
7
7
  },
8
8
  {
9
9
  name: 'PRECIO_AL_PUBLICO',
10
10
  required: false,
11
- type: 'number'
11
+ types: ['number', 'string']
12
12
  },
13
13
  {
14
14
  name: 'VALOR_DE_COMPRA',
15
15
  required: false,
16
- type: 'number'
16
+ types: ['number', 'string']
17
17
  },
18
18
  {
19
19
  name: 'CANTIDAD',
20
20
  required: true,
21
- type: 'number'
21
+ types: ['number']
22
22
  },
23
23
  {
24
24
  name: 'DESCRIPCION',
25
25
  required: true,
26
- type: 'string'
26
+ types: ['string']
27
27
  },
28
28
  {
29
29
  name: 'DESCUENTO',
30
30
  required: false,
31
- type: 'number'
31
+ types: ['number', 'string']
32
32
  },
33
33
  {
34
34
  name: 'CATEGORIA',
35
35
  required: false,
36
- type: 'string'
36
+ types: ['string']
37
37
  },
38
38
  {
39
39
  name: 'CODIGO_DE_BARRAS',
40
40
  required: false,
41
- type: 'string'
41
+ types: ['string', 'number']
42
42
  },
43
43
  {
44
44
  name: 'IMPUESTO (%)',
45
45
  required: false,
46
- type: 'number'
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, type }) => {
54
- if (required && !(name in product)) {
55
- errors.push(`Producto ${productIndex + 1}: Faltan la columna requerida: ${name}.`)
56
- } else if (product[name] !== undefined) {
57
- const isValidType = typeof product[name] === type || (type === 'number' && typeof product[name] === 'number' && !isNaN(product[name]))
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 ${type}.`)
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 && Boolean(!data.length)) return setActive(0)
121
- if (active === STEPS.UPLOAD_FILE && Boolean(data.length)) return setActive(STEPS.UPLOAD_PRODUCTS)
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) => {
@@ -61,6 +61,7 @@ uPhoNum
61
61
  ULocation
62
62
  upLat
63
63
  uState
64
+ idRole
64
65
  upLon
65
66
  upIdeDoc
66
67
  siteWeb
@@ -69,6 +70,11 @@ associateStore
69
70
  createAt
70
71
  role {
71
72
  name
73
+ permissions
74
+ description
75
+ createdAt
76
+ updatedAt
77
+
72
78
  }
73
79
  }
74
80
  }
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 { version } from '../package.json'
9
+ export const version = packageJson.version
@@ -19,7 +19,7 @@ export const statusOrder = {
19
19
  2: 'PROCESO',
20
20
  3: 'LISTOS',
21
21
  4: 'CONCLUIDOS',
22
- 5: 'RECHAZADOS'
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: 0,
107
+ minimumFractionDigits: 2,
108
108
  style: 'decimal',
109
- maximumFractionDigits: 0
109
+ maximumFractionDigits: 2
110
110
  }).format(numberValue)
111
111
  }
112
112