({ workspaceId, tableId }: RowMutationContext)
| 833 | * Batch create rows in a table. Supports optional per-row positions for undo restore. |
| 834 | */ |
| 835 | export function useBatchCreateTableRows({ workspaceId, tableId }: RowMutationContext) { |
| 836 | const queryClient = useQueryClient() |
| 837 | const router = useRouter() |
| 838 | |
| 839 | return useMutation({ |
| 840 | mutationFn: async ( |
| 841 | variables: BatchCreateTableRowsParams |
| 842 | ): Promise<BatchCreateTableRowsResponse> => { |
| 843 | return requestJson(batchCreateTableRowsContract, { |
| 844 | params: { tableId }, |
| 845 | body: { |
| 846 | workspaceId, |
| 847 | rows: variables.rows as RowData[], |
| 848 | positions: variables.positions, |
| 849 | orderKeys: variables.orderKeys, |
| 850 | }, |
| 851 | }) |
| 852 | }, |
| 853 | onError: (error) => |
| 854 | notifyRowWriteError(error, () => router.push(buildUpgradeHref(workspaceId, 'tables'))), |
| 855 | onSettled: () => { |
| 856 | invalidateRowCount(queryClient, tableId) |
| 857 | }, |
| 858 | }) |
| 859 | } |
| 860 | |
| 861 | /** |
| 862 | * Update a single row in a table. |
no test coverage detected