Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ed54e33
commit 0090334
Showing
4 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import type {SupabaseClient} from "@supabase/supabase-js"; | ||
import type {Database} from "../../../supabase/database.types"; | ||
|
||
const GetUserDevices = (supabase: SupabaseClient<Database>) => | ||
async (owner: string) => { | ||
const {data, error} = await supabase | ||
.from('device') | ||
.select() | ||
.eq('owner', owner); | ||
|
||
if (error) { | ||
console.error(error); | ||
} | ||
|
||
return data; | ||
} | ||
|
||
export default GetUserDevices; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,18 @@ | ||
<script lang="ts"> | ||
import type { PageData } from './$types'; | ||
export let data: PageData; | ||
$: ({ devices } = data); | ||
</script> | ||
|
||
<div>WIP: Devices</div> | ||
|
||
{#if devices?.length} | ||
<ul> | ||
{#each devices as device} | ||
<li>{device.name}</li> | ||
{/each} | ||
</ul> | ||
{:else} | ||
<div>No devices found</div> | ||
{/if} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { redirect } from '@sveltejs/kit'; | ||
import GetUserDevices from "../../lib/features/device/getUserDevices/getUserDevices"; | ||
import type { PageLoad } from './$types'; | ||
|
||
export const load: PageLoad = async ({ parent }) => { | ||
const { supabase, session } = await parent(); | ||
if (!session) { | ||
throw redirect(303, '/'); | ||
} | ||
|
||
const getUserDevices = GetUserDevices(supabase); | ||
const devices = await getUserDevices(session.user.id); | ||
|
||
return { | ||
devices | ||
}; | ||
}; |
This file was deleted.
Oops, something went wrong.