npm-pkg-hook 1.4.2 → 1.4.3
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/useSales/index.js +36 -32
package/package.json
CHANGED
|
@@ -27,8 +27,9 @@ import {
|
|
|
27
27
|
import { updateExistingOrders } from '../useUpdateExistingOrders'
|
|
28
28
|
import { useGetSale } from './useGetSale'
|
|
29
29
|
import { convertToIntegerOrFloat } from './helpers'
|
|
30
|
-
import { useCatWithProduct } from './../useCatWithProduct/index'
|
|
31
|
-
import { useCheckboxState } from '../useCheckbox'
|
|
30
|
+
import { useCatWithProduct } from './../useCatWithProduct/index'
|
|
31
|
+
import { useCheckboxState } from '../useCheckbox'
|
|
32
|
+
import { useLogout } from '../useLogout'
|
|
32
33
|
export * from './useGetAllSales'
|
|
33
34
|
export { GET_ALL_COUNT_SALES } from './queries'
|
|
34
35
|
|
|
@@ -62,6 +63,8 @@ export const useSales = ({
|
|
|
62
63
|
const domain = getCurrentDomain()
|
|
63
64
|
const [loadingSale, setLoadingSale] = useState(false)
|
|
64
65
|
const [errorSale, setErrorSale] = useState(false)
|
|
66
|
+
const [onClickLogout] = useLogout({})
|
|
67
|
+
|
|
65
68
|
const [modalItem, setModalItem] = useState(false)
|
|
66
69
|
const [openCommentModal, setOpenCommentModal] = useState(false)
|
|
67
70
|
const keyToSaveData = process.env.LOCAL_SALES_STORE
|
|
@@ -74,7 +77,7 @@ export const useSales = ({
|
|
|
74
77
|
setCheckedItems,
|
|
75
78
|
handleChangeCheck
|
|
76
79
|
} = useCheckboxState(datCat, [], [])
|
|
77
|
-
|
|
80
|
+
const arr = checkedItems ? Array.from(checkedItems) : []
|
|
78
81
|
const [totalProductPrice, setTotalProductPrice] = useState(0)
|
|
79
82
|
const [showMore, setShowMore] = useState(100)
|
|
80
83
|
const [inputValue, setInputValue] = useState('')
|
|
@@ -117,6 +120,9 @@ export const useSales = ({
|
|
|
117
120
|
description: message
|
|
118
121
|
})
|
|
119
122
|
setAlertBox({ message, type: 'success' })
|
|
123
|
+
if (message === 'Token expired') {
|
|
124
|
+
onClickLogout()
|
|
125
|
+
}
|
|
120
126
|
setOpenCurrentSale(data?.registerSalesStore?.Response.success)
|
|
121
127
|
},
|
|
122
128
|
onError: (error) => {
|
|
@@ -188,12 +194,12 @@ export const useSales = ({
|
|
|
188
194
|
return setSearch(e.target.value)
|
|
189
195
|
}
|
|
190
196
|
const handleChange = (e, error) => {
|
|
191
|
-
const { name, value } = e.target
|
|
197
|
+
const { name, value } = e.target
|
|
192
198
|
setErrors({ ...errors, [e.target.name]: error })
|
|
193
199
|
setValues((prevValues) => ({
|
|
194
200
|
...prevValues,
|
|
195
|
-
[name]: value
|
|
196
|
-
}))
|
|
201
|
+
[name]: value
|
|
202
|
+
}))
|
|
197
203
|
}
|
|
198
204
|
const onChangeInput = (e) => {
|
|
199
205
|
return setValuesDates({ ...valuesDates, [e.target.name]: e.target.value })
|
|
@@ -462,15 +468,15 @@ export const useSales = ({
|
|
|
462
468
|
return { ...obj, ExtProductFoodsSubOptionalAll: filteredSubOptions }
|
|
463
469
|
})
|
|
464
470
|
.filter((obj) => obj !== null) // Elimine todos los objetos nulos del arreglo
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
471
|
+
const filteredDataExtra = dataExtra?.filter((p) => p?.quantity !== undefined && p?.quantity !== 0)
|
|
472
|
+
if (product?.PRODUCT?.pId) {
|
|
473
|
+
dispatch({
|
|
474
|
+
type: 'PUT_EXTRA_PRODUCTS_AND_OPTIONAL_PRODUCT',
|
|
475
|
+
payload: product.PRODUCT.pId,
|
|
476
|
+
dataOptional: filteredDataOptional,
|
|
477
|
+
dataExtra: filteredDataExtra
|
|
478
|
+
})
|
|
479
|
+
}
|
|
474
480
|
} catch (_error) {
|
|
475
481
|
return sendNotification({
|
|
476
482
|
title: 'Error',
|
|
@@ -480,31 +486,30 @@ export const useSales = ({
|
|
|
480
486
|
}
|
|
481
487
|
}
|
|
482
488
|
|
|
483
|
-
function handleIncrementExtra({ Adicionales, index }) {
|
|
484
|
-
const { pId } = product?.PRODUCT || {}
|
|
485
|
-
const exPid = Adicionales.exPid || null
|
|
489
|
+
function handleIncrementExtra ({ Adicionales, index }) {
|
|
490
|
+
const { pId } = product?.PRODUCT || {}
|
|
491
|
+
const exPid = Adicionales.exPid || null
|
|
486
492
|
|
|
487
493
|
if (exPid && pId) {
|
|
488
494
|
const newExtra = dataExtra.map((producto) => {
|
|
489
495
|
if (exPid === producto.exPid) {
|
|
490
|
-
const initialQuantity = producto?.quantity ? producto?.quantity : 0
|
|
491
|
-
const newQuantity = initialQuantity + 1
|
|
492
|
-
const newExtraPrice = producto.extraPrice * newQuantity
|
|
496
|
+
const initialQuantity = producto?.quantity ? producto?.quantity : 0
|
|
497
|
+
const newQuantity = initialQuantity + 1
|
|
498
|
+
const newExtraPrice = producto.extraPrice * newQuantity
|
|
493
499
|
|
|
494
500
|
return {
|
|
495
501
|
...producto,
|
|
496
502
|
quantity: newQuantity,
|
|
497
|
-
newExtraPrice
|
|
498
|
-
}
|
|
503
|
+
newExtraPrice
|
|
504
|
+
}
|
|
499
505
|
}
|
|
500
|
-
return producto
|
|
501
|
-
})
|
|
506
|
+
return producto
|
|
507
|
+
})
|
|
502
508
|
|
|
503
|
-
setDataExtra(newExtra)
|
|
509
|
+
setDataExtra(newExtra)
|
|
504
510
|
}
|
|
505
511
|
}
|
|
506
512
|
|
|
507
|
-
|
|
508
513
|
function handleDecrementExtra ({ Adicionales, index }) {
|
|
509
514
|
const { pId } = product?.PRODUCT || {}
|
|
510
515
|
const exPid = Adicionales.exPid || null
|
|
@@ -823,8 +828,7 @@ export const useSales = ({
|
|
|
823
828
|
const client = useApolloClient()
|
|
824
829
|
const { getOnePedidoStore } = useGetSale()
|
|
825
830
|
const handleSubmit = () => {
|
|
826
|
-
|
|
827
|
-
if (errors?.change || errors?.valueDelivery) {
|
|
831
|
+
if (errors?.change || errors?.valueDelivery) {
|
|
828
832
|
return sendNotification({
|
|
829
833
|
title: 'error',
|
|
830
834
|
backgroundColor: 'warning',
|
|
@@ -834,12 +838,12 @@ export const useSales = ({
|
|
|
834
838
|
setLoadingSale(true)
|
|
835
839
|
const code = RandomCode(10)
|
|
836
840
|
setCode(code)
|
|
837
|
-
function convertirAEntero(cadena) {
|
|
841
|
+
function convertirAEntero (cadena) {
|
|
838
842
|
if (typeof cadena === 'string') {
|
|
839
|
-
const numeroEntero = parseInt(cadena?.replace('.', ''))
|
|
843
|
+
const numeroEntero = parseInt(cadena?.replace('.', ''))
|
|
840
844
|
return numeroEntero
|
|
841
845
|
}
|
|
842
|
-
return cadena ||
|
|
846
|
+
return cadena || 0
|
|
843
847
|
}
|
|
844
848
|
return registerSalesStore({
|
|
845
849
|
variables: {
|