All Device Code
All Device Code
setDevices(allDevices.data.Data.data);
console.log("this is the all devices",allDevices.data.Data.data);
} catch (error) {
console.error("Failed to fetch devices:", error);
setDevices([]);
}
};
fetchDevices();
}, []);
return (
<div className="all-devices-container" style={{height:'70vh',
overflowY:'scroll',padding:'20px'}}>
{/* Scanner Section */}
<div className="device-section">
<h2
style={{fontSize:'1.5rem',marginBottom:'10px',marginTop:'10px'}}>Scanners</h2>
<div className="relative flex items-center">
{/* Backward Button */}
{currentIndex > 0 && (
<button
type="button"
onClick={handlePrevious}
className="px-3 py-2 rounded-full transition duration-300 hover:bg-
gray-300 disabled:opacity-50"
disabled={currentIndex === 0}
>
<FontAwesomeIcon icon={faChevronLeft} />
</button>
)}
<div className="device-image">
<img src={device.imageUrl} alt={device.device_Name}
className="w-full h-auto" />
</div>
<div className="device-details">
<h3 className="font-semibold text-lg">{device.device_Name}</h3>
<h3><strong>Device Type:</strong> {device.device_Type}</h3>
<h3>
<strong>Status:</strong>
<span className={`status ${device.Status.toLowerCase()}`}>
{device.status === 'ONLINE' && '✔️'}
{device.status === 'OFFLINE' && '❌'}
{device.status === 'ERROR' && '⚠️'}
</span>
</h3>
</div>
<div className="device-section">
<h2 style={{fontSize:'1.5rem',marginBottom:'10px',marginTop:'10px'}}>RFID
Devices</h2>
<div className="relative flex items-center">
{/* Backward Button */}
{currentIndex > 0 && (
<button
type="button"
onClick={handlePrevious}
className="px-3 py-2 rounded-full transition duration-300 hover:bg-
gray-300 disabled:opacity-50"
disabled={currentIndex === 0}
>
<FontAwesomeIcon icon={faChevronLeft} />
</button>
)}
<div className="device-section">
<h2
style={{fontSize:'1.5rem',marginBottom:'10px',marginTop:'10px'}}>Barcode
Reader</h2>
<div className="relative flex items-center">
{/* Backward Button */}
{currentIndex > 0 && (
<button
type="button"
onClick={handlePrevious}
className="px-3 py-2 rounded-full transition duration-300 hover:bg-
gray-300 disabled:opacity-50"
disabled={currentIndex === 0}
>
<FontAwesomeIcon icon={faChevronLeft} />
</button>
)}