From e296d381a0e03d69ccd2a73ee9e04a44fdf6db75 Mon Sep 17 00:00:00 2001 From: pranalidhanavade Date: Wed, 9 Oct 2024 10:00:17 +0530 Subject: [PATCH] fix: alert component condition issue Signed-off-by: pranalidhanavade --- src/components/AlertComponent/index.tsx | 150 ++++++++++++------------ 1 file changed, 77 insertions(+), 73 deletions(-) diff --git a/src/components/AlertComponent/index.tsx b/src/components/AlertComponent/index.tsx index 5c14f8ebf..66de75f4d 100644 --- a/src/components/AlertComponent/index.tsx +++ b/src/components/AlertComponent/index.tsx @@ -1,78 +1,82 @@ -import React from 'react'; + import type { IAlertComponent } from './interface'; +const getAlertClass = (type:string) => { + switch (type) { + case 'warning': + return 'text-yellow-700 bg-yellow-100 border-yellow-500 dark:bg-yellow-200 dark:text-yellow-800'; + case 'failure': + return 'text-red-700 bg-red-100 border-red-500 dark:bg-red-200 dark:text-red-800'; + case 'success': + return 'text-green-700 bg-green-100 border-green-500 dark:bg-green-200 dark:text-green-800'; + default: + + return 'text-gray-700 bg-gray-100 border-gray-500 dark:bg-gray-200 dark:text-gray-800'; + } +}; export const AlertComponent = ({ - message, - type, - viewButton, - onAlertClose, - path = '', + message, + type, + viewButton, + onAlertClose, + path = '', }: IAlertComponent) => { - const getAlertClass = () => { - switch (type) { - case 'warning': - return 'text-yellow-700 bg-yellow-100 border-yellow-500 dark:bg-yellow-200 dark:text-yellow-800'; - case 'failure': - return 'text-red-700 bg-red-100 border-red-500 dark:bg-red-200 dark:text-red-800'; - case 'success': - return 'text-green-700 bg-green-100 border-green-500 dark:bg-green-200 dark:text-green-800'; - default: - return 'text-gray-700 bg-gray-100 border-gray-500 dark:bg-gray-200 dark:text-gray-800'; - } - }; - return ( - message !== null ? ( -
-
-
-
-
-
{message}
- {viewButton && ( - - )} -
-
- -
-
-
- ) : ( - <> - - - ) - ); -}; \ No newline at end of file + return ( + message !== null ? (<> + ): + ( + ( +
+
getAlertClass(type)}`} + role="alert" + > +
+
+
+
{message}
+ {viewButton && ( + + )} +
+
+ +
+
+
+ + ) + ) + + + ); +};