@@ -16,11 +16,13 @@ import {
1616} from '@/components/ui/pagination'
1717
1818import { Verify } from '@/lib/firebase/firebase'
19- import { CheckCircle } from 'lucide-react'
2019import type { Metadata } from 'next'
2120import { SITE_NAME } from '@/lib/consts'
2221import { getListNotifications } from '@/lib/api/notification'
2322import { readAllNotificationsAction } from '@/lib/actions/notification'
23+ import { TabLink } from '@/components/borrows/TabLink'
24+ import { CheckCircle } from 'lucide-react'
25+ import { Notification } from '@/components/notifications/Notification'
2426
2527export const metadata : Metadata = {
2628 title : `Notifications · ${ SITE_NAME } ` ,
@@ -32,6 +34,7 @@ export default async function Notifications({
3234 searchParams : Promise < {
3335 skip ?: number
3436 limit ?: number
37+ is_unread ?: 'true'
3538 } >
3639} ) {
3740 const sp = await searchParams
@@ -46,6 +49,7 @@ export default async function Notifications({
4649 {
4750 limit : limit ,
4851 skip : skip ,
52+ is_unread : sp ?. is_unread ,
4953 } ,
5054 {
5155 headers,
@@ -88,21 +92,20 @@ export default async function Notifications({
8892 </ Button >
8993 </ div >
9094 </ nav >
91- < ul className = "space-y-2" >
92- { res . data . map ( ( notification ) => (
93- < li key = { notification . id } className = "p-4 border rounded-md" >
94- < div className = "flex items-center justify-between" >
95- < div >
96- < h2 className = "text-lg font-semibold" > { notification . title } </ h2 >
97- < p className = "text-sm text-gray-500" > { notification . message } </ p >
98- </ div >
99- < span className = "text-xs text-gray-400" >
100- { new Date ( notification . created_at ) . toLocaleDateString ( ) }
101- </ span >
102- </ div >
103- </ li >
95+ < TabLink
96+ tabs = { [
97+ { name : 'Unread' , href : '/notifications?is_unread=true' } ,
98+ { name : 'All' , href : '/notifications' } ,
99+ ] }
100+ activeHref = { `/notifications${ sp ?. is_unread ? `?is_unread=${ sp . is_unread } ` : '' } ` }
101+ />
102+
103+ < div className = "space-y-2" >
104+ { res . data . map ( ( noti ) => (
105+ < Notification key = { noti . id } noti = { noti } />
104106 ) ) }
105- </ ul >
107+ </ div >
108+
106109 < Pagination >
107110 < PaginationContent >
108111 { res . meta . skip > 0 && (
0 commit comments