c09710f4e5
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.
48 lines
1.5 KiB
TypeScript
48 lines
1.5 KiB
TypeScript
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
|
|
}
|
|
}
|