Hub Location

import React, { useState, useEffect } from 'react'; import './ChargingHub.css'; // Mock data for demonstration purposes const mockChargingPorts = [ { id: 1, number: 1, status: 'available', type: 'DC Fast', power: '250kW', lastUsed: null }, { id: 2, number: 2, status: 'charging', type: 'DC Fast', power: '250kW', vehicle: 'Tesla Model 3', startTime: '14:30', endTime: '15:15', progress: 68 }, { id: 3, number: 3, status: 'reserved', type: 'DC Fast', power: '250kW', reservedFor: '17:00', duration: '45 min' }, { id: 4, number: 4, status: 'maintenance', type: 'DC Fast', power: '250kW', maintenanceNote: 'Scheduled maintenance', estimatedCompletion: '18:00' }, { id: 5, number: 5, status: 'available', type: 'DC Fast', power: '250kW', lastUsed: '13:45' }, { id: 6, number: 6, status: 'charging', type: 'DC Fast', power: '250kW', vehicle: 'Tesla Model Y', startTime: '15:10', endTime: '15:55', progress: 42 }, { id: 7, number: 7, status: 'available', type: 'DC Fast', power: '250kW', lastUsed: '12:30' }, { id: 8, number: 8, status: 'charging', type: 'DC Fast', power: '250kW', vehicle: 'GMC Hummer EV', startTime: '15:25', endTime: '16:10', progress: 25 }, ]; const mockEnergyData = { currentDemand: 625, peakDemand: 1200, solarGeneration: 85, batteryStorage: 72, gridConsumption: 540, dailyUsage: [ { hour: '00:00', demand: 120 }, { hour: '01:00', demand: 90 }, { hour: '02:00', demand: 75 }, { hour: '03:00', demand: 60 }, { hour: '04:00', demand: 45 }, { hour: '05:00', demand: 60 }, { hour: '06:00', demand: 150 }, { hour: '07:00', demand: 300 }, { hour: '08:00', demand: 450 }, { hour: '09:00', demand: 600 }, { hour: '10:00', demand: 750 }, { hour: '11:00', demand: 900 }, { hour: '12:00', demand: 1050 }, { hour: '13:00', demand: 1150 }, { hour: '14:00', demand: 1200 }, { hour: '15:00', demand: 1100 }, { hour: '16:00', demand: 950 }, { hour: '17:00', demand: 800 }, { hour: '18:00', demand: 700 }, { hour: '19:00', demand: 600 }, { hour: '20:00', demand: 500 }, { hour: '21:00', demand: 400 }, { hour: '22:00', demand: 300 }, { hour: '23:00', demand: 200 }, ], }; const mockVisitors = { current: 24, capacity: 50, averageDuration: 38, peakHours: '12:00 - 14:00', amenityUsage: { lounge: 65, cafe: 48, retail: 32, workspace: 25, }, }; const mockReservations = [ { id: 101, name: 'John Smith', vehicle: 'Tesla Model 3', time: '17:00', duration: '45 min', port: 3, status: 'confirmed' }, { id: 102, name: 'Sarah Johnson', vehicle: 'Tesla Model Y', time: '17:30', duration: '30 min', port: 1, status: 'confirmed' }, { id: 103, name: 'Michael Brown', vehicle: 'Ford F-150 Lightning', time: '18:15', duration: '60 min', port: 5, status: 'pending' }, { id: 104, name: 'Emily Davis', vehicle: 'Rivian R1T', time: '19:00', duration: '45 min', port: 7, status: 'confirmed' }, ]; function ChargingHub() { const [activeTab, setActiveTab] = useState('dashboard'); const [loading, setLoading] = useState(true); const [currentTime, setCurrentTime] = useState(''); const [hubStatus, setHubStatus] = useState({ name: 'The Link - Downtown', location: 'Springfield, IL', status: 'operational', occupancy: '48%', availablePorts: 3, totalPorts: 8, energyEfficiency: '92%', }); useEffect(() => { // Simulate loading const timer = setTimeout(() => { setLoading(false); }, 1500); // Update current time const updateTime = () => { const now = new Date(); const hours = now.getHours().toString().padStart(2, '0'); const minutes = now.getMinutes().toString().padStart(2, '0'); setCurrentTime(`${hours}:${minutes}`); }; updateTime(); const timeInterval = setInterval(updateTime, 60000); return () => { clearTimeout(timer); clearInterval(timeInterval); }; }, []); // Function to render status badge with appropriate color const renderStatusBadge = (status) => { let className = 'status-badge'; switch(status) { case 'available': className += ' available'; break; case 'charging': className += ' charging'; break; case 'reserved': className += ' reserved'; break; case 'maintenance': className += ' maintenance'; break; default: break; } return {status}; }; // Function to render progress bar for charging ports const renderProgressBar = (progress) => { return (
Initializing Hub Dashboard...