import Alert from '@shared/atoms/Alert' import Button from '@shared/atoms/Button' import Loader from '@shared/atoms/Loader' import SuccessConfetti from '@shared/SuccessConfetti' import React, { ReactElement, useState, FormEvent } from 'react' import styles from './EditFeedback.module.css' 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 EditFeedback({ error, success, loading, successAction, setError }: { 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 ( {error ? ( <> Sorry, something went wrong. Please try again. {moreInfo && } {moreInfo === false ? 'More Info' : 'Hide error'} > ) : success ? ( } /> ) : ( )} ) }
Sorry, something went wrong. Please try again.