Update student to have an ID

This commit is contained in:
Clayzxr
2025-01-24 20:48:33 +01:00
parent c3d3354537
commit fcc0a4413c
5 changed files with 87 additions and 33 deletions
@@ -6,12 +6,11 @@ interface Promotion {
}
interface Student {
id: number;
userId: string;
firstName: string;
lastName: string;
mail: string;
promotionId: number;
promotionName: string;
}
export default function ConsultStudents() {
@@ -27,6 +26,7 @@ export default function ConsultStudents() {
}
const result = await response.json();
console.log("Fetched data:", result);
setData(result);
} catch (err) {
console.error("Error fetching data:", err);
@@ -43,7 +43,7 @@ export default function ConsultStudents() {
{error && <p className="error">{error}</p>}
{data?.promotions.map((promo) => (
<div key={promo.id}>
<h3>Promotion: {promo.id}</h3>
<h3>Promotion: {promo.name}</h3>
<table>
<thead>
<tr>
@@ -57,8 +57,8 @@ export default function ConsultStudents() {
{data.students
.filter((student) => student.promotionId === promo.id)
.map((student) => (
<tr key={student.id}>
<td>{student.id}</td>
<tr key={student.userId}>
<td>{student.userId}</td>
<td>{student.firstName}</td>
<td>{student.lastName}</td>
<td>{student.mail}</td>
@@ -33,10 +33,12 @@ export default function UploadStudents() {
for (const sheetName of workbook.SheetNames) {
const sheet = workbook.Sheets[sheetName];
const data = XLSX.utils.sheet_to_json(sheet, {
header: ["Nom", "Prénom", "Mail"],
header: ["Identifiant", "Nom", "Prénom", "Mail"],
range: 1, // Ignorer les en-têtes
});
console.log(`Data from sheet ${sheetName}:`, data);
const response = await fetch("/students/api/insert_students", {
method: "POST",
headers: { "Content-Type": "application/json" },