From b8a609ad0a33204d5779222f436fe13dd5fb181a Mon Sep 17 00:00:00 2001 From: yoelmarain Date: Mon, 18 Nov 2024 17:10:01 -0300 Subject: [PATCH] =?UTF-8?q?fix:=20:boom:=20agregar=20verificaci=C3=B3n=20d?= =?UTF-8?q?e=20cuotas=20adeudadas=20antes=20de=20firmar=20compromiso=20de?= =?UTF-8?q?=20pago?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Pages-Alumnos/CompromisoDePago.tsx | 40 +++++++++++++++---- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/FrontAdmin/src/components/Pages-Alumnos/CompromisoDePago.tsx b/FrontAdmin/src/components/Pages-Alumnos/CompromisoDePago.tsx index 6406dffd..5e58e391 100644 --- a/FrontAdmin/src/components/Pages-Alumnos/CompromisoDePago.tsx +++ b/FrontAdmin/src/components/Pages-Alumnos/CompromisoDePago.tsx @@ -15,10 +15,13 @@ import { Skeleton, TableContainer, Icon, - Button + Button, + Alert, + AlertIcon } from '@chakra-ui/react'; import { DownloadIcon, ViewIcon } from '@chakra-ui/icons'; import { FetchCompromisos, FetchUltimoCompromiso, FirmarCompromiso } from "../../API-Alumnos/Compromiso"; +import { FetchGetCuotas } from "../../API-Alumnos/Pagos"; import {useEffect, useState} from 'react'; import {formatoFechaISOaDDMMAAAA} from "../../utils/general"; import { useToast } from "../Toast/useToast"; @@ -28,6 +31,7 @@ export default function CompromisoDePago() { const [compromisos, setCompromisos] = useState([]); const [ultimoCompromiso, setUltimoCompromiso] = useState(false); +const [adeuda, setAdeuda] = useState(false); const [ultimo, setUltimo] = useState([]); const [refresh, setRefresh] = useState(false); const [pdfUrl, setPdfUrl] = useState(null); @@ -53,7 +57,8 @@ const handleViewPdf = async (url: string) => { useEffect(() => { const fetchCompromisos = async () => { try{ - const data = await FetchCompromisos(); + const dni = Number(Cookies.get('dni')); + const data = await FetchCompromisos(dni); setCompromisos(data.results); console.log(data); } catch (error) { @@ -72,6 +77,19 @@ useEffect(() => { } fetchUltimoCompromiso(); + const fetchAdeuda = async () => { + try { + const dni = Number(Cookies.get('dni')); + const data = await FetchGetCuotas(dni); + if (data.length > 0) { + setAdeuda(true); + } + } catch (error) { + console.log(error); + } + } + fetchAdeuda(); + }, [refresh]); @@ -107,10 +125,18 @@ const handleFirmar = async () => { return ( - {ultimoCompromiso && - - El compromiso de pago del periodo actual ya se encuentra firmado ({formatoFechaISOaDDMMAAAA(ultimo.fecha_firmado)}). - + {ultimoCompromiso && + + + El compromiso de pago del periodo actual ya se encuentra firmado ({formatoFechaISOaDDMMAAAA(ultimo.fecha_firmado)}). + + + } + {!ultimoCompromiso && adeuda && + + + Aun adeuda cuotas. No puede firmar el compromiso de pago. + } @@ -130,7 +156,7 @@ return ( - +