Skip to content

Commit

Permalink
used utility function for handle alert component issue
Browse files Browse the repository at this point in the history
Signed-off-by: pranalidhanavade <[email protected]>
  • Loading branch information
pranalidhanavade committed Oct 9, 2024
1 parent 573925f commit ca524dc
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/components/User/UserDashBoard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -451,21 +451,14 @@ const UserDashBoard = () => {
</div>
);
};

const getSafeMessage = (message: string | null, error: string | null): string => {
if (message) return message; // return message if it's not null
if (typeof error === 'string') return error; // return error if it's a string
return ''; // default to an empty string if both are null or error is not a string
};


return (
<>
<div className="px-4 pt-6">
<div className="cursor-pointer">
<AlertComponent
// message={message || error}
message={getSafeMessage(message, error)}
message={message ? message : (error ? error : '')}
type={message ? 'warning' : 'failure'}
viewButton={viewButton}
path={pathRoutes.users.invitations}
Expand All @@ -477,8 +470,8 @@ const UserDashBoard = () => {
</div>
<div className="cursor-pointer">
<AlertComponent
message={getSafeMessage(ecoMessage, error)}
type={message ? 'warning' : 'failure'}
message={ecoMessage ? ecoMessage : (error ? error : '')}
type={'warning'}
viewButton={viewButton}
path={`${envConfig.PUBLIC_ECOSYSTEM_FRONT_END_URL}${pathRoutes.users.dashboard}` }

Expand Down

0 comments on commit ca524dc

Please sign in to comment.