Skip to content

Commit

Permalink
refactor: rework time and active to use shared navigator
Browse files Browse the repository at this point in the history
  • Loading branch information
edeleastar committed Sep 29, 2023
1 parent 0ca7511 commit 7d49feb
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 82 deletions.
12 changes: 12 additions & 0 deletions app/src/routes/(time)/active/[courseid]/+layout.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<script lang="ts">
import "../../../../app.postcss";
import TimeNavigator from "$lib/ui/navigators/TimeNavigator.svelte";
export let data: any;
let { supabase, session } = data;
$: ({ supabase, session } = data);
</script>

<TimeNavigator subTitle={"Students Online Now"} {supabase} {session}>
<slot />
</TimeNavigator>
34 changes: 6 additions & 28 deletions app/src/routes/(time)/active/[courseid]/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,34 +1,12 @@
<script lang="ts">
import "../../../../app.postcss";
import { AppShell } from "@skeletonlabs/skeleton";
import HomeFooter from "$lib/ui/navigators/footers/HomeFooter.svelte";
import LayoutMenu from "$lib/ui/navigators/menus/LayoutMenu.svelte";
import MainNavigator from "$lib/ui/navigators/MainNavigator.svelte";
import TutorsTitle from "$lib/ui/navigators/titles/TutorsTitle.svelte";
import { studentsOnlineList } from "./stores";
import StudentCard from "./StudentCard.svelte";
</script>

<AppShell class="h-screen">
<svelte:fragment slot="header">
<MainNavigator>
<svelte:fragment slot="lead">
<TutorsTitle title="Tutors Live Stream" subtitle="online now" />
</svelte:fragment>
<svelte:fragment slot="trail">
<span class="divider-vertical h-10 hidden lg:block" />
<LayoutMenu />
</svelte:fragment>
</MainNavigator>
</svelte:fragment>
<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 $studentsOnlineList as studentLo}
<StudentCard lo={studentLo} />
{/each}
</div>
<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 $studentsOnlineList as studentLo}
<StudentCard lo={studentLo} />
{/each}
</div>
<svelte:fragment slot="pageFooter">
<HomeFooter />
</svelte:fragment>
</AppShell>
</div>
5 changes: 5 additions & 0 deletions app/src/routes/(time)/time/[courseid]/+layout.server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const load = async ({ locals: { getSession } }) => {
return {
session: await getSession()
};
};
12 changes: 12 additions & 0 deletions app/src/routes/(time)/time/[courseid]/+layout.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<script lang="ts">
import "../../../../app.postcss";
import TimeNavigator from "$lib/ui/navigators/TimeNavigator.svelte";
export let data: any;
let { supabase, session } = data;
$: ({ supabase, session } = data);
</script>

<TimeNavigator subTitle={"Tutors Time Data"} {supabase} {session}>
<slot />
</TimeNavigator>
19 changes: 19 additions & 0 deletions app/src/routes/(time)/time/[courseid]/+layout.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { createSupabaseLoadClient } from "@supabase/auth-helpers-sveltekit";
import type { Database } from "../DatabaseDefinitions";

export const load = async ({ fetch, data, depends }) => {
depends("supabase:auth");

const supabase = createSupabaseLoadClient<Database>({
supabaseUrl: import.meta.env.VITE_PUBLIC_SUPABASE_URL,
supabaseKey: import.meta.env.VITE_PUBLIC_SUPABASE_ANON_KEY,
event: { fetch },
serverSession: data.session
});

const {
data: { session }
} = await supabase.auth.getSession();

return { supabase, session };
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
import InstructorCalendarTime from "$lib/ui/time/InstructorCalendarTime.svelte";
import CalendarTime from "$lib/ui/time/CalendarTime.svelte";
import type { PageData } from "./$types";
export let data: any;
export let data: PageData;
const storeTab: Writable<string> = writable("Labs");
let pinBuffer = "";
let instructorMode = false;
Expand Down
52 changes: 0 additions & 52 deletions app/src/routes/(time)/time/[courseid]/[...userid]/+layout.svelte

This file was deleted.

0 comments on commit 7d49feb

Please sign in to comment.