blob: a6780e1e2c06d3c24d4b8ce4eac78d794de9c97e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
"use client";
import { useRouter } from "next/navigation";
import { Button } from "@/components/ui/button";
import { MoreHorizontal } from "lucide-react";
import { api } from "@hoarder/shared-react/trpc";
import { ZBookmarkList } from "@hoarder/shared/types/lists";
import { ListOptions } from "./ListOptions";
export default function ListHeader({
initialData,
}: {
initialData: ZBookmarkList & { bookmarks: string[] };
}) {
const router = useRouter();
const { data: list, error } = api.lists.get.useQuery(
{
listId: initialData.id,
},
{
initialData,
},
);
if (error) {
// This is usually exercised during list deletions.
if (error.data?.code == "NOT_FOUND") {
router.push("/dashboard/lists");
}
}
return (
<div className="flex items-center justify-between">
<span className="text-2xl">
{list.icon} {list.name}
</span>
<div className="flex">
<ListOptions list={list}>
<Button variant="ghost">
<MoreHorizontal />
</Button>
</ListOptions>
</div>
</div>
);
}
|