feat: add admin interface for viewing and managing contact messages, including a new service and sidebar navigation.

This commit is contained in:
pradeepkumar
2026-03-20 12:43:56 +05:30
parent 4ef751509a
commit 82ed2ef987
3 changed files with 248 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
import api, { ApiResponse } from './api';
export interface ContactMessage {
id: string;
name: string;
email: string;
phone: string | null;
message: string;
isRead: boolean;
createdAt: string;
}
export interface ContactCounts {
total: number;
unread: number;
}
class ContactService {
async getAllMessages(isRead?: boolean): Promise<ContactMessage[]> {
const params: Record<string, string> = {};
if (isRead !== undefined) params.isRead = String(isRead);
const response = await api.get<ApiResponse<ContactMessage[]>>('/contact/admin/all', { params });
return response.data.data;
}
async getCounts(): Promise<ContactCounts> {
const response = await api.get<ApiResponse<ContactCounts>>('/contact/admin/counts');
return response.data.data;
}
async markAsRead(id: string): Promise<ContactMessage> {
const response = await api.patch<ApiResponse<ContactMessage>>(`/contact/admin/${id}/read`);
return response.data.data;
}
async deleteMessage(id: string): Promise<void> {
await api.delete(`/contact/admin/${id}`);
}
}
export const contactService = new ContactService();