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
-1
View File
@@ -1,6 +1,5 @@
<script context="module">
export function preload(page, { config }) {
console.log(`page`, page);
return { config, isMvpUser: !!page.query.mvp };
}
</script>
+6 -7
View File
@@ -5,14 +5,14 @@
export async function preload(page, params) {
const parsedUser = JSON.parse(params.user);
if (parsedUser && parsedUser.id) {
return fetchCourses(parsedUser.id);
}
// if (parsedUser && parsedUser.id) {
// return fetchCourses(parsedUser.id);
// }
return {
allCourses: [],
organizationId: null,
cantFetch: !parsedUser,
cantFetch: true,
};
}
</script>
@@ -64,7 +64,7 @@
title,
description,
group_id,
organization_id: organizationId,
// organization_id: organizationId,
});
// Get profile of author and add as member
@@ -100,7 +100,7 @@
}
async function getCourses(userId) {
console.log(`getCourses process.browser`, process.browser);
console.log(`getCourses process.browser`, process.browser, cantFetch);
if (process.browser) {
if (cantFetch && typeof cantFetch === 'boolean' && !allCourses.length) {
const coursesResult = await fetchCourses(userId);
@@ -113,7 +113,6 @@
}
onMount(async () => {
console.log(`onMount cantFetch`, cantFetch);
courses.set(allCourses);
});
+7 -5
View File
@@ -5,21 +5,23 @@
</script>
<script>
import { onMount } from 'svelte';
import Overview from '../../../components/Course/index.svelte';
import CourseContainer from '../../../components/CourseContainer/index.svelte';
import { setCourseData, course } from '../../../components/Course/store';
import { setCourseData } from '../../../components/Course/store';
import { fetchCourse } from '../../../utils/services/courses';
export let courseId;
onMount(async () => {
async function onCourseIdChange(courseId) {
if (!courseId) return;
console.log(`overview courseId`, courseId);
if ($course.id) return;
const { data } = await fetchCourse(courseId);
setCourseData(data);
});
}
$: onCourseIdChange(courseId);
</script>
<CourseContainer>
+7 -2
View File
@@ -75,10 +75,15 @@
<p
class="bg-yellow-500 w-1/4 text-sm text-center rounded-xl text-white"
>
Pending confirmation
Pending Invite
</p>
{/if}
<p class="text-lg w-1/4 break-all">{person.email}</p>
<a
href="mailto:{person.email}"
class="text-md w-1/4 mx-2 text-blue-600"
>
{person.email}
</a>
<p class="text-lg w-1/4 ">{ROLE_LABEL[person.role_id]}</p>
</div>
{/each}
+2 -2
View File
@@ -135,7 +135,7 @@
This are the organizations you work at
</p>
<div class="my-3 py-2 px-4 border shadow-sm rounded-md">
<div class="hidden my-3 py-2 px-4 border shadow-sm rounded-md">
<h4 class="m-0 font-normal">
<a class="text-blue-700 font-bold" href="/courses"> CitiBim </a>
</h4>
@@ -156,7 +156,7 @@
</div>
</div>
<div class="my-2 py-2 px-4 border shadow-sm rounded-md">
<div class="hidden my-2 py-2 px-4 border shadow-sm rounded-md">
<h4 class="m-0 font-normal">
<a class="text-blue-700 font-bold" href="/courses">
Climate Change Group