MCPcopy Index your code
hub / github.com/simstudioai/sim / useImportCsvIntoTableAsync

Function useImportCsvIntoTableAsync

apps/sim/hooks/queries/tables.ts:1541–1568  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1539 * Resolves immediately; progress + completion arrive over the table-events SSE stream.
1540 */
1541export function useImportCsvIntoTableAsync() {
1542 const queryClient = useQueryClient()
1543 return useMutation({
1544 mutationFn: async ({
1545 workspaceId,
1546 tableId,
1547 file,
1548 mode,
1549 mapping,
1550 createColumns,
1551 onProgress,
1552 }: ImportCsvIntoTableAsyncParams) => {
1553 const fileKey = await uploadCsvToWorkspaceStorage(file, workspaceId, onProgress)
1554 const response = await requestJson(importIntoTableAsyncContract, {
1555 params: { tableId },
1556 body: { workspaceId, fileKey, fileName: file.name, mode, mapping, createColumns },
1557 })
1558 return response.data
1559 },
1560 onError: (error) => {
1561 logger.error('Failed to start async CSV import:', error)
1562 toast.error(error.message, { duration: 5000 })
1563 },
1564 onSettled: (_data, _error, variables) => {
1565 invalidateRowCount(queryClient, variables.tableId)
1566 },
1567 })
1568}
1569
1570interface ImportCsvIntoTableParams {
1571 workspaceId: string

Callers 1

ImportCsvDialogFunction · 0.90

Calls 4

requestJsonFunction · 0.90
invalidateRowCountFunction · 0.85
errorMethod · 0.80

Tested by

no test coverage detected