feat(notifications): add notification history page and API
This commit introduces the notification history feature, allowing users to view a log of their past notifications. Key changes include: - Added a "Notifications" link to the sidebar with a new icon. - Defined API endpoints for fetching notification history and details. - Added a "sent" status variant for displaying notification status. Additionally, this commit includes related UI improvements: - The user's full name is now dynamically displayed in the header, replacing the hardcoded placeholder. - Table headers are now styled in uppercase for improved readability and consistency.
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import api from "../axios";
|
||||
import { API_ENDPOINTS } from "../endpoints";
|
||||
import {
|
||||
TNotificationDetailsResponse,
|
||||
TNotificationHistoryResponse,
|
||||
} from "../types/NotificationHistory";
|
||||
import { ApiResponse } from "../types/shared";
|
||||
|
||||
export const notificationService = {
|
||||
getNotifications: async (
|
||||
params?: Record<string, any>,
|
||||
): Promise<TNotificationHistoryResponse> => {
|
||||
try {
|
||||
return (await api.get(API_ENDPOINTS.NOTIFICATIONS.HISTORY, { params }))
|
||||
.data;
|
||||
} catch (error) {
|
||||
console.error(
|
||||
"ERROR Caught in notification service => getNotifications",
|
||||
error,
|
||||
);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
getNotificationDetails: async (
|
||||
id: string,
|
||||
): Promise<ApiResponse<TNotificationDetailsResponse>> => {
|
||||
try {
|
||||
return (await api.get(API_ENDPOINTS.NOTIFICATIONS.DETAILS(id))).data;
|
||||
} catch (error) {
|
||||
console.error(
|
||||
"ERROR Caught in notification service => getNotificationDetails",
|
||||
error,
|
||||
);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user