diff --git a/client/src/pages/Devices.jsx b/client/src/pages/Devices.jsx index 9068ac1..d8c542c 100644 --- a/client/src/pages/Devices.jsx +++ b/client/src/pages/Devices.jsx @@ -17,6 +17,8 @@ const Devices = () => { const [showAddModal, setShowAddModal] = useState(false); const [editingDevice, setEditingDevice] = useState(null); const [filter, setFilter] = useState('all'); // 'all', 'approved', 'pending' + const [showDetailsModal, setShowDetailsModal] = useState(false); + const [selectedDevice, setSelectedDevice] = useState(null); useEffect(() => { fetchDevices(); @@ -63,6 +65,21 @@ const Devices = () => { } }; + const handleViewDetails = (device) => { + setSelectedDevice(device); + setShowDetailsModal(true); + }; + + const handleViewOnMap = (device) => { + if (device.geo_lat && device.geo_lon) { + // Open Google Maps with the device location + const url = `https://www.google.com/maps?q=${device.geo_lat},${device.geo_lon}&z=15`; + window.open(url, '_blank'); + } else { + alert('Device location coordinates are not available'); + } + }; + const handleDeleteDevice = async (deviceId) => { if (window.confirm('Are you sure you want to deactivate this device?')) { try { @@ -312,10 +329,16 @@ const Devices = () => { ) : null}