chore: flatten repo
This commit is contained in:
20
src/routes/progress/topics/+page.server.ts
Normal file
20
src/routes/progress/topics/+page.server.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { db } from '$lib/db';
|
||||
import type { PageServerLoad } from './$types';
|
||||
|
||||
export const load: PageServerLoad = async () => {
|
||||
const topics = await db.query.topics.findMany({
|
||||
with: {
|
||||
topicsToTasks: {
|
||||
with: {
|
||||
task: true
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
topics.sort((a, b) => b.topicsToTasks.length - a.topicsToTasks.length);
|
||||
|
||||
return {
|
||||
topics
|
||||
};
|
||||
};
|
||||
29
src/routes/progress/topics/+page.svelte
Normal file
29
src/routes/progress/topics/+page.svelte
Normal file
@@ -0,0 +1,29 @@
|
||||
<script lang="ts">
|
||||
import { goto } from '$app/navigation';
|
||||
import * as Table from '$lib/components/ui/table/index.js';
|
||||
|
||||
let { data } = $props();
|
||||
</script>
|
||||
|
||||
<Table.Root>
|
||||
<Table.Header>
|
||||
<Table.Row>
|
||||
<Table.Head class="w-[100px]">Name</Table.Head>
|
||||
<Table.Head>Amount of Tasks</Table.Head>
|
||||
<Table.Head class="text-right">Actions</Table.Head>
|
||||
</Table.Row>
|
||||
</Table.Header>
|
||||
<Table.Body>
|
||||
{#each data.topics as topic}
|
||||
<Table.Row
|
||||
onclick={() => goto(`/progress/topics/${topic.id}`)}
|
||||
class="cursor-pointer hover:bg-muted/50"
|
||||
>
|
||||
<Table.Cell class="font-medium">{topic.name}</Table.Cell>
|
||||
<Table.Cell>{topic.topicsToTasks.length}</Table.Cell>
|
||||
|
||||
<Table.Cell class="text-right"></Table.Cell>
|
||||
</Table.Row>
|
||||
{/each}
|
||||
</Table.Body>
|
||||
</Table.Root>
|
||||
18
src/routes/progress/topics/[id]/+page.server.ts
Normal file
18
src/routes/progress/topics/[id]/+page.server.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { db } from '$lib/db';
|
||||
import { topics } from '$lib/db/schema';
|
||||
import { eq } from 'drizzle-orm';
|
||||
|
||||
export const load = async ({ params }) => {
|
||||
return {
|
||||
topic: await db.query.topics.findFirst({
|
||||
with: {
|
||||
topicsToTasks: {
|
||||
with: {
|
||||
task: true
|
||||
}
|
||||
}
|
||||
},
|
||||
where: eq(topics.id, params.id)
|
||||
})
|
||||
};
|
||||
};
|
||||
14
src/routes/progress/topics/[id]/+page.svelte
Normal file
14
src/routes/progress/topics/[id]/+page.svelte
Normal file
@@ -0,0 +1,14 @@
|
||||
<script lang="ts">
|
||||
let { data } = $props();
|
||||
</script>
|
||||
|
||||
<h1 class="my-4 text-2xl font-bold text-center">{data.topic.name}</h1>
|
||||
|
||||
<h2 class="text-xl font-bold">Tasks ({data.topic?.topicsToTasks.length})</h2>
|
||||
{#each data.topic?.topicsToTasks as task}
|
||||
<div class="flex gap-4 items-center relative">
|
||||
<a href="/progress/{task.task.id}" class="text-lg font-semibold hover:underline"
|
||||
>{task.task.name}</a
|
||||
>
|
||||
</div>
|
||||
{/each}
|
||||
Reference in New Issue
Block a user