Skip to content

Commit b7161e5

Browse files
committed
refactor DashboardNav to handle dynamic image sources based on entity type
1 parent 5f15c53 commit b7161e5

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

app/[locale]/dashboard/components/dashboard-nav.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,17 @@ import styles from '../dashboard.module.scss';
1414

1515
interface DashboardNavProps {
1616
items: SidebarNavItem[];
17+
type?: string;
1718
}
1819
export function DashboardNav({
1920
items,
2021
entityDetails,
22+
type,
2123
}: DashboardNavProps & { entityDetails?: any }) {
2224
const [isCollapsed, setIsCollapsed] = useState(false);
2325

2426
const [isImageValid, setIsImageValid] = useState(() => {
25-
return entityDetails?.logo ? true : false;
27+
return type === 'organization' && entityDetails?.logo ? true : type === 'self' && entityDetails?.profilePicture ? true : false;
2628
});
2729
const path = usePathname();
2830

@@ -45,6 +47,7 @@ export function DashboardNav({
4547

4648
const sidebarIcon = isCollapsed ? Icons.expand : Icons.collapse;
4749

50+
4851
return (
4952
<aside
5053
className={cn(
@@ -62,7 +65,7 @@ export function DashboardNav({
6265
<Image
6366
height={140}
6467
width={140}
65-
src={`${process.env.NEXT_PUBLIC_BACKEND_URL}/${entityDetails?.logo?.url}`}
68+
src={ type === 'organization' ? `${process.env.NEXT_PUBLIC_BACKEND_URL}/${entityDetails?.logo?.url}` : `${process.env.NEXT_PUBLIC_BACKEND_URL}/${entityDetails?.profilePicture?.url}` }
6669
alt={`${entityDetails?.name} logo`}
6770
onError={() => {
6871
setIsImageValid(false);
@@ -80,7 +83,7 @@ export function DashboardNav({
8083
)}
8184
<div className="flex flex-col items-center gap-3 text-center">
8285
<Text variant="headingMd" fontWeight="medium">
83-
{entityDetails?.name || entityDetails}
86+
{entityDetails?.name || entityDetails.firstName}
8487
</Text>
8588
<Link
8689
href={

0 commit comments

Comments
 (0)