feat: allow disabled links
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
<script setup lang="ts">
|
||||
import type { TableColumn } from "@nuxt/ui";
|
||||
|
||||
const UBadge = resolveComponent("UBadge");
|
||||
|
||||
const props = defineProps<{
|
||||
data: Link[];
|
||||
status: "pending" | "idle" | "success" | "error";
|
||||
@@ -28,6 +30,16 @@ const columns: TableColumn<Link>[] = [
|
||||
row.original.url,
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "disabled",
|
||||
header: "Status",
|
||||
cell: ({ row }) =>
|
||||
h(UBadge, {
|
||||
label: row.original.disabled ? "Disabled" : "Active",
|
||||
color: row.original.disabled ? "error" : "success",
|
||||
variant: "subtle",
|
||||
}),
|
||||
},
|
||||
{
|
||||
id: "actions",
|
||||
cell: ({ row }) =>
|
||||
|
||||
@@ -17,10 +17,15 @@ const signOut = async () => {
|
||||
const { data: links, status, refresh } = useLazyFetch("/api/links", { key: "links", server: false, });
|
||||
|
||||
const route = useRoute();
|
||||
const category = computed(() => route.query.filter === "disabled" ? "disabled" : "all",);
|
||||
const category = computed(() => {
|
||||
if (route.query.filter === "active") return "active";
|
||||
if (route.query.filter === "disabled") return "disabled";
|
||||
return "all";
|
||||
});
|
||||
|
||||
const filteredLinks = computed(() => {
|
||||
if (!links.value) return [];
|
||||
if (category.value === "active") return links.value.filter((l) => !l.disabled);
|
||||
if (category.value === "disabled") return links.value.filter((l) => l.disabled);
|
||||
return links.value;
|
||||
});
|
||||
@@ -61,6 +66,13 @@ const deleteLink = async (link: Link) => {
|
||||
to: '/dashboard',
|
||||
active: category === 'all',
|
||||
},
|
||||
{
|
||||
label: 'Active',
|
||||
icon: 'i-lucide-link-2',
|
||||
badge: links?.filter((l) => !l.disabled).length ?? 0,
|
||||
to: '/dashboard?filter=active',
|
||||
active: category === 'active',
|
||||
},
|
||||
{
|
||||
label: 'Disabled',
|
||||
icon: 'i-lucide-link-2-off',
|
||||
@@ -80,7 +92,7 @@ const deleteLink = async (link: Link) => {
|
||||
|
||||
<UDashboardPanel>
|
||||
<template #header>
|
||||
<UDashboardNavbar :title="category === 'all' ? 'All links' : 'Disabled links'">
|
||||
<UDashboardNavbar :title="category === 'all' ? 'All links' : category === 'active' ? 'Active links' : 'Disabled links'">
|
||||
<template #right>
|
||||
<UButton icon="i-lucide-plus" @click="openModal(null)">
|
||||
New link
|
||||
|
||||
Reference in New Issue
Block a user