84 lines
3.5 KiB
TypeScript
84 lines
3.5 KiB
TypeScript
import React, { useState } from 'react';
|
|
import { Alert } from '../../types.ts';
|
|
import { VideoIcon, FanIcon } from '../icons/Icons.tsx';
|
|
|
|
interface OvercrowdingDetailScreenProps {
|
|
alert: Alert;
|
|
onBack: () => void;
|
|
}
|
|
|
|
const OvercrowdingDetailScreen: React.FC<OvercrowdingDetailScreenProps> = ({ alert, onBack }) => {
|
|
const [detailView, setDetailView] = useState<'image' | 'live'>('image');
|
|
return (
|
|
<div className="bg-gray-100 h-full overflow-y-auto">
|
|
<div className="p-3 pt-8">
|
|
<div className="flex items-center space-x-4 mb-3">
|
|
<button onClick={onBack} className="text-gray-700 text-xl">
|
|
<i className="fa-solid fa-arrow-left"></i>
|
|
</button>
|
|
<h1 className="text-lg font-bold text-gray-800">Detail Kepadatan Berlebih</h1>
|
|
</div>
|
|
<div className="relative w-full aspect-video bg-black rounded-lg overflow-hidden group">
|
|
{detailView === 'image' && (
|
|
<>
|
|
<img
|
|
src="https://i.imgur.com/8p8Yq3g.jpg"
|
|
alt="Camera view of chicken coop with overcrowding"
|
|
className="w-full h-full object-cover"
|
|
/>
|
|
<div
|
|
className="absolute border-2 border-yellow-400 bg-yellow-400/30"
|
|
style={{ top: '30%', left: '20%', width: '60%', height: '50%' }}
|
|
>
|
|
<span className="absolute -top-5 left-0 text-white bg-yellow-500 text-[8px] px-1 rounded-sm">
|
|
Area Padat
|
|
</span>
|
|
</div>
|
|
</>
|
|
)}
|
|
{detailView === 'live' && (
|
|
<div className="w-full h-full flex flex-col items-center justify-center bg-gray-900">
|
|
<VideoIcon className="text-4xl text-yellow-500" />
|
|
<p className="text-white text-sm mt-2">Kamera Langsung: Zona A-1</p>
|
|
<p className="text-gray-400 text-xs">Menghubungkan...</p>
|
|
</div>
|
|
)}
|
|
</div>
|
|
<div className="flex bg-gray-200 rounded-lg p-1 my-3">
|
|
<button
|
|
onClick={() => setDetailView('image')}
|
|
className={`w-1/2 py-1.5 text-xs font-bold rounded-md transition ${detailView === 'image' ? 'bg-white text-yellow-600 shadow' : 'text-gray-600'}`}
|
|
>
|
|
Heatmap
|
|
</button>
|
|
<button
|
|
onClick={() => setDetailView('live')}
|
|
className={`w-1/2 py-1.5 text-xs font-bold rounded-md transition ${detailView === 'live' ? 'bg-white text-yellow-600 shadow' : 'text-gray-600'}`}
|
|
>
|
|
Kamera Langsung
|
|
</button>
|
|
</div>
|
|
<div className="bg-white p-3 rounded-lg shadow-sm">
|
|
<p className="text-sm text-gray-600">
|
|
<i className="fa-solid fa-clock w-5"></i> Waktu: {alert.timestamp}
|
|
</p>
|
|
<p className="text-sm text-gray-600">
|
|
<i className="fa-solid fa-location-dot w-5"></i> Lokasi: Zona A-1
|
|
</p>
|
|
<p className="text-sm text-gray-600">
|
|
<i className="fa-solid fa-ruler-combined w-5"></i> Kepadatan: 36.2 kg/m²
|
|
</p>
|
|
</div>
|
|
<div className="mt-4 space-y-2">
|
|
<button className="w-full flex items-center justify-center space-x-2 bg-blue-600 text-white px-4 py-3 rounded-lg hover:bg-blue-700 transition duration-300 shadow-sm font-semibold">
|
|
<FanIcon />
|
|
<span>Aktifkan Kipas Pendingin</span>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default OvercrowdingDetailScreen;
|