refactor(projects): remove project member management ui
This commit is contained in:
@@ -5,7 +5,6 @@ export type WorkspaceLogSection =
|
||||
| "workspace_members"
|
||||
| "clients"
|
||||
| "projects"
|
||||
| "project_members"
|
||||
| "tags"
|
||||
| "time_entries"
|
||||
| "rates"
|
||||
|
||||
@@ -12,26 +12,6 @@ export interface ProjectClient {
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface ProjectMemberPayload {
|
||||
user_id: string;
|
||||
role: "manager" | "member" | string;
|
||||
}
|
||||
|
||||
export interface ProjectMembership {
|
||||
id: string;
|
||||
project: string;
|
||||
user: string;
|
||||
user_details: {
|
||||
id: string;
|
||||
first_name: string;
|
||||
last_name: string;
|
||||
phone_number: string;
|
||||
avatar?: string;
|
||||
};
|
||||
role: "manager" | "member" | string;
|
||||
is_active: boolean;
|
||||
}
|
||||
|
||||
export interface Project {
|
||||
id: string;
|
||||
name: string;
|
||||
@@ -42,8 +22,6 @@ export interface Project {
|
||||
workspace: string;
|
||||
created_by?: AuditUser | null;
|
||||
client: ProjectClient | null;
|
||||
my_role?: string;
|
||||
members?: ProjectMembership[];
|
||||
}
|
||||
|
||||
export interface ProjectPayload {
|
||||
@@ -84,13 +62,9 @@ export const getProject = async (id: string) => {
|
||||
return response.json();
|
||||
};
|
||||
|
||||
export const createProject = async (
|
||||
data: Partial<ProjectPayload> & {
|
||||
workspace: string;
|
||||
name: string;
|
||||
members?: ProjectMemberPayload[];
|
||||
}
|
||||
) => {
|
||||
export const createProject = async (
|
||||
data: Partial<ProjectPayload> & { workspace: string; name: string }
|
||||
) => {
|
||||
const response = await authFetch("/api/projects/", {
|
||||
method: "POST",
|
||||
body: JSON.stringify(data),
|
||||
@@ -103,10 +77,10 @@ export const createProject = async (
|
||||
return response.json();
|
||||
};
|
||||
|
||||
export const updateProject = async (
|
||||
id: string,
|
||||
data: Partial<ProjectPayload> & { members?: ProjectMemberPayload[] }
|
||||
) => {
|
||||
export const updateProject = async (
|
||||
id: string,
|
||||
data: Partial<ProjectPayload>
|
||||
) => {
|
||||
const response = await authFetch(`/api/projects/${id}/`, {
|
||||
method: "PATCH",
|
||||
body: JSON.stringify(data),
|
||||
@@ -143,50 +117,4 @@ export const toggleArchiveProject = async (id: string) => {
|
||||
throw new Error(errorData?.detail || errorData?.message || `Failed to archive project`);
|
||||
}
|
||||
return response.json();
|
||||
};
|
||||
|
||||
|
||||
export const getProjectMemberships = async (projectId: string) => {
|
||||
const response = await authFetch(`/api/memberships/?project=${projectId}`);
|
||||
if (!response.ok) throw new Error("Failed to fetch project memberships");
|
||||
return response.json();
|
||||
};
|
||||
|
||||
export const addProjectMembership = async (projectId: string, userId: string, role: string) => {
|
||||
const response = await authFetch(`/api/memberships/`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ project_id: projectId, user_id: userId, role }),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json().catch(() => null);
|
||||
throw new Error(errorData?.detail || errorData?.message || "Failed to add project member");
|
||||
}
|
||||
return response.json();
|
||||
};
|
||||
|
||||
export const updateProjectMembership = async (membershipId: string, role: string, isActive: boolean = true) => {
|
||||
const response = await authFetch(`/api/memberships/${membershipId}/`, {
|
||||
method: "PATCH",
|
||||
body: JSON.stringify({ role, is_active: isActive }),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json().catch(() => null);
|
||||
throw new Error(errorData?.detail || errorData?.message || "Failed to update project member");
|
||||
}
|
||||
return response.json();
|
||||
};
|
||||
|
||||
export const removeProjectMembership = async (membershipId: string) => {
|
||||
const response = await authFetch(`/api/memberships/${membershipId}/`, {
|
||||
method: "DELETE",
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json().catch(() => null);
|
||||
throw new Error(errorData?.detail || errorData?.message || "Failed to remove member");
|
||||
}
|
||||
if (response.status === 204) return { success: true };
|
||||
return response.json().catch(() => ({ success: true }));
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user