Get courses by members data

This commit is contained in:
rotimi-best
2021-08-24 18:20:07 +03:00
parent 4509d0eef1
commit 47b81928cc
9 changed files with 35 additions and 32 deletions
+7 -10
View File
@@ -1,16 +1,13 @@
import { supabase } from '../../utils/functions/supabase';
export async function fetchCourses(userId) {
const { data: orgMember } = await supabase
.from('organizationmember')
.select(`organization_id`)
.eq('profile_id', userId)
.single();
export async function fetchCourses(profileId) {
if (!profileId) return;
const { data: allCourses } = await supabase
.from('course')
.select(`id, title, description`)
.eq('organization_id', orgMember.organization_id);
.rpc('get_courses')
.eq('profile_id', profileId);
return { allCourses, organizationId: orgMember.organization_id };
console.log(`allCourses`, allCourses);
return { allCourses };
}