Skip to content

Commit

Permalink
user dashboard alert component fixes
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 de1e01d commit 383eea1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 15 deletions.
18 changes: 10 additions & 8 deletions src/components/AlertComponent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@ export const AlertComponent = ({
onAlertClose,
path = '',
}: IAlertComponent) => {

console.log("message",message);
console.log(typeof message)
return (
// message !== null ? (<>
// </>):
// (
message === null ? (<>
</>):
(

(
<div className="w-full">
<div
className={`flex flex-col gap-2 p-4 text-sm rounded-lg mb-4 ${() => getAlertClass(type)}`}
className={`flex flex-col gap-2 p-4 text-sm rounded-lg mb-4 ${getAlertClass(type)}`}
role="alert"
>
<div
Expand All @@ -48,7 +50,7 @@ export const AlertComponent = ({
</div>
<button
aria-label="Dismiss"
className={`-mx-1.5 -my-1.5 ml-auto inline-flex h-8 w-8 rounded-lg p-1.5 ${() => getAlertClass(type)}`}
className={`-mx-1.5 -my-1.5 ml-auto inline-flex h-8 w-8 rounded-lg p-1.5 ${getAlertClass(type)}`}
type="button"
onClick={onAlertClose}
>
Expand All @@ -58,7 +60,7 @@ export const AlertComponent = ({
strokeWidth="0"
viewBox="0 0 20 20"
aria-hidden="true"
className={`w-5 h-5 ${() => getAlertClass(type)}`}
className={`w-5 h-5 ${getAlertClass(type)}`}
height="1em"
width="1em"
xmlns="http://www.w3.org/2000/svg"
Expand All @@ -78,5 +80,5 @@ export const AlertComponent = ({
)


// );
);
};
25 changes: 18 additions & 7 deletions src/components/User/UserDashBoard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ interface ICredDef {
}

const UserDashBoard = () => {
const [message, setMessage] = useState<string | null>(null);
const [ecoMessage, setEcoMessage] = useState<string | null>(null);
const [message, setMessage] = useState<string | null>('');
const [ecoMessage, setEcoMessage] = useState<string | null>('');
const [viewButton, setViewButton] = useState<boolean>(false);
const [error, setError] = useState<string | null>(null);
const [currentPage, setCurrentPage] = useState(initialPageState);
Expand Down Expand Up @@ -86,11 +86,13 @@ const UserDashBoard = () => {

const getAllInvitations = async () => {
setLoading(true);
try {
const response = await getUserInvitations(
currentPage.pageNumber,
currentPage.pageSize,
'',
);
console.log('response', response);
const { data } = response as AxiosResponse;

if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) {
Expand All @@ -105,13 +107,18 @@ const UserDashBoard = () => {
total: totalPages,
});
} else {
setError(response as string);
// setError(response as string);
setError(data?.message || 'Failed to fetch invitations');
}
} catch(err) {
setError('An unexpected error occurred');
}
setLoading(false);
};

const getAllOrganizations = async () => {
setOrgLoading(true);
try {
const response = await getOrganizations(
currentPage.pageNumber,
currentPage.pageSize,
Expand All @@ -125,8 +132,12 @@ const UserDashBoard = () => {
);
setOrganizationList(orgList);
} else {
setError(response as string);
setError(data?.message || 'Failed to fetch ecosystem invitations');
}
}
catch(err){
setError('An unexpected error occurred');
}
setOrgLoading(false);
};

Expand Down Expand Up @@ -449,20 +460,20 @@ const UserDashBoard = () => {
viewButton={viewButton}
path={pathRoutes.users.invitations}
onAlertClose={() => {
setMessage(null);
setMessage('');
setError(null);
}}
/>
</div>
<div className="cursor-pointer">
<AlertComponent
message={ecoMessage}
message={ecoMessage || error}
type={'warning'}
viewButton={viewButton}
path={`${envConfig.PUBLIC_ECOSYSTEM_FRONT_END_URL}${pathRoutes.users.dashboard}` }

onAlertClose={() => {
setEcoMessage(null);
setEcoMessage('');
setError(null);
}}
/>
Expand Down

0 comments on commit 383eea1

Please sign in to comment.