From 4421d703b6d8871181ec86c0de780b5bcb9d6e87 Mon Sep 17 00:00:00 2001 From: Tanmay Kalra Date: Mon, 25 Aug 2025 23:31:10 +0530 Subject: [PATCH] Improved Ui of elec page --- src/Pages/Electricity.jsx | 311 +++++++++++++++++--------------------- 1 file changed, 136 insertions(+), 175 deletions(-) diff --git a/src/Pages/Electricity.jsx b/src/Pages/Electricity.jsx index 319efe8..a8d3b9a 100644 --- a/src/Pages/Electricity.jsx +++ b/src/Pages/Electricity.jsx @@ -1,6 +1,6 @@ import React, { useState, useEffect, useMemo } from 'react'; import { Zap, Droplets, Clock, AlertTriangle, CheckCircle, XCircle, Calendar, MapPin, Bell, TrendingUp, TrendingDown, Activity, BarChart3, PieChart } from 'lucide-react'; -import { LineChart, Line, BarChart, Bar, PieChart as RechartsPieChart, Pie, Cell, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer, AreaChart, Area } from 'recharts'; +import { LineChart, Line, BarChart as ReBarChart, Bar, PieChart as RePieChart, Pie, Cell, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer, AreaChart, Area } from 'recharts'; const UtilitiesDashboard = () => { const [currentTime, setCurrentTime] = useState(new Date()); @@ -46,7 +46,7 @@ const UtilitiesDashboard = () => { totalOutages: Math.floor(Math.random() * 8), uptime: 95 + Math.random() * 5 })); - }, []); + }, [areas]); const outageReasons = [ { reason: 'Equipment Failure', count: 12, percentage: 35 }, @@ -80,9 +80,9 @@ const UtilitiesDashboard = () => { }, [liveUpdates]); const getStatusColor = (status) => ({ - active: 'text-green-600 bg-green-100', - maintenance: 'text-yellow-600 bg-yellow-100', - outage: 'text-red-600 bg-red-100' + active: 'text-emerald-700 bg-emerald-100', + maintenance: 'text-yellow-700 bg-yellow-100', + outage: 'text-red-700 bg-red-100' }[status] || 'text-gray-600 bg-gray-100'); const getStatusIcon = (status) => ({ @@ -102,61 +102,64 @@ const UtilitiesDashboard = () => { }); const KPICard = ({ title, value, trend, icon, unit = '' }) => ( -
-
-
+
+
+
{icon}
{trend !== undefined && ( -
= 0 ? 'bg-green-100 text-green-800' : 'bg-red-100 text-red-800' +
= 0 ? 'bg-emerald-100 text-emerald-700' : 'bg-red-100 text-red-700' }`}> {trend >= 0 ? : } {trend >= 0 ? '+' : ''}{trend.toFixed(1)}%
)}
-

{title}

-

+

{title}

+

{typeof value === 'number' ? value.toLocaleString() : value}{unit}

); return ( -
+
{/* Header */} -
+
-
+
-
- C -
-

Civix Utilities

+ + C + +

Civix Utilities

-
- +
+ {formatTime(currentTime)} • {formatDate(currentTime)}
-
+
-
+
{/* Controls */} -
-
-
-

Dashboard View

-
+
+
+
+

Dashboard View

+
{['dashboard', 'analytics', 'insights'].map((mode) => (
- -
-
-
+
{/* KPI Cards */} -
+
} unit="%" /> } unit="%" /> isOngoing(o)).length} trend={-15.2} icon={} /> } unit=" min" /> -
+ {/* Charts */} {viewMode === 'dashboard' && ( -
-
-

Live Consumption (24h)

+
+
+

Live Consumption (24h)

- - - - + + + + - - + +
- -
-

Outage Frequency by Area

+
+

Outage Frequency by Area

- - - - - + + + + + - +
-
+
)} {viewMode === 'analytics' && ( -
-
-

Outage Reasons Distribution

+
+
+

Outage Reasons Distribution

- - `${reason}: ${percentage}%`}> + + `${reason}: ${percentage}%`}> {outageReasons.map((entry, index) => )} - - + +
-
-

Uptime Trends by Area

+
+

Uptime Trends by Area

- - - - - + + + + +
-
+
)} {viewMode === 'insights' && ( -
-

Predictive Insights & Recommendations

-
+
+

Predictive Insights & Recommendations

+
-

Maintenance Recommendations

+

Maintenance Recommendations

-
-

Sector 2: Schedule transformer maintenance within 2 weeks

-
-
-

DLF Phase 1: Water pipeline inspection recommended

-
+
Sector 2: Schedule transformer maintenance within 2 weeks
+
DLF Phase 1: Water pipeline inspection recommended
-

Performance Forecast

+

Performance Forecast

-
-

Next Month: Expected uptime improvement of 1.2%

-
-
-

Peak Hours: Consumption expected to increase by 12%

-
+
Next Month: Expected uptime improvement of 1.2%
+
Peak Hours: Consumption expected to increase by 12%
-
+ )} {/* Status Cards */} -
-
-
-
-
- -
-

Electricity

+
+
+
+
+ + Electricity
-
+
{getStatusIcon(currentStatus.electricity.status)} {currentStatus.electricity.status}
-
-
- Uptime (30 days) - {currentStatus.electricity.uptime} -
-
- Last outage - {currentStatus.electricity.lastOutage} -
-
- Affected areas - {currentStatus.electricity.affectedAreas} -
-
+
+
Uptime (30d)
{currentStatus.electricity.uptime}
+
Last Outage
{currentStatus.electricity.lastOutage}
+
Affected Areas
{currentStatus.electricity.affectedAreas}
+
- -
-
-
-
- -
-

Water Supply

+
+
+
+ + Water Supply
-
+
{getStatusIcon(currentStatus.water.status)} {currentStatus.water.status}
-
-
- Uptime (30 days) - {currentStatus.water.uptime} -
-
- Last outage - {currentStatus.water.lastOutage} -
-
- Affected areas - {currentStatus.water.affectedAreas} -
-
+
+
Uptime (30d)
{currentStatus.water.uptime}
+
Last Outage
{currentStatus.water.lastOutage}
+
Affected Areas
{currentStatus.water.affectedAreas}
+
-
+
- {/* Filters */} -
-

Filter Outages

-
+ {/* Outage Filters */} +
+

Filter Outages

+
- - setSelectedUtility(e.target.value)} className="w-full p-3 border border-emerald-100/60 dark:border-emerald-800/30 rounded-lg bg-white dark:bg-emerald-950 text-emerald-900 dark:text-white font-semibold focus:ring-emerald-400">
- - setSelectedArea(e.target.value)} className="w-full p-3 border border-emerald-100/60 dark:border-emerald-800/30 rounded-lg bg-white dark:bg-emerald-950 text-emerald-900 dark:text-white font-semibold focus:ring-emerald-400"> {areas.map(area => )}
-
+ {/* Scheduled Outages */} -
+
-

Scheduled Outages

- +

Scheduled Outages

+
{filteredOutages.map((outage) => ( -
-
-
- {outage.type === 'electricity' ? : } +
+
+
+ {outage.type === 'electricity' ? : }
-
-

{outage.type}

- {isOngoing(outage) && ONGOING} +
+ {outage.type} + {isOngoing(outage) && ONGOING}
-
-
- - {outage.area} -
-
- - {formatDate(outage.startTime)} -
-
- - {formatTime(outage.startTime)} - {formatTime(outage.endTime)} -
+
+ {outage.area} + {formatDate(outage.startTime)} + {formatTime(outage.startTime)} - {formatTime(outage.endTime)}
-

{outage.reason}

+

{outage.reason}

))}
-
-
+
+
); }; -export default UtilitiesDashboard; \ No newline at end of file +export default UtilitiesDashboard;