(workspaceId: string)
| 580 | * Delete a table from a workspace. |
| 581 | */ |
| 582 | export function useDeleteTable(workspaceId: string) { |
| 583 | const queryClient = useQueryClient() |
| 584 | |
| 585 | return useMutation({ |
| 586 | mutationFn: async (tableId: string) => { |
| 587 | return requestJson(deleteTableContract, { |
| 588 | params: { tableId }, |
| 589 | query: { workspaceId }, |
| 590 | }) |
| 591 | }, |
| 592 | onError: (error) => { |
| 593 | if (isValidationError(error)) return |
| 594 | toast.error(error.message, { duration: 5000 }) |
| 595 | }, |
| 596 | onSettled: (_data, _error, tableId) => { |
| 597 | queryClient.invalidateQueries({ queryKey: tableKeys.lists() }) |
| 598 | queryClient.removeQueries({ queryKey: tableKeys.detail(tableId) }) |
| 599 | queryClient.removeQueries({ queryKey: tableKeys.rowsRoot(tableId) }) |
| 600 | }, |
| 601 | }) |
| 602 | } |
| 603 | |
| 604 | /** |
| 605 | * Create a row in a table. |
no test coverage detected