disable editing when not logged in
This commit is contained in:
@@ -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')
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -37,9 +37,11 @@
|
||||
|
||||
<Popover.Root bind:open>
|
||||
<Popover.Trigger bind:this={triggerRef}>
|
||||
<Button variant="outline" class="justify-between" role="combobox" aria-expanded={open}>
|
||||
+
|
||||
</Button>
|
||||
{#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()}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user