diff --git a/src/app/(home)/_components/list-button.tsx b/src/app/(home)/_components/list-button.tsx new file mode 100644 index 0000000..e4de4c7 --- /dev/null +++ b/src/app/(home)/_components/list-button.tsx @@ -0,0 +1,51 @@ +"use client"; + +import {} from "@radix-ui/react-dropdown-menu"; +import { Dot, MoreHorizontal } from "lucide-react"; +import Link from "next/link"; +import { Button } from "~/app/_components/ui/button"; +import { + DropdownMenu, + DropdownMenuTrigger, + DropdownMenuContent, + DropdownMenuItem, +} from "~/app/_components/ui/dropdown-menu"; +import { api } from "~/trpc/react"; + +export const ListButton = ({ id, name }: { id: number; name: string }) => { + const newName = "test new name"; + + const { mutate: updateMutation } = api.list.update.useMutation(); + const { mutate: deleteMutation } = api.list.delete.useMutation(); + + const handleRename = () => updateMutation({ listId: id, name: newName }); + const handleDelete = () => deleteMutation({ listId: id }); + + return ( + + + + {name} + + + + + Open menu + + + + Rename + Delete + + + + + ); +}; diff --git a/src/app/(home)/page.tsx b/src/app/(home)/page.tsx new file mode 100644 index 0000000..7fb8e41 --- /dev/null +++ b/src/app/(home)/page.tsx @@ -0,0 +1,39 @@ +import { auth } from "~/server/auth"; +import { UserNav } from "~/app/_components/user-nav"; +import { Button } from "~/app/_components/ui/button"; +import { api } from "~/trpc/server"; +import { ListButton } from "~/app/(home)/_components/list-button"; + +export default async function Home() { + const session = await auth(); + if (!session) { + + Not signed in + ; + } + + const allLists = await api.list.getAll(); + + return ( + + + {session?.user.name ? `${session.user.name}'s notes` : "notes"} + + + + + + create a new list + + + + + {allLists.map(({ id, name }) => ( + + ))} + + + + + ); +} diff --git a/src/app/page.tsx b/src/app/page.tsx deleted file mode 100644 index 27421d5..0000000 --- a/src/app/page.tsx +++ /dev/null @@ -1,84 +0,0 @@ -import { auth } from "~/server/auth"; -import { - Table, - TableBody, - TableCaption, - TableCell, - TableHead, - TableHeader, - TableRow, -} from "~/app/_components/ui/table"; -import { UserNav } from "~/app/_components/user-nav"; -import { DataTable } from "~/app/_components/data-table"; -import { z } from "zod"; -import { promises as fs } from "fs"; -import path from "path"; -import { columns } from "~/app/_components/columns"; -import { taskSchema } from "~/app/_components/schema"; - -async function getTasks() { - const data = await fs.readFile( - path.join(process.cwd(), "src/app/_data/tasks.json"), - ); - - const tasks = JSON.parse(data.toString()); - - return z.array(taskSchema).parse(tasks); -} - -export default async function Home() { - const session = await auth(); - if (!session) { - - Not signed in - ; - } - - const tasks = await getTasks(); - - return ( - - - {session?.user.name ? `${session.user.name}'s notes` : "notes"} - - - - {/* - A list of your recent invoices. - - - Invoice - Status - Method - Amount - - - - - INV001 - Paid - Credit Card - $250.00 - - - */} - - - - - Welcome back! - - - Here's a list of your tasks for this month! - - - - - - - - - - - ); -}
- Here's a list of your tasks for this month! -