From 0fd2c49372b6800fd7820fbeac29b4dc65879f67 Mon Sep 17 00:00:00 2001 From: pranalidhanavade Date: Wed, 9 Oct 2024 12:38:02 +0530 Subject: [PATCH] used utility function for handle alert component issue Signed-off-by: pranalidhanavade --- src/components/User/UserDashBoard.tsx | 61 +++++++++++++-------------- 1 file changed, 29 insertions(+), 32 deletions(-) diff --git a/src/components/User/UserDashBoard.tsx b/src/components/User/UserDashBoard.tsx index ccc4efa17..9cdcd2aeb 100644 --- a/src/components/User/UserDashBoard.tsx +++ b/src/components/User/UserDashBoard.tsx @@ -54,7 +54,7 @@ const UserDashBoard = () => { const [message, setMessage] = useState(''); const [ecoMessage, setEcoMessage] = useState(''); const [viewButton, setViewButton] = useState(false); - const [error, setError] = useState(''); + const [error, setError] = useState(''); const [currentPage, setCurrentPage] = useState(initialPageState); const [organizationsList, setOrganizationList] = useState | null>(null); @@ -106,8 +106,8 @@ const UserDashBoard = () => { total: totalPages, }); } else { - setError(response as string); - // setError('Failed to fetch invitations'); + // setError(response as string); + setError('Failed to fetch invitations'); } } catch(err) { setError('An unexpected error occurred'); @@ -162,8 +162,8 @@ const UserDashBoard = () => { total: totalPages, }); } else { - setError(response as string); - // setError('Failed to fetch invitations'); + // setError(response as string); + setError('Failed to fetch invitations'); } } catch(err){ @@ -450,41 +450,38 @@ const UserDashBoard = () => { ); }; - console.log("errror_:::::::::::", typeof error); - console.log("mesaage---:::::::::", typeof message); return ( <>
- {(error !== '' || message !== '') && - { - setMessage(''); - setError(''); - }} - /> - } + {(error || message) && ( // Check if either error or message exists + { + setMessage(''); // Reset message on close + setError(''); // Reset error on close + }} + /> + )}
- {(error !== '' || ecoMessage !== '') && - { - setEcoMessage(''); - setError(''); - }} - /> -} + {(error || ecoMessage) && ( // Check if either error or ecoMessage exists + { + setEcoMessage(''); // Reset ecoMessage on close + setError(''); // Reset error on close + }} + /> + )}
{walletData && walletData.length > 0 ? ( <>