fix: show notification on error fetching marks #116
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import { supabase } from '$lib/utils/functions/supabase';
|
import { supabase } from '$lib/utils/functions/supabase';
|
||||||
|
|
||||||
export async function fetchMarks(courseId) {
|
export async function fetchMarks(courseId) {
|
||||||
const { data } = await supabase.rpc('get_marks').eq('course_id', courseId);
|
const { data, error } = await supabase.rpc('get_marks').eq('course_id', courseId);
|
||||||
|
|
||||||
return { data };
|
return { data, error };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,9 +13,9 @@
|
|||||||
import { profile } from '$lib/utils/store/user';
|
import { profile } from '$lib/utils/store/user';
|
||||||
import { browser } from '$app/environment';
|
import { browser } from '$app/environment';
|
||||||
import { course } from '$lib/components/Course/store';
|
import { course } from '$lib/components/Course/store';
|
||||||
|
import { snackbar } from '$lib/components/Snackbar/store';
|
||||||
|
|
||||||
export let data;
|
export let data;
|
||||||
const { courseId } = data;
|
|
||||||
|
|
||||||
let borderBottomGrey = 'border-r-0 border-t-0 border-b border-l-0 border-gray-300';
|
let borderBottomGrey = 'border-r-0 border-t-0 border-b border-l-0 border-gray-300';
|
||||||
let borderleftGrey = 'border-r-0 border-t-0 border-b-0 border-l border-gray-300';
|
let borderleftGrey = 'border-r-0 border-t-0 border-b-0 border-l border-gray-300';
|
||||||
@@ -35,7 +35,14 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function firstRender(courseId: string) {
|
async function firstRender(courseId: string) {
|
||||||
const { data: marks } = await fetchMarks(courseId);
|
const { data: marks, error } = await fetchMarks(courseId);
|
||||||
|
if (error) {
|
||||||
|
console.error('Error fetching marks', error);
|
||||||
|
snackbar.error('Error fetching marks');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!marks || !Array.isArray(marks)) return;
|
||||||
|
|
||||||
marks.forEach((mark) => {
|
marks.forEach((mark) => {
|
||||||
const { groupmember_id, exercise_id, total_points_gotten } = mark;
|
const { groupmember_id, exercise_id, total_points_gotten } = mark;
|
||||||
|
|||||||
Reference in New Issue
Block a user