get project

This commit is contained in:
hamid zarghami
2026-07-11 11:40:55 +03:30
parent 651fb16feb
commit 9c84048730
4 changed files with 40 additions and 17 deletions
@@ -18,6 +18,14 @@ export const useGetProjectDetail = (id: string) => {
});
};
export const useGetProject = (id: string) => {
return useQuery({
queryKey: ["project", id],
queryFn: () => api.getProject(id),
enabled: !!id,
});
};
export const useCreateProject = () => {
const queryClient = useQueryClient();
@@ -35,13 +43,7 @@ export const useUpdateProject = () => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: ({
id,
params,
}: {
id: string;
params: UpdateProjectType;
}) => api.updateProject(id, params),
mutationFn: ({ id, params }: { id: string; params: UpdateProjectType }) => api.updateProject(id, params),
onSuccess: (_data, variables) => {
queryClient.invalidateQueries({ queryKey: ["projects"] });
queryClient.invalidateQueries({
@@ -1,5 +1,5 @@
import axios from "../../../../config/axios";
import { CreateProjectType, UpdateProjectType } from "../types/ProjectTypes";
import { CreateProjectType, GetProjectResponse, UpdateProjectType } from "../types/ProjectTypes";
export const getProjectsByWorkspace = async (workspaceId: string) => {
const { data } = await axios.get(`/task-manager/projects/user/workspace/${workspaceId}`);
@@ -11,6 +11,11 @@ export const getProjectDetail = async (id: string) => {
return data;
};
export const getProject = async (id: string): Promise<GetProjectResponse> => {
const { data } = await axios.get(`/task-manager/projects/detail/${id}`);
return data;
};
export const createProject = async (params: CreateProjectType) => {
const { data } = await axios.post(`/task-manager/projects`, params);
return data;
@@ -1,3 +1,5 @@
import { IResponse } from "../../../../types/response.types";
export type ProjectItem = {
id: string;
name: string;
@@ -29,3 +31,21 @@ export type ProjectDetailType = CreateProjectType & {
};
export type UpdateProjectType = CreateProjectType;
export type ProjectTaskType = unknown;
export type ProjectTaskPhaseType = {
id: string;
name: string;
tasks: ProjectTaskType[];
};
export type ProjectWithPhasesType = {
id: string;
name: string;
taskPhases: ProjectTaskPhaseType[];
};
export interface GetProjectResponse extends IResponse<ProjectWithPhasesType> {
statusCode: number;
}