import { useTranslation } from 'next-i18next'; interface AlertProps { onClose?: () => void; type: 'error' | 'warning'; message: string; } function Alert(props: AlertProps): JSX.Element { const { t } = useTranslation(['index', 'errors']); let color = 'red'; let icon; switch (props.type) { case 'error': color = 'red' // icon = () => // break; case 'warning': color = 'yellow' break; } return (
{icon && icon()} {props.message} {props.onClose && {t('index:errorClose')} }
) } export default Alert;