diff --git a/app/(admin)/adminDashboard/dashlayout.tsx b/app/(admin)/adminDashboard/dashlayout.tsx index 5fb5f1d..94655b5 100644 --- a/app/(admin)/adminDashboard/dashlayout.tsx +++ b/app/(admin)/adminDashboard/dashlayout.tsx @@ -19,7 +19,7 @@ const DashboardLayout = ({ children }: { children: React.ReactNode }) => {
{/* This is where your page content will be injected */} -
+
{children}
diff --git a/app/(admin)/adminDashboard/page.tsx b/app/(admin)/adminDashboard/page.tsx index 2cd5ad4..e0c3ab7 100644 --- a/app/(admin)/adminDashboard/page.tsx +++ b/app/(admin)/adminDashboard/page.tsx @@ -167,7 +167,7 @@ const AdminDashboard = () => { return (
-

Admin Dashboard

+

Admin Dashboard

diff --git a/components/dashboards/EnergyLineChart.tsx b/components/dashboards/EnergyLineChart.tsx index e8e1eb3..944dc37 100644 --- a/components/dashboards/EnergyLineChart.tsx +++ b/components/dashboards/EnergyLineChart.tsx @@ -14,6 +14,10 @@ import { endOfYear, } from 'date-fns'; import { fetchPowerTimeseries, fetchForecast } from '@/app/utils/api'; +import { color } from 'html2canvas/dist/types/css/types/color'; +import DatePicker from 'react-datepicker'; +import 'react-datepicker/dist/react-datepicker.css'; +import './datepicker-dark.css'; // custom dark mode styles ChartJS.register(zoomPlugin); @@ -81,6 +85,22 @@ const EnergyLineChart = ({ siteId }: EnergyLineChartProps) => { const [selectedDate, setSelectedDate] = useState(new Date()); const [forecast, setForecast] = useState([]); + function useIsDarkMode() { + const [isDark, setIsDark] = useState(() => + typeof document !== 'undefined' + ? document.body.classList.contains('dark') + : false + ); + + useEffect(() => { + const check = () => setIsDark(document.body.classList.contains('dark')); + const observer = new MutationObserver(check); + observer.observe(document.body, { attributes: true, attributeFilter: ['class'] }); + return () => observer.disconnect(); + }, []); + + return isDark; +} useEffect(() => { const now = new Date(); @@ -200,6 +220,11 @@ const EnergyLineChart = ({ siteId }: EnergyLineChartProps) => { const maxValue = allValues.length > 0 ? Math.max(...allValues) : 0; const yAxisSuggestedMax = maxValue * 1.15; + const isDark = useIsDarkMode(); + +const axisColor = isDark ? '#fff' : '#222'; + + const data = { labels: filteredLabels.map(formatLabel), datasets: [ @@ -235,7 +260,12 @@ const EnergyLineChart = ({ siteId }: EnergyLineChartProps) => { responsive: true, maintainAspectRatio: false, plugins: { - legend: { position: 'top' as const }, + legend: { + position: 'top', + labels: { + color: axisColor, // legend text color + }, + }, zoom: { zoom: { wheel: { enabled: true }, @@ -244,12 +274,22 @@ const EnergyLineChart = ({ siteId }: EnergyLineChartProps) => { }, pan: { enabled: true, mode: 'x' as const }, }, - tooltip: { enabled: true, mode: 'index' as const, intersect: false }, + tooltip: { + enabled: true, + mode: 'index', + intersect: false, + backgroundColor: isDark ? '#232b3e' : '#fff', + titleColor: axisColor, + bodyColor: axisColor, + borderColor: isDark ? '#444' : '#ccc', + borderWidth: 1, + }, }, scales: { x: { title: { display: true, + color: axisColor, text: viewMode === 'day' ? 'Time (HH:MM)' @@ -260,8 +300,11 @@ const EnergyLineChart = ({ siteId }: EnergyLineChartProps) => { : viewMode === 'monthly' ? 'Month' : 'Year', - font: { weight: 'bold' as const }, + font: { weight: 'normal' as const }, }, + ticks: { + color: axisColor, + }, }, y: { beginAtZero: true, @@ -269,9 +312,14 @@ const EnergyLineChart = ({ siteId }: EnergyLineChartProps) => { title: { display: true, text: 'Power (kW)', - font: { weight: 'bold' as const }, + color: axisColor, + font: { weight: 'normal' as const }, }, + ticks: { + color: axisColor, }, + }, + }, } as const; @@ -280,7 +328,7 @@ const EnergyLineChart = ({ siteId }: EnergyLineChartProps) => { }; return ( -
+

Energy Consumption & Generation

@@ -289,20 +337,20 @@ const EnergyLineChart = ({ siteId }: EnergyLineChartProps) => {
-
+
{viewMode === 'day' && ( )} -