From 5f00a0dbf10df3a07e3672e34e5137a0472108a4 Mon Sep 17 00:00:00 2001 From: rahmatrafli1 Date: Tue, 17 Mar 2026 22:05:20 +0700 Subject: [PATCH] feat: Add CRUD functionality for books, categories, and loans - Implemented Create, Edit, and Index pages for Buku (Books) with form handling and validation. - Added Create, Edit, and Index pages for Kategori (Categories) with form handling and validation. - Developed Create and Index pages for Peminjaman (Loans) with form handling and validation. - Integrated status management and action buttons for loan records. - Enhanced UI with responsive design and user-friendly navigation. --- resources/js/Layouts/MainLayout.jsx | 81 ++++++++++ resources/js/Pages/Anggota/Create.jsx | 158 +++++++++++++++++++ resources/js/Pages/Anggota/Edit.jsx | 154 +++++++++++++++++++ resources/js/Pages/Anggota/Index.jsx | 142 +++++++++++++++++ resources/js/Pages/Buku/Create.jsx | 188 +++++++++++++++++++++++ resources/js/Pages/Buku/Edit.jsx | 182 ++++++++++++++++++++++ resources/js/Pages/Buku/Index.jsx | 142 +++++++++++++++++ resources/js/Pages/Dashboard.jsx | 133 ++++++++++++++++ resources/js/Pages/Kategori/Create.jsx | 98 ++++++++++++ resources/js/Pages/Kategori/Edit.jsx | 96 ++++++++++++ resources/js/Pages/Kategori/Index.jsx | 122 +++++++++++++++ resources/js/Pages/Peminjaman/Create.jsx | 156 +++++++++++++++++++ resources/js/Pages/Peminjaman/Index.jsx | 161 +++++++++++++++++++ 13 files changed, 1813 insertions(+) create mode 100644 resources/js/Layouts/MainLayout.jsx create mode 100644 resources/js/Pages/Anggota/Create.jsx create mode 100644 resources/js/Pages/Anggota/Edit.jsx create mode 100644 resources/js/Pages/Anggota/Index.jsx create mode 100644 resources/js/Pages/Buku/Create.jsx create mode 100644 resources/js/Pages/Buku/Edit.jsx create mode 100644 resources/js/Pages/Buku/Index.jsx create mode 100644 resources/js/Pages/Dashboard.jsx create mode 100644 resources/js/Pages/Kategori/Create.jsx create mode 100644 resources/js/Pages/Kategori/Edit.jsx create mode 100644 resources/js/Pages/Kategori/Index.jsx create mode 100644 resources/js/Pages/Peminjaman/Create.jsx create mode 100644 resources/js/Pages/Peminjaman/Index.jsx diff --git a/resources/js/Layouts/MainLayout.jsx b/resources/js/Layouts/MainLayout.jsx new file mode 100644 index 0000000..88db98d --- /dev/null +++ b/resources/js/Layouts/MainLayout.jsx @@ -0,0 +1,81 @@ +import { Link, usePage } from '@inertiajs/react'; +import { useState } from 'react'; + +export default function MainLayout({ children }) { + const [sidebarOpen, setSidebarOpen] = useState(true); + const { url } = usePage(); + + const menus = [ + { name: 'Dashboard', href: '/', icon: '🏠' }, + { name: 'Buku', href: '/buku', icon: '📚' }, + { name: 'Kategori', href: '/kategori', icon: '🏷️' }, + { name: 'Anggota', href: '/anggota', icon: '👥' }, + { name: 'Peminjaman', href: '/peminjaman', icon: '📋' }, + ]; + + return ( +
+ {/* Sidebar */} + + + {/* Main Content */} +
+ {/* Header */} +
+

Sistem Perpustakaanku

+ 📅 {new Date().toLocaleDateString('id-ID', { + weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' + })} +
+ + {/* Flash Message */} + + + {/* Content */} +
+ {children} +
+
+
+ ); +} + +function FlashMessage() { + const { flash } = usePage().props; + if (!flash?.success) return null; + + return ( +
+ + {flash.success} +
+ ); +} \ No newline at end of file diff --git a/resources/js/Pages/Anggota/Create.jsx b/resources/js/Pages/Anggota/Create.jsx new file mode 100644 index 0000000..315dcc1 --- /dev/null +++ b/resources/js/Pages/Anggota/Create.jsx @@ -0,0 +1,158 @@ +import MainLayout from "@/Layouts/MainLayout"; +import { Head, useForm, Link } from "@inertiajs/react"; + +export default function AnggotaCreate() { + const { data, setData, post, processing, errors } = useForm({ + nama: "", + email: "", + no_telepon: "", + alamat: "", + tanggal_bergabung: "", + status: "aktif", + }); + + const handleSubmit = (e) => { + e.preventDefault(); + post("/anggota"); + }; + + return ( + + + +
+
+ + ← Kembali + + / + Tambah Anggota +
+ +
+

+ 👥 Tambah Anggota Baru +

+ +
+ + + setData("nama", e.target.value) + } + className="w-full border rounded-lg px-3 py-2 focus:ring-2 focus:ring-indigo-400 focus:outline-none" + placeholder="Masukkan nama lengkap" + /> + + + + + setData("email", e.target.value) + } + className="w-full border rounded-lg px-3 py-2 focus:ring-2 focus:ring-indigo-400 focus:outline-none" + placeholder="contoh@email.com" + /> + + +
+ + + setData("no_telepon", e.target.value) + } + className="w-full border rounded-lg px-3 py-2 focus:ring-2 focus:ring-indigo-400 focus:outline-none" + placeholder="08xxxxxxxxxx" + /> + + + + + setData( + "tanggal_bergabung", + e.target.value, + ) + } + className="w-full border rounded-lg px-3 py-2 focus:ring-2 focus:ring-indigo-400 focus:outline-none" + /> + +
+ + +