feat: convert Chat.jsx to RQ

This commit is contained in:
Daniel D Orlando 2023-04-03 16:46:35 -07:00
parent 573112de7b
commit 1cb8ef9803
6 changed files with 53 additions and 111 deletions

View file

@ -57,6 +57,23 @@ export const useGetConversationByIdQuery = (
);
}
//This isn't ideal because its just a query and we're using mutation, but it was the only way
//to make it work with how the Chat component is structured
export const useGetConversationByIdMutation = (
id: string,
callback: (data: t.TConversation) => void
): UseMutationResult<t.TConversation> => {
const queryClient = useQueryClient();
return useMutation(() => dataService.getConversationById(id),
{
onSuccess: (res: t.TConversation) => {
callback(res);
queryClient.invalidateQueries([QueryKeys.conversation, id]);
},
}
);
};
export const useUpdateConversationMutation = (
id: string
): UseMutationResult<