project list

This commit is contained in:
hamid zarghami
2026-07-11 10:19:39 +03:30
parent b0737ea6ad
commit 47691a649f
11 changed files with 485 additions and 166 deletions
@@ -1,15 +1,23 @@
import { useMutation, useQueryClient } from "@tanstack/react-query";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import * as api from "../service/ProjectService";
import { CreateProjectType } from "../types/ProjectTypes";
export const useGetProjectsByWorkspace = (workspaceId: string) => {
return useQuery({
queryKey: ["projects", workspaceId],
queryFn: () => api.getProjectsByWorkspace(workspaceId),
enabled: !!workspaceId,
});
};
export const useCreateProject = () => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: (variables: CreateProjectType) => api.createProject(variables),
onSuccess: () => {
onSuccess: (_data, variables) => {
queryClient.invalidateQueries({
queryKey: ["projects"],
queryKey: ["projects", variables.workspaceId],
});
},
});