Skip to content

Commit

Permalink
feat: added edit api to application with usequery
Browse files Browse the repository at this point in the history
  • Loading branch information
maricdiranovic committed Feb 18, 2025
1 parent 6539312 commit 865d0b4
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions client/src/hooks/my-projects/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,35 @@ export function useCreateMemberProject() {
},
});
}

export const updateMemberProject = async ({
projectId,
projectData,
}: {
projectId: string;
projectData: FormData;
}) => {
return API.request({
method: 'PUT',
url: `/members/projects/${projectId}`,
data: projectData,
headers: {
'Content-Type': 'multipart/form-data',
},
}).then((res) => res.data);
};

export function useUpdateMemberProject() {
const queryClient = useQueryClient();

return useMutation(updateMemberProject, {
onSuccess: (data, { projectId }) => {
queryClient.invalidateQueries(['myProjects']); // Refresh project list
queryClient.invalidateQueries(['project', projectId]); // Refresh specific project details
console.info('Project updated successfully:', data);
},
onError: (error) => {
console.error('Error updating project:', error);
},
});
}

0 comments on commit 865d0b4

Please sign in to comment.