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