From 6ecc054bc9ab4a64c0ea56d0c93f9e40b4ef1c2c Mon Sep 17 00:00:00 2001 From: Jason Liu Date: Thu, 23 Sep 2021 16:48:26 -0400 Subject: [PATCH] cleaned up alert banner with option to prevent closing TODO: Allow different types of alerts --- components/Alert.tsx | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/components/Alert.tsx b/components/Alert.tsx index 4fffdfb..a253178 100644 --- a/components/Alert.tsx +++ b/components/Alert.tsx @@ -1,24 +1,39 @@ -import {useTranslation} from 'next-i18next'; +import { useTranslation } from 'next-i18next'; interface AlertProps { - onClose: () => void; - errorMessage: string; + 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 ( -
- {props.errorMessage} - - - {t('index:errorClose')} - - - +
+ {icon && icon()} + {props.message} + {props.onClose && + + {t('index:errorClose')} + + + }
) }