+ let:isIndeterminate
+ >
{#if isChecked}
{:else if isIndeterminate}
diff --git a/frontend/src/lib/components/ui/checkbox/index.ts b/frontend/src/lib/components/ui/checkbox/index.ts
index 94d8674..6d92d94 100644
--- a/frontend/src/lib/components/ui/checkbox/index.ts
+++ b/frontend/src/lib/components/ui/checkbox/index.ts
@@ -1,6 +1,6 @@
-import Root from './checkbox.svelte'
+import Root from "./checkbox.svelte";
export {
Root,
//
Root as Checkbox,
-}
+};
diff --git a/frontend/src/lib/db/schema.ts b/frontend/src/lib/db/schema.ts
index bd1e113..11b97ec 100644
--- a/frontend/src/lib/db/schema.ts
+++ b/frontend/src/lib/db/schema.ts
@@ -5,6 +5,7 @@ import {
timestamp,
integer,
uuid,
+ boolean,
} from 'drizzle-orm/pg-core'
import { relations, type InferSelectModel } from 'drizzle-orm'
@@ -17,6 +18,7 @@ export const shortener = pgTable('shortener', {
.defaultNow()
.notNull(),
userId: integer('user_id').notNull(),
+ active: boolean('active').notNull().default(true),
projectId: integer('project_id'),
})
diff --git a/frontend/src/routes/(app)/links/+page.svelte b/frontend/src/routes/(app)/links/+page.svelte
index 2753903..2b7733b 100644
--- a/frontend/src/routes/(app)/links/+page.svelte
+++ b/frontend/src/routes/(app)/links/+page.svelte
@@ -12,6 +12,7 @@
import { Input } from '$lib/components/ui/input'
import { Label } from '$lib/components/ui/label'
import { Badge } from '$lib/components/ui/badge'
+ import { Checkbox } from '$lib/components/ui/checkbox'
import {
BarChart,
ExternalLink,
@@ -35,6 +36,7 @@
let editShortenerCode = ''
let editShortenerLink = ''
let editShortenerCategory: any = undefined
+ let editShortenerActive = false
let isEditLoading = false
let open: boolean = false
@@ -42,15 +44,27 @@
$: selectedProject = data.selected_project.label
- const openEditDialog = (code: string, link: string) => {
+ const openEditDialog = (
+ code: string,
+ link: string,
+ projectId: number | null,
+ projectName: string | undefined,
+ active: boolean,
+ ) => {
editDialogOpen = true
editShortenerCode = code
editShortenerLink = link
- editShortenerCategory = undefined
+ editShortenerActive = active
+ if (projectId) {
+ editShortenerCategory = { value: projectId, label: projectName }
+ } else {
+ editShortenerCategory = undefined
+ }
}
const editShortener = async (code: string, link: string) => {
isEditLoading = true
+ console.log(editShortenerCategory)
await fetch(`/api/shortener/${code}`, {
method: 'put',
body: JSON.stringify({
@@ -58,6 +72,7 @@
projectId: editShortenerCategory
? editShortenerCategory.value
: undefined,
+ active: editShortenerActive,
}),
})
await invalidateAll()
@@ -169,10 +184,25 @@
- {shortener.project
- ? shortener.project.name
- : 'Uncategorized'}
+
+
+ {#if shortener.active}
+
+ Active
+ {:else}
+
+ Inactive
+ {/if}
+
+ {shortener.project
+ ? shortener.project.name
+ : 'Uncategorized'}
+
{shortener.link}
@@ -201,7 +231,13 @@
- openEditDialog(shortener.code, shortener.link)}>
+ openEditDialog(
+ shortener.code,
+ shortener.link,
+ shortener.projectId,
+ shortener.project?.name,
+ shortener.active,
+ )}>
Edit
+