(workspaceId: string)
| 556 | * Rename a table. |
| 557 | */ |
| 558 | export function useRenameTable(workspaceId: string) { |
| 559 | const queryClient = useQueryClient() |
| 560 | |
| 561 | return useMutation({ |
| 562 | mutationFn: async ({ tableId, name }: { tableId: string; name: string }) => { |
| 563 | return requestJson(renameTableContract, { |
| 564 | params: { tableId }, |
| 565 | body: { workspaceId, name }, |
| 566 | }) |
| 567 | }, |
| 568 | onError: (error) => { |
| 569 | if (isValidationError(error)) return |
| 570 | toast.error(error.message, { duration: 5000 }) |
| 571 | }, |
| 572 | onSettled: (_data, _error, variables) => { |
| 573 | queryClient.invalidateQueries({ queryKey: tableKeys.detail(variables.tableId) }) |
| 574 | queryClient.invalidateQueries({ queryKey: tableKeys.lists() }) |
| 575 | }, |
| 576 | }) |
| 577 | } |
| 578 | |
| 579 | /** |
| 580 | * Delete a table from a workspace. |
no test coverage detected