feat(worker): server-authoritative pause/resume on the stopwatch
This commit is contained in:
@@ -51,3 +51,25 @@ export function useDiscardSession() {
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function usePauseSession() {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: (id: number) =>
|
||||
apiFetch<WorkSession>(`/api/sessions/${id}/pause`, { method: 'POST' }),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['sessions'] });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useResumeSession() {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: (id: number) =>
|
||||
apiFetch<WorkSession>(`/api/sessions/${id}/resume`, { method: 'POST' }),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['sessions'] });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user