Files
edr-platform/apps/edr-freight-web/backoffice/src/shared/components/ui/DashboardDropdown.tsx
natib21 e6e44e773b fix ui
2026-07-10 11:25:59 +00:00

59 lines
1.7 KiB
TypeScript

import React from "react";
import { ChevronDown } from "lucide-react";
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuTrigger,
} from "@/shared/common/ui/dropdown-menu";
import { Button } from "@/shared/common/ui/button";
import { getFormattedDashboardLabel } from "@/performance-management/utils/dashboardUtils";
interface DashboardDropdownProps {
dashboards?: any[];
selectedDashboard?: any;
onSelect: (dashboard: any) => void;
isLoading?: boolean;
}
export const DashboardDropdown: React.FC<DashboardDropdownProps> = ({
dashboards = [],
selectedDashboard,
onSelect,
isLoading = false,
}) => {
return (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
variant="outline"
className="flex items-center justify-between w-60"
disabled={isLoading}
>
{isLoading
? "Loading dashboards..."
: getFormattedDashboardLabel(selectedDashboard?.name) ||
"Select Dashboard"}
<ChevronDown className="ml-2 h-4 w-4 opacity-70" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent className="w-60">
<DropdownMenuLabel>Available Dashboards</DropdownMenuLabel>
{dashboards?.length > 0 ? (
dashboards.map((dashboard: any) => (
<DropdownMenuItem
key={dashboard.id}
onClick={() => onSelect(dashboard)}>
{getFormattedDashboardLabel(dashboard.name)}
</DropdownMenuItem>
))
) : (
<DropdownMenuItem disabled>No dashboards found</DropdownMenuItem>
)}
</DropdownMenuContent>
</DropdownMenu>
);
};