(workspaceId: string)
| 511 | * Create a new table in a workspace. |
| 512 | */ |
| 513 | export function useCreateTable(workspaceId: string) { |
| 514 | const queryClient = useQueryClient() |
| 515 | |
| 516 | return useMutation({ |
| 517 | mutationFn: async (params: Omit<CreateTableBodyInput, 'workspaceId'>) => { |
| 518 | return requestJson(createTableContract, { |
| 519 | body: { ...params, workspaceId }, |
| 520 | }) |
| 521 | }, |
| 522 | onError: (error) => { |
| 523 | if (isValidationError(error)) return |
| 524 | toast.error(error.message, { duration: 5000 }) |
| 525 | }, |
| 526 | onSettled: () => { |
| 527 | queryClient.invalidateQueries({ queryKey: tableKeys.lists() }) |
| 528 | }, |
| 529 | }) |
| 530 | } |
| 531 | |
| 532 | /** |
| 533 | * Add a column to an existing table. |
no test coverage detected