11"use client"
22
3- import { Search } from "lucide-react"
3+ import { Search , Star } from "lucide-react"
4+ import Image from "next/image"
45import Link from "next/link"
56import { useState } from "react"
67import { toast } from "sonner"
78import { useDebounce } from "use-debounce"
9+ import logo from "@/assets/logo.png"
810import { Button } from "@/components/ui/button"
911import {
1012 Card ,
@@ -30,9 +32,11 @@ import {
3032} from "@/components/ui/table"
3133import { useUrls } from "@/hooks/urls"
3234import type { UrlRecord , UrlsQueryParams } from "@/lib/schemas"
35+ import { copyToClipboard } from "@/lib/utils"
3336import { CreateUrlDialog } from "./create-url-dialog"
3437import { EditUrlDialog } from "./edit-url-dialog"
3538import { PaginationControls } from "./pagination"
39+ import { Toggle } from "./ui/toggle"
3640import { UrlRecordRow } from "./url-record-row"
3741
3842export function Dashboard ( ) {
@@ -58,6 +62,14 @@ export function Dashboard() {
5862 url ?: UrlRecord
5963 } > ( { open : false } )
6064
65+ const handleCustomOnlyToggle = ( ) => {
66+ setQueryParams ( ( prev ) => ( {
67+ ...prev ,
68+ customOnly : ! prev . customOnly ,
69+ page : 1 ,
70+ } ) )
71+ }
72+
6173 const handleSortChange = ( value : string ) => {
6274 const [ sortBy , sortOrder ] = value . split ( "-" ) as [
6375 UrlsQueryParams [ "sortBy" ] ,
@@ -97,22 +109,13 @@ export function Dashboard() {
97109 }
98110 }
99111
100- const copyToClipboard = async ( text : string ) => {
101- try {
102- await navigator . clipboard . writeText ( text )
103- toast . success ( "Copied to clipboard" )
104- } catch ( error ) {
105- console . error ( "Error copying to clipboard:" , error )
106- toast . error ( "Failed to copy to clipboard" )
107- }
108- }
109-
110112 const currentSort = `${ qp . sortBy } -${ qp . sortOrder } `
111113
112114 return (
113115 < div className = "container mx-auto p-6 space-y-6" >
114- < div className = "flex justify-between items-center" >
115- < div >
116+ < div className = "flex gap-4 items-center" >
117+ < Image src = { logo } alt = "PoliNetwork Logo" className = "h-16 w-16" />
118+ < div className = "mr-auto" >
116119 < h1 className = "text-3xl font-bold" > URL Shortener Dashboard</ h1 >
117120 < p className = "text-muted-foreground" >
118121 Manage your shortened URLs for PoliNetwork domains
@@ -163,6 +166,14 @@ export function Dashboard() {
163166 < SelectItem value = "short_code-desc" > Short Code Z-A</ SelectItem >
164167 </ SelectContent >
165168 </ Select >
169+ < Toggle
170+ pressed = { queryParams . customOnly }
171+ onPressedChange = { handleCustomOnlyToggle }
172+ className = "data-[state=on]:bg-secondary data-[state=on]:*:[svg]:fill-yellow-300 data-[state=on]:*:[svg]:stroke-yellow-300"
173+ >
174+ < Star className = "h-4 w-4" />
175+ Show Custom Only
176+ </ Toggle >
166177 </ div >
167178
168179 { /* Table */ }
@@ -179,11 +190,14 @@ export function Dashboard() {
179190 < Table >
180191 < TableHeader >
181192 < TableRow >
193+ < TableHead className = "w-4" >
194+ < Star className = "h-4 w-4" />
195+ </ TableHead >
182196 < TableHead > Short URL</ TableHead >
183197 < TableHead > Original URL</ TableHead >
184- < TableHead > Clicks</ TableHead >
185198 < TableHead > Created</ TableHead >
186- < TableHead > Actions</ TableHead >
199+ < TableHead className = "w-0 text-center" > Clicks</ TableHead >
200+ < TableHead className = "w-0 text-center" > Actions</ TableHead >
187201 </ TableRow >
188202 </ TableHeader >
189203 < TableBody >
0 commit comments