mirror of
https://github.com/Sea-Haven-Industries/proposal-system.git
synced 2026-09-30 11:13:14 +00:00
77 lines
1.9 KiB
TypeScript
77 lines
1.9 KiB
TypeScript
|
|
import apiClient from './client';
|
||
|
|
|
||
|
|
export interface DashboardStats {
|
||
|
|
pendingCount: number;
|
||
|
|
approvedThisWeek: number;
|
||
|
|
avgTurnaroundHours: number;
|
||
|
|
totalProposals: number;
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface UpdateProposalRequest {
|
||
|
|
refinedScope?: string;
|
||
|
|
notes?: string;
|
||
|
|
assignedAdminId?: string;
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface AuditEntry {
|
||
|
|
id: string;
|
||
|
|
proposalId: string | null;
|
||
|
|
userId: string;
|
||
|
|
userName: string;
|
||
|
|
action: string;
|
||
|
|
details: Record<string, unknown>;
|
||
|
|
timestamp: string;
|
||
|
|
ipAddress: string | null;
|
||
|
|
}
|
||
|
|
|
||
|
|
export const adminApi = {
|
||
|
|
getDashboard: async (): Promise<DashboardStats> => {
|
||
|
|
const res = await apiClient.get('/admin/dashboard');
|
||
|
|
return res.data;
|
||
|
|
},
|
||
|
|
|
||
|
|
updateProposal: async (id: string, data: UpdateProposalRequest): Promise<void> => {
|
||
|
|
await apiClient.put(`/proposals/${id}`, data);
|
||
|
|
},
|
||
|
|
|
||
|
|
approveProposal: async (id: string): Promise<void> => {
|
||
|
|
await apiClient.post(`/proposals/${id}/approve`);
|
||
|
|
},
|
||
|
|
|
||
|
|
sendProposal: async (id: string): Promise<void> => {
|
||
|
|
await apiClient.post(`/proposals/${id}/send`);
|
||
|
|
},
|
||
|
|
|
||
|
|
reviseProposal: async (id: string): Promise<void> => {
|
||
|
|
await apiClient.post(`/proposals/${id}/revise`);
|
||
|
|
},
|
||
|
|
|
||
|
|
getHistory: async (id: string): Promise<unknown[]> => {
|
||
|
|
const res = await apiClient.get(`/proposals/${id}/history`);
|
||
|
|
return res.data;
|
||
|
|
},
|
||
|
|
|
||
|
|
getAudit: async (id: string): Promise<AuditEntry[]> => {
|
||
|
|
const res = await apiClient.get(`/proposals/${id}/audit`);
|
||
|
|
return res.data;
|
||
|
|
},
|
||
|
|
|
||
|
|
generateSuggestions: async (id: string): Promise<void> => {
|
||
|
|
await apiClient.post(`/proposals/${id}/generate-suggestions`);
|
||
|
|
},
|
||
|
|
|
||
|
|
getSimilar: async (id: string): Promise<unknown[]> => {
|
||
|
|
const res = await apiClient.get(`/proposals/${id}/similar`);
|
||
|
|
return res.data;
|
||
|
|
},
|
||
|
|
|
||
|
|
getPdf: async (id: string): Promise<{ downloadUrl: string; expiresAt: string } | null> => {
|
||
|
|
try {
|
||
|
|
const res = await apiClient.get(`/proposals/${id}/pdf`);
|
||
|
|
return res.data;
|
||
|
|
} catch {
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
},
|
||
|
|
};
|