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

Function useImportCsvAsync

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

Source from the content-addressed store, hash-verified

1470 * terminal state arrive over the table-events SSE stream (see `useTableEventStream`).
1471 */
1472export function useImportCsvAsync() {
1473 const queryClient = useQueryClient()
1474 return useMutation({
1475 mutationFn: async ({ workspaceId, file, onProgress }: ImportCsvAsyncParams) => {
1476 const fileKey = await uploadCsvToWorkspaceStorage(file, workspaceId, onProgress)
1477 const response = await requestJson(importTableAsyncContract, {
1478 body: { workspaceId, fileKey, fileName: file.name },
1479 })
1480 return response.data
1481 },
1482 onError: (error) => {
1483 logger.error('Failed to start async CSV import:', error)
1484 toast.error(error.message, { duration: 5000 })
1485 },
1486 onSettled: () => {
1487 queryClient.invalidateQueries({ queryKey: tableKeys.lists() })
1488 },
1489 })
1490}
1491
1492interface ImportFileAsTableParams {
1493 workspaceId: string

Callers 1

TablesFunction · 0.90

Calls 3

requestJsonFunction · 0.90
errorMethod · 0.80

Tested by

no test coverage detected