intern project and user fix bug and implementation

This commit is contained in:
Kemas M. Aryadary Rasyad
2026-06-26 04:01:10 +07:00
parent f63efb0e12
commit 2e162bfc1e
28 changed files with 997 additions and 454 deletions
+85 -18
View File
@@ -1,29 +1,96 @@
// services/ProjectService.ts
import api from "../lib/api";
import type { Project, InternTask, Intern, ProjectTask } from "../types/project.types";
import type {
Project,
ProjectDetail,
InternTaskItem,
InternDetail,
CreateProjectPayload,
UpdateProjectPayload,
AssignMemberPayload,
MemberAssignment,
ProjectMember
} from "../types/project.types";
export const getMyProjects = async (): Promise<Project[]> => {
const res = await api.get("/project-api/my-projects");
// POST /project-api/add
export const createProject = async (
payload: CreateProjectPayload
): Promise<ProjectDetail> => {
const res = await api.post("/project-api/add", payload);
return res.data.data;
};
export const getProjectById = async (id: string): Promise<Project> => {
const res = await api.get(`/project-api/get/${id}`);
return res.data.data;
};
export const getMyTasks = async (): Promise<InternTask[]> => {
const res = await api.get("/project-api/my-tasks");
return res.data.data;
};
export const getProjectInterns = async (projectId: string): Promise<Intern[]> => {
const res = await api.get(`/project-api/interns`, {
params: { projectId }
// GET /project-api/get
export const getProjects = async (
status?: "active" | "completed" | "archived"
): Promise<Project[]> => {
const res = await api.get("/project-api/get", {
params: status ? { status } : undefined,
});
return res.data.data;
};
export const getProjectTasks = async (projectId: string): Promise<ProjectTask[]> => {
const res = await api.get(`/task-api/projects/${projectId}/tasks`);
// GET /project-api/get/{id} → ambil members saja
export const getProjectMembers = async (
id: string | number
): Promise<ProjectMember[]> => {
const res = await api.get(`/project-api/get/${id}`);
return res.data.data.members;
};
// GET /project-api/get/{id}
export const getProjectById = async (
id: string | number
): Promise<ProjectDetail> => {
const res = await api.get(`/project-api/get/${id}`);
return res.data.data;
};
// PATCH /project-api/update/{id}
export const updateProject = async (
id: string | number,
payload: UpdateProjectPayload
): Promise<ProjectDetail> => {
const res = await api.patch(`/project-api/update/${id}`, payload);
return res.data.data;
};
// DELETE /project-api/delete/{id} — soft delete (archive)
export const archiveProject = async (
id: string | number
): Promise<ProjectDetail> => {
const res = await api.delete(`/project-api/delete/${id}`);
return res.data.data;
};
// GET /project-api/my-projects (intern only)
export const getMyProjects = async (): Promise<ProjectDetail[]> => {
const res = await api.get("/project-api/my-projects");
return res.data.data;
};
// GET /project-api/my-tasks (intern only)
export const getMyTasks = async (): Promise<InternTaskItem[]> => {
const res = await api.get("/project-api/my-tasks");
return res.data.data;
};
// GET /project-api/mentor-projects (admin/mentor only)
export const getMentorProjects = async (): Promise<Project[]> => {
const res = await api.get("/project-api/mentor-projects");
return res.data.data;
};
// GET /project-api/interns (admin/mentor only)
export const getAllInterns = async (): Promise<InternDetail[]> => {
const res = await api.get("/project-api/interns");
return res.data.data;
};
// POST /project-api/assign-member (admin/mentor only)
export const assignMember = async (
payload: AssignMemberPayload
): Promise<MemberAssignment> => {
const res = await api.post("/project-api/assign-member", payload);
return res.data.data;
};