Remove console log
This commit is contained in:
@@ -6,7 +6,7 @@ interface Promotion {
|
||||
}
|
||||
|
||||
interface MobilityData {
|
||||
id: number | null; // null pour les nouvelles entrées
|
||||
id: number | null;
|
||||
studentId: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
@@ -27,7 +27,6 @@ export default function EditMobility() {
|
||||
|
||||
useEffect(() => {
|
||||
async function fetchMobilityData() {
|
||||
console.log("EditMobility: Fetching data from API...");
|
||||
const response = await fetch("/mobility/api/insert_mobility");
|
||||
const data = await response.json();
|
||||
console.log("EditMobility: Data fetched successfully:", data);
|
||||
@@ -39,7 +38,7 @@ export default function EditMobility() {
|
||||
(mobility: any) => mobility.studentId === student.id
|
||||
);
|
||||
return {
|
||||
id: existingMobility ? existingMobility.id : null, // null si aucune mobilité existante
|
||||
id: existingMobility ? existingMobility.id : null,
|
||||
studentId: student.id,
|
||||
firstName: student.firstName,
|
||||
lastName: student.lastName,
|
||||
@@ -73,9 +72,7 @@ export default function EditMobility() {
|
||||
|
||||
const handleSave = async () => {
|
||||
setIsSaving(true);
|
||||
|
||||
try {
|
||||
console.log("EditMobility: Sending data to API...");
|
||||
const response = await fetch("/mobility/api/insert_mobility", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
@@ -97,7 +94,6 @@ export default function EditMobility() {
|
||||
}
|
||||
};
|
||||
|
||||
// Grouper les données par promotion
|
||||
const groupedData = promotions.map((promo) => ({
|
||||
promotion: promo.name,
|
||||
students: mobilityData.filter(
|
||||
|
||||
@@ -4,12 +4,8 @@ import connect from "$root/databases/connect.ts";
|
||||
export const handler: Handlers = {
|
||||
// deno-lint-ignore require-await
|
||||
async GET() {
|
||||
console.log("API /mobility/api/insert_mobility GET called");
|
||||
|
||||
try {
|
||||
console.log("Connecting to mobility database...");
|
||||
using connection = connect("mobility");
|
||||
console.log("Connected to databases.");
|
||||
|
||||
const mobilities = connection.database.prepare(
|
||||
`SELECT
|
||||
@@ -53,8 +49,6 @@ export const handler: Handlers = {
|
||||
},
|
||||
|
||||
async POST(request) {
|
||||
console.log("API /mobility/api/insert_mobility POST called");
|
||||
|
||||
try {
|
||||
const body = await request.json();
|
||||
const { data } = body;
|
||||
@@ -63,30 +57,7 @@ export const handler: Handlers = {
|
||||
throw new Error("Invalid request body");
|
||||
}
|
||||
|
||||
console.log("Connecting to mobility database...");
|
||||
using connection = connect("mobility");
|
||||
console.log("Connected to databases.");
|
||||
|
||||
const attachedDatabases = connection.database
|
||||
.prepare("PRAGMA database_list")
|
||||
.all();
|
||||
console.log("Attached databases:", attachedDatabases);
|
||||
|
||||
const tablesInMain = connection.database
|
||||
.prepare("SELECT name FROM sqlite_master WHERE type='table'")
|
||||
.all();
|
||||
console.log("Tables in main:", tablesInMain);
|
||||
|
||||
const tablesInStudents = connection.database
|
||||
.prepare("SELECT name FROM students.sqlite_master WHERE type='table'")
|
||||
.all();
|
||||
console.log("Tables in students:", tablesInStudents);
|
||||
|
||||
const testQuery = connection.database
|
||||
.prepare("SELECT COUNT(*) AS count FROM students.students")
|
||||
.get();
|
||||
console.log(`Test query result: Students table has ${testQuery.count} rows.`);
|
||||
|
||||
const insertQuery = connection.database.prepare(
|
||||
`INSERT INTO mobility (
|
||||
id, studentId, startDate, endDate, weeksCount, destinationCountry, destinationName, mobilityStatus
|
||||
@@ -113,16 +84,6 @@ export const handler: Handlers = {
|
||||
mobilityStatus = "N/A",
|
||||
} = mobility;
|
||||
|
||||
console.log(`Checking if studentId ${studentId} exists in students.students`);
|
||||
const studentExists = connection.database
|
||||
.prepare("SELECT COUNT(*) AS count FROM students.students WHERE userId = ?")
|
||||
.get(studentId);
|
||||
|
||||
if (studentExists.count === 0) {
|
||||
console.warn(`Student with ID ${studentId} does not exist. Skipping.`);
|
||||
continue;
|
||||
}
|
||||
|
||||
let calculatedWeeksCount = weeksCount;
|
||||
if (startDate && endDate) {
|
||||
const start = new Date(startDate);
|
||||
@@ -134,7 +95,6 @@ export const handler: Handlers = {
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`Inserting/Updating mobility for studentId: ${studentId}`);
|
||||
insertQuery.run(
|
||||
id,
|
||||
studentId,
|
||||
|
||||
Reference in New Issue
Block a user