From 9a45e404ac13385270969c4cb3f71460d8819acf Mon Sep 17 00:00:00 2001 From: alfonso Date: Fri, 4 Aug 2023 15:49:06 -0500 Subject: [PATCH] Added delete feature to NoPartes Catalog --- package.json | 2 +- .../Amazon/Reportes/AmazonNoPartes.tsx | 90 +++++++++++++++++-- .../Amazon/Services/Amazon.Services.ts | 3 + src/Components/Utils/Toast/msgInformativo.tsx | 2 +- 4 files changed, 87 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 17f330d..5784264 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,7 @@ "start-dev": "env-cmd -f .env.development react-scripts start", "start-qa": "env-cmd -f .env.qa react-scripts start", "start-prod": "env-cmd -f .env.production react-scripts start", - "build-qa": "env-cmd -f .env.qa react-scripts build", + "build-qa": "env-cmd -f .env.qa react-scripts -version -patch build", "build-prod": "env-cmd -f .env.production react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject" diff --git a/src/Components/Clientes/Amazon/Reportes/AmazonNoPartes.tsx b/src/Components/Clientes/Amazon/Reportes/AmazonNoPartes.tsx index 77b59d7..8c02df9 100644 --- a/src/Components/Clientes/Amazon/Reportes/AmazonNoPartes.tsx +++ b/src/Components/Clientes/Amazon/Reportes/AmazonNoPartes.tsx @@ -4,6 +4,7 @@ import DataTable from 'react-data-table-component' import I2096NoParte from '../Interfaces/I2096NoParte' import AmazonDS from '../Services/Amazon.Services' import { + deleteNoPartes, populateNoPartes, updateNoPartes } from '../../../../store/features/Clientes/2096/AmazonNoPartes' @@ -12,7 +13,7 @@ import { useDispatch, useSelector } from 'react-redux' import { useEffect, useState } from 'react' import { MsgInformativo } from '../../../Utils/Toast/msgInformativo' import { IconContext } from 'react-icons' -import { BsFillPencilFill } from 'react-icons/bs' +import { BsFillPencilFill, BsFillXCircleFill } from 'react-icons/bs' import I2096PaisClave from '../Interfaces/I2096PaisClave' import DTO2096PerfilesParecidos from '../DTO/DTO2096PerfilesParecidos' @@ -42,6 +43,7 @@ export default function AmazonNoPartes(props: IAmazonNoPartesProps) { const [ShowModalLog, setShowModalLog] = useState(false) const [ShowModalNoParteVerificacion, setShowModalNoParteVerificacion] = useState(false) + const [ShowModalDelete, setShowModalDelete] = useState(false) const [header, setHeader] = useState('') const [msgColor, setMsgColor] = useState('primary') const [show, setShowMsg] = useState(false) @@ -76,6 +78,30 @@ export default function AmazonNoPartes(props: IAmazonNoPartesProps) { ), sortable: true }, + { + name: '', + width: '60px', + cell: (row: I2096NoParte) => ( + + +
{ + setIDParte(row.id) + setShowModalDelete(true) + }} + > + + + +
+ +
+ ), + sortable: true + }, { name: '', width: '60px', @@ -427,19 +453,32 @@ export default function AmazonNoPartes(props: IAmazonNoPartesProps) { setMsg('La informacion se guardo correctamente') setShowMsg(true) }) - .catch(function(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) + } + return + }) + } + + const deleteNoParte = () => { + AmazonDS.DeleteNoParte(IDParte) + .then((response) => { + dispatch(deleteNoPartes(IDParte)) + setHeader('Informativo') + setMsg('La informacion se guardo correctamente') + setShowMsg(true) + }) + .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(message) - setShowMsg(true) */ return }) } @@ -690,6 +729,41 @@ export default function AmazonNoPartes(props: IAmazonNoPartesProps) { {/* */} + + { + setShowModalDelete(false) + }} + size={'sm'} + dialogClassName={'modal-50w'} + > + + + + + +

¿Esta seguro de eliminar el no parte: {Parte}

+
+ +
+
+
+ + + + + + + + + + + + {/* */} + +
+ (`/AmazonInvoice/Bot/Clasificacion?id=${id}`) } + DeleteNoParte(id: number) { + return http.delete(`/AmazonInvoice/DeleteNoParte?id=${id}`) + } } export default new AmazonDataService() diff --git a/src/Components/Utils/Toast/msgInformativo.tsx b/src/Components/Utils/Toast/msgInformativo.tsx index f75f300..0b07e51 100644 --- a/src/Components/Utils/Toast/msgInformativo.tsx +++ b/src/Components/Utils/Toast/msgInformativo.tsx @@ -15,7 +15,7 @@ interface IProps { export const MsgInformativo: FC = (props) => { return (
- +