| 1 | import type { Metadata } from "next"; |
| 2 | |
| 3 | import { CursorPagination } |
| 4 | import { TabLink } |
| 5 | import { createServerClient } |
| 6 | |
| 7 | import { MarkAllReadButton } |
| 8 | import { NotificationItem } |
| 9 | import { |
| 10 | Empty, |
| 11 | EmptyDescription, |
| 12 | EmptyHeader, |
| 13 | EmptyTitle, |
| 14 | } from "@/components/ui/empty"; |
| 15 | |
| 16 | export const metadata: |
| 17 | |
| 18 | export default async function |
| 19 | searchParams, |
| 20 | }: PageProps< |
| 21 | const { filter, |
| 22 | const all = |
| 23 | const pageCursor = |
| 24 | |
| 25 | const client = |
| 26 | const { data |
| 27 | params: { query: { |
| 28 | }); |
| 29 | // signed out: the layout is already on its way to sign-in |
| 30 | if (!data) |
| 31 | |
| 32 | return ( |
| 33 | <div className="flex flex-col gap-4 |
| 34 | <div className="flex flex-wrap items-center gap-2 border-b |
| 35 | <h1 className="mr-4 pb-2 text-xl font-semibold |
| 36 | <nav className="-mb-px flex gap-1 |
| 37 | <TabLink href=" |
| 38 | Unread |
| 39 | </TabLink> |
| 40 | <TabLink href=" |
| 41 | All |
| 42 | </TabLink> |
| 43 | </nav> |
| 44 | {data.notifications.some |
| 45 | <MarkAllReadButton /> |
| 46 | )} |
| 47 | </div> |
| 48 | |
| 49 | {data.notifications.length |
| 50 | <Empty className=" |
| 51 | <EmptyHeader> |
| 52 | <EmptyTitle> |
| 53 | {all ? "No notifications yet |
| 54 | </EmptyTitle> |
| 55 | <EmptyDescription> |
| 56 | Mentions, assignments and activity on threads you follow show up |
| 57 | here. |
| 58 | </EmptyDescription> |
| 59 | </EmptyHeader> |
| 60 | </Empty> |
| 61 | ) : ( |
| 62 | <ul className="divide-y rounded-lg border |
| 63 | {data.notifications.map |
| 64 | <NotificationItem |
| 65 | key={notification.id |
| 66 | notification={notification} |
| 67 | /> |
| 68 | ))} |
| 69 | </ul> |
| 70 | )} |
| 71 | |
| 72 | <CursorPagination |
| 73 | pathname="/notifications" |
| 74 | params={{ filter: |
| 75 | cursor={pageCursor} |
| 76 | nextCursor={data.nextCursor |
| 77 | /> |
| 78 | </div> |
| 79 | ); |
| 80 | } |