jaecoo-kelapagading/app/(admin)/admin/promotion/page.tsx

61 lines
2.0 KiB
TypeScript
Raw Normal View History

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";
import PromotionTable from "@/components/table/promotion-table";
2026-01-18 17:01:09 +00:00
import { useRouter } from "next/navigation";
import withReactContent from "sweetalert2-react-content";
import Swal from "sweetalert2";
import Cookies from "js-cookie";
2025-11-18 06:56:39 +00:00
export default function PromotionPage() {
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);
// TODO: kirim data ke API di sini
};
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">Promo</h1>
<p>Kelola Promo 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/promotion/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 Promo Baru
</Button>
</Link>
)}
2025-11-18 06:56:39 +00:00
<PromotionTable />
</div>
</div>
</div>
</div>
);
}