Initial commit: ICU Patient Display Management System
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { fetchApi } from "@/lib/api";
|
||||
import { Plus, Search } from "lucide-react";
|
||||
import Link from "next/link";
|
||||
|
||||
export default function RoomsPage() {
|
||||
const [rooms, setRooms] = useState<any[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [search, setSearch] = useState("");
|
||||
|
||||
useEffect(() => {
|
||||
fetchApi('/rooms')
|
||||
.then(data => {
|
||||
setRooms(data);
|
||||
setLoading(false);
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
setLoading(false);
|
||||
});
|
||||
}, []);
|
||||
|
||||
const filtered = rooms.filter((r: any) =>
|
||||
r.room_number?.toLowerCase().includes(search.toLowerCase()) ||
|
||||
r.ward?.toLowerCase().includes(search.toLowerCase())
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<div className="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-3 sm:gap-4 bg-white/75 dark:bg-zinc-900/75 backdrop-blur-md border border-zinc-200/60 dark:border-zinc-800/60 px-4 sm:px-5 py-3 sm:py-3.5 rounded-xl shadow-xs">
|
||||
<div>
|
||||
<h1 className="text-xl sm:text-2xl font-bold text-zinc-900 dark:text-zinc-100 flex items-center gap-2">
|
||||
<svg className="text-red-500 w-5 h-5 sm:w-6 sm:h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4" /></svg>
|
||||
ICU Rooms
|
||||
</h1>
|
||||
<p className="text-xs sm:text-sm text-zinc-600 dark:text-zinc-400 mt-0.5">Manage hospital rooms and ward assignments.</p>
|
||||
</div>
|
||||
<Link href="/rooms/new" className="w-full sm:w-auto bg-red-600 hover:bg-red-500 text-white px-4 py-2.5 rounded-lg font-medium transition-colors flex items-center justify-center gap-2 text-sm shadow-sm">
|
||||
<Plus size={18} /> Add Room
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
<div className="bg-zinc-50/90 dark:bg-zinc-900/90 border border-zinc-200 dark:border-zinc-800 rounded-xl overflow-hidden shadow-sm">
|
||||
<div className="p-3 sm:p-4 border-b border-zinc-200 dark:border-zinc-800 flex justify-between items-center bg-zinc-100/50 dark:bg-zinc-900/50">
|
||||
<div className="flex items-center bg-white dark:bg-zinc-950 border border-zinc-200 dark:border-zinc-800 rounded-lg px-3 py-2 w-full sm:w-72">
|
||||
<Search className="text-zinc-400 mr-2 shrink-0" size={16} />
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Search Room Number or Ward..."
|
||||
value={search}
|
||||
onChange={(e) => setSearch(e.target.value)}
|
||||
className="bg-transparent border-none outline-none text-zinc-700 dark:text-zinc-300 placeholder-zinc-500 text-xs sm:text-sm w-full"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="overflow-x-auto">
|
||||
<table className="min-w-[500px] w-full text-left text-xs sm:text-sm text-zinc-700 dark:text-zinc-300">
|
||||
<thead className="bg-white/80 dark:bg-zinc-950/50 text-zinc-600 dark:text-zinc-400 border-b border-zinc-200 dark:border-zinc-800 uppercase text-[10px] sm:text-xs font-semibold">
|
||||
<tr>
|
||||
<th className="px-4 sm:px-6 py-3.5">Room ID</th>
|
||||
<th className="px-4 sm:px-6 py-3.5">Room Number</th>
|
||||
<th className="px-4 sm:px-6 py-3.5">Ward</th>
|
||||
<th className="px-4 sm:px-6 py-3.5">Assigned Display ID</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{loading ? (
|
||||
<tr>
|
||||
<td colSpan={4} className="px-4 sm:px-6 py-8 text-center text-zinc-500">Loading rooms...</td>
|
||||
</tr>
|
||||
) : filtered.length === 0 ? (
|
||||
<tr>
|
||||
<td colSpan={4} className="px-4 sm:px-6 py-8 text-center text-zinc-500">No rooms found.</td>
|
||||
</tr>
|
||||
) : (
|
||||
filtered.map((room: any) => (
|
||||
<tr key={room.id} className="border-b border-zinc-200/50 dark:border-zinc-800/50 hover:bg-zinc-100 dark:hover:bg-zinc-800/20 transition-colors">
|
||||
<td className="px-4 sm:px-6 py-3.5 font-mono text-zinc-500 whitespace-nowrap">{room.id}</td>
|
||||
<td className="px-4 sm:px-6 py-3.5 font-medium text-zinc-800 dark:text-zinc-200 whitespace-nowrap">{room.room_number}</td>
|
||||
<td className="px-4 sm:px-6 py-3.5 whitespace-nowrap">{room.ward}</td>
|
||||
<td className="px-4 sm:px-6 py-3.5 font-mono whitespace-nowrap">{room.display_id || 'None'}</td>
|
||||
</tr>
|
||||
))
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user