Skip to content

Commit

Permalink
fix: gallery sort + progress bar
Browse files Browse the repository at this point in the history
  • Loading branch information
edeleastar committed Oct 9, 2023
1 parent 583437d commit 4616f4a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
23 changes: 11 additions & 12 deletions app/src/routes/(time)/gallery/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import "../../../app.postcss";
import { onMount } from "svelte";
import { getCourseSummary, type CourseSummary } from "$lib/services/utils/all-course-access";
import { readVisits } from "$lib/services/utils/firebase";
import { ProgressBar } from "@skeletonlabs/skeleton";
import TutorsShell from "$lib/ui/app-shells/TutorsShell.svelte";
import GalleryCard from "$lib/ui/learning-objects/layout/GalleryCard.svelte";
Expand All @@ -13,26 +12,24 @@
let los: CourseSummary[] = [];
let modules = 0;
let totalVisits = 0;
let subTitle = "";
onMount(async () => {
if (data.allCourses) {
data.allCourses.forEach(async (courseId: string) => {
try {
const visits = await readVisits(courseId);
if (visits) {
totalVisits += visits;
const courseSummary = await getCourseSummary(courseId);
if (!courseSummary.isPrivate) {
modules++;
subTitle = `Showcasing ${modules} modules`;
los.push(courseSummary);
los = [...los];
const courseSummary = await getCourseSummary(courseId);
if (!courseSummary.isPrivate) {
modules++;
subTitle = `Showcasing ${modules} modules`;
los.push(courseSummary);
if (modules === data.allCourses.length) {
los.sort((lo1: CourseSummary, lo2: CourseSummary) => lo1.title.localeCompare(lo2.title));
}
los = [...los];
}
} catch (error: any) {
modules--;
console.log(`invalid course ${courseId} : ${error.message}`);
}
});
Expand All @@ -41,7 +38,9 @@
</script>

<TutorsShell {session} {supabase} title={"Tutors Module Gallery"} {subTitle}>
<ProgressBar label="Progress Bar" value={modules} max={50} />
{#if modules < data.allCourses.length}
<ProgressBar label="Progress Bar" value={modules} max={data.allCourses.length} />
{/if}
<div class="bg-surface-100-800-token mx-auto mb-2 place-items-center overflow-hidden rounded-xl p-4">
<div class="flex flex-wrap justify-center">
{#each los as lo}
Expand Down
12 changes: 6 additions & 6 deletions app/src/routes/(time)/gallery/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ const validCourses = [
"classic-design-patterns",
"bi-vis-2023",
"careerdevelopment",
"wit-hdip-comp-sci-2022-computer-systems",
"dsa1-jan-2024",
"wit-hdip-comp-sci-2021-database",
"devfor.netlify",
"devfor",
"enterprise-apps",
"fsf21",
"funcprog23-reg",
Expand All @@ -18,8 +17,7 @@ const validCourses = [
"setu-mgd",
"netfor",
"of-2022s2-8z1",
"osforensic",
"bsa-hci-webdesign",
"osforensics",
"ictforforestry",
"placement-project",
"professionalcomms",
Expand All @@ -41,7 +39,7 @@ const validCourses = [
"website-development-2",
"adv-full-stack-oth-2023",
"business-analytics2-2023",
"wit-hdip-comp-sci-2022-computer-system",
"wit-hdip-comp-sci-2022-computer-systems",
"wit-hdip-comp-sci-2022-security",
"wit-hdip-comp-sci-2022-devops",
"ict-for-scientists",
Expand All @@ -53,7 +51,9 @@ const validCourses = [
"wad2-2022-setu",
"wit-hdip-comp-sci-2023-workshop-2-4",
"wit-hdip-comp-sci-2023-workshop-1-3",
"mobile-app-dev-tutors-2022"
"mobile-app-dev-tutors-2022",
"wit-hdip-comp-sci-2022",
"life-etc2022"
];

export const load: PageLoad = async ({ params }) => {
Expand Down

0 comments on commit 4616f4a

Please sign in to comment.