axios costos
This commit is contained in:
@@ -8,6 +8,8 @@ import ShowError from "@/app/Components/Global/ShowError";
|
||||
import { cookies } from "next/headers";
|
||||
import { GetStudentWhitoutSancion } from "@/app/lib/getStudentWhitoutSancion";
|
||||
|
||||
import axios from "axios";
|
||||
|
||||
import "@/app/globals.css";
|
||||
|
||||
export default async function Page(props: {
|
||||
@@ -26,6 +28,7 @@ export default async function Page(props: {
|
||||
|
||||
let student: any = null;
|
||||
let errorMessage = "";
|
||||
let costos: any[] = [];
|
||||
|
||||
if (numAcount) {
|
||||
const result = await GetStudentWhitoutSancion(parseInt(numAcount));
|
||||
@@ -37,6 +40,24 @@ export default async function Page(props: {
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await axios.get("http://localhost:5000/costo");
|
||||
costos = response.data;
|
||||
} catch (error) {
|
||||
console.error("Error obteniendo costos:", error);
|
||||
}
|
||||
|
||||
|
||||
const getCostsByService = (id_servicio: number) => {
|
||||
return costos
|
||||
.filter((c) => c.id_servicio === id_servicio)
|
||||
.map((c) => ({
|
||||
value: Number(c.costo),
|
||||
id_costo: c.id_costo,
|
||||
fecha_registro: c.fecha_registro,
|
||||
}));
|
||||
};
|
||||
|
||||
let options: any[] = [];
|
||||
|
||||
if (student) {
|
||||
@@ -51,7 +72,7 @@ export default async function Page(props: {
|
||||
label: "Impresiones B/N",
|
||||
content: (
|
||||
<Impressions
|
||||
costs={[{ value: 1 }, { value: 2 }]}
|
||||
costs={getCostsByService(1)}
|
||||
numAcount={student.id_cuenta}
|
||||
id_servicio={1}
|
||||
/>
|
||||
@@ -62,7 +83,7 @@ export default async function Page(props: {
|
||||
label: "Impresiones color",
|
||||
content: (
|
||||
<Impressions
|
||||
costs={[{ value: 4 }, { value: 5 }]}
|
||||
costs={getCostsByService(2)}
|
||||
numAcount={student.id_cuenta}
|
||||
id_servicio={2}
|
||||
/>
|
||||
@@ -73,7 +94,7 @@ export default async function Page(props: {
|
||||
label: "Plotter",
|
||||
content: (
|
||||
<Impressions
|
||||
costs={[{ value: 15 }]}
|
||||
costs={getCostsByService(3)}
|
||||
numAcount={student.id_cuenta}
|
||||
id_servicio={3}
|
||||
/>
|
||||
@@ -84,7 +105,7 @@ export default async function Page(props: {
|
||||
label: "Escaner",
|
||||
content: (
|
||||
<Impressions
|
||||
costs={[{ value: 1 }]}
|
||||
costs={getCostsByService(6)}
|
||||
numAcount={student.id_cuenta}
|
||||
id_servicio={6}
|
||||
/>
|
||||
@@ -96,8 +117,8 @@ export default async function Page(props: {
|
||||
const optionsToUse =
|
||||
roleNumber === 5
|
||||
? options.filter(
|
||||
(option) => option.key === "Recibo" || option.key === "B/N"
|
||||
)
|
||||
(option) => option.key === "Recibo" || option.key === "B/N"
|
||||
)
|
||||
: options;
|
||||
|
||||
return (
|
||||
@@ -115,13 +136,9 @@ export default async function Page(props: {
|
||||
Carrera={student.carrera.carrera}
|
||||
Credito={student.credito}
|
||||
/>
|
||||
<div style={{ height: "10px" }}> </div>
|
||||
|
||||
<Toggle
|
||||
defaultView={key}
|
||||
options={optionsToUse}
|
||||
/>
|
||||
<div style={{ height: "10px" }}></div>
|
||||
|
||||
<Toggle defaultView={key} options={optionsToUse} />
|
||||
</>
|
||||
)}
|
||||
</section>
|
||||
|
||||
Reference in New Issue
Block a user