Skip to content

Commit 46aab93

Browse files
committed
fix: what was fixable
1 parent c479621 commit 46aab93

File tree

22 files changed

+234
-79
lines changed

22 files changed

+234
-79
lines changed

Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ RUN --mount=type=cache,id=pnpm,target=./pnpm/store pnpm install --frozen-lockfil
2323
FROM base AS builder
2424

2525
COPY --from=deps /app/node_modules ./node_modules
26-
RUN pwd
2726
COPY . .
2827

2928
# Next.js collects completely anonymous telemetry data about general usage.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"@radix-ui/react-label": "^2.1.7",
2525
"@radix-ui/react-select": "^2.2.6",
2626
"@radix-ui/react-slot": "^1.2.3",
27+
"@radix-ui/react-toggle": "^1.1.10",
2728
"@scalar/nextjs-api-reference": "^0.8.23",
2829
"@t3-oss/env-nextjs": "^0.13.8",
2930
"@tanstack/react-query": "^5.90.5",

pnpm-lock.yaml

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/api/[...ts-rest]/route.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const handler = createNextHandler(
1212
search: query.search,
1313
sortBy: query.sortBy,
1414
sortOrder: query.sortOrder,
15+
customOnly: query.customOnly,
1516
})
1617
return {
1718
status: 200,

src/app/globals.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,4 +188,11 @@
188188
@apply bg-background text-foreground;
189189
letter-spacing: var(--tracking-normal);
190190
}
191+
}
192+
193+
@layer base {
194+
button:not(:disabled),
195+
[role="button"]:not(:disabled) {
196+
cursor: pointer;
197+
}
191198
}

src/assets/logo.png

8.96 KB
Loading

src/components/dashboard.tsx

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
"use client"
22

3-
import { Search } from "lucide-react"
3+
import { Search, Star } from "lucide-react"
4+
import Image from "next/image"
45
import Link from "next/link"
56
import { useState } from "react"
67
import { toast } from "sonner"
78
import { useDebounce } from "use-debounce"
9+
import logo from "@/assets/logo.png"
810
import { Button } from "@/components/ui/button"
911
import {
1012
Card,
@@ -30,9 +32,11 @@ import {
3032
} from "@/components/ui/table"
3133
import { useUrls } from "@/hooks/urls"
3234
import type { UrlRecord, UrlsQueryParams } from "@/lib/schemas"
35+
import { copyToClipboard } from "@/lib/utils"
3336
import { CreateUrlDialog } from "./create-url-dialog"
3437
import { EditUrlDialog } from "./edit-url-dialog"
3538
import { PaginationControls } from "./pagination"
39+
import { Toggle } from "./ui/toggle"
3640
import { UrlRecordRow } from "./url-record-row"
3741

3842
export 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>

src/components/pagination.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { useState } from "react"
2+
import type { PaginatedUrlsResponse } from "@/lib/schemas"
23
import { withPages } from "@/lib/utils"
34
import {
45
Pagination,
@@ -16,13 +17,12 @@ import {
1617
SelectValue,
1718
} from "./ui/select"
1819

19-
export function PaginationControls(props: {
20-
page: number
21-
limit: number
22-
total: number
23-
onPageChange: (page: number) => void
24-
onLimitChange?: (limit: number) => void
25-
}) {
20+
export function PaginationControls(
21+
props: {
22+
onPageChange: (page: number) => void
23+
onLimitChange?: (limit: number) => void
24+
} & PaginatedUrlsResponse["pagination"]
25+
) {
2626
const [limit, setLimit] = useState(props.limit)
2727

2828
const handleLimitChange = (value: string) => {
@@ -56,7 +56,7 @@ export function PaginationControls(props: {
5656
/>
5757
</PaginationItem>
5858

59-
{withPages(props.page, props.total).map(({ page, ellipses }) => {
59+
{withPages(props.page, props.totalPages).map(({ page, ellipses }) => {
6060
return (
6161
<div key={page} className="flex">
6262
{ellipses && (

src/components/ui/card.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type * as React from "react"
1+
import * as React from "react"
22

33
import { cn } from "@/lib/utils"
44

@@ -20,7 +20,7 @@ function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
2020
<div
2121
data-slot="card-header"
2222
className={cn(
23-
"@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",
23+
"@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",
2424
className
2525
)}
2626
{...props}

src/components/ui/dialog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"use client"
22

3+
import * as React from "react"
34
import * as DialogPrimitive from "@radix-ui/react-dialog"
45
import { XIcon } from "lucide-react"
5-
import type * as React from "react"
66

77
import { cn } from "@/lib/utils"
88

0 commit comments

Comments
 (0)