This commit is contained in:
[Valentino Heman Budiarto] 2026-02-19 18:14:19 +07:00
parent d09c21a41f
commit 9d4cc8bfed
29 changed files with 8582 additions and 1 deletions

@ -1 +0,0 @@
Subproject commit 557ce3b43798549993dbd59b8afa3d053356e57d

41
frontend/.gitignore vendored Normal file
View File

@ -0,0 +1,41 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/versions
# testing
/coverage
# next.js
/.next/
/out/
# production
/build
# misc
.DS_Store
*.pem
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*
# env files (can opt-in for committing if needed)
.env*
# vercel
.vercel
# typescript
*.tsbuildinfo
next-env.d.ts

36
frontend/README.md Normal file
View File

@ -0,0 +1,36 @@
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
## Getting Started
First, run the development server:
```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
## Learn More
To learn more about Next.js, take a look at the following resources:
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
## Deploy on Vercel
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.

154
frontend/app/admin/page.tsx Normal file
View File

@ -0,0 +1,154 @@
"use client";
import { useEffect, useState } from "react";
import axios from "axios";
import { useRouter } from "next/navigation";
import { LogOut, CheckCircle, XCircle, Clock } from "lucide-react";
export default function AdminDashboard() {
const router = useRouter();
const [admin, setAdmin] = useState<any>(null);
const [bookings, setBookings] = useState<any[]>([]);
const [loading, setLoading] = useState(true);
useEffect(() => {
const token = localStorage.getItem("token");
const userData = localStorage.getItem("user");
if (!token || !userData) {
router.push("/login");
return;
}
const userObj = JSON.parse(userData);
// Tendang kalau bukan admin yang masuk
if (userObj.role !== "admin") {
router.push("/dashboard");
return;
}
setAdmin(userObj);
fetchBookings(token);
}, []);
const fetchBookings = async (token: string) => {
try {
const response = await axios.get("http://localhost:8080/api/bookings", {
headers: { Authorization: `Bearer ${token}` },
});
setBookings(response.data.data || []);
} catch (error) {
console.error("Gagal ambil data booking:", error);
} finally {
setLoading(false);
}
};
const handleUpdateStatus = async (bookingId: string, newStatus: string) => {
const token = localStorage.getItem("token");
try {
await axios.patch(
`http://localhost:8080/api/bookings/${bookingId}`,
{ status: newStatus },
{ headers: { Authorization: `Bearer ${token}` } }
);
alert(`Booking berhasil di-${newStatus}!`);
fetchBookings(token as string); // Refresh data setelah update
} catch (error) {
alert("Gagal mengubah status booking.");
console.error(error);
}
};
const handleLogout = () => {
localStorage.removeItem("token");
localStorage.removeItem("user");
router.push("/login");
};
if (loading) return <div className="p-10 text-center">Memuat panel admin...</div>;
return (
<div className="min-h-screen bg-gray-100">
{/* Navbar Admin */}
<nav className="bg-slate-800 shadow-sm px-6 py-4 flex justify-between items-center text-white sticky top-0 z-10">
<div>
<h1 className="text-xl font-bold text-blue-400">S-CLASS | ADMIN PANEL</h1>
<p className="text-xs text-gray-300">Welcome, {admin?.full_name}</p>
</div>
<button
onClick={handleLogout}
className="flex items-center gap-2 text-sm bg-red-500 hover:bg-red-600 px-4 py-2 rounded-lg transition"
>
<LogOut size={16} /> Keluar
</button>
</nav>
{/* Konten Utama */}
<main className="max-w-6xl mx-auto p-6">
<h2 className="text-2xl font-bold text-gray-800 mb-6">Manajemen Peminjaman Ruangan</h2>
<div className="bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden">
<table className="w-full text-left border-collapse">
<thead>
<tr className="bg-gray-50 text-gray-600 text-sm border-b">
<th className="p-4">Ruangan</th>
<th className="p-4">Peminjam</th>
<th className="p-4">Waktu</th>
<th className="p-4">Keperluan</th>
<th className="p-4">Status</th>
<th className="p-4 text-center">Aksi</th>
</tr>
</thead>
<tbody>
{bookings.length === 0 ? (
<tr>
<td colSpan={6} className="text-center p-8 text-gray-500">Belum ada pengajuan peminjaman.</td>
</tr>
) : (
bookings.map((b) => (
<tr key={b.booking_id} className="border-b hover:bg-gray-50">
<td className="p-4 font-semibold text-gray-800">{b.room?.name}</td>
<td className="p-4 text-sm text-gray-600">ID User: {b.user_id.substring(0,8)}...</td>
<td className="p-4 text-sm text-gray-600">
<div>Mulai: {new Date(b.start_time).toLocaleString('id-ID')}</div>
<div>Selesai: {new Date(b.end_time).toLocaleString('id-ID')}</div>
</td>
<td className="p-4 text-sm text-gray-600">{b.purpose}</td>
<td className="p-4">
<span className={`px-2 py-1 text-xs font-bold rounded-full ${
b.status === 'Approved' ? 'bg-green-100 text-green-700' :
b.status === 'Rejected' ? 'bg-red-100 text-red-700' :
'bg-yellow-100 text-yellow-700'
}`}>
{b.status}
</span>
</td>
<td className="p-4">
{b.status === 'Pending' ? (
<div className="flex justify-center gap-2">
<button
onClick={() => handleUpdateStatus(b.booking_id, 'Approved')}
className="bg-green-500 hover:bg-green-600 text-white p-2 rounded-lg" title="Setujui">
<CheckCircle size={18} />
</button>
<button
onClick={() => handleUpdateStatus(b.booking_id, 'Rejected')}
className="bg-red-500 hover:bg-red-600 text-white p-2 rounded-lg" title="Tolak">
<XCircle size={18} />
</button>
</div>
) : (
<div className="text-center text-gray-400 text-xs">- Selesai -</div>
)}
</td>
</tr>
))
)}
</tbody>
</table>
</div>
</main>
</div>
);
}

View File

@ -0,0 +1,245 @@
"use client";
import { useState } from "react";
import { useRouter } from "next/navigation";
import { Calendar, Clock, Save, X, AlertTriangle } from "lucide-react";
export default function AddBookingPage() {
const router = useRouter();
const [isLoading, setIsLoading] = useState(false);
// State untuk form input
const [formData, setFormData] = useState({
room: "Ruang T-301",
date: "",
startTime: "",
endTime: "",
purpose: "",
});
const handleChange = (e: React.ChangeEvent<HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement>) => {
setFormData({ ...formData, [e.target.name]: e.target.value });
};
// --- LOGIKA VALIDASI (Business Logic) ---
const validateBookingRules = () => {
// 1. Cek kelengkapan data dasar
if (!formData.date || !formData.startTime || !formData.endTime) {
alert("Mohon lengkapi Tanggal dan Jam terlebih dahulu.");
return false;
}
// 2. Ambil Jam Mulai
const startHour = parseInt(formData.startTime.split(":")[0]);
// 3. Cek Jam Khusus (Diatas 21:00 ATAU Sebelum 06:00)
const isSpecialTime = startHour >= 21 || startHour < 6;
if (isSpecialTime) {
const bookingDate = new Date(formData.date);
const today = new Date();
// Reset jam agar perhitungan murni berdasarkan tanggal
bookingDate.setHours(0, 0, 0, 0);
today.setHours(0, 0, 0, 0);
// Hitung selisih hari
const diffTime = bookingDate.getTime() - today.getTime();
const diffDays = diffTime / (1000 * 3600 * 24);
// ATURAN: Harus H-3
if (diffDays < 3) {
alert(
`Gagal! Peminjaman di jam khusus (${formData.startTime}) harus dilakukan minimal 3 hari sebelumnya.\n\n` +
`Jarak peminjaman Anda: ${diffDays} hari dari sekarang.`
);
return false;
}
}
return true;
};
const handleSubmit = (e: React.FormEvent) => {
e.preventDefault();
// Jalankan validasi
if (!validateBookingRules()) return;
setIsLoading(true);
// --- MOCK API CALL ---
console.log("Mengirim Data:", formData);
setTimeout(() => {
alert("Berhasil! Jadwal telah disimpan.");
setIsLoading(false);
// Redirect kembali ke halaman List Booking
router.push("/dashboard/bookings");
}, 1500);
};
return (
<div className="mx-auto max-w-270">
{/* Header Halaman */}
<div className="mb-6 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between">
<h2 className="text-2xl font-bold text-black">
Buat Peminjaman Baru
</h2>
<nav>
<ol className="flex items-center gap-2 text-sm">
<li><a className="font-medium text-gray-500" href="/dashboard/bookings">Booking /</a></li>
<li className="font-medium text-yellow-500">Add</li>
</ol>
</nav>
</div>
{/* Form Container */}
<div className="rounded-xl border border-stroke bg-white shadow-sm border-gray-200 dark:bg-boxdark">
<div className="border-b border-stroke py-4 px-6.5 border-gray-200">
<h3 className="font-medium text-black ">
Formulir Pengajuan Jadwal
</h3>
</div>
<form onSubmit={handleSubmit}>
<div className="p-6.5">
{/* --- Baris 1: Ruangan & Tanggal --- */}
<div className="mb-4.5 flex flex-col gap-6 xl:flex-row">
{/* Input Ruangan */}
<div className="w-full xl:w-1/2">
<label className="mb-2.5 block text-black font-medium">
Pilih Ruangan <span className="text-red-500">*</span>
</label>
<div className="relative z-20 bg-white border border-gray-300 text-gray-900 focus:ring-yellow-500">
<select
name="room"
value={formData.room}
onChange={handleChange}
className="relative z-20 w-full appearance-none rounded border border-stroke bg-transparent py-3 px-5 outline-none transition focus:border-yellow-500 active:border-yellow-500 dark:border-form-strokedark dark:bg-form-input dark:focus:border-yellow-500 text-black "
>
<option value="Ruang T-301">Ruang T-301 (Teori)</option>
<option value="Ruang T-302">Ruang T-302 (Teori)</option>
<option value="Lab Kendali">Lab Sistem Kendali</option>
<option value="Lab IoT">Lab IoT & Embedded</option>
<option value="Ruang Sidang">Ruang Sidang TA</option>
</select>
<span className="absolute top-1/2 right-4 z-30 -translate-y-1/2">
<svg className="fill-current" width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M6.98438 9.98438H17.0156C17.3781 9.98438 17.5656 10.4219 17.3094 10.6781L12.3094 15.6781C12.1406 15.8469 11.8594 15.8469 11.6906 15.6781L6.69062 10.6781C6.43438 10.4219 6.62188 9.98438 6.98438 9.98438Z" fill="gray" /></svg>
</span>
</div>
</div>
{/* Input Tanggal */}
<div className="w-full xl:w-1/2">
<label className="mb-2.5 block text-black font-medium">
Tanggal Peminjaman <span className="text-red-500">*</span>
</label>
<div className="relative">
<input
type="date"
name="date"
required
value={formData.date}
onChange={handleChange}
className="w-full rounded border border-stroke bg-gray-50 py-3 pl-11.5 pr-4.5 text-black focus:border-yellow-500 focus-visible:outline-none border-gray-200 dark:focus:border-yellow-500"
/>
<Calendar className="absolute left-4.5 top-3 text-gray-400" size={20} />
</div>
</div>
</div>
{/* --- Baris 2: Waktu Mulai & Selesai --- */}
<div className="mb-4.5 flex flex-col gap-6 xl:flex-row">
<div className="w-full xl:w-1/2">
<label className="mb-2.5 block text-black font-medium">
Waktu Mulai <span className="text-red-500">*</span>
</label>
<div className="relative">
<input
type="time"
name="startTime"
required
value={formData.startTime}
onChange={handleChange}
className="w-full rounded border border-stroke bg-gray-50 py-3 pl-11.5 pr-4.5 text-black focus:border-yellow-500 focus-visible:outline-none border-gray-200 dark:focus:border-yellow-500"
/>
<Clock className="absolute left-4.5 top-3 text-gray-400" size={20} />
</div>
{/* Info Validasi */}
<p className="mt-2 text-xs text-orange-500 flex items-center gap-1">
<AlertTriangle size={12} />
Peminjaman jam 21:00 - 06:00 wajib H-3.
</p>
</div>
<div className="w-full xl:w-1/2">
<label className="mb-2.5 block text-black font-medium">
Waktu Selesai <span className="text-red-500">*</span>
</label>
<div className="relative">
<input
type="time"
name="endTime"
required
value={formData.endTime}
onChange={handleChange}
className="w-full rounded border border-stroke bg-gray-50 py-3 pl-11.5 pr-4.5 text-black focus:border-yellow-500 focus-visible:outline-none border-gray-200 dark:focus:border-yellow-500"
/>
<Clock className="absolute left-4.5 top-3 text-gray-400" size={20} />
</div>
</div>
</div>
{/* --- Baris 3: Keperluan --- */}
<div className="mb-6">
<label className="mb-2.5 block text-black font-medium">
Keperluan / Mata Kuliah <span className="text-red-500">*</span>
</label>
<textarea
rows={4}
name="purpose"
required
placeholder="Jelaskan keperluan peminjaman ruang..."
value={formData.purpose}
onChange={handleChange}
className="w-full rounded border border-stroke bg-transparent py-3 px-5 text-black outline-none transition focus:border-yellow-500 active:border-yellow-500 dark:border-form-strokedark dark:bg-form-input dark:focus:border-yellow-500"
></textarea>
</div>
{/* --- Tombol Aksi --- */}
<div className="flex gap-4 justify-end">
<button
type="button"
onClick={() => router.push("/dashboard/bookings")}
className="flex items-center justify-center gap-2 rounded border border-stroke py-2.5 px-6 font-medium text-black hover:shadow-1 border-gray-200 transition-all hover:bg-gray-100"
>
<X size={18} />
Batal
</button>
<button
type="submit"
disabled={isLoading}
className={`flex items-center justify-center gap-2 rounded bg-yellow-500 py-2.5 px-6 font-medium text-white hover:bg-yellow-600 transition-all ${
isLoading ? "opacity-70 cursor-not-allowed" : ""
}`}
>
{isLoading ? (
"Menyimpan..."
) : (
<>
<Save size={18} />
Simpan Jadwal
</>
)}
</button>
</div>
</div>
</form>
</div>
</div>
);
}

View File

@ -0,0 +1,247 @@
"use client";
import { useState } from "react";
import { ChevronLeft, ChevronRight, Calendar as CalendarIcon, Clock, MapPin } from "lucide-react";
// --- Tipe Data Mock ---
type Booking = {
id: number;
room: string;
date: string; // Format YYYY-MM-DD
startTime: string;
endTime: string;
purpose: string;
status: "Approved" | "Pending";
};
// --- Data Dummy (Mock Data) ---
const mockBookings: Booking[] = [
{
id: 1,
room: "Ruang T-301",
date: "2026-02-05",
startTime: "07:30",
endTime: "10:00",
purpose: "Kuliah Sistem Kendali",
status: "Approved",
},
{
id: 2,
room: "Lab IoT",
date: "2026-02-05", // Tanggal sama dengan atas
startTime: "13:00",
endTime: "15:00",
purpose: "Praktikum Embedded System",
status: "Approved",
},
{
id: 3,
room: "Ruang T-302",
date: "2026-02-12",
startTime: "09:00",
endTime: "11:30",
purpose: "Seminar Proposal",
status: "Pending",
},
{
id: 4,
room: "Lab Kendali",
date: "2026-02-20",
startTime: "10:00",
endTime: "12:00",
purpose: "Riset Skripsi",
status: "Approved",
},
];
export default function CalendarPage() {
const [currentDate, setCurrentDate] = useState(new Date(2026, 1)); // Februari 2026
const [selectedDate, setSelectedDate] = useState<string | null>(null);
// --- Helper Functions ---
const getDaysInMonth = (year: number, month: number) => new Date(year, month + 1, 0).getDate();
const getFirstDayOfMonth = (year: number, month: number) => new Date(year, month, 1).getDay();
const handlePrevMonth = () => {
setCurrentDate(new Date(currentDate.getFullYear(), currentDate.getMonth() - 1));
setSelectedDate(null);
};
const handleNextMonth = () => {
setCurrentDate(new Date(currentDate.getFullYear(), currentDate.getMonth() + 1));
setSelectedDate(null);
};
const handleDateClick = (day: number) => {
const year = currentDate.getFullYear();
const month = String(currentDate.getMonth() + 1).padStart(2, "0");
const dateStr = String(day).padStart(2, "0");
const fullDate = `${year}-${month}-${dateStr}`;
// Toggle seleksi: Jika diklik lagi, tutup detailnya
if (selectedDate === fullDate) {
setSelectedDate(null);
} else {
setSelectedDate(fullDate);
}
};
// --- Generate Calendar Grid ---
const year = currentDate.getFullYear();
const month = currentDate.getMonth();
const daysInMonth = getDaysInMonth(year, month);
const firstDay = getFirstDayOfMonth(year, month);
// Array kosong untuk padding hari sebelum tanggal 1
const emptyDays = Array.from({ length: firstDay }, (_, i) => i);
// Array tanggal 1 sampai akhir bulan
const days = Array.from({ length: daysInMonth }, (_, i) => i + 1);
// Nama Bulan
const monthNames = [
"Januari", "Februari", "Maret", "April", "Mei", "Juni",
"Juli", "Agustus", "September", "Oktober", "November", "Desember"
];
// Filter booking untuk tanggal yang dipilih
const selectedBookings = mockBookings.filter((b) => b.date === selectedDate);
return (
<div className="flex flex-col gap-6 lg:flex-row">
{/* --- KIRI: KALENDER --- */}
<div className="flex-1 rounded-xl border border-stroke bg-white shadow-sm border-gray-200 dark:bg-boxdark">
{/* Header Kalender */}
<div className="flex items-center justify-between border-b border-stroke p-4 border-gray-200 sm:p-6">
<div className="flex items-center gap-2">
<div className="h-10 w-10 flex items-center justify-center rounded-full bg-yellow-50 text-yellow-600">
<CalendarIcon size={20} />
</div>
<div>
<h2 className="text-lg font-bold text-black ">
{monthNames[month]} {year}
</h2>
<p className="text-xs text-gray-500">Pilih tanggal untuk melihat detail.</p>
</div>
</div>
<div className="flex gap-2">
<button onClick={handlePrevMonth} className="p-2 rounded hover:bg-gray-100 dark:hover:bg-meta-4 transition">
<ChevronLeft size={20} />
</button>
<button onClick={handleNextMonth} className="p-2 rounded hover:bg-gray-100 dark:hover:bg-meta-4 transition">
<ChevronRight size={20} />
</button>
</div>
</div>
{/* Grid Kalender */}
<div className="p-4 sm:p-6">
{/* Nama Hari */}
<div className="grid grid-cols-7 mb-2">
{["Min", "Sen", "Sel", "Rab", "Kam", "Jum", "Sab"].map((d) => (
<span key={d} className="text-center text-sm font-medium text-gray-500 py-2">
{d}
</span>
))}
</div>
{/* Tanggal */}
<div className="grid grid-cols-7 gap-2">
{/* Render Empty Cells */}
{emptyDays.map((_, i) => (
<div key={`empty-${i}`} className="h-24 sm:h-32"></div>
))}
{/* Render Date Cells */}
{days.map((day) => {
// Format tanggal hari ini untuk pengecekan data
const currentDayStr = `${year}-${String(month + 1).padStart(2, "0")}-${String(day).padStart(2, "0")}`;
const hasBooking = mockBookings.some((b) => b.date === currentDayStr);
const isSelected = selectedDate === currentDayStr;
return (
<div
key={day}
onClick={() => handleDateClick(day)}
className={`relative flex h-24 sm:h-32 cursor-pointer flex-col justify-between rounded border p-2 transition hover:bg-gray-50 dark:hover:bg-meta-4
${isSelected
? "border-yellow-500 bg-yellow-50 dark:bg-slate-800"
: "border-stroke border-gray-200 bg-white dark:bg-boxdark"
}`}
>
<span className={`text-sm font-medium ${isSelected ? "text-yellow-600" : "text-black "}`}>
{day}
</span>
{/* Indikator Booking (Dot / Bar) */}
{hasBooking && (
<div className="flex flex-col gap-1">
{mockBookings
.filter(b => b.date === currentDayStr)
.slice(0, 2) // Batasi tampilan max 2 baris di grid
.map((b, idx) => (
<div key={idx} className="truncate rounded-sm bg-blue-100 px-1 py-0.5 text-[10px] font-medium text-blue-700 dark:bg-blue-900 dark:text-blue-100">
{b.startTime} - {b.room}
</div>
))}
{mockBookings.filter(b => b.date === currentDayStr).length > 2 && (
<span className="text-[10px] text-gray-400 text-center">+ Lainnya</span>
)}
</div>
)}
</div>
);
})}
</div>
</div>
</div>
{/* --- KANAN: DETAIL SIDEBAR --- */}
{selectedDate && (
<div className="w-full lg:w-80 shrink-0 animate-in fade-in slide-in-from-right duration-300">
<div className="rounded-xl border border-stroke bg-white p-6 shadow-sm border-gray-200 dark:bg-boxdark">
<h3 className="mb-4 text-xl font-bold text-black border-b border-stroke pb-2 border-gray-200">
Jadwal {selectedDate}
</h3>
{selectedBookings.length > 0 ? (
<div className="flex flex-col gap-4">
{selectedBookings.map((booking) => (
<div key={booking.id} className="rounded-lg border border-gray-100 bg-gray-50 p-4 border-gray-200 bg-gray-50">
<div className="flex items-center justify-between mb-2">
<span className={`px-2 py-0.5 rounded text-xs font-medium ${
booking.status === "Approved"
? "bg-green-100 text-green-700"
: "bg-yellow-100 text-yellow-700"
}`}>
{booking.status}
</span>
</div>
<h4 className="font-bold text-black mb-1">{booking.purpose}</h4>
<div className="flex items-center gap-2 text-sm text-gray-500 mt-2">
<MapPin size={16} /> {booking.room}
</div>
<div className="flex items-center gap-2 text-sm text-gray-500 mt-1">
<Clock size={16} /> {booking.startTime} - {booking.endTime}
</div>
</div>
))}
</div>
) : (
<div className="py-10 text-center">
<p className="text-gray-400 text-sm">Tidak ada jadwal pada tanggal ini.</p>
<button className="mt-4 text-sm font-medium text-yellow-600 hover:underline">
+ Tambah Jadwal
</button>
</div>
)}
</div>
</div>
)}
</div>
);
}

View File

@ -0,0 +1,189 @@
"use client";
import { useState } from "react";
import { useRouter } from "next/navigation";
export default function BookingPage() {
const router = useRouter();
const [isLoading, setIsLoading] = useState(false);
// State untuk form input
const [formData, setFormData] = useState({
room: "Ruang T-301",
date: "",
startTime: "",
endTime: "",
purpose: "",
});
const handleChange = (e: React.ChangeEvent<HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement>) => {
setFormData({ ...formData, [e.target.name]: e.target.value });
};
// --- LOGIKA VALIDASI KHUSUS ---
const validateBookingRules = () => {
// 1. Pastikan tanggal dan jam sudah diisi
if (!formData.date || !formData.startTime) {
alert("Mohon lengkapi Tanggal dan Jam Mulai terlebih dahulu.");
return false;
}
// 2. Ambil Jam dari input (Format "HH:mm", kita ambil HH nya saja)
const startHour = parseInt(formData.startTime.split(":")[0]);
// 3. Cek apakah jam termasuk "Jam Khusus" (Diatas 21:00 ATAU Sebelum 06:00)
// Note: startHour >= 21 artinya jam 21:00 ke atas. startHour < 6 artinya jam 00:00 - 05:59
const isSpecialTime = startHour >= 21 || startHour < 6;
if (isSpecialTime) {
// Hitung selisih hari antara HARI INI dan TANGGAL BOOKING
const bookingDate = new Date(formData.date);
const today = new Date();
// Reset jam ke 00:00:00 agar perhitungan murni berdasarkan tanggal
bookingDate.setHours(0, 0, 0, 0);
today.setHours(0, 0, 0, 0);
// Hitung selisih waktu dalam milidetik
const diffTime = bookingDate.getTime() - today.getTime();
// Konversi milidetik ke hari (1 hari = 1000ms * 3600detik * 24jam)
const diffDays = diffTime / (1000 * 3600 * 24);
// ATURAN: Jika selisih kurang dari 3 hari, tolak!
if (diffDays < 3) {
alert(
`Gagal! Peminjaman di jam khusus (${formData.startTime}) harus dilakukan minimal 3 hari sebelumnya.\n\n` +
`Jarak peminjaman Anda: ${diffDays} hari dari sekarang.`
);
return false; // Validasi Gagal
}
}
return true; // Validasi Berhasil
};
const handleSubmit = (e: React.FormEvent) => {
e.preventDefault();
// Jalankan validasi sebelum proses loading
const isValid = validateBookingRules();
if (!isValid) {
return; // Berhenti di sini jika validasi gagal
}
setIsLoading(true);
// --- LOGIKA SEMENTARA (MOCK) ---
console.log("Data Booking dikirim:", formData);
setTimeout(() => {
alert("Peminjaman Berhasil! Token akses Anda telah dibuat.");
setIsLoading(false);
router.push("/dashboard");
}, 1500);
};
return (
<div className="min-h-screen bg-gray-50 p-6 flex items-center justify-center">
<div className="w-full max-w-lg bg-white rounded-xl shadow-md border border-gray-200 overflow-hidden">
{/* Header Form */}
<div className="bg-yellow-500 px-6 py-4 flex justify-between items-center">
<h1 className="text-xl font-bold text-white">Formulir Peminjaman Ruang</h1>
<button
onClick={() => router.back()}
className="text-white/80 hover:text-white text-sm"
>
&larr; Batal
</button>
</div>
<form onSubmit={handleSubmit} className="p-8 space-y-6">
{/* Pilihan Ruangan */}
<div>
<label className="block text-sm font-medium text-gray-700 mb-2">Pilih Ruangan</label>
<select
name="room"
value={formData.room}
onChange={handleChange}
className="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-yellow-400 outline-none text-gray-900"
>
<option value="Ruang T-301">Ruang T-301 (Teori)</option>
<option value="Ruang T-302">Ruang T-302 (Teori)</option>
<option value="Lab Kendali">Lab Sistem Kendali</option>
<option value="Lab IoT">Lab IoT & Embedded</option>
</select>
</div>
{/* Tanggal */}
<div>
<label className="block text-sm font-medium text-gray-700 mb-2">Tanggal Peminjaman</label>
<input
type="date"
name="date"
required
value={formData.date}
onChange={handleChange}
className="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-yellow-400 outline-none text-gray-900"
/>
</div>
{/* Waktu Mulai & Selesai */}
<div className="grid grid-cols-2 gap-4">
<div>
<label className="block text-sm font-medium text-gray-700 mb-2">Waktu Mulai</label>
<input
type="time"
name="startTime"
required
value={formData.startTime}
onChange={handleChange}
className="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-yellow-400 outline-none text-gray-900"
/>
<p className="text-xs text-gray-400 mt-1">*Jam 21:00-06:00 butuh H-3</p>
</div>
<div>
<label className="block text-sm font-medium text-gray-700 mb-2">Waktu Selesai</label>
<input
type="time"
name="endTime"
required
value={formData.endTime}
onChange={handleChange}
className="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-yellow-400 outline-none text-gray-900"
/>
</div>
</div>
{/* Keperluan */}
<div>
<label className="block text-sm font-medium text-gray-700 mb-2">Keperluan</label>
<textarea
name="purpose"
rows={3}
placeholder="Contoh: Kuliah Pengganti Sistem Kendali Digital"
value={formData.purpose}
onChange={handleChange}
className="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-yellow-400 outline-none text-gray-900"
></textarea>
</div>
{/* Tombol Submit */}
<button
type="submit"
disabled={isLoading}
className={`w-full py-3 rounded-lg text-white font-bold shadow transition-all
${isLoading
? "bg-gray-400 cursor-not-allowed"
: "bg-blue-600 hover:bg-blue-700 active:scale-95"
}`}
>
{isLoading ? "Memproses Jadwal..." : "Ajukan Peminjaman"}
</button>
</form>
</div>
</div>
);
}

View File

@ -0,0 +1,27 @@
import Header from "@/components/Header";
import Sidebar from "@/components/Sidebar";
export default function DashboardLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<div className="dark:bg-boxdark-2 bg-gray-100 min-h-screen">
<div className="flex h-screen overflow-hidden">
{/* Sidebar akan tampil di sini */}
<Sidebar />
{/* Area Konten Utama */}
<div className="relative flex flex-1 flex-col overflow-y-auto overflow-x-hidden">
<Header />
<main>
<div className="mx-auto max-w-screen-2xl p-4 md:p-6 2xl:p-10">
{children}
</div>
</main>
</div>
</div>
</div>
);
}

View File

@ -0,0 +1,266 @@
"use client";
import { useEffect, useState } from "react";
import axios from "axios";
import { useRouter } from "next/navigation";
import { LogOut, MapPin, Users, Calendar, X, Clock, FileText } from "lucide-react";
// Tipe Data
interface Room {
room_id: number;
name: string;
category: string;
capacity: number;
floor: string;
status: string;
}
export default function Dashboard() {
const router = useRouter();
const [user, setUser] = useState<any>(null);
const [rooms, setRooms] = useState<Room[]>([]);
const [loading, setLoading] = useState(true);
// --- STATE UNTUK MODAL BOOKING ---
const [isModalOpen, setIsModalOpen] = useState(false);
const [selectedRoom, setSelectedRoom] = useState<Room | null>(null);
const [startTime, setStartTime] = useState("");
const [endTime, setEndTime] = useState("");
const [purpose, setPurpose] = useState("");
const [submitLoading, setSubmitLoading] = useState(false);
// ----------------------------------
useEffect(() => {
const token = localStorage.getItem("token");
const userData = localStorage.getItem("user");
if (!token || !userData) {
router.push("/login");
return;
}
setUser(JSON.parse(userData));
fetchRooms(token);
}, []);
const fetchRooms = async (token: string) => {
try {
const response = await axios.get("http://localhost:8080/api/rooms", {
headers: { Authorization: `Bearer ${token}` },
});
setRooms(response.data.data);
} catch (error) {
console.error("Error:", error);
router.push("/login");
} finally {
setLoading(false);
}
};
const handleLogout = () => {
localStorage.removeItem("token");
localStorage.removeItem("user");
router.push("/login");
};
// --- BUKA MODAL ---
const openBookingModal = (room: Room) => {
setSelectedRoom(room);
setIsModalOpen(true);
// Reset form
setStartTime("");
setEndTime("");
setPurpose("");
};
// --- SUBMIT BOOKING ---
const handleBookingSubmit = async (e: React.FormEvent) => {
e.preventDefault();
setSubmitLoading(true);
const token = localStorage.getItem("token");
try {
// Perlu convert string datetime-local ke Format ISO string (RFC3339) buat Golang
// Contoh input: "2026-02-06T14:30" -> Output: "2026-02-06T14:30:00.000Z"
const startISO = new Date(startTime).toISOString();
const endISO = new Date(endTime).toISOString();
await axios.post(
"http://localhost:8080/api/bookings",
{
room_id: selectedRoom?.room_id,
start_time: startISO,
end_time: endISO,
purpose: purpose,
},
{
headers: { Authorization: `Bearer ${token}` },
}
);
alert("Booking Berhasil Diajukan! Menunggu persetujuan.");
setIsModalOpen(false); // Tutup modal
} catch (error: any) {
// Tangkap error dari Backend (Misal: Bentrok / 409 Conflict)
const errorMsg = error.response?.data?.error || "Gagal melakukan booking.";
alert("GAGAL: " + errorMsg);
} finally {
setSubmitLoading(false);
}
};
if (loading) return <div className="p-10 text-center">Memuat data...</div>;
return (
<div className="min-h-screen bg-gray-50 relative">
{/* Navbar */}
<nav className="bg-white shadow-sm px-6 py-4 flex justify-between items-center sticky top-0 z-10">
<div>
<h1 className="text-xl font-bold text-blue-600">S-CLASS</h1>
<p className="text-xs text-gray-500">Welcome, {user?.full_name}</p>
</div>
<div className="flex gap-4">
{/* Tombol Cek History (Nanti kita buat halamannya) */}
<button
onClick={() => router.push('/history')}
className="text-sm text-gray-600 hover:text-blue-600 font-medium"
>
Riwayat Saya
</button>
<button
onClick={handleLogout}
className="flex items-center gap-2 text-sm text-red-500 hover:bg-red-50 px-3 py-2 rounded-lg transition"
>
<LogOut size={16} /> Keluar
</button>
</div>
</nav>
{/* Konten Utama */}
<main className="max-w-6xl mx-auto p-6">
<h2 className="text-2xl font-bold text-gray-800 mb-6">Pilih Ruangan</h2>
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
{rooms.map((room) => (
<div key={room.room_id} className="bg-white rounded-xl shadow-sm border border-gray-100 p-5 flex flex-col justify-between">
<div>
<div className="flex justify-between items-start mb-3">
<span className={`px-2 py-1 text-xs font-semibold rounded-full ${
room.status === 'Available' ? 'bg-green-100 text-green-700' : 'bg-red-100 text-red-700'
}`}>
{room.status}
</span>
<span className="text-gray-400 text-xs">{room.category}</span>
</div>
<h3 className="text-lg font-bold text-gray-800 mb-1">{room.name}</h3>
<div className="space-y-2 text-sm text-gray-600 mt-4">
<div className="flex items-center gap-2">
<MapPin size={16} className="text-blue-400" /> {room.floor}
</div>
<div className="flex items-center gap-2">
<Users size={16} className="text-blue-400" /> Kapasitas: {room.capacity}
</div>
</div>
</div>
<button
className="mt-5 w-full bg-blue-600 text-white py-2 rounded-lg hover:bg-blue-700 transition flex justify-center items-center gap-2"
onClick={() => openBookingModal(room)}
>
<Calendar size={16} />
Booking Ruangan
</button>
</div>
))}
</div>
</main>
{/* --- MODAL POPUP FORMULIR --- */}
{isModalOpen && selectedRoom && (
<div className="fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4">
<div className="bg-white rounded-2xl w-full max-w-md shadow-2xl overflow-hidden">
{/* Header Modal */}
<div className="bg-blue-600 p-4 flex justify-between items-center text-white">
<h3 className="font-bold text-lg">Form Peminjaman</h3>
<button onClick={() => setIsModalOpen(false)} className="hover:bg-blue-700 p-1 rounded">
<X size={20} />
</button>
</div>
{/* Body Form */}
<form onSubmit={handleBookingSubmit} className="p-6 space-y-4">
<div className="bg-blue-50 p-3 rounded-lg border border-blue-100 mb-2">
<p className="text-sm text-blue-800 font-semibold">Ruangan: {selectedRoom.name}</p>
<p className="text-xs text-blue-600">{selectedRoom.floor}</p>
</div>
<div>
<label className="block text-sm font-medium text-gray-700 mb-1">Waktu Mulai</label>
<div className="relative">
<Clock className="absolute left-3 top-2.5 text-gray-400 h-4 w-4" />
<input
type="datetime-local"
required
className="pl-9 w-full border border-gray-300 rounded-lg p-2 text-sm focus:ring-blue-500 focus:border-blue-500"
value={startTime}
onChange={(e) => setStartTime(e.target.value)}
/>
</div>
</div>
<div>
<label className="block text-sm font-medium text-gray-700 mb-1">Waktu Selesai</label>
<div className="relative">
<Clock className="absolute left-3 top-2.5 text-gray-400 h-4 w-4" />
<input
type="datetime-local"
required
className="pl-9 w-full border border-gray-300 rounded-lg p-2 text-sm focus:ring-blue-500 focus:border-blue-500"
value={endTime}
onChange={(e) => setEndTime(e.target.value)}
/>
</div>
</div>
<div>
<label className="block text-sm font-medium text-gray-700 mb-1">Keperluan / Kegiatan</label>
<div className="relative">
<FileText className="absolute left-3 top-3 text-gray-400 h-4 w-4" />
<textarea
required
rows={3}
placeholder="Contoh: Rapat Progres Skripsi"
className="pl-9 w-full border border-gray-300 rounded-lg p-2 text-sm focus:ring-blue-500 focus:border-blue-500"
value={purpose}
onChange={(e) => setPurpose(e.target.value)}
/>
</div>
</div>
<div className="pt-2 flex gap-3">
<button
type="button"
onClick={() => setIsModalOpen(false)}
className="flex-1 py-2 border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-50 text-sm font-medium"
>
Batal
</button>
<button
type="submit"
disabled={submitLoading}
className={`flex-1 py-2 rounded-lg text-white text-sm font-medium
${submitLoading ? 'bg-blue-400 cursor-not-allowed' : 'bg-blue-600 hover:bg-blue-700'}`}
>
{submitLoading ? 'Mengirim...' : 'Ajukan Booking'}
</button>
</div>
</form>
</div>
</div>
)}
</div>
);
}

View File

@ -0,0 +1,208 @@
"use client";
import { useState } from "react";
import { Search, Filter, Lightbulb, Projector, Wind } from "lucide-react";
// --- Tipe Data Mock ---
type Room = {
id: number;
name: string;
category: "Teori" | "Laboratorium";
capacity: number;
status: "Available" | "In Use" | "Maintenance";
devices: {
ac: boolean;
lamp: boolean;
projector: boolean;
};
floor: string;
};
// --- Data Dummy Ruangan (Mock Data) ---
const initialRooms: Room[] = [
{
id: 1,
name: "Ruang T-301",
category: "Teori",
capacity: 40,
status: "Available",
devices: { ac: false, lamp: false, projector: false },
floor: "Lantai 3",
},
{
id: 2,
name: "Ruang T-302",
category: "Teori",
capacity: 40,
status: "In Use",
devices: { ac: true, lamp: true, projector: true }, // Sedang dipakai
floor: "Lantai 3",
},
{
id: 3,
name: "Lab. Sistem Kendali",
category: "Laboratorium",
capacity: 20,
status: "Available",
devices: { ac: false, lamp: true, projector: false }, // Mungkin lampunya lupa dimatikan?
floor: "Lantai 2",
},
{
id: 4,
name: "Lab. IoT & Embedded",
category: "Laboratorium",
capacity: 25,
status: "In Use",
devices: { ac: true, lamp: true, projector: false },
floor: "Lantai 2",
},
{
id: 5,
name: "Ruang Sidang TA",
category: "Teori",
capacity: 15,
status: "Maintenance",
devices: { ac: false, lamp: false, projector: false },
floor: "Lantai 1",
},
];
export default function RoomsPage() {
const [rooms] = useState<Room[]>(initialRooms);
const [filterStatus, setFilterStatus] = useState<string>("All");
const [searchQuery, setSearchQuery] = useState("");
// --- Logika Filtering ---
const filteredRooms = rooms.filter((room) => {
// Filter berdasarkan Tab Status (All / Available / In Use)
const matchStatus =
filterStatus === "All" || room.status === filterStatus;
// Filter berdasarkan Search Box (Nama Ruangan)
const matchSearch = room.name
.toLowerCase()
.includes(searchQuery.toLowerCase());
return matchStatus && matchSearch;
});
return (
<div className="space-y-6">
{/* --- HEADER & CONTROLS --- */}
<div className="flex flex-col gap-4 md:flex-row md:items-center md:justify-between bg-white p-6 rounded-xl shadow-sm border border-gray-200">
<div>
<h2 className="text-2xl font-bold text-gray-800">Daftar Ruangan</h2>
<p className="text-sm text-gray-500">
Monitoring status ruangan dan perangkat IoT.
</p>
</div>
<div className="flex flex-col sm:flex-row gap-3">
{/* Search Box */}
<div className="relative">
<input
type="text"
placeholder="Cari ruangan..."
value={searchQuery}
onChange={(e) => setSearchQuery(e.target.value)}
className="pl-10 pr-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-yellow-400 w-full sm:w-64"
/>
<Search className="absolute left-3 top-2.5 text-gray-400" size={18} />
</div>
{/* Filter Dropdown (Sederhana) */}
<div className="flex items-center gap-2 bg-gray-50 px-3 rounded-lg border border-gray-200">
<Filter size={18} className="text-gray-500" />
<select
value={filterStatus}
onChange={(e) => setFilterStatus(e.target.value)}
className="bg-transparent py-2 outline-none text-sm font-medium text-gray-700 cursor-pointer"
>
<option value="All">Semua Status</option>
<option value="Available">Tersedia (Available)</option>
<option value="In Use">Sedang Dipakai (In Use)</option>
<option value="Maintenance">Perbaikan</option>
</select>
</div>
</div>
</div>
{/* --- ROOM GRID --- */}
<div className="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-6">
{filteredRooms.map((room) => (
<div
key={room.id}
className={`relative overflow-hidden rounded-xl border bg-white p-6 shadow-sm hover:shadow-md transition-shadow duration-300
${room.status === "In Use" ? "border-blue-200" :
room.status === "Available" ? "border-green-200" : "border-gray-200"}`}
>
{/* Status Badge di Pojok Kanan Atas */}
<span
className={`absolute top-4 right-4 px-3 py-1 rounded-full text-xs font-semibold
${
room.status === "Available"
? "bg-green-100 text-green-700"
: room.status === "In Use"
? "bg-blue-100 text-blue-700"
: "bg-gray-100 text-gray-600"
}`}
>
{room.status}
</span>
{/* Info Utama Ruangan */}
<div className="mb-4">
<h3 className="text-lg font-bold text-gray-800">{room.name}</h3>
<p className="text-xs text-gray-500 uppercase tracking-wider mt-1">
{room.category} {room.floor}
</p>
</div>
<div className="flex items-center gap-2 mb-6">
<span className="text-sm text-gray-600 bg-gray-100 px-2 py-1 rounded">
Kapasitas: {room.capacity} Org
</span>
</div>
{/* Status Perangkat IoT (Visualisasi) */}
<div className="pt-4 border-t border-gray-100">
<p className="text-xs text-gray-400 font-medium mb-3">STATUS PERANGKAT</p>
<div className="flex justify-between gap-2">
{/* AC Status */}
<div className={`flex flex-1 flex-col items-center p-2 rounded-lg text-xs font-medium transition-colors
${room.devices.ac ? "bg-blue-50 text-blue-600" : "bg-gray-50 text-gray-400"}`}>
<Wind size={20} className="mb-1" />
AC {room.devices.ac ? "ON" : "OFF"}
</div>
{/* Lampu Status */}
<div className={`flex flex-1 flex-col items-center p-2 rounded-lg text-xs font-medium transition-colors
${room.devices.lamp ? "bg-yellow-50 text-yellow-600" : "bg-gray-50 text-gray-400"}`}>
<Lightbulb size={20} className="mb-1" />
Light {room.devices.lamp ? "ON" : "OFF"}
</div>
{/* Proyektor Status */}
<div className={`flex flex-1 flex-col items-center p-2 rounded-lg text-xs font-medium transition-colors
${room.devices.projector ? "bg-purple-50 text-purple-600" : "bg-gray-50 text-gray-400"}`}>
<Projector size={20} className="mb-1" />
LCD {room.devices.projector ? "ON" : "OFF"}
</div>
</div>
</div>
</div>
))}
</div>
{/* Empty State jika filter tidak menemukan hasil */}
{filteredRooms.length === 0 && (
<div className="text-center py-20 bg-gray-50 rounded-xl border-dashed border-2 border-gray-200">
<p className="text-gray-500">Tidak ada ruangan yang cocok dengan filter Anda.</p>
</div>
)}
</div>
);
}

BIN
frontend/app/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

1
frontend/app/globals.css Normal file
View File

@ -0,0 +1 @@
@import "tailwindcss";

View File

@ -0,0 +1,137 @@
"use client";
import { useEffect, useState } from "react";
import axios from "axios";
import { useRouter } from "next/navigation";
import { ArrowLeft, Calendar, Clock, MapPin, AlertCircle, CheckCircle, XCircle } from "lucide-react";
interface Booking {
booking_id: string;
room: {
name: string;
floor: string;
};
start_time: string;
end_time: string;
purpose: string;
status: string;
created_at: string;
}
export default function HistoryPage() {
const router = useRouter();
const [bookings, setBookings] = useState<Booking[]>([]);
const [loading, setLoading] = useState(true);
useEffect(() => {
const token = localStorage.getItem("token");
if (!token) {
router.push("/login");
return;
}
fetchHistory(token);
}, []);
const fetchHistory = async (token: string) => {
try {
const response = await axios.get("http://localhost:8080/api/bookings", {
headers: { Authorization: `Bearer ${token}` },
});
setBookings(response.data.data || []);
} catch (error) {
console.error("Gagal ambil history:", error);
} finally {
setLoading(false);
}
};
// Fungsi untuk memformat tanggal agar enak dibaca (Contoh: 10 Feb 2026, 08:00)
const formatDate = (isoString: string) => {
const date = new Date(isoString);
return date.toLocaleDateString("id-ID", {
day: "numeric", month: "short", year: "numeric",
hour: "2-digit", minute: "2-digit"
});
};
// Fungsi menentukan warna status
const getStatusBadge = (status: string) => {
switch (status) {
case "Approved":
return <span className="flex items-center gap-1 bg-green-100 text-green-700 px-3 py-1 rounded-full text-xs font-bold"><CheckCircle size={14}/> Disetujui</span>;
case "Rejected":
return <span className="flex items-center gap-1 bg-red-100 text-red-700 px-3 py-1 rounded-full text-xs font-bold"><XCircle size={14}/> Ditolak</span>;
default: // Pending
return <span className="flex items-center gap-1 bg-yellow-100 text-yellow-700 px-3 py-1 rounded-full text-xs font-bold"><AlertCircle size={14}/> Menunggu</span>;
}
};
if (loading) return <div className="p-10 text-center">Memuat riwayat...</div>;
return (
<div className="min-h-screen bg-gray-50">
{/* Navbar Header */}
<nav className="bg-white shadow-sm px-6 py-4 sticky top-0 z-10">
<div className="max-w-4xl mx-auto flex items-center gap-4">
<button
onClick={() => router.push("/dashboard")}
className="p-2 hover:bg-gray-100 rounded-full transition"
>
<ArrowLeft className="text-gray-600" />
</button>
<h1 className="text-xl font-bold text-gray-800">Riwayat Peminjaman</h1>
</div>
</nav>
<main className="max-w-4xl mx-auto p-6">
{bookings.length === 0 ? (
<div className="text-center py-20 text-gray-500">
<Calendar size={48} className="mx-auto mb-4 text-gray-300" />
<p>Belum ada riwayat booking.</p>
<button onClick={() => router.push("/dashboard")} className="text-blue-600 mt-2 hover:underline">
Yuk booking sekarang!
</button>
</div>
) : (
<div className="space-y-4">
{bookings.map((item) => (
<div key={item.booking_id} className="bg-white p-5 rounded-xl shadow-sm border border-gray-100 hover:shadow-md transition">
<div className="flex justify-between items-start mb-4">
<div>
<h3 className="text-lg font-bold text-gray-800">{item.room.name}</h3>
<div className="flex items-center gap-1 text-xs text-gray-500 mt-1">
<MapPin size={12} /> {item.room.floor}
</div>
</div>
{getStatusBadge(item.status)}
</div>
<div className="grid grid-cols-1 md:grid-cols-2 gap-4 text-sm text-gray-600 bg-gray-50 p-3 rounded-lg">
<div>
<p className="text-xs text-gray-400 mb-1">Waktu Mulai</p>
<div className="flex items-center gap-2 font-medium">
<Calendar size={14} className="text-blue-500"/>
{formatDate(item.start_time)}
</div>
</div>
<div>
<p className="text-xs text-gray-400 mb-1">Waktu Selesai</p>
<div className="flex items-center gap-2 font-medium">
<Clock size={14} className="text-orange-500"/>
{formatDate(item.end_time)}
</div>
</div>
</div>
<div className="mt-4 pt-3 border-t border-gray-100">
<p className="text-xs text-gray-400">Keperluan:</p>
<p className="text-sm text-gray-800 font-medium">{item.purpose}</p>
</div>
</div>
))}
</div>
)}
</main>
</div>
);
}

23
frontend/app/layout.tsx Normal file
View File

@ -0,0 +1,23 @@
import type { Metadata } from "next";
import { Inter } from "next/font/google";
import "./globals.css";
const inter = Inter({ subsets: ["latin"] });
export const metadata: Metadata = {
title: "S-CLASS Dashboard",
description: "Smart Classroom Management System",
};
export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
/* TAMBAHKAN className="light" DI SINI */
<html lang="en" className="light" style={{ colorScheme: 'light' }}>
<body className={inter.className}>{children}</body>
</html>
);
}

124
frontend/app/login/page.tsx Normal file
View File

@ -0,0 +1,124 @@
"use client";
import { useState } from "react";
import axios from "axios";
import { useRouter } from "next/navigation";
import { Lock, User } from "lucide-react"; // Ikon cantik
export default function LoginPage() {
const router = useRouter();
// State untuk menyimpan input user
const [nrp, setNrp] = useState("");
const [password, setPassword] = useState("");
const [loading, setLoading] = useState(false);
const [error, setError] = useState("");
// Fungsi saat tombol Login ditekan
const handleLogin = async (e: React.FormEvent) => {
e.preventDefault();
setLoading(true);
setError("");
try {
// 1. Tembak API Backend
const response = await axios.post("http://localhost:8080/api/auth/login", {
nrp_nip: nrp,
password: password,
});
// 2. Jika sukses, simpan Token & Data User ke LocalStorage (Browser)
const { token, user } = response.data;
localStorage.setItem("token", token);
localStorage.setItem("user", JSON.stringify(user));
// 3. Pindah ke halaman Dashboard (Nanti kita buat)
//alert("Login Berhasil! Selamat datang " + user.full_name); // Alert boleh dimatikan kalau mau
if (user.role === "admin") {
router.push("/admin");
} else {
router.push("/dashboard");
}
} catch (err: any) {
// Jika gagal, tampilkan pesan error dari backend
setError(err.response?.data?.error || "Gagal terhubung ke server");
} finally {
setLoading(false);
}
};
return (
<div className="flex min-h-screen items-center justify-center bg-gray-100">
<div className="w-full max-w-md bg-white p-8 rounded-2xl shadow-lg">
{/* Header / Logo */}
<div className="text-center mb-8">
<h1 className="text-3xl font-bold text-blue-600 mb-2">S-CLASS</h1>
<p className="text-gray-500">Smart Classroom Booking System</p>
</div>
{/* Form Login */}
<form onSubmit={handleLogin} className="space-y-6">
{/* Pesan Error jika ada */}
{error && (
<div className="bg-red-100 text-red-600 p-3 rounded-lg text-sm text-center">
{error}
</div>
)}
{/* Input NRP */}
<div>
<label className="block text-sm font-medium text-gray-700 mb-1">NRP / NIP</label>
<div className="relative">
<div className="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
<User className="h-5 w-5 text-gray-400" />
</div>
<input
type="text"
required
className="block w-full pl-10 pr-3 py-2 border border-gray-300 rounded-lg focus:ring-blue-500 focus:border-blue-500"
placeholder="Masukkan NRP..."
value={nrp}
onChange={(e) => setNrp(e.target.value)}
/>
</div>
</div>
{/* Input Password */}
<div>
<label className="block text-sm font-medium text-gray-700 mb-1">Password</label>
<div className="relative">
<div className="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
<Lock className="h-5 w-5 text-gray-400" />
</div>
<input
type="password"
required
className="block w-full pl-10 pr-3 py-2 border border-gray-300 rounded-lg focus:ring-blue-500 focus:border-blue-500"
placeholder="••••••"
value={password}
onChange={(e) => setPassword(e.target.value)}
/>
</div>
</div>
{/* Tombol Login */}
<button
type="submit"
disabled={loading}
className={`w-full flex justify-center py-3 px-4 border border-transparent rounded-lg shadow-sm text-sm font-medium text-white
${loading ? "bg-blue-400 cursor-not-allowed" : "bg-blue-600 hover:bg-blue-700 focus:ring-2 focus:ring-offset-2 focus:ring-blue-500"}`}
>
{loading ? "Memproses..." : "Masuk Sekarang"}
</button>
</form>
{/* Footer Kecil */}
<div className="mt-6 text-center text-xs text-gray-400">
© 2026 Skripsi S-CLASS Project
</div>
</div>
</div>
);
}

6
frontend/app/page.tsx Normal file
View File

@ -0,0 +1,6 @@
import { redirect } from "next/navigation";
export default function Home() {
// Langsung lempar user ke halaman login
redirect("/login");
}

View File

@ -0,0 +1,39 @@
export default function Header() {
return (
<header className="sticky top-0 z-40 flex w-full bg-white drop-shadow-1 dark:bg-boxdark dark:drop-shadow-none">
<div className="flex grow items-center justify-between px-4 py-4 shadow-2 md:px-6 2xl:px-11">
{/* Search Bar (Hiasan) */}
<div className="hidden sm:block">
<form action="#" method="POST">
<div className="relative">
<input
type="text"
placeholder="Type to search..."
className="w-full bg-transparent pl-9 pr-4 font-medium focus:outline-none xl:w-125"
/>
</div>
</form>
</div>
{/* User Area */}
<div className="flex items-center gap-3 2xsm:gap-7">
<div className="flex items-center gap-4">
<span className="hidden text-right lg:block">
<span className="block text-sm font-medium text-black ">
Valentino Heman
</span>
<span className="block text-xs font-medium">Mahasiswa</span>
</span>
{/* Avatar Bulat */}
<div className="h-10 w-10 rounded-full bg-slate-300 overflow-hidden">
{/* Nanti bisa diisi Image */}
<div className="flex items-center justify-center h-full text-slate-600 font-bold">VH</div>
</div>
</div>
</div>
</div>
</header>
);
}

View File

@ -0,0 +1,104 @@
"use client";
import Link from "next/link";
import { usePathname } from "next/navigation";
import { LayoutDashboard, BookOpen, PlusCircle, Calendar, MonitorPlay } from "lucide-react"; // Icon
export default function Sidebar() {
const pathname = usePathname();
// Helper untuk mengecek apakah menu sedang aktif
const isActive = (path: string) => pathname === path;
return (
<aside className="hidden lg:flex flex-col w-72 h-screen overflow-y-hidden bg-slate-900 text-white duration-300 ease-linear dark:bg-slate-900 border-r border-slate-800">
{/* --- LOGO AREA --- */}
<div className="flex items-center justify-center gap-2 px-6 py-5.5 lg:py-6.5 border-b border-slate-800">
<div className="text-2xl font-bold text-yellow-500">S-CLASS</div>
<div className="text-xs text-gray-400 font-medium">Admin Panel</div>
</div>
{/* --- MENU LIST --- */}
<div className="no-scrollbar flex flex-col overflow-y-auto duration-300 ease-linear">
<nav className="mt-5 px-4 py-4 lg:mt-9 lg:px-6">
{/* GROUP: MENU UTAMA */}
<div>
<h3 className="mb-4 ml-4 text-sm font-semibold text-gray-400">MENU</h3>
<ul className="mb-6 flex flex-col gap-1.5">
{/* Dashboard */}
<li>
<Link
href="/dashboard"
className={`group relative flex items-center gap-2.5 rounded-sm px-4 py-2 font-medium duration-300 ease-in-out hover:bg-slate-700 ${
isActive("/dashboard") ? "bg-slate-700 text-white" : "text-gray-300"
}`}
>
<LayoutDashboard size={18} />
Dashboard
</Link>
</li>
{/* GROUP: ROOMS */}
<li className="mt-4 mb-2 ml-4 text-xs font-medium text-gray-500 uppercase">ROOMS</li>
<li>
<Link
href="/dashboard/rooms"
className={`group relative flex items-center gap-2.5 rounded-sm px-4 py-2 font-medium duration-300 ease-in-out hover:bg-slate-700 ${
isActive("/dashboard/rooms") ? "bg-slate-700 text-white" : "text-gray-300"
}`}
>
<MonitorPlay size={18} />
View Rooms
</Link>
</li>
{/* GROUP: BOOKING */}
<li className="mt-4 mb-2 ml-4 text-xs font-medium text-gray-500 uppercase">BOOKINGS</li>
<li>
<Link
href="/dashboard/bookings"
className={`group relative flex items-center gap-2.5 rounded-sm px-4 py-2 font-medium duration-300 ease-in-out hover:bg-slate-700 ${
isActive("/dashboard/bookings") ? "bg-slate-700 text-white" : "text-gray-300"
}`}
>
<BookOpen size={18} />
View Booking
</Link>
</li>
<li>
<Link
href="/dashboard/bookings/add"
className={`group relative flex items-center gap-2.5 rounded-sm px-4 py-2 font-medium duration-300 ease-in-out hover:bg-slate-700 ${
isActive("/dashboard/bookings/add") ? "bg-slate-700 text-white" : "text-gray-300"
}`}
>
<PlusCircle size={18} />
Add Booking
</Link>
</li>
<li>
<Link
href="/dashboard/bookings/calendar"
className={`group relative flex items-center gap-2.5 rounded-sm px-4 py-2 font-medium duration-300 ease-in-out hover:bg-slate-700 ${
isActive("/dashboard/bookings/calendar") ? "bg-slate-700 text-white" : "text-gray-300"
}`}
>
<Calendar size={18} />
Calendar View
</Link>
</li>
</ul>
</div>
</nav>
</div>
</aside>
);
}

View File

@ -0,0 +1,18 @@
import { defineConfig, globalIgnores } from "eslint/config";
import nextVitals from "eslint-config-next/core-web-vitals";
import nextTs from "eslint-config-next/typescript";
const eslintConfig = defineConfig([
...nextVitals,
...nextTs,
// Override default ignores of eslint-config-next.
globalIgnores([
// Default ignores of eslint-config-next:
".next/**",
"out/**",
"build/**",
"next-env.d.ts",
]),
]);
export default eslintConfig;

7
frontend/next.config.ts Normal file
View File

@ -0,0 +1,7 @@
import type { NextConfig } from "next";
const nextConfig: NextConfig = {
/* config options here */
};
export default nextConfig;

6636
frontend/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

28
frontend/package.json Normal file
View File

@ -0,0 +1,28 @@
{
"name": "frontend",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "eslint"
},
"dependencies": {
"axios": "^1.13.4",
"lucide-react": "^0.563.0",
"next": "16.1.6",
"react": "19.2.3",
"react-dom": "19.2.3"
},
"devDependencies": {
"@tailwindcss/postcss": "^4",
"@types/node": "^20",
"@types/react": "^19",
"@types/react-dom": "^19",
"eslint": "^9",
"eslint-config-next": "16.1.6",
"tailwindcss": "^4",
"typescript": "^5"
}
}

View File

@ -0,0 +1,7 @@
const config = {
plugins: {
"@tailwindcss/postcss": {},
},
};
export default config;

1
frontend/public/file.svg Normal file
View File

@ -0,0 +1 @@
<svg fill="none" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M14.5 13.5V5.41a1 1 0 0 0-.3-.7L9.8.29A1 1 0 0 0 9.08 0H1.5v13.5A2.5 2.5 0 0 0 4 16h8a2.5 2.5 0 0 0 2.5-2.5m-1.5 0v-7H8v-5H3v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1M9.5 5V2.12L12.38 5zM5.13 5h-.62v1.25h2.12V5zm-.62 3h7.12v1.25H4.5zm.62 3h-.62v1.25h7.12V11z" clip-rule="evenodd" fill="#666" fill-rule="evenodd"/></svg>

After

Width:  |  Height:  |  Size: 391 B

View File

@ -0,0 +1 @@
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><g clip-path="url(#a)"><path fill-rule="evenodd" clip-rule="evenodd" d="M10.27 14.1a6.5 6.5 0 0 0 3.67-3.45q-1.24.21-2.7.34-.31 1.83-.97 3.1M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16m.48-1.52a7 7 0 0 1-.96 0H7.5a4 4 0 0 1-.84-1.32q-.38-.89-.63-2.08a40 40 0 0 0 3.92 0q-.25 1.2-.63 2.08a4 4 0 0 1-.84 1.31zm2.94-4.76q1.66-.15 2.95-.43a7 7 0 0 0 0-2.58q-1.3-.27-2.95-.43a18 18 0 0 1 0 3.44m-1.27-3.54a17 17 0 0 1 0 3.64 39 39 0 0 1-4.3 0 17 17 0 0 1 0-3.64 39 39 0 0 1 4.3 0m1.1-1.17q1.45.13 2.69.34a6.5 6.5 0 0 0-3.67-3.44q.65 1.26.98 3.1M8.48 1.5l.01.02q.41.37.84 1.31.38.89.63 2.08a40 40 0 0 0-3.92 0q.25-1.2.63-2.08a4 4 0 0 1 .85-1.32 7 7 0 0 1 .96 0m-2.75.4a6.5 6.5 0 0 0-3.67 3.44 29 29 0 0 1 2.7-.34q.31-1.83.97-3.1M4.58 6.28q-1.66.16-2.95.43a7 7 0 0 0 0 2.58q1.3.27 2.95.43a18 18 0 0 1 0-3.44m.17 4.71q-1.45-.12-2.69-.34a6.5 6.5 0 0 0 3.67 3.44q-.65-1.27-.98-3.1" fill="#666"/></g><defs><clipPath id="a"><path fill="#fff" d="M0 0h16v16H0z"/></clipPath></defs></svg>

After

Width:  |  Height:  |  Size: 1.0 KiB

1
frontend/public/next.svg Normal file
View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 394 80"><path fill="#000" d="M262 0h68.5v12.7h-27.2v66.6h-13.6V12.7H262V0ZM149 0v12.7H94v20.4h44.3v12.6H94v21h55v12.6H80.5V0h68.7zm34.3 0h-17.8l63.8 79.4h17.9l-32-39.7 32-39.6h-17.9l-23 28.6-23-28.6zm18.3 56.7-9-11-27.1 33.7h17.8l18.3-22.7z"/><path fill="#000" d="M81 79.3 17 0H0v79.3h13.6V17l50.2 62.3H81Zm252.6-.4c-1 0-1.8-.4-2.5-1s-1.1-1.6-1.1-2.6.3-1.8 1-2.5 1.6-1 2.6-1 1.8.3 2.5 1a3.4 3.4 0 0 1 .6 4.3 3.7 3.7 0 0 1-3 1.8zm23.2-33.5h6v23.3c0 2.1-.4 4-1.3 5.5a9.1 9.1 0 0 1-3.8 3.5c-1.6.8-3.5 1.3-5.7 1.3-2 0-3.7-.4-5.3-1s-2.8-1.8-3.7-3.2c-.9-1.3-1.4-3-1.4-5h6c.1.8.3 1.6.7 2.2s1 1.2 1.6 1.5c.7.4 1.5.5 2.4.5 1 0 1.8-.2 2.4-.6a4 4 0 0 0 1.6-1.8c.3-.8.5-1.8.5-3V45.5zm30.9 9.1a4.4 4.4 0 0 0-2-3.3 7.5 7.5 0 0 0-4.3-1.1c-1.3 0-2.4.2-3.3.5-.9.4-1.6 1-2 1.6a3.5 3.5 0 0 0-.3 4c.3.5.7.9 1.3 1.2l1.8 1 2 .5 3.2.8c1.3.3 2.5.7 3.7 1.2a13 13 0 0 1 3.2 1.8 8.1 8.1 0 0 1 3 6.5c0 2-.5 3.7-1.5 5.1a10 10 0 0 1-4.4 3.5c-1.8.8-4.1 1.2-6.8 1.2-2.6 0-4.9-.4-6.8-1.2-2-.8-3.4-2-4.5-3.5a10 10 0 0 1-1.7-5.6h6a5 5 0 0 0 3.5 4.6c1 .4 2.2.6 3.4.6 1.3 0 2.5-.2 3.5-.6 1-.4 1.8-1 2.4-1.7a4 4 0 0 0 .8-2.4c0-.9-.2-1.6-.7-2.2a11 11 0 0 0-2.1-1.4l-3.2-1-3.8-1c-2.8-.7-5-1.7-6.6-3.2a7.2 7.2 0 0 1-2.4-5.7 8 8 0 0 1 1.7-5 10 10 0 0 1 4.3-3.5c2-.8 4-1.2 6.4-1.2 2.3 0 4.4.4 6.2 1.2 1.8.8 3.2 2 4.3 3.4 1 1.4 1.5 3 1.5 5h-5.8z"/></svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -0,0 +1 @@
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1155 1000"><path d="m577.3 0 577.4 1000H0z" fill="#fff"/></svg>

After

Width:  |  Height:  |  Size: 128 B

View File

@ -0,0 +1 @@
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path fill-rule="evenodd" clip-rule="evenodd" d="M1.5 2.5h13v10a1 1 0 0 1-1 1h-11a1 1 0 0 1-1-1zM0 1h16v11.5a2.5 2.5 0 0 1-2.5 2.5h-11A2.5 2.5 0 0 1 0 12.5zm3.75 4.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5M7 4.75a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0m1.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5" fill="#666"/></svg>

After

Width:  |  Height:  |  Size: 385 B

34
frontend/tsconfig.json Normal file
View File

@ -0,0 +1,34 @@
{
"compilerOptions": {
"target": "ES2017",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "react-jsx",
"incremental": true,
"plugins": [
{
"name": "next"
}
],
"paths": {
"@/*": ["./*"]
}
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts",
".next/dev/types/**/*.ts",
"**/*.mts"
],
"exclude": ["node_modules"]
}