Add per-project Department management

Departments are now a customizable per-project list (standard + custom),
matching the existing custom task type/status pattern, instead of a fixed
7-value enum. They're usable directly on tasks (new field, independent of
assignee) and continue to drive team member department roles.
This commit is contained in:
2026-07-22 04:03:33 +08:00
parent 11e1369f2f
commit c09710f4e5
20 changed files with 1220 additions and 75 deletions
+47
View File
@@ -0,0 +1,47 @@
import { apiClient } from './api'
export interface AllDepartmentsResponse {
departments: string[]
standard_departments: string[]
custom_departments: string[]
}
export interface CustomDepartmentCreate {
department: string
}
export interface CustomDepartmentUpdate {
old_name: string
new_name: string
}
export interface DepartmentInUseError {
error: string
department: string
member_count: number
task_count: number
}
export const departmentService = {
async getAllDepartments(projectId: number): Promise<AllDepartmentsResponse> {
const response = await apiClient.get(`/projects/${projectId}/departments`)
return response.data
},
async addDepartment(projectId: number, data: CustomDepartmentCreate): Promise<AllDepartmentsResponse> {
const response = await apiClient.post(`/projects/${projectId}/departments`, data)
return response.data
},
async updateDepartment(projectId: number, department: string, data: CustomDepartmentUpdate): Promise<AllDepartmentsResponse> {
const encodedDepartment = encodeURIComponent(department)
const response = await apiClient.put(`/projects/${projectId}/departments/${encodedDepartment}`, data)
return response.data
},
async deleteDepartment(projectId: number, department: string): Promise<AllDepartmentsResponse> {
const encodedDepartment = encodeURIComponent(department)
const response = await apiClient.delete(`/projects/${projectId}/departments/${encodedDepartment}`)
return response.data
}
}