From 651e2e9cab7fa07a97a6fb9ddbfbba85a1d76a00 Mon Sep 17 00:00:00 2001 From: Felix Morales Date: Thu, 28 Sep 2023 16:29:09 -0500 Subject: [PATCH] Cambiar el campo clave de pedimento por un select --- .../Corresponsales/TraficoCorresponsales.tsx | 39 ++++++++++++++----- .../Catalogos/ICatClavesPedimentos.ts | 5 +++ .../Catalogos/ClavesPedimentos.Service.ts | 10 +++++ 3 files changed, 45 insertions(+), 9 deletions(-) create mode 100644 src/Interfaces/Catalogos/ICatClavesPedimentos.ts create mode 100644 src/Services/Catalogos/ClavesPedimentos.Service.ts diff --git a/src/Components/Corresponsales/TraficoCorresponsales.tsx b/src/Components/Corresponsales/TraficoCorresponsales.tsx index 25eb335..71dc21f 100644 --- a/src/Components/Corresponsales/TraficoCorresponsales.tsx +++ b/src/Components/Corresponsales/TraficoCorresponsales.tsx @@ -115,6 +115,8 @@ import { ITiposMercancias } from '../../Interfaces/Catalogos/ICatTiposMercancias import axios from 'axios' import { TargetURL } from '../../Constants/TargetURL' import CentrosCostosService from '../../Services/Catalogos/CentrosCostos.Service' +import ClavesPedimentosService from '../../Services/Catalogos/ClavesPedimentos.Service' +import { ICatClavesPedimentos } from '../../Interfaces/Catalogos/ICatClavesPedimentos' interface IProps { IDTrafico: number @@ -310,7 +312,7 @@ export default function TraficoCorresponsales (props:IProps) { const [EncabezadoPedimento1, setEncabezadoPedimento1] = useState("Pedimento"); const [EncabezadoPedimento2, setEncabezadoPedimento2] = useState("."); const [CentroCostos, setCentroCostos] = useState(''); - + const [ClavesPedimentos, setClavesPedimentos] = useState([]) const FechaRegistro = currentDate() const msgColor = 'primary' @@ -522,6 +524,14 @@ export default function TraficoCorresponsales (props:IProps) { } const LoadEverything = () => { + ClavesPedimentosService.getAllClavesPedimentos() + .then(response => setClavesPedimentos(response.data)) + .catch((e: Error) => { + setHeader('Error') + setMsg('Ocurrio un error: ' + e) + setShowMsg(true) + return + }) CorresponsalesDataService.getAll() .then((response) => { dispatch(populateCatCorresponsales(response.data)) @@ -1921,15 +1931,26 @@ export default function TraficoCorresponsales (props:IProps) { Clave { + setClavePedimento(e.target.value) + }} + className="form-select form-select-sm" value={ClavePedimento} - disabled={ - Depto !== 'Corresponsalias' ? true : false - } - onChange={(e) => {if(e.target.value.length <= 2) setClavePedimento(e.target.value)}} - /> + disabled={(Depto !== 'Corresponsalias')} + > + + {ClavesPedimentos + ? ClavesPedimentos.map((item, index) => { + return ( + + ) + }) + : ''} + diff --git a/src/Interfaces/Catalogos/ICatClavesPedimentos.ts b/src/Interfaces/Catalogos/ICatClavesPedimentos.ts new file mode 100644 index 0000000..5d48df5 --- /dev/null +++ b/src/Interfaces/Catalogos/ICatClavesPedimentos.ts @@ -0,0 +1,5 @@ +export interface ICatClavesPedimentos{ + id: number; + clave: string; + descripcion: string; +} \ No newline at end of file diff --git a/src/Services/Catalogos/ClavesPedimentos.Service.ts b/src/Services/Catalogos/ClavesPedimentos.Service.ts new file mode 100644 index 0000000..361871f --- /dev/null +++ b/src/Services/Catalogos/ClavesPedimentos.Service.ts @@ -0,0 +1,10 @@ +import http from "../common/http-common"; +import { ICatClavesPedimentos } from "../../Interfaces/Catalogos/ICatClavesPedimentos"; + +class ClavesPedimentosService{ + getAllClavesPedimentos(){ + return http.get('/Catalogos/CatClavesPedimentos/GetAll'); + } +} + +export default new ClavesPedimentosService(); \ No newline at end of file