From 8f4bcf1df95ee7d43a9288e37407e752f7477c6a Mon Sep 17 00:00:00 2001 From: alfonso Date: Thu, 3 Aug 2023 10:02:19 -0500 Subject: [PATCH] Fixed form: AmazonNoPartes Fraccion + subdivision also validated with public web service --- .../Amazon/Reportes/AmazonNoPartes.tsx | 130 ++++++++++-------- src/Components/Utils/Toast/msgInformativo.tsx | 4 +- 2 files changed, 76 insertions(+), 58 deletions(-) diff --git a/src/Components/Clientes/Amazon/Reportes/AmazonNoPartes.tsx b/src/Components/Clientes/Amazon/Reportes/AmazonNoPartes.tsx index 1c8396e..77b59d7 100644 --- a/src/Components/Clientes/Amazon/Reportes/AmazonNoPartes.tsx +++ b/src/Components/Clientes/Amazon/Reportes/AmazonNoPartes.tsx @@ -35,10 +35,13 @@ export default function AmazonNoPartes(props: IAmazonNoPartesProps) { const [NoParteLOG, setNoParteLOG] = useState([]) const [PaisClaves, setPaisClaves] = useState([]) const [Data, setData] = useState([]) - const [DataNoParteVerificacion, setDataNoParteVeriifcacion] = useState([]) + const [DataNoParteVerificacion, setDataNoParteVeriifcacion] = useState< + DTO2096NoParteVerificacion[] + >([]) const [ShowModal, setShowModal] = useState(false) const [ShowModalLog, setShowModalLog] = useState(false) - const [ShowModalNoParteVerificacion, setShowModalNoParteVerificacion] = useState(false) + const [ShowModalNoParteVerificacion, setShowModalNoParteVerificacion] = + useState(false) const [header, setHeader] = useState('') const [msgColor, setMsgColor] = useState('primary') const [show, setShowMsg] = useState(false) @@ -81,12 +84,11 @@ export default function AmazonNoPartes(props: IAmazonNoPartesProps) {
{ loadDataNoParteVerificacion(row) setShowModalNoParteVerificacion(true) - }} > @@ -166,13 +168,15 @@ export default function AmazonNoPartes(props: IAmazonNoPartesProps) { { name: 'UMF', width: '80px', - selector: (row: I2096NoParte) => row.unidadMedidaFactura ? row.unidadMedidaFactura : '', + selector: (row: I2096NoParte) => + row.unidadMedidaFactura ? row.unidadMedidaFactura : '', sortable: true }, { name: 'UMC', width: '80px', - selector: (row: I2096NoParte) => row.unidadMedidaCOVE ? row.unidadMedidaCOVE : '', + selector: (row: I2096NoParte) => + row.unidadMedidaCOVE ? row.unidadMedidaCOVE : '', sortable: true }, { @@ -215,7 +219,8 @@ export default function AmazonNoPartes(props: IAmazonNoPartesProps) { { name: 'Fracc Original', width: '130px', - cell: (row: I2096NoParteLog) => row.fraccionOriginal ? row.fraccionOriginal : '', + cell: (row: I2096NoParteLog) => + row.fraccionOriginal ? row.fraccionOriginal : '', sortable: true }, { @@ -228,7 +233,8 @@ export default function AmazonNoPartes(props: IAmazonNoPartesProps) { { name: 'NICO Original', width: '130px', - cell: (row: I2096NoParteLog) => row.subdivisionOriginal ? row.subdivisionOriginal : '', + cell: (row: I2096NoParteLog) => + row.subdivisionOriginal ? row.subdivisionOriginal : '', sortable: true, center: true }, @@ -237,7 +243,7 @@ export default function AmazonNoPartes(props: IAmazonNoPartesProps) { width: '250px', cell: (row: I2096NoParteLog) => row.descripcionAgenteAduanal, wrap: true, - sortable: true, + sortable: true }, { name: 'Desc Original', @@ -246,7 +252,7 @@ export default function AmazonNoPartes(props: IAmazonNoPartesProps) { wrap: true, sorteable: true }, - + { name: 'Fecha / Hora', width: '200px', @@ -256,7 +262,7 @@ export default function AmazonNoPartes(props: IAmazonNoPartesProps) { { name: 'Usuario', width: '300px', - cell: (row: I2096NoParteLog) => row.sUsuario ? row.sUsuario : '', + cell: (row: I2096NoParteLog) => (row.sUsuario ? row.sUsuario : ''), wrap: true, sortable: true } @@ -294,7 +300,7 @@ export default function AmazonNoPartes(props: IAmazonNoPartesProps) { width: '100px', cell: (row: DTO2096NoParteVerificacion) => row.aduana, wrap: true, - sortable: true, + sortable: true }, { name: 'Pedimento', @@ -305,7 +311,6 @@ export default function AmazonNoPartes(props: IAmazonNoPartesProps) { } ] - const openLink = (item: string) => { window.open('https://www.amazon.com/dp/' + item) } @@ -315,7 +320,7 @@ export default function AmazonNoPartes(props: IAmazonNoPartesProps) { if (Id === 0) return NoAsignado else if (Data.length) { const Usuario = Data.filter((item) => item.idUsuario === Id) - return Usuario ? Usuario[0].nombre : NoAsignado + return Usuario.length ? Usuario[0].nombre : NoAsignado } return NoAsignado } @@ -396,6 +401,7 @@ export default function AmazonNoPartes(props: IAmazonNoPartesProps) { } AmazonDS.NoPartesGet(Search) .then((response) => { + console.log(response.data) dispatch(populateNoPartes(response.data)) }) .catch((e: Error) => { @@ -417,11 +423,23 @@ export default function AmazonNoPartes(props: IAmazonNoPartesProps) { AmazonDS.NoPartesUpdate(data) .then((response) => { dispatch(updateNoPartes(response.data)) + setHeader('Informativo') + setMsg('La informacion se guardo correctamente') + setShowMsg(true) }) - .catch((e: Error) => { + .catch(function(error) { + console.log(error.toJSON()) + if (error.message == 'Request failed with status code 400') { + setHeader('Error') + setMsg('Fraccion no valida!') + setShowMsg(true) + } + /* console.log(error.toJSON()) + const errorMessage = error?.response?.data?.message + const message = errorMessage setHeader('Error') - setMsg('Ocurrio un error: ' + e) - setShowMsg(true) + setMsg(message) + setShowMsg(true) */ return }) } @@ -616,26 +634,26 @@ export default function AmazonNoPartes(props: IAmazonNoPartesProps) { No Parte: {Parte} - {/*
*/} - - - 0 - })} - /> - - - {/*
*/} + {/*
*/} + + + 0 + })} + /> + + + {/*
*/}
@@ -651,25 +669,25 @@ export default function AmazonNoPartes(props: IAmazonNoPartesProps) { No Parte: {Search} - - - - - - {/*
*/} + + + + + + {/* */} = (props) => { return (
- - +