Fixed issues with assignment progress tracking + added subject progress tracking
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { defaultStyles } from '@/constants/defaultStyles';
|
||||
import { CheckAssignmentCompletion, CheckSubjectCompletion } from '@/lib/progress';
|
||||
import { supabase } from '@/lib/supabase';
|
||||
import type { Assignment, Task } from '@/lib/types';
|
||||
import { Session } from '@supabase/supabase-js';
|
||||
@@ -78,6 +79,17 @@ export default function ViewDetailsAssignment() {
|
||||
}
|
||||
|
||||
Alert.alert("Assignment deleted successfully!");
|
||||
|
||||
const sId = assignment?.sId;
|
||||
|
||||
if (sId) {
|
||||
try {
|
||||
await CheckSubjectCompletion(sId);
|
||||
} catch {
|
||||
Alert.alert("Failed to update subject status");
|
||||
}
|
||||
}
|
||||
|
||||
router.back();
|
||||
}
|
||||
}
|
||||
@@ -106,6 +118,15 @@ export default function ViewDetailsAssignment() {
|
||||
}
|
||||
|
||||
Alert.alert("Task deleted successfully!");
|
||||
|
||||
if (aId) {
|
||||
try {
|
||||
await CheckAssignmentCompletion(aId);
|
||||
} catch {
|
||||
Alert.alert("Failed to update assignment completion state");
|
||||
}
|
||||
}
|
||||
|
||||
GetTasks(aId);
|
||||
}
|
||||
}
|
||||
@@ -153,9 +174,10 @@ export default function ViewDetailsAssignment() {
|
||||
<View style={defaultStyles.checkbox}>
|
||||
{assignment.isCompleted && <Text style={defaultStyles.checkboxMark}>✓</Text>}
|
||||
</View>
|
||||
<View style={{ width: "100%", marginTop: 8 }}>
|
||||
<Text style={defaultStyles.body}>{assignment.lastChanged}</Text>
|
||||
<View style={{ marginTop: 10 }}>
|
||||
<Text style={{ marginBottom: 4 }}>{progress}%</Text>
|
||||
|
||||
|
||||
<View
|
||||
style={{
|
||||
width: "100%",
|
||||
@@ -174,7 +196,6 @@ export default function ViewDetailsAssignment() {
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
<Text style={defaultStyles.body}>{assignment.lastChanged}</Text>
|
||||
|
||||
<Button title="Edit" onPress={() => router.push({pathname: "/assignment/editAssignment", params: { aId: assignment.aId }})} />
|
||||
<Button title="Delete" onPress={() => DeleteAssignment(assignment.aId)} />
|
||||
|
||||
Reference in New Issue
Block a user