251208:0010 Backend & Frontend Debug
Some checks failed
Spec Validation / validate-markdown (push) Has been cancelled
Spec Validation / validate-diagrams (push) Has been cancelled
Spec Validation / check-todos (push) Has been cancelled

This commit is contained in:
2025-12-08 00:10:37 +07:00
parent 32d820ea6b
commit dcd126d704
99 changed files with 2775 additions and 1480 deletions

View File

@@ -1,48 +1,21 @@
// File: lib/services/notification.service.ts
import apiClient from "@/lib/api/client";
import {
SearchNotificationDto,
CreateNotificationDto
} from "@/types/dto/notification/notification.dto";
import { NotificationResponse } from "@/types/notification";
export const notificationService = {
/** * ดึงรายการแจ้งเตือนของผู้ใช้ปัจจุบัน
* GET /notifications
*/
getMyNotifications: async (params?: SearchNotificationDto) => {
const response = await apiClient.get("/notifications", { params });
getUnread: async (): Promise<NotificationResponse> => {
const response = await apiClient.get("/notifications/unread");
// Backend should return { items: [], unreadCount: number }
// Or just items and we count on frontend, but typically backend gives count.
return response.data;
},
/** * สร้างการแจ้งเตือนใหม่ (มักใช้โดย System หรือ Admin)
* POST /notifications
*/
create: async (data: CreateNotificationDto) => {
const response = await apiClient.post("/notifications", data);
return response.data;
},
/** * อ่านแจ้งเตือน (Mark as Read)
* PATCH /notifications/:id/read
*/
markAsRead: async (id: number | string) => {
markAsRead: async (id: number) => {
const response = await apiClient.patch(`/notifications/${id}/read`);
return response.data;
},
/** * อ่านทั้งหมด (Mark All as Read)
* PATCH /notifications/read-all
*/
markAllAsRead: async () => {
const response = await apiClient.patch("/notifications/read-all");
return response.data;
},
/** * ลบการแจ้งเตือน
* DELETE /notifications/:id
*/
delete: async (id: number | string) => {
const response = await apiClient.delete(`/notifications/${id}`);
const response = await apiClient.patch(`/notifications/read-all`);
return response.data;
}
};
};