Skip to content

Commit

Permalink
Utilize async mutate fn and export isPending to help with loading states
Browse files Browse the repository at this point in the history
  • Loading branch information
samau3 committed Oct 27, 2024
1 parent 629fd2e commit ab089de
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions client/src/pages/patients/useDeletePatient.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import LifelineAPI from './LifelineAPI';
*
* @returns {{
* mutate: (patientId: string) => Promise<void>
* isPending: boolean
* }}
*/
export function useDeletePatient() {
const queryClient = useQueryClient();

const { mutate } = useMutation({
const { mutateAsync, isPending } = useMutation({
mutationKey: ['deletePatient'],
mutationFn: async (patientId) => {
const res = await LifelineAPI.deletePatient(patientId);
Expand All @@ -28,5 +29,5 @@ export function useDeletePatient() {
},
});

return { mutate };
return { mutateAsync, isPending };
}

0 comments on commit ab089de

Please sign in to comment.