refactor notifications popover to include unread count, mark all as read button, and loading state
```
This commit is contained in:
louiscklaw
2025-05-12 13:10:19 +08:00
parent 1a77c3a5e8
commit cf70e2af21
8 changed files with 224 additions and 23 deletions

View File

@@ -1,14 +1,18 @@
//
// RULES:
// api method for get notifications by user id
import { pb } from '@/lib/pb';
import { COL_NOTIFICATIONS } from '@/constants';
import { pb } from '@/lib/pb';
import type { Notification } from './type.d';
export async function getNotificationsByUserId(userId: string): Promise<Notification[]> {
const records = await pb.collection(COL_NOTIFICATIONS).getFullList({
filter: `author.id = "000000000000001"`,
expand: 'author, to_user_id',
filter: `to_user_id.id = "${userId}"`,
sort: '-created',
});
return records as unknown as Notification[];
}