diff --git a/src/app/App.tsx b/src/app/App.tsx index 2a41d19..007447b 100644 --- a/src/app/App.tsx +++ b/src/app/App.tsx @@ -27,6 +27,7 @@ export type AppPage = | "irrigationFilters" | "irrigationConsumption" | "irrigationDrainage" + | "meteoCharts" function App() { const [activePage, setActivePage] = useState("dashboard"); diff --git a/src/assets/meteo-pane.png b/src/assets/meteo-pane.png new file mode 100644 index 0000000..8bafd80 Binary files /dev/null and b/src/assets/meteo-pane.png differ diff --git a/src/components/charts/WorkspaceChart.tsx b/src/components/charts/WorkspaceChart.tsx index b6a3ce8..3055da3 100644 --- a/src/components/charts/WorkspaceChart.tsx +++ b/src/components/charts/WorkspaceChart.tsx @@ -25,6 +25,7 @@ import { YAxis, } from "recharts"; +import { displayUnit } from "../../shared/utils/displayUnit"; export type WorkspaceChartMode = "line" | "area" | "bar"; export type WorkspaceChartTimeRange = "15m" | "1h" | "6h" | "24h" | "7d" | "30d"; @@ -587,7 +588,7 @@ export function WorkspaceChart({ style={{ backgroundColor: variable.color }} /> {variable.label} - {variable.unit && ` (${variable.unit})`} + {variable.unit && ` (${displayUnit(variable.unit)})`} ))} @@ -596,15 +597,15 @@ export function WorkspaceChart({
Média:{" "} - {formatValue(stats.average, primaryVariable.unit)} + {formatValue(stats.average, displayUnit(primaryVariable.unit))} Máx:{" "} - {formatValue(stats.max, primaryVariable.unit)} + {formatValue(stats.max, displayUnit(primaryVariable.unit))} Mín:{" "} - {formatValue(stats.min, primaryVariable.unit)} + {formatValue(stats.min, displayUnit(primaryVariable.unit))}
)} @@ -634,7 +635,7 @@ export function WorkspaceChart({ = 0 ? "+" : ""; - return `${prefix}${value.toFixed(1)}${unit ? ` ${unit}` : ""}`; -} + const prefix = value >= 0 ? "+" : ""; + const normalizedUnit = displayUnit(unit); + + return `${prefix}${value.toFixed(1)}${normalizedUnit ? ` ${normalizedUnit}` : ""}`; +} function formatRangeLabel(range: WorkspaceChartTimeRange) { return range.toUpperCase(); } @@ -1090,6 +1096,7 @@ function axisIdForUnit(unit: string): string { } function normalizeUnit(unit?: string): string { - return unit?.trim() ?? ""; + return displayUnit(unit); } + export default WorkspaceChart; \ No newline at end of file diff --git a/src/components/layout/TopBar.tsx b/src/components/layout/TopBar.tsx index 83a9188..f266eac 100644 --- a/src/components/layout/TopBar.tsx +++ b/src/components/layout/TopBar.tsx @@ -300,7 +300,9 @@ function pageTitle(page: AppPage | null) { return "Gráficos Gerais"; case "meteo": - return "Meteorologia"; + return "Previsões"; + case "meteoCharts": + return "Gráficos"; case "synoptic": return "Sinótico"; diff --git a/src/components/navigation/Sidebar.tsx b/src/components/navigation/Sidebar.tsx index af2132f..e2b533c 100644 --- a/src/components/navigation/Sidebar.tsx +++ b/src/components/navigation/Sidebar.tsx @@ -30,31 +30,36 @@ type SidebarProps = { const RADIUS = "rounded-[6px]"; -const navigationItems: { +const meteoItems: { label: string; page: AppPage; icon: React.ElementType; }[] = [ - { label: "Painel Principal", page: "dashboard", icon: Home }, - { label: "Meteorologia", page: "meteo", icon: CloudSun }, - { label: "Gráficos Gerais", page: "maincharts", icon: BarChart3 }, - { label: "Sinótico", page: "synoptic" , icon: MonitorDot } - + { label: "Previsões", page: "meteo", icon: CloudSun }, + { label: "Gráficos", page: "meteoCharts", icon: BarChart3 }, ]; -const climateItems = [ - { label: "Iluminação", icon: Lightbulb }, - { label: "Ventilação", icon: Wind }, - { label: "Gráficos", icon: BarChart3 }, -]; +const climateItems: { + label: string; + page?: AppPage; + icon: React.ElementType; +}[] = [ + { label: "Iluminação", icon: Lightbulb }, + { label: "Ventilação", icon: Wind }, + { label: "Gráficos", page: "climateCharts", icon: BarChart3 }, + ]; -const irrigationItems = [ - { label: "Regas", icon: Droplet }, - { label: "Filtros de Rega", icon: Filter }, - { label: "Consumos", icon: Gauge }, - { label: "Drenagem", icon: Waves }, - { label: "Gráficos", icon: BarChart3 }, -]; +const irrigationItems: { + label: string; + page?: AppPage; + icon: React.ElementType; +}[] = [ + { label: "Regas", icon: Droplet }, + { label: "Filtros de Rega", icon: Filter }, + { label: "Consumos", icon: Gauge }, + { label: "Drenagem", icon: Waves }, + { label: "Gráficos", icon: BarChart3 }, + ]; const utilityItems: { label: string; @@ -74,30 +79,40 @@ export function Sidebar({ }: SidebarProps) { const isDark = theme === "dark"; + const [meteoOpen, setMeteoOpen] = useState(true); const [climateOpen, setClimateOpen] = useState(false); const [irrigationOpen, setIrrigationOpen] = useState(false); const [activeTreeItem, setActiveTreeItem] = useState(null); - const handleTreeClick = (key: string) => { + const handleTreeClick = (key: string, page?: AppPage) => { setActiveTreeItem(key); - if (key === "climate:Gráficos") { - onNavigate("climateCharts"); + if (page) { + onNavigate(page); } }; - const handleTreeToggle = (section: "climate" | "irrigation") => { + const handleTreeToggle = (section: "meteo" | "climate" | "irrigation") => { if (collapsed) { onToggleCollapsed(); } + if (section === "meteo") { + setMeteoOpen((current) => !current); + setClimateOpen(false); + setIrrigationOpen(false); + return; + } + if (section === "climate") { setClimateOpen((current) => !current); + setMeteoOpen(false); setIrrigationOpen(false); return; } setIrrigationOpen((current) => !current); + setMeteoOpen(false); setClimateOpen(false); }; @@ -105,10 +120,8 @@ export function Sidebar({