Skip to content

Commit

Permalink
Merge pull request #274 from jadmsaadaot/SUBMIT-task#310-B
Browse files Browse the repository at this point in the history
Add All project before project breadcrumb
  • Loading branch information
jadmsaadaot authored Jan 31, 2025
2 parents 5b39619 + b760404 commit d5e5c57
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@ const BreadcrumbNav: React.FC = () => {

const breadcrumbs = useMemo(() => {
return matches
.map((match) => {
const { meta, pathname } = match;
if (meta && meta[0]?.title && pathname) {
return {
title: meta[0].title,
path: pathname,
};
}
return null;
.flatMap((match) => {
if (!match.meta) return [];

// eslint-disable-next-line @typescript-eslint/no-explicit-any
return match.meta.map((meta: any) => ({
title: meta.title,
path: meta.path || match.pathname,
}));
})
.filter(Boolean) as RouteSegment[];
}, [matches]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ export const Route = createFileRoute(
getAccountProjectQueryOptions(Number(projectId)),
),
component: ProjectLayout,
meta: ({ loaderData }) => [{ title: loaderData.project.name }],
meta: ({ loaderData, params }) => [
{ title: "All Projects", path: "/proponent/projects/" },
{
title: loaderData.project.name,
path: `/proponent/projects/${params.projectId}`,
},
],
pendingComponent: () => (
<PageGrid>
<ProjectsSkeleton />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ export const Route = createFileRoute(
getAccountProjectForStaffQueryOptions(Number(projectId)),
),
component: ProjectLayout,
meta: ({ loaderData }) => [{ title: loaderData.project.name }],
meta: ({ loaderData, params }) => [
{ title: "All Projects", path: "/staff/projects/" },
{
title: loaderData.project.name,
path: `/staff/projects/${params.projectId}`,
},
],
pendingComponent: () => (
<PageGrid>
<ProjectsSkeleton />
Expand Down

0 comments on commit d5e5c57

Please sign in to comment.