feat: tasks table

This commit is contained in:
2025-01-11 18:31:52 +01:00
parent 45be47ff32
commit c617a75291

View File

@@ -2,45 +2,64 @@
let { data } = $props(); let { data } = $props();
</script> </script>
<div class="flex justify-center items-center"> <div class="flex flex-col items-center p-4">
<h1 class="font-bold text-xl text-center m-4">Tasks ({data.tasks.length})</h1> <div class="w-full max-w-4xl flex justify-center gap-8 items-center mt-4 mb-8">
<a href={'/progress/create'}> <h1 class="font-bold text-2xl">
<button class="px-4 py-2 rounded bg-green-500">Create</button> Tasks ({data.tasks.length})
</h1>
<a href="/progress/create">
<button class="px-4 py-2 bg-green-500 text-white rounded hover:bg-green-600 transition">
Create
</button>
</a> </a>
</div> </div>
<table> {#if data.tasks.length > 0}
<div class="overflow-x-auto w-full">
<table class="min-w-full bg-white border border-gray-200">
<thead> <thead>
<tr> <tr class="bg-gray-100">
<th>ID</th> <th class="px-6 py-3 border-b text-left text-sm font-semibold text-gray-700">Name</th>
<th>Name</th> <th class="px-6 py-3 border-b text-left text-sm font-semibold text-gray-700">Type</th>
<th>Progress</th> <th class="px-6 py-3 border-b text-left text-sm font-semibold text-gray-700"
<th>Actions</th> >Progress</th
>
<th class="px-6 py-3 border-b text-left text-sm font-semibold text-gray-700">Actions</th
>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{#each data.tasks as task} {#each data.tasks as task, index}
<tr> <tr class="{index % 2 === 0 ? 'bg-white' : 'bg-gray-50'} hover:bg-gray-200">
<td> <td class="px-6 py-2 border-b">
<a href={'/progress/' + task.id}> <a href={`/progress/${task.id}`} class="text-blue-500 hover:underline">
{task.id}
</a>
</td><td>
<a href={'/progress/' + task.id}>
{task.name} {task.name}
</a> </a>
</td> </td>
<td> <td class="px-6 py-2 border-b">
<a href={'/progress/' + task.id}> <a href={`/progress/${task.id}`} class="text-blue-500 hover:underline">
{task.progress} {task.type}
</a> </a>
</td> </td>
<td>
<a href={'/progress/' + task.id}> <td class="px-6 py-2 border-b">
<button>Delete</button> {task.progress}%
</a> </td>
<td class="px-6 py-2 border-b">
<button
onclick={() => {}}
class="px-3 py-1 bg-red-500 text-white rounded hover:bg-red-600 transition"
aria-label={`Delete task ${task.name}`}
>
Delete
</button>
</td> </td>
</tr> </tr>
{/each}</tbody {/each}
> </tbody>
</table> </table>
</div>
{:else}
<p class="text-gray-500">No tasks available. Click "Create" to add a new task.</p>
{/if}
</div>