Added progress bar for assignments (UI fix needed)

This commit is contained in:
Teodor
2026-04-23 03:27:26 +02:00
parent e178ab0b4b
commit a35353f45b
17 changed files with 388 additions and 115 deletions

15
lib/progress.ts Normal file
View File

@@ -0,0 +1,15 @@
import { supabase } from '@/lib/supabase';
export async function CheckAssignmentCompletion(aId: string) {
const { data, error } = await supabase.from("tasks").select("tId, isCompleted").eq("aId", aId);
if (error) throw error;
const tasks = data ?? [];
const allCompleted = tasks.length > 0 && tasks.every((task) => task.isCompleted === true);
const { error: updateError } = await supabase.from("assignments").update({ isCompleted: allCompleted, lastChanged: new Date().toISOString()}).eq("aId", aId);
if (updateError) throw updateError;
}