import Alert from '../atoms/Alert' import Button from '../atoms/Button' import Loader from '../atoms/Loader' import React, { ReactElement, useState, FormEvent } from 'react' import styles from './MetadataFeedback.module.css' import SuccessConfetti from '../atoms/SuccessConfetti' interface Action { name: string onClick?: () => void to?: string } function ActionSuccess({ action }: { action: Action }) { const { name, onClick, to } = action return ( {name} ) } function ActionError({ setError }: { setError: (error: string) => void }) { return ( setError(undefined)} > Try Again ) } export default function MetadataFeedback({ title, error, success, loading, successAction, setError }: { title: string error: string success: string loading?: string successAction: Action setError: (error: string) => void }): ReactElement { const [moreInfo, setMoreInfo] = useState(false) function toggleMoreInfo(e: FormEvent) { e.preventDefault() moreInfo === true ? setMoreInfo(false) : setMoreInfo(true) } return ( {title} {error ? ( <> Sorry, something went wrong. Please try again. {moreInfo && } {moreInfo === false ? 'More Info' : 'Hide error'} > ) : success ? ( } /> ) : ( )} ) }
Sorry, something went wrong. Please try again.