Skip to content

Commit

Permalink
feat: Add FetchGetCuotas function to fetch cuotas for a specific alumno
Browse files Browse the repository at this point in the history
  • Loading branch information
yoelmarain committed Sep 23, 2024
1 parent 1e948be commit 49e40ae
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
24 changes: 24 additions & 0 deletions FrontAdmin/src/API-Alumnos/Pagos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,30 @@ export const FetchPostPago = async (
}
};

export const FetchGetCuotas = async () => {
try {
const token = Cookies.get('tokennn');
const dni = Cookies.get('dni');

const response = await fetch(`http://localhost:8000/api/pagos/alumno/${dni}`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`,
},
});

if (response.ok) {
const data = await response.json();
return data;
} else {
throw new Error('Error en la respuesta del servidor');
}
} catch (error) {
throw new Error('Network error: ' + error);
}
};

const cuotas = [
{
numero: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { Box, Table, Thead, Tbody, Tr, Th, Td, Flex, Text, Badge, Checkbox, Inpu
import { EditIcon, DeleteIcon, AddIcon, SearchIcon } from '@chakra-ui/icons';
import Cuotas from '../../../API-Alumnos/Pagos';
import {useState , useEffect} from 'react';
import { FetchGetCuotas } from '../../../API-Alumnos/Pagos';
import { get } from 'http';


function TablaCuotas () {
Expand All @@ -11,7 +13,16 @@ function TablaCuotas () {

useEffect(() => {
// Aca se deberia hacer el fetch de las cuotas del alumno
setCuotas(Cuotas)
const getCuotas = async () => {
try {
const cuotas = await FetchGetCuotas();
setCuotas(cuotas);
} catch (error) {
console.error('Error:', error);
}
}
getCuotas();
// setCuotas(Cuotas)
}, [])

useEffect(() => {
Expand Down

0 comments on commit 49e40ae

Please sign in to comment.