2025-11-18 06:56:39 +00:00
|
|
|
"use client";
|
|
|
|
|
|
2026-01-18 17:01:09 +00:00
|
|
|
import { useEffect, useState } from "react";
|
2025-11-18 06:56:39 +00:00
|
|
|
import ArticleTable from "@/components/table/article-table";
|
|
|
|
|
import { Button } from "@/components/ui/button";
|
|
|
|
|
import { Plus } from "lucide-react";
|
|
|
|
|
import { BannerDialog } from "@/components/form/banner-dialog";
|
|
|
|
|
import Link from "next/link";
|
|
|
|
|
import ProductTable from "@/components/table/product-table";
|
|
|
|
|
import AgentTable from "@/components/table/agent-table";
|
2026-01-18 17:01:09 +00:00
|
|
|
import withReactContent from "sweetalert2-react-content";
|
|
|
|
|
import Swal from "sweetalert2";
|
|
|
|
|
import Cookies from "js-cookie";
|
|
|
|
|
import { useRouter } from "next/navigation";
|
2025-11-18 06:56:39 +00:00
|
|
|
|
|
|
|
|
export default function AgentPage() {
|
|
|
|
|
const [openDialog, setOpenDialog] = useState(false);
|
|
|
|
|
|
2026-01-18 17:01:09 +00:00
|
|
|
const [userLevelId, setUserLevelId] = useState<string | null>(null);
|
|
|
|
|
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
const MySwal = withReactContent(Swal);
|
|
|
|
|
|
|
|
|
|
// 🔹 Ambil userlevelId dari cookies
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
const ulne = Cookies.get("ulne"); // contoh: "3"
|
|
|
|
|
setUserLevelId(ulne ?? null);
|
|
|
|
|
}, []);
|
|
|
|
|
|
2025-11-18 06:56:39 +00:00
|
|
|
const handleSubmitBanner = (data: any) => {
|
|
|
|
|
console.log("Banner Data:", data);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div>
|
|
|
|
|
<div className="overflow-x-hidden overflow-y-scroll w-full">
|
|
|
|
|
<div className="px-2 md:px-4 md:py-4 w-full">
|
|
|
|
|
<div className="pl-3">
|
|
|
|
|
<h1 className="text-[#1F6779] text-2xl font-semibold">Agent</h1>
|
|
|
|
|
<p>Kelola Agent JAECOO</p>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="dark:bg-[#18181b] rounded-xl p-3">
|
2026-01-18 17:01:09 +00:00
|
|
|
{userLevelId !== "3" && (
|
|
|
|
|
<Link href={"/admin/agent/create"}>
|
|
|
|
|
<Button className="bg-[#1F6779] text-white w-full lg:w-fit hover:bg-[#1a9bb5] flex items-center gap-2">
|
|
|
|
|
<Plus className="h-4 w-4" />
|
|
|
|
|
Tambah Agent
|
|
|
|
|
</Button>
|
|
|
|
|
</Link>
|
|
|
|
|
)}
|
2025-11-18 06:56:39 +00:00
|
|
|
<AgentTable />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|