feat: Basic homepage
This commit is contained in:
parent
d68be16688
commit
bb93de3074
4 changed files with 44 additions and 4 deletions
|
@ -1,3 +1,5 @@
|
|||
export interface Database {
|
||||
listTracksWithProducer: (producerId: string) => Promise<{ title: string }[]>;
|
||||
listTracksWithProducer: (
|
||||
producerId: string
|
||||
) => Promise<{ title: string; producer: { username: string } }[]>;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,12 @@ export class DatabasePrisma implements Database {
|
|||
listTracksWithProducer = async (producerId: string) => {
|
||||
const tracks = await this.client.track.findMany({
|
||||
select: {
|
||||
title: true
|
||||
title: true,
|
||||
producer: {
|
||||
select: {
|
||||
username: true
|
||||
}
|
||||
}
|
||||
},
|
||||
where: {
|
||||
producerId
|
||||
|
|
10
src/routes/+page.server.ts
Normal file
10
src/routes/+page.server.ts
Normal file
|
@ -0,0 +1,10 @@
|
|||
import type { PageServerLoad } from './$types';
|
||||
|
||||
export const load: PageServerLoad = async ({ locals: { authReq, database } }) => {
|
||||
const session = await authReq.validate();
|
||||
const tracks = await database.listTracksWithProducer(session.user.userId);
|
||||
|
||||
return {
|
||||
tracks
|
||||
};
|
||||
};
|
|
@ -1,5 +1,28 @@
|
|||
<script lang="ts">
|
||||
export let data;
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>Larsen</title>
|
||||
</svelte:head>
|
||||
|
||||
<h1>Your Tracks</h1>
|
||||
{#if data.isLoggedIn}
|
||||
<h1>Your Tracks</h1>
|
||||
|
||||
{#if data.tracks.length === 0}
|
||||
No tracks!
|
||||
{/if}
|
||||
|
||||
{#each data.tracks as track}
|
||||
<article>
|
||||
<hgroup>
|
||||
<h1>{track.title}</h1>
|
||||
<h2>by {track.producer.username}</h2>
|
||||
</hgroup>
|
||||
|
||||
This is a track
|
||||
</article>
|
||||
{/each}
|
||||
{:else}
|
||||
Oh no.
|
||||
{/if}
|
||||
|
|
Loading…
Reference in a new issue