Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dynamic breadcrump and temporarily disable fetch error toasts #39

Merged
merged 2 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions app/[orgId]/problems/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ export default function ProblemsPage({
setProblems(data);
} catch (error) {
console.error("Error fetching problems:", error);
toast({
title: "Error fetching problems",
description: "Using mock data as fallback",
variant: "destructive",
});
// toast({
// title: "Error fetching problems",
// description: "Using mock data as fallback",
// variant: "destructive",
// });
setProblems(mockProblems);
}
};
Expand Down
39 changes: 30 additions & 9 deletions components/app-sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,18 @@ export function AppSidebar({ children }: { children: React.ReactNode }) {
// Get the base path (e.g., /[orgId])
const basePath = pathname.split("/").slice(0, 2).join("/");

// Utility function to generate breadcrumbs from pathname
const generateBreadcrumbs = (pathname: string) => {
const paths = pathname.split("/").filter(Boolean);
return paths.map((path) => ({
href: "/" + paths.slice(0, paths.indexOf(path) + 1).join("/"),
label: path
.split("-")
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
.join(" "),
}));
};

return (
<ThemeProvider>
<SidebarProvider>
Expand Down Expand Up @@ -383,15 +395,24 @@ export function AppSidebar({ children }: { children: React.ReactNode }) {
<Separator orientation="vertical" className="mr-2 h-4" />
<Breadcrumb>
<BreadcrumbList>
<BreadcrumbItem className="hidden md:block">
<BreadcrumbLink href="#">
Building Your Application
</BreadcrumbLink>
</BreadcrumbItem>
<BreadcrumbSeparator className="hidden md:block" />
<BreadcrumbItem>
<BreadcrumbPage>Data Fetching</BreadcrumbPage>
</BreadcrumbItem>
{generateBreadcrumbs(usePathname()).map(
(crumb, index, array) => (
<React.Fragment key={crumb.href}>
<BreadcrumbItem className="hidden md:block">
{index === array.length - 1 ? (
<BreadcrumbPage>{crumb.label}</BreadcrumbPage>
) : (
<BreadcrumbLink href={crumb.href}>
{crumb.label}
</BreadcrumbLink>
)}
</BreadcrumbItem>
{index < array.length - 1 && (
<BreadcrumbSeparator className="hidden md:block" />
)}
</React.Fragment>
),
)}
</BreadcrumbList>
</Breadcrumb>
</div>
Expand Down
Loading