import { useState } from 'react' import { AlertDialog, AlertDialogAction, AlertDialogBody, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, Button, } from 'ui' import { Admonition } from 'ui-patterns/Admonition' const resetTemplate = async () => { await new Promise((resolve) => setTimeout(resolve, 1200)) throw new Error('Template reset failed') } export default function AlertDialogAsyncError() { const [error, setError] = useState(null) const handleResetTemplate = async () => { setError(null) try { await resetTemplate() } catch (error) { setError('Check the template configuration and try again.') throw error } } return ( Reset email template? This will replace the current email template with the default version. Any unsaved changes will be lost. {error && ( )} Cancel Reset template ) }