fix: joining course error
This commit is contained in:
@@ -6,7 +6,7 @@ export const getStudentInviteLink = (_course: Course, orgSiteName: string, origi
|
||||
const hash = encodeURIComponent(
|
||||
btoa(
|
||||
JSON.stringify({
|
||||
groupId: _course.group?.id,
|
||||
id: _course.id,
|
||||
name: _course.title,
|
||||
description: _course.description,
|
||||
orgSiteName
|
||||
|
||||
@@ -11,15 +11,15 @@ export const load = async ({ params = { hash: '' } }) => {
|
||||
const courseHashData = atob(decodeURIComponent(params.hash));
|
||||
console.log('courseHashData', courseHashData);
|
||||
|
||||
const { groupId, name, description, orgSiteName } = JSON.parse(courseHashData);
|
||||
const { id, name, description, orgSiteName } = JSON.parse(courseHashData);
|
||||
|
||||
if (!groupId || !name || !description || !orgSiteName) {
|
||||
if (!id || !name || !description || !orgSiteName) {
|
||||
throw 'Validation failed';
|
||||
}
|
||||
const currentOrg = await getCurrentOrg(orgSiteName, true);
|
||||
|
||||
return {
|
||||
groupId,
|
||||
id,
|
||||
name,
|
||||
description,
|
||||
currentOrg
|
||||
|
||||
@@ -34,16 +34,28 @@
|
||||
return goto(`/signup?redirect=${$page.url?.pathname || ''}`);
|
||||
}
|
||||
|
||||
const { data: courseData, error } = await supabase
|
||||
.from('course')
|
||||
.select('group_id')
|
||||
.eq('id', data.id)
|
||||
.single();
|
||||
|
||||
console.log({ courseData });
|
||||
if (!courseData?.group_id) {
|
||||
console.error('error getting group', error);
|
||||
return;
|
||||
}
|
||||
|
||||
const member = {
|
||||
profile_id: $profile.id,
|
||||
group_id: data.groupId,
|
||||
group_id: courseData.group_id,
|
||||
role_id: ROLE.STUDENT
|
||||
};
|
||||
|
||||
const teacherMembers = await supabase
|
||||
.from('groupmember')
|
||||
.select('id, profile(email)')
|
||||
.eq('group_id', data.groupId)
|
||||
.eq('group_id', courseData.group_id)
|
||||
.eq('role_id', ROLE.TUTOR)
|
||||
.returns<
|
||||
{
|
||||
@@ -62,7 +74,7 @@
|
||||
addGroupMember(member).then((addedMember) => {
|
||||
loading = false;
|
||||
if (addedMember.error) {
|
||||
console.error('Error adding student to group', data.groupId, addedMember.error);
|
||||
console.error('Error adding student to group', courseData.group_id, addedMember.error);
|
||||
snackbar.error('snackbar.invite.failed_join');
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user