131 lines
3.1 KiB
TypeScript
131 lines
3.1 KiB
TypeScript
import SearchUser from "../../Components/Global/SearchUser/searchUser";
|
|
import Receipt from "../../Components/Receipt/Receipt";
|
|
import Toggle from "../../Components/Global/Toggle/Toggle";
|
|
import Information from "../../Components/Global/Information/information";
|
|
import Impressions from "@/app/Components/Impressions/impressions";
|
|
import ShowError from "@/app/Components/Global/ShowError";
|
|
|
|
import { GetStudent } from "@/app/lib/getStudent";
|
|
import { cookies } from "next/headers";
|
|
|
|
import "@/app/globals.css";
|
|
|
|
export default async function Page(props: {
|
|
searchParams?: Promise<{
|
|
key: string;
|
|
numAcount: string;
|
|
}>;
|
|
}) {
|
|
const params = await props.searchParams;
|
|
const key = params?.key && params.key;
|
|
const numAcount = params?.numAcount ? params.numAcount : null;
|
|
|
|
const cookieStore = await cookies();
|
|
const role = cookieStore.get("role")?.value || "";
|
|
const roleNumber = parseInt(role);
|
|
|
|
let student: any = null;
|
|
let errorMessage = "";
|
|
|
|
if (numAcount) {
|
|
const result = await GetStudent(parseInt(numAcount));
|
|
|
|
if (result.error) {
|
|
errorMessage = `${result.error}`;
|
|
} else {
|
|
student = result as Student;
|
|
}
|
|
}
|
|
|
|
let options: any[] = [];
|
|
|
|
if (student) {
|
|
options = [
|
|
{
|
|
key: "Recibo",
|
|
label: "Recibo",
|
|
content: <Receipt numAcount={student.id_cuenta} />,
|
|
},
|
|
{
|
|
key: "B/N",
|
|
label: "Impresiones B/N",
|
|
content: (
|
|
<Impressions
|
|
costs={[{ value: 1 }, { value: 2 }]}
|
|
numAcount={student.id_cuenta}
|
|
id_servicio={1}
|
|
/>
|
|
),
|
|
},
|
|
{
|
|
key: "color",
|
|
label: "Impresiones color",
|
|
content: (
|
|
<Impressions
|
|
costs={[{ value: 4 }, { value: 5 }]}
|
|
numAcount={student.id_cuenta}
|
|
id_servicio={2}
|
|
/>
|
|
),
|
|
},
|
|
{
|
|
key: "Plotter",
|
|
label: "Plotter",
|
|
content: (
|
|
<Impressions
|
|
costs={[{ value: 15 }]}
|
|
numAcount={student.id_cuenta}
|
|
id_servicio={3}
|
|
/>
|
|
),
|
|
},
|
|
{
|
|
key: "Escaner",
|
|
label: "Escaner",
|
|
content: (
|
|
<Impressions
|
|
costs={[{ value: 1 }]}
|
|
numAcount={student.id_cuenta}
|
|
id_servicio={6}
|
|
/>
|
|
),
|
|
},
|
|
];
|
|
}
|
|
|
|
const optionsToUse =
|
|
roleNumber === 5
|
|
? options.filter(
|
|
(option) => option.key === "Recibo" || option.key === "B/N"
|
|
)
|
|
: options;
|
|
|
|
return (
|
|
<section className="containerSection">
|
|
{errorMessage && <ShowError key={Date.now()} message={errorMessage} />}
|
|
|
|
<h2 className="title">IMPRESIONES Y PLOTEO</h2>
|
|
<SearchUser value={numAcount} />
|
|
|
|
{student && (
|
|
<>
|
|
<Information
|
|
NoCuenta={student.id_cuenta}
|
|
Nombre={student.nombre}
|
|
Carrera={student.carrera.carrera}
|
|
Credito={student.credito}
|
|
/>
|
|
<div style={{ height: "10px" }}> </div>
|
|
|
|
<Toggle
|
|
defaultView={key}
|
|
options={optionsToUse}
|
|
/>
|
|
|
|
</>
|
|
)}
|
|
</section>
|
|
);
|
|
}
|
|
//IO
|