| 104 | * Deletes a task by ID. |
| 105 | */ |
| 106 | export function useTaskDelete() { |
| 107 | const queryClient = useQueryClient(); |
| 108 | return useMutation({ |
| 109 | mutationFn: async (taskId: string) => { |
| 110 | const res = await api.tasks[":id"].$delete({ |
| 111 | param: { id: taskId }, |
| 112 | }); |
| 113 | if (!res.ok) { |
| 114 | const text = await res.text(); |
| 115 | throw new Error(`Delete failed: ${res.status} ${text}`); |
| 116 | } |
| 117 | }, |
| 118 | onSuccess: () => { |
| 119 | void queryClient.invalidateQueries({ queryKey: ["tasks"] }); |
| 120 | }, |
| 121 | }); |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * Dispatches a new inbound message task. |