skl/resources/js/components/Partials/Peraturan.tsx

113 lines
4.8 KiB
TypeScript

import React from "react";
import { Button } from "@/components/ui/button";
import { Card, CardContent } from "@/components/ui/card";
import { Badge } from "@/components/ui/badge";
import { ArrowRight, FileText } from "lucide-react";
import { Link } from "@inertiajs/react";
interface SubKategori {
SubKategoriId: number;
NamaSubKategori: string;
}
interface Kategori {
KategoriId: number;
NamaKategori: string;
}
interface Post {
PostId: number;
JudulPost: string;
DescPost: string;
SlugPost: string;
ImagePost: string;
IsPublish: boolean;
created_at: string;
kategori?: Kategori;
subkategori?: SubKategori;
}
interface CardPeraturanProps {
peraturan: Post[];
}
const RegulationSection = ({ peraturan }: CardPeraturanProps) => {
return (
<section className="relative w-full py-8 px-6">
{/* Background Green Box */}
<div className="absolute top-0 left-0 h-[600px] md:h-full w-full md:w-1/3 bg-green-800 rounded-br-[30px] md:rounded-tr-[30px] md:rounded-br-[30px] -z-10"></div>
<div className="md:container md:max-w-7xl mx-auto grid grid-cols-1 md:grid-cols-3 gap-6 items-start relative">
{/* Green Info Box */}
<div className=" text-white md:p-6 rounded-lg flex flex-col items-center md:items-start relative z-10 h-full justify-center">
<div className="bg-[#67bb6e] p-4 w-32 h-32 rounded-lg flex items-center justify-center mb-6">
<FileText className="w-24 h-24 text-white" />
</div>
<Badge className="bg-black text-white hover:bg-green-600 cursor-pointer">
Informasi
</Badge>
<h2 className="text-2xl font-bold">Peraturan</h2>
<p className="text-sm text-[#94bb98] mt-2 text-center md:text-left pr-3">
Aplikasi Sistem Ketaatan Lingkungan memastikan kepatuhan
terhadap perizinan, pengelolaan limbah, emisi, serta
pengawasan lingkungan.
</p>
<Link href="/peraturan">
<Button variant="link" className="text-white mt-4 pl-0">
Selengkapnya
</Button>
</Link>
</div>
{/* List of Regulations */}
<div className="col-span-2 grid grid-cols-1 md:grid-cols-2 gap-6 relative z-10">
{peraturan.map((item) => (
<Card key={item.PostId} className="md:p-4">
<img
src={`/storage/${item.ImagePost}`}
alt={item.JudulPost}
className="rounded-md"
/>
<CardContent className="p-4">
<Badge className="bg-red-600 text-white">
{item.kategori?.NamaKategori}
</Badge>
<p className="text-gray-500 text-sm mt-2">
{new Date(
item.created_at
).toLocaleDateString("id-ID", {
day: "numeric",
month: "long",
year: "numeric",
})}
</p>
<h3 className="text-md font-semibold mt-2 text-gray-900">
{item.JudulPost}
</h3>
<p className="text-sm text-gray-600 mt-2">
{item.DescPost.replace(
/<[^>]*>/g,
""
).slice(0, 160)}
...
</p>
<Link href={`/peraturan/${item.SlugPost}`}>
<Button
variant="link"
className="text-red-600 mt-2 pl-0"
>
Baca Selengkapnya{" "}
<ArrowRight className="ml-2 w-4 h-4" />
</Button>
</Link>
</CardContent>
</Card>
))}
</div>
</div>
</section>
);
};
export default RegulationSection;