disable editing when not logged in

This commit is contained in:
2025-02-24 20:18:06 +01:00
parent cf8c444d4a
commit 122830a3f5
2 changed files with 10 additions and 5 deletions

View File

@@ -2,7 +2,7 @@ import { db } from '$lib/db';
import { tasks, tasksToTopics, topics } from '$lib/db/schema';
import { eq, and } from 'drizzle-orm';
export const load = async ({ params }) => {
export const load = async ({ cookies, params }) => {
return {
task: await db.query.tasks.findFirst({
with: {
@@ -14,7 +14,8 @@ export const load = async ({ params }) => {
},
where: eq(tasks.id, params.id)
}),
topics: await db.query.topics.findMany()
topics: await db.query.topics.findMany(),
editable: cookies.get('token')
};
};

View File

@@ -37,9 +37,11 @@
<Popover.Root bind:open>
<Popover.Trigger bind:this={triggerRef}>
{#if data.editable}
<Button variant="outline" class="justify-between" role="combobox" aria-expanded={open}>
+
</Button>
{/if}
</Popover.Trigger>
<Popover.Content class="w-[200px] p-0">
<Command.Root>
@@ -126,6 +128,7 @@
value={data.task?.currentPoints}
class="w-20 p-2 border rounded"
min="0"
readonly={!data.editable}
onchange={(e) => e.target.form?.submit()}
/>
@@ -139,6 +142,7 @@
name="totalPoints"
value={data.task?.totalPoints}
class="w-20 p-2 border rounded"
readonly={!data.editable}
min="1"
onchange={(e) => e.target.form?.submit()}
/>