import ShowError from "@/app/Components/Global/ShowError";
import { GetSancionByStudent } from "@/app/lib/getSancionByStudent";

export default async function Page(props: {
  searchParams?: Promise<{
    numAcount: string;
  }>;
}) {
  const params = await props.searchParams;
  const numAcount = params?.numAcount ? params.numAcount : null;

  let student: any = null;
  let errorMessage = "";

  if (numAcount) {
    const result = await GetSancionByStudent(parseInt(numAcount));
    if (result.error) {
      errorMessage = `${result.error}`;
    } else {
      student = result as Student;
    }
  }
  return (
    <>
      {errorMessage && <ShowError key={Date.now()} message={errorMessage} />}

      <h2 className="title"> Quitar Sanciones </h2>

    </>
  );
}
//IO
