import { RenderConfigScreenCtx } from 'datocms-plugin-sdk'; import { Button, Canvas, Spinner } from 'datocms-react-ui'; import { useState } from 'react'; import downloadRecords from '../utils/downloadRecords'; import s from './styles.module.scss'; type Props = { ctx: RenderConfigScreenCtx; }; export default function ConfigScreen({ ctx }: Props) { const [isLoading, setLoading] = useState(false); const [progress, setProgress] = useState(0); const handleRecords = async () => { setLoading(true); setProgress(0); await downloadRecords({ apiToken: ctx.currentUserAccessToken as string, progressCallback: (count: number) => { setProgress(count); } }); setLoading(false); }; return (

Finding records to download.

This can take a few minutes, please do not reload or exit the page.

Records found: {progress}

); }