Skip to content

Commit

Permalink
feat: new feat
Browse files Browse the repository at this point in the history
  • Loading branch information
lucastavarex committed Sep 4, 2024
1 parent 648e71e commit 003a301
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 29 deletions.
15 changes: 4 additions & 11 deletions src/app/(demo)/satelite/[sateliteView]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { ContentLayout } from "@/components/admin-panel/content-layout";
import { Breadcrumb, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator } from "@/components/ui/breadcrumb";
import Link from "next/link";
import SateliteContent from "../satelite-content";

interface SateliteViewProps {
Expand All @@ -9,19 +7,14 @@ interface SateliteViewProps {
};
}

// Add generateStaticParams function
export async function generateStaticParams() {
const staticPaths = ['CP', 'KI', 'LI', 'SI', 'TT'];

return staticPaths.map((sateliteView) => ({
sateliteView,
}));
}
export const revalidate = 60;

export default async function SateliteView({ params }: SateliteViewProps) {
const response = await fetch("https://rnc.dados.rio/GetData", {
cache: 'no-store'
cache: 'no-store',
next: { revalidate: 60 },
});

const apiResponse = await response.json();

return (
Expand Down
2 changes: 0 additions & 2 deletions src/app/(demo)/satelite/satelite-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import Link from "next/link";
import Image from "next/image";
import { Card, CardContent } from "@/components/ui/card";
import { LineChartComponent } from "@/components/ui/line-chart";
import Nav from "@/components/nav";

interface SateliteContentProps {
sateliteView: string;
Expand Down Expand Up @@ -33,7 +32,6 @@ export default function SateliteContent({ sateliteView, data }: SateliteContentP

return (
<Card className="rounded-lg border-none">
<Nav sateliteView={sateliteView} />
<CardContent className="p-6">
<div className="flex justify-center items-center min-h-[calc(100vh-64px-20px-24px-56px-48px)]">
<div className="grid grid-cols-12 gap-4 w-full">
Expand Down
44 changes: 36 additions & 8 deletions src/components/admin-panel/collapse-menu-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ interface CollapseMenuButtonProps {
active: boolean;
submenus: Submenu[];
isOpen: boolean | undefined;
labelBold?: boolean;
}
export function CollapseMenuButton({
icon: Icon,
label,
active,
submenus,
isOpen
isOpen,
labelBold = true
}: CollapseMenuButtonProps) {
const isSubmenuActive = submenus.some((submenu) => submenu.active);
const [isCollapsed, setIsCollapsed] = useState<boolean>(isSubmenuActive);
Expand Down Expand Up @@ -75,7 +77,8 @@ export function CollapseMenuButton({
"max-w-[150px] truncate",
isOpen
? "translate-x-0 opacity-100"
: "-translate-x-96 opacity-0"
: "-translate-x-96 opacity-0",
isCollapsed && "font-bold"
)}
>
{label}
Expand All @@ -102,6 +105,7 @@ export function CollapseMenuButton({
nestedSubmenus?.length > 0 ? (
<CollapseMenuButton
key={index}
labelBold={false}
icon={Dot}
label={label}
active={active}
Expand Down Expand Up @@ -164,15 +168,39 @@ export function CollapseMenuButton({
{label}
</DropdownMenuLabel>
<DropdownMenuSeparator />
{submenus.map(({ href, label }, index) => (
<DropdownMenuItem key={index} asChild>
<Link className="cursor-pointer" href={href}>
<p className="max-w-[180px] truncate">{label}</p>
</Link>
</DropdownMenuItem>

{submenus.map(({ href, label, submenus: nestedSubmenus }, index) => (
nestedSubmenus?.length > 0 ? (
<DropdownMenuItem key={index} asChild>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="ghost" className="w-full justify-start h-10">
<p className="max-w-[180px] truncate">{label}</p>
<ChevronDown size={16} className="ml-auto" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent side="right" sideOffset={10} align="start">
{nestedSubmenus.map(({ href, label }: any, nestedIndex: any) => (
<DropdownMenuItem key={nestedIndex} asChild>
<Link className="cursor-pointer" href={href}>
<p className="max-w-[160px] truncate">{label}</p>
</Link>
</DropdownMenuItem>
))}
</DropdownMenuContent>
</DropdownMenu>
</DropdownMenuItem>
) : (
<DropdownMenuItem key={index} asChild>
<Link className="cursor-pointer" href={href}>
<p className="max-w-[180px] truncate">{label}</p>
</Link>
</DropdownMenuItem>
)
))}
<DropdownMenuArrow className="fill-border" />
</DropdownMenuContent>

</DropdownMenu>
);
}
76 changes: 68 additions & 8 deletions src/lib/menu-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import {
Radar,
CloudRainWind,
LayoutGrid,
LucideIcon
LucideIcon,
BarChartBigIcon
} from "lucide-react";

type Submenu = {
Expand Down Expand Up @@ -84,26 +85,85 @@ export function getMenuList(pathname: string): Group[] {
}
]
},


{
href: "/radar",
href: "",
label: "Radar",
active: pathname.includes("/radar"),
icon: Radar,
submenus: []
submenus: [
{
href: "",
label: "Mendanha",
active: pathname.includes("/radar"),
submenus: [
{
href: "/radar/refletividade-horizontal",
label: "Refletividade Horizontal",
active: pathname === "/radar/refletividade-horizontal"
},
{
href: "/radar/estimativa-de-chuva-atual-impa",
label: "Estimativa de Chuva Atual (IMPA)",
active: pathname === "/radar/estimativa-de-chuva-atual-impa"
},
]
}
]
},
{
href: "",
label: "Chuva",
label: "Pluviômetros",
active: pathname.includes("/pluviometro"),
icon: BarChartBigIcon,
submenus: [
{
href: "",
label: "AlertaRio",
active: pathname.includes("/pluviometro"),
submenus: [
{
href: "/pluviometro/estimativa-de-chuva-atual",
label: "Estimativa de Chuva Atual",
active: pathname === "/pluviometro/estimativa-de-chuva-atual"
}
]
}
]
},
{
href: "",
label: "Previsão de Chuva",
active: pathname.includes("/chuva"),
icon: CloudRainWind,
submenus: [
{
href: "/chuva",
label: "Chovendo agora",
label: "1h, 2h, 3h",
active: pathname === "/chuva",
submenus: [
{
href: "/chuva/satelite/rio-now-cast",
label: "Satélite (RioNowCast)",
active: pathname === "/chuva/satelite/rio-now-cast"
},
{
href: "/chuva/pluv-est-met-radar/rio-now-cast",
label: "Estimativa de Chuva Atual",
active: pathname === "/chuva/pluv-est-met-radar/rio-now-cast"
}
]
},
{
href: "/chuva",
label: "xy, yh, zh",
active: pathname === "/chuva",
submenus: []
submenus: [
{
href: "/chuva/IMPA",
label: "IMPA",
active: pathname === "/chuva/IMPA"
}
]
}
]
}
Expand Down

0 comments on commit 003a301

Please sign in to comment.