Skip to content

Commit

Permalink
fix: show notification on error fetching marks #116
Browse files Browse the repository at this point in the history
  • Loading branch information
rotimi-best committed Dec 19, 2023
1 parent cdd4f65 commit 4b2e58b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions apps/dashboard/src/lib/utils/services/marks/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { supabase } from '$lib/utils/functions/supabase';

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 };
}
11 changes: 9 additions & 2 deletions apps/dashboard/src/routes/courses/[id]/marks/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
import { profile } from '$lib/utils/store/user';
import { browser } from '$app/environment';
import { course } from '$lib/components/Course/store';
import { snackbar } from '$lib/components/Snackbar/store';
export let data;
const { courseId } = data;
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';
Expand All @@ -35,7 +35,14 @@
}
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) => {
const { groupmember_id, exercise_id, total_points_gotten } = mark;
Expand Down

2 comments on commit 4b2e58b

@vercel
Copy link

@vercel vercel bot commented on 4b2e58b Dec 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 4b2e58b Dec 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

landingpage – ./apps/classroomio-com

classroomio-com.vercel.app
landingpage-git-main-rotimi-best.vercel.app
landingpage-rotimi-best.vercel.app

Please sign in to comment.