removed automatic change for subject to inactive if all assignments are completed
This commit is contained in:
@@ -13,17 +13,3 @@ export async function CheckAssignmentCompletion(aId: string) {
|
||||
|
||||
if (updateError) throw updateError;
|
||||
}
|
||||
|
||||
export async function CheckSubjectCompletion(sId: string) {
|
||||
const { data, error } = await supabase.from("assignments").select("aId, isCompleted").eq("sId", sId);
|
||||
|
||||
if (error) throw error;
|
||||
|
||||
const assignments = data ?? [];
|
||||
|
||||
const allCompleted = assignments.length > 0 && assignments.every((assignment) => assignment.isCompleted === true);
|
||||
|
||||
const { error: updateError } = await supabase.from("subjects").update({ isActive: allCompleted, lastChanged: new Date().toISOString()}).eq("sId", sId);
|
||||
|
||||
if (updateError) throw updateError;
|
||||
}
|
||||
Reference in New Issue
Block a user