Add /tasks route to load all tasks.

Currently just a proof of concept. The data is pulled from the database
and a few fields display in a table.
This commit is contained in:
themodrnhakr 2025-09-27 14:20:39 -05:00
parent 5fddf2f394
commit 136b58c44f
2 changed files with 42 additions and 0 deletions

View File

@ -0,0 +1,10 @@
import TasksService from "$lib/server/services/tasks";
import type { PageServerLoad } from "./$types";
export const load: PageServerLoad = async () => {
const tasks = new TasksService("internal");
return {
tasks: await tasks.getAll(),
test: "string",
};
};

View File

@ -0,0 +1,32 @@
<script lang="ts">
import type { PageProps } from "./$types";
let { data }: PageProps = $props();
</script>
{#if data.tasks}
<p>{data.tasks.length} total records.</p>
<table>
<thead>
<tr>
<td><strong>Id</strong></td>
<td><strong>Description</strong></td>
<td><strong>Status</strong></td>
</tr>
</thead>
<tbody>
{#each data.tasks as task (task.id)}
<tr>
<td
>{task.type?.prefix +
task.taskId}</td
>
<td>{task.description}</td>
<td>{task.status}</td>
</tr>
{/each}
</tbody>
</table>
{:else}
<p>There was an error accessing the database.</p>
{/if}