apply DRY to alumno-sancio
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { envConfig } from "@/app/lib/config";
|
||||
import { Alumno, AlumnoSancion, Sancion } from "@/app/types/sanction";
|
||||
import { GetSancionByStudent } from "@/app/lib/getSancionByStudent";
|
||||
import TableSanction from "./TableSanction";
|
||||
import axios from "axios";
|
||||
import Swal from "sweetalert2";
|
||||
@@ -21,12 +22,11 @@ export default function ApplySanction({ idCuenta }: { idCuenta: number }) {
|
||||
|
||||
const fetchAlumnoSanciones = async () => {
|
||||
try {
|
||||
const res = await axios.get(
|
||||
`${envConfig.apiUrl}/alumno-sancion/${idCuenta}`
|
||||
);
|
||||
|
||||
setAlumno(res.data.student ?? null);
|
||||
setAlumnoSanciones(res.data.alusancion ?? []);
|
||||
const res = await GetSancionByStudent(idCuenta);
|
||||
|
||||
setAlumno(res.student ?? null);
|
||||
setAlumnoSanciones(res.alusancion ?? []);
|
||||
} catch {
|
||||
} finally {
|
||||
setLoadingTable(true)
|
||||
|
||||
Reference in New Issue
Block a user