1
This commit is contained in:
@@ -18,6 +18,10 @@ export interface ProjectItem {
|
||||
id: string;
|
||||
name: string;
|
||||
region?: string | null;
|
||||
road_type?: string | null;
|
||||
project_year?: number | null;
|
||||
estimated_length_m?: number | null;
|
||||
memo?: string | null;
|
||||
status?: string | null;
|
||||
owner_name?: string | null;
|
||||
workflow_stage: number;
|
||||
@@ -92,6 +96,18 @@ export interface ResourceData {
|
||||
stats: ResourceSnapshot;
|
||||
}
|
||||
|
||||
export interface AutomationItem {
|
||||
id: number;
|
||||
project_id: string;
|
||||
name: string;
|
||||
logic_type: string;
|
||||
config_json: Record<string, unknown>;
|
||||
status: "DRAFT" | "ACTIVE" | "INACTIVE";
|
||||
last_executed_at?: string | null;
|
||||
created_at?: string | null;
|
||||
updated_at?: string | null;
|
||||
}
|
||||
|
||||
export interface UpdateUserRequest {
|
||||
name: string;
|
||||
position?: string | null;
|
||||
@@ -99,6 +115,27 @@ export interface UpdateUserRequest {
|
||||
phone?: string | null;
|
||||
}
|
||||
|
||||
export interface UpdateProjectRequest {
|
||||
name: string;
|
||||
region?: string | null;
|
||||
road_type?: string | null;
|
||||
project_year?: number | null;
|
||||
estimated_length_m?: number | null;
|
||||
memo?: string | null;
|
||||
status?: string | null;
|
||||
}
|
||||
|
||||
export interface AdminUpdateUserRequest extends UpdateUserRequest {
|
||||
status?: string | null;
|
||||
}
|
||||
|
||||
export interface AutomationRequest {
|
||||
name: string;
|
||||
logic_type: string;
|
||||
config_json: Record<string, unknown>;
|
||||
status: "DRAFT" | "ACTIVE" | "INACTIVE";
|
||||
}
|
||||
|
||||
export interface CreateCompanyRequest {
|
||||
name: string;
|
||||
business_registration_number: string;
|
||||
@@ -212,7 +249,6 @@ export async function fetchAllProjects(): Promise<ProjectItem[]> {
|
||||
return data.projects;
|
||||
}
|
||||
|
||||
|
||||
export async function fetchAllCompanies(): Promise<CompanyInfo[]> {
|
||||
const data = await request<{ companies: CompanyInfo[] }>("/dashboard/admin/companies");
|
||||
return data.companies;
|
||||
@@ -230,6 +266,27 @@ export function changeUserRole(userId: number, role: string): Promise<unknown> {
|
||||
});
|
||||
}
|
||||
|
||||
export function updateProject(projectId: string, payload: UpdateProjectRequest): Promise<unknown> {
|
||||
return request(`/dashboard/projects/${encodeURIComponent(projectId)}`, {
|
||||
method: "PUT",
|
||||
body: body(payload),
|
||||
});
|
||||
}
|
||||
|
||||
export function deleteProject(projectId: string): Promise<unknown> {
|
||||
return request(`/dashboard/projects/${encodeURIComponent(projectId)}`, { method: "DELETE" });
|
||||
}
|
||||
|
||||
export function updateDashboardUser(
|
||||
userId: number,
|
||||
payload: AdminUpdateUserRequest,
|
||||
): Promise<unknown> {
|
||||
return request(`/dashboard/admin/users/${userId}`, {
|
||||
method: "PUT",
|
||||
body: body(payload),
|
||||
});
|
||||
}
|
||||
|
||||
export function assignUserToCompany(userId: number, companyId: number | null): Promise<unknown> {
|
||||
return request(`/dashboard/admin/users/${userId}/company`, {
|
||||
method: "PATCH",
|
||||
@@ -254,3 +311,35 @@ export async function fetchAuditLogs(): Promise<AuditLog[]> {
|
||||
export async function fetchSystemResources(days = 30): Promise<ResourceData> {
|
||||
return request<ResourceData>(`/dashboard/admin/resources?days=${encodeURIComponent(days)}`);
|
||||
}
|
||||
|
||||
export async function fetchProjectAutomations(projectId: string): Promise<AutomationItem[]> {
|
||||
const data = await request<{ automations: AutomationItem[] }>(
|
||||
`/dashboard/projects/${encodeURIComponent(projectId)}/automations`,
|
||||
);
|
||||
return data.automations;
|
||||
}
|
||||
|
||||
export function createProjectAutomation(
|
||||
projectId: string,
|
||||
payload: AutomationRequest,
|
||||
): Promise<unknown> {
|
||||
return request(`/dashboard/projects/${encodeURIComponent(projectId)}/automations`, {
|
||||
method: "POST",
|
||||
body: body(payload),
|
||||
});
|
||||
}
|
||||
|
||||
export function updateProjectAutomation(
|
||||
automationId: number,
|
||||
payload: AutomationRequest,
|
||||
): Promise<unknown> {
|
||||
return request(`/dashboard/automations/${automationId}`, { method: "PUT", body: body(payload) });
|
||||
}
|
||||
|
||||
export function deleteProjectAutomation(automationId: number): Promise<unknown> {
|
||||
return request(`/dashboard/automations/${automationId}`, { method: "DELETE" });
|
||||
}
|
||||
|
||||
export function executeProjectAutomation(automationId: number): Promise<unknown> {
|
||||
return request(`/dashboard/automations/${automationId}/execute`, { method: "POST" });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user