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 { tasks, tasksToTopics, topics } from '$lib/db/schema';
|
||||||
import { eq, and } from 'drizzle-orm';
|
import { eq, and } from 'drizzle-orm';
|
||||||
|
|
||||||
export const load = async ({ params }) => {
|
export const load = async ({ cookies, params }) => {
|
||||||
return {
|
return {
|
||||||
task: await db.query.tasks.findFirst({
|
task: await db.query.tasks.findFirst({
|
||||||
with: {
|
with: {
|
||||||
@@ -14,7 +14,8 @@ export const load = async ({ params }) => {
|
|||||||
},
|
},
|
||||||
where: eq(tasks.id, params.id)
|
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.Root bind:open>
|
||||||
<Popover.Trigger bind:this={triggerRef}>
|
<Popover.Trigger bind:this={triggerRef}>
|
||||||
|
{#if data.editable}
|
||||||
<Button variant="outline" class="justify-between" role="combobox" aria-expanded={open}>
|
<Button variant="outline" class="justify-between" role="combobox" aria-expanded={open}>
|
||||||
+
|
+
|
||||||
</Button>
|
</Button>
|
||||||
|
{/if}
|
||||||
</Popover.Trigger>
|
</Popover.Trigger>
|
||||||
<Popover.Content class="w-[200px] p-0">
|
<Popover.Content class="w-[200px] p-0">
|
||||||
<Command.Root>
|
<Command.Root>
|
||||||
@@ -126,6 +128,7 @@
|
|||||||
value={data.task?.currentPoints}
|
value={data.task?.currentPoints}
|
||||||
class="w-20 p-2 border rounded"
|
class="w-20 p-2 border rounded"
|
||||||
min="0"
|
min="0"
|
||||||
|
readonly={!data.editable}
|
||||||
onchange={(e) => e.target.form?.submit()}
|
onchange={(e) => e.target.form?.submit()}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
@@ -139,6 +142,7 @@
|
|||||||
name="totalPoints"
|
name="totalPoints"
|
||||||
value={data.task?.totalPoints}
|
value={data.task?.totalPoints}
|
||||||
class="w-20 p-2 border rounded"
|
class="w-20 p-2 border rounded"
|
||||||
|
readonly={!data.editable}
|
||||||
min="1"
|
min="1"
|
||||||
onchange={(e) => e.target.form?.submit()}
|
onchange={(e) => e.target.form?.submit()}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user