Skip to content

Commit

Permalink
Merge branch 'dev' into TUP-104-Front-darse-de-baja
Browse files Browse the repository at this point in the history
  • Loading branch information
samuop committed Dec 3, 2024
2 parents 501d9a0 + d775ced commit 6b1030e
Show file tree
Hide file tree
Showing 25 changed files with 723 additions and 402 deletions.
1 change: 1 addition & 0 deletions FrontAdmin/src/API-Alumnos/Pagos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export const FetchResumenPagos = async (dni: number | undefined ) => {

if (response.ok) {
const data = await response.json();
console.log('resumen pagos', data);
return data;
} else {
throw new Error('Error en la respuesta del servidor');
Expand Down
59 changes: 29 additions & 30 deletions FrontAdmin/src/API/Login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,36 @@ import Cookies from 'js-cookie';



export const FetchLogin = async (password: string, account: string) => {
try {
const response = await fetch(`http://localhost:8000/api/auth/login/`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ email: account ,password }),
});
export const FetchLogin = async ( legajo: string, contrasenia: string,) => {
try {
const response = await fetch(`http://localhost:8000/api/sysacad/login/`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({legajo ,contrasenia }),
});

if (response.ok) {
const data = await response.json();
if (response.ok) {
const data = await response.json();
const roles = data.user.groups[0];
localStorage.setItem('userRol', JSON.stringify(roles));
Cookies.set('tokennn', data.access);
Cookies.set('dni', data.user.dni);
Cookies.set('cuil', data.user.cuil);
Cookies.set('refresh_token', data.refresh);
Cookies.set('access_expiration', data.access_expiration);
Cookies.set('refresh_expiration', data.refresh_expiration);
Cookies.set('full_name', data.user.full_name);

const roles = data.user.groups[0];
localStorage.setItem('userRol', JSON.stringify(roles));

Cookies.set('tokennn', data.access);
Cookies.set('dni', data.user.dni);
Cookies.set('refresh_token', data.refresh);
Cookies.set('access_expiration', data.access_expiration);
Cookies.set('refresh_expiration', data.refresh_expiration);
Cookies.set('full_name', data.user.full_name);

return data;
} else {
const errorResponse = await response.json();
throw new Error(
JSON.stringify(errorResponse)
);
return data;
} else {
const errorResponse = await response.json();
throw new Error(
JSON.stringify(errorResponse)
);
}
} catch (error: any) {
throw new Error('' + error);
}
} catch (error: any) {
throw new Error('' + error);
}
};
4 changes: 2 additions & 2 deletions FrontAdmin/src/Context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ const AuthProvider = ({ children }: { children: ReactNode }) => {
}
};

const onLogin = async (password: string, account: string) => {
const onLogin = async (legajo: string, contrasenia: string) => {
try {
await FetchLogin(password, account);
await FetchLogin(legajo, contrasenia);
setRolUser(JSON.parse(localStorage.getItem('userRol') || '[]'));
setIsAuthenticated(true);

Expand Down
16 changes: 13 additions & 3 deletions FrontAdmin/src/components/Header/HeaderContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,18 @@ import Perfil from '../Modal/Perfil';

export function HeaderContent({ onOpen }: { onOpen: any }) {
const { onLogout } = useAuth();
const user = Cookies.get('full_name');
const user = Cookies.get('full_name') || '';

function formatUserName(fullName: string): string {
const parts = fullName.trim().split(',');
if (parts.length === 2) {
const lastName = parts[0].trim();
const firstName = parts[1].trim();
return `${firstName}, ${lastName}`;
}
return fullName.trim();
}

// Perfil
const {
isOpen: isOpen1,
Expand All @@ -34,7 +45,6 @@ export function HeaderContent({ onOpen }: { onOpen: any }) {
// TODO: Implementar la lógica de confirmar
}


return (
<Flex
borderBottom="1px"
Expand Down Expand Up @@ -67,7 +77,7 @@ export function HeaderContent({ onOpen }: { onOpen: any }) {
<Text fontFamily={"'Roboto',sans-serif"} fontWeight="600">{user}</Text>
<MenuButton borderRadius={'full'}>
<Avatar
name={Cookies.get("full_name")}
name={formatUserName(user || '')}
borderRadius="full"
/>
</MenuButton>
Expand Down
22 changes: 19 additions & 3 deletions FrontAdmin/src/components/Modal/Perfil.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Button, Flex, Modal, ModalBody, ModalCloseButton, ModalContent, Text, ModalFooter, ModalHeader, ModalOverlay, Input, FormControl, FormLabel, IconButton } from '@chakra-ui/react';
import { Button, Flex, Modal, ModalBody, ModalCloseButton, ModalContent, Text, ModalFooter, ModalHeader, ModalOverlay, Input, FormControl, FormLabel, IconButton, Avatar } from '@chakra-ui/react';
import { HiOutlineUserCircle } from "react-icons/hi";
import { EditIcon } from '@chakra-ui/icons';
import { FetchDetalleAlumno } from '../../API/DetalleAlumno';
Expand Down Expand Up @@ -75,6 +75,17 @@ export default function Perfil({ isOpen, onClose, confirmar }: ModalComponentPro
}
};


function formatUserName(fullName: string): string {
const parts = fullName.trim().split(',');
if (parts.length === 2) {
const lastName = parts[0].trim();
const firstName = parts[1].trim();
return `${firstName}, ${lastName}`;
}
return fullName.trim();
}

return (
<Modal isOpen={isOpen} onClose={onClose}>
<ModalOverlay />
Expand All @@ -83,8 +94,13 @@ export default function Perfil({ isOpen, onClose, confirmar }: ModalComponentPro
<ModalCloseButton />
<ModalBody>
<Flex justifyContent={"center"} alignItems={"center"} direction={"column"}>
<Flex direction={"row"} alignItems={"center"}>
<HiOutlineUserCircle size={120} />
<Flex direction={"row"} alignItems={"center"} alignContent={'center'}>
<Avatar
name={formatUserName(data.full_name || '')}
borderRadius="full"
size={"2xl"}
/>

<Flex direction={"column"} ml={5} textAlign={"left"}>
<Text fontWeight={"bold"} fontSize={20}>{data.full_name}</Text>
<Text fontSize={18}>{new Intl.NumberFormat('es-Es').format(data.dni)}</Text>
Expand Down
4 changes: 2 additions & 2 deletions FrontAdmin/src/components/Pages-Alumnos/CompromisoDePago.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ const handleFirmar = async () => {
return (

<Flex justifyContent={"center"} alignItems={"center"} direction={"column"}>
{ultimoCompromiso && <Flex alignItems={"center"} w={'100%'} direction={"column"} mb={4} mt={4}>
{ultimoCompromiso && <Flex alignItems={"center"} w={'85%'} direction={"column"} mb={4} mt={4}>
<Alert status='success'>
<AlertIcon />
El compromiso de pago del periodo actual ya se encuentra firmado ({formatoFechaISOaDDMMAAAA(ultimo.fecha_firmado)}).
Expand Down Expand Up @@ -163,7 +163,7 @@ return (
{compromisos.length > 0 ? (
<Flex mb={5} justifyContent={"center"} alignItems={"center"} w={"85%"} direction={"column"}>
<Flex justifyContent={"flex-start"} w={"100%"}>
<Text fontWeight="bold" fontSize="xl" mb={2}>Historial compromisos de pago Firmados</Text>
<Text fontWeight="bold" fontSize="xl" mb={2}>Historial compromisos de pago firmados</Text>
</Flex>
<Box flex={1} w={"100%"}>
<TableContainer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { Flex, Button, Text, Stack, Card, CardBody, Box,Tabs,TabList, TabPanels, TabPanel, Table, Tag,Thead,Tr, Th, Tbody, Tab,Td, Tooltip } from "@chakra-ui/react";
import { Flex, Button, Text, Stack, Card, CardBody, Box,Tabs,TabList, TabPanels, TabPanel, Table, Tag,Thead,Tr, Th, Tbody, Tab,Td, Tooltip, Alert, AlertIcon } from "@chakra-ui/react";
import { useDisclosure } from "@chakra-ui/react";
import {useState, useEffect} from 'react';
import {AttachmentIcon, ArrowLeftIcon, ArrowRightIcon, QuestionOutlineIcon} from '@chakra-ui/icons';
Expand Down Expand Up @@ -278,22 +278,34 @@ function InformarPago() {
{compromisoFirmado && compromisoFirmado.results[0]?.firmo_ultimo_compromiso ? 'Firmado' : 'Pendiente de firma'}
</Text>
</Tag>
<Tag w={"100%"} p="10px" fontSize={16} bg={alumno?.estado_financiero === 'Habilitado' ? "#C0EBA6" : "#FF8A8A"} >
<Tag w={"100%"} p="10px" fontSize={16} bg={alumno?.estado_academico === 'Habilitado' ? "#C0EBA6" : "#FF8A8A"} >
<Text color="gray">
Estado:
Condición Sysacad:
</Text>
<Text size="sm" pl="8px" fontWeight="semibold">
{alumno?.estado_financiero}
</Text>
</Tag>
<Tag w={"100%"} p="10px" fontSize={16}>
<Text color="gray">
Ultimo Periodo Cursado
</Text>
<Text size="sm" pl="8px" fontWeight="semibold">
{alumnoInfo.ultimo_cursado}
{alumno?.estado_academico}
</Text>
</Tag>
{alumno?.estado_financiero === 'Inhabilitado' ?
<Tag w={"100%"} p="10px" fontSize={16} bg="#FF8A8A">
<Text color="gray">
Motivo:
</Text>
<Text size="sm" pl="8px" fontWeight="semibold">
Deudor
</Text>
</Tag>
:
<Tag w={"100%"} p="10px" fontSize={16}>
<Text color="gray">
Ultimo Periodo Cursado
</Text>
<Text size="sm" pl="8px" fontWeight="semibold">
{alumnoInfo.ultimo_cursado}
</Text>
</Tag>
}

</Box>
<Box w={"100%"} display={"flex"} justifyContent={"center"} >
{cuotas.length > 0 ? (
Expand Down Expand Up @@ -350,10 +362,18 @@ function InformarPago() {


) : (
<Text textAlign="center" padding="20px">Aún no tienes cuotas generadas. <br />Verifica la firma del compromiso de pago para generar tus cuotas.</Text>
<Alert status="info" alignItems="center" justifyContent="center" textAlign="center" width="70%">
<AlertIcon mr={1} />

<Text>
Aún no tienes cuotas generadas. Verifica la firma del compromiso de pago para generar tus cuotas.
</Text>

</Alert>
)}

</Box>
</Box>
{cuotas.length > 0 ?
<Box w="90%" mt="20px" ml="70px">
<Flex justifyContent="space-between" >
<Button onClick={handlePreviousPage} isDisabled={offset === 0} _hover="none" color="white" leftIcon={<ArrowLeftIcon/>}>
Expand All @@ -365,6 +385,7 @@ function InformarPago() {
</Button>
</Flex>
</Box>
: null }

{detail != null ?
<Box display={"flex"} justifyContent={"center"} flex={1} w={"100%"}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,10 @@ const DrawerInformar: React.FC<DrawerInformarProps> = ({ isOpen, onClose, cuotas
mesesCuota = mesesCuota.sort((a, b) => a - b); // Ordenar de menor a mayor
const dni = Cookies.get('dni');
const fullName = Cookies.get('full_name');
const cuil = Cookies.get('cuil');
const fechaHoy = obtenerFechaForm();
const meses = obtenerMesesDeCuotas(mesesCuota);
const googleFormUrl = `https://docs.google.com/forms/d/e/1FAIpQLSfNe4krjpaC7I_9FA7Do3MAuQr7eC9wF5zVHIgOV2XeqzAAnA/viewform?usp=pp_url&entry.1045781291=${fullName}&entry.839337160=Tecnicatura+Universitaria+en+Programaci%C3%B3n&entry.1065046570=${dni}&entry.1651003915=${encodeURIComponent(fechaHoy)}&entry.180139663=${meses}&entry.463277821=${comentarios}`;
const googleFormUrl = `https://docs.google.com/forms/d/e/1FAIpQLSfNe4krjpaC7I_9FA7Do3MAuQr7eC9wF5zVHIgOV2XeqzAAnA/viewform?usp=pp_url&entry.1045781291=${fullName}&entry.839337160=Tecnicatura+Universitaria+en+Programaci%C3%B3n&entry.1065046570=${dni}&entry.1166974658=${cuil}&entry.1651003915=${encodeURIComponent(fechaHoy)}&entry.180139663=${meses}&entry.463277821=${comentarios}`;
window.open(googleFormUrl, '_blank');

//onRefresh();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Box, Table, Thead, Tbody, Tr, Th, Td, Flex, Text, Skeleton, Checkbox, Tooltip} from '@chakra-ui/react';
import { Box, Table, Thead, Tbody, Tr, Th, Td, Flex, Text, Skeleton, Checkbox, Tooltip, Alert, AlertIcon} from '@chakra-ui/react';
import {useState , useEffect} from 'react';
import { FetchGetCuotas } from '../../../API-Alumnos/Pagos';
import { formatoFechaISOaDDMMAAAA } from '../../../utils/general';
Expand Down Expand Up @@ -157,7 +157,12 @@ function TablaCuotas({ refresh, setCuotasSeleccionadas, cuotasSeleccionadas }: T
</Tbody>
</Table>
) : (
<Text>No hay cuotas para mostrar. Por favor, firmar el compromiso de pago.</Text>
<Alert status="info" alignItems="center" justifyContent="center" textAlign="center" >
<AlertIcon mr={1}/>
<Text>
No hay cuotas para mostrar. Por favor, firmar el compromiso de pago.
</Text>
</Alert>
)
)}

Expand Down
27 changes: 14 additions & 13 deletions FrontAdmin/src/components/Pages/Alumnos/SubPages/FichaAlumno.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ interface Alumno {
telefono: number;
estado_academico: string;
estado_financiero: string;
ultimo_cursado: string;
cuil: string;
}


Expand Down Expand Up @@ -184,7 +186,6 @@ function FichaAlumno() {
try {
const dniNumber = parseInt(dni, 10); // Convierte a número
const data = await FetchEstadoCuenta(dniNumber);
console.log('dniNumber en este punto', dni);
const dataDetalle = await FetchDetalleAlumno(dniNumber);
const dataMaterias = await FetchMateriasAlumno(dniNumber);
setAlumno(dataDetalle);
Expand Down Expand Up @@ -377,10 +378,10 @@ function FichaAlumno() {
fontWeight="Bold"
>{`${alumno.full_name}`}</Text>
<Text color="gray" mt="10px">
Número DNI:
CUIL:
</Text>
<Text size="sm" pl="8px" fontWeight="semibold">
{new Intl.NumberFormat().format(alumno.dni)}
{alumno.cuil}
</Text>
<Text color="gray" mt="10px">
Legajo:
Expand Down Expand Up @@ -410,17 +411,17 @@ function FichaAlumno() {
{compromisoFirmado && compromisoFirmado.results[0]?.firmo_ultimo_compromiso ? 'Firmado' : 'Pendiente de firma'}
</Text>
<Text color="gray" mt="10px">
Estado:
Condición Sysacad:
</Text>
<Text size="sm" pl="8px" fontWeight="semibold" mb="20px">
{alumno.estado_financiero}
{alumno.estado_academico}
</Text>
<Text color="gray" mt="20px">
Ultimo Periodo Cursado
</Text>
<Text size="sm" pl="8px" fontWeight="semibold" mb="20px">
{`${materias[0].anio_cursada} / ${materias[0].cuatrimestre}C`}
</Text>
{<Text size="sm" pl="8px" fontWeight="semibold" mb="20px">
{alumno.ultimo_cursado}
</Text>}

</Box>

Expand Down Expand Up @@ -537,7 +538,7 @@ function FichaAlumno() {


) : (
<Text textAlign="center" padding="20px">Aún no tienes cuotas generadas. <br />Verifica la firma del compromiso de pago para generar tus cuotas.</Text>
<Text textAlign="center" padding="20px">El alumno aún no tiene cuotas generadas. </Text>
)}

</Box>
Expand Down Expand Up @@ -569,7 +570,7 @@ function FichaAlumno() {
</Tr>
</Thead>
<Tbody>
{pagos?.results
{pagos && pagos.results.length > 0 ? pagos.results
.filter(pago =>
pago.cuotas.length > 0 &&
pago.cuotas.some(cuota => cuota.id_cuota === detail) // Verifica si alguna cuota cumple la condición
Expand All @@ -591,7 +592,7 @@ function FichaAlumno() {
) : null
))}
</Tr>
))}
)) : 'No existen cuotas para el alumno'}
</Tbody>
</Table>
</Box>
Expand Down Expand Up @@ -645,14 +646,14 @@ function FichaAlumno() {
<Tr mt={6}>
<Th textAlign="center">Fecha Desde</Th>
<Th textAlign="center">Fecha Hasta</Th>
<Th textAlign="center">Descripción</Th>
<Th textAlign="center">Motivo</Th>
</Tr>
</Thead>
<Tbody>
{inhabilitaciones.map((inhabilitacion, index) => (
<Tr key={index}>
<Td textAlign="center">{new Date(inhabilitacion.fecha_desde).toLocaleDateString()}</Td>
<Td textAlign="center">{new Date(inhabilitacion.fecha_hasta).toLocaleDateString()}</Td>
<Td textAlign="center">{inhabilitacion.fecha_hasta === null ? ' - ' : new Date(inhabilitacion.fecha_hasta).toLocaleDateString()}</Td>
<Td textAlign="center">{inhabilitacion.descripcion}</Td>
</Tr>
))}
Expand Down
Loading

0 comments on commit 6b1030e

Please sign in to comment.