update
This commit is contained in:
parent
94c045c12e
commit
fc3d410084
|
|
@ -0,0 +1,12 @@
|
||||||
|
import DetailAgentForm from "@/components/form/agent/detail-agent-form";
|
||||||
|
import DetailProductForm from "@/components/form/product/detail-product-form";
|
||||||
|
|
||||||
|
export default function DetailAgentPage() {
|
||||||
|
return (
|
||||||
|
<div className="">
|
||||||
|
<div className="h-[96vh] p-3 lg:p-8 bg-slate-100 dark:!bg-black overflow-y-auto">
|
||||||
|
<DetailAgentForm isDetail={true} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
import DetailProductForm from "@/components/form/product/detail-product-form";
|
||||||
|
|
||||||
|
export default function DetailProductPage() {
|
||||||
|
return (
|
||||||
|
<div className="">
|
||||||
|
<div className="h-[96vh] p-3 lg:p-8 bg-slate-100 dark:!bg-black overflow-y-auto">
|
||||||
|
<DetailProductForm isDetail={true} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -14,6 +14,7 @@ import { getGaleryFileData } from "@/service/galery";
|
||||||
|
|
||||||
export function DialogDetailGaleri({ open, onClose, data }: any) {
|
export function DialogDetailGaleri({ open, onClose, data }: any) {
|
||||||
const [images, setImages] = useState<any[]>([]);
|
const [images, setImages] = useState<any[]>([]);
|
||||||
|
const [openApproverHistory, setOpenApproverHistory] = useState(false);
|
||||||
|
|
||||||
const fetchImages = async () => {
|
const fetchImages = async () => {
|
||||||
try {
|
try {
|
||||||
|
|
@ -21,7 +22,7 @@ export function DialogDetailGaleri({ open, onClose, data }: any) {
|
||||||
const allImages = res?.data?.data ?? [];
|
const allImages = res?.data?.data ?? [];
|
||||||
|
|
||||||
const filteredImages = allImages.filter(
|
const filteredImages = allImages.filter(
|
||||||
(img: any) => img.gallery_id === data.id
|
(img: any) => img.gallery_id === data.id,
|
||||||
);
|
);
|
||||||
|
|
||||||
setImages(filteredImages);
|
setImages(filteredImages);
|
||||||
|
|
@ -39,108 +40,232 @@ export function DialogDetailGaleri({ open, onClose, data }: any) {
|
||||||
const openFile = (url: string) => {
|
const openFile = (url: string) => {
|
||||||
window.open(url, "_blank");
|
window.open(url, "_blank");
|
||||||
};
|
};
|
||||||
|
const handleOpenApproverHistory = () => {
|
||||||
|
setOpenApproverHistory(true);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={open} onOpenChange={onClose}>
|
<>
|
||||||
<DialogContent className="max-w-3xl rounded-2xl p-0 overflow-hidden">
|
<Dialog open={open} onOpenChange={onClose}>
|
||||||
{/* Header */}
|
<DialogContent className="max-w-3xl rounded-2xl p-0 overflow-hidden">
|
||||||
<div className="bg-[#1F6779] text-white px-6 py-4">
|
{/* Header */}
|
||||||
<DialogTitle className="text-white">Detail Galeri</DialogTitle>
|
<div className="bg-[#1F6779] text-white px-6 py-4">
|
||||||
</div>
|
<DialogTitle className="text-white">Detail Galeri</DialogTitle>
|
||||||
|
|
||||||
<div className="px-6 py-6 space-y-6">
|
|
||||||
{/* Images List */}
|
|
||||||
<div>
|
|
||||||
<p className="font-medium mb-2">Daftar Gambar</p>
|
|
||||||
|
|
||||||
<div className="grid grid-cols-3 gap-4">
|
|
||||||
{images.length === 0 && (
|
|
||||||
<p className="text-gray-500 col-span-3 text-center">
|
|
||||||
Tidak ada gambar.
|
|
||||||
</p>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{images.map((img) => (
|
|
||||||
<div
|
|
||||||
key={img.id}
|
|
||||||
className="relative h-32 w-full cursor-pointer group"
|
|
||||||
onClick={() => openFile(img.image_url)}
|
|
||||||
>
|
|
||||||
<Image
|
|
||||||
src={img.image_url}
|
|
||||||
alt={img.title}
|
|
||||||
fill
|
|
||||||
className="object-cover rounded-lg"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div className="absolute inset-0 bg-black/40 opacity-0 group-hover:opacity-100 text-white flex items-center justify-center text-sm transition">
|
|
||||||
Lihat File
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Title */}
|
<div className="px-6 py-3">
|
||||||
<h2 className="text-2xl font-semibold text-[#1F6779]">
|
{/* Images List */}
|
||||||
{data.title}
|
<div>
|
||||||
</h2>
|
<h2 className="text-2xl font-semibold text-black">
|
||||||
|
{data.title}
|
||||||
{/* Deskripsi */}
|
</h2>
|
||||||
<div>
|
<div className="my-3">
|
||||||
<p className="font-medium text-sm text-gray-700">Deskripsi</p>
|
<p className="font-medium text-sm text-black">Deskripsi</p>
|
||||||
<p className="text-gray-600">{data.description}</p>
|
<p className="text-gray-800">{data.description}</p>
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Tanggal Upload */}
|
|
||||||
<div>
|
|
||||||
<p className="font-medium text-sm text-gray-700">Tanggal Upload</p>
|
|
||||||
<p className="text-gray-600">
|
|
||||||
{new Date(data.created_at).toLocaleDateString("id-ID")}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Timeline */}
|
|
||||||
<div>
|
|
||||||
<p className="font-medium text-sm text-gray-700 mb-2">
|
|
||||||
Status Timeline
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<div className="flex flex-col gap-3">
|
|
||||||
<div className="flex items-start gap-3">
|
|
||||||
<CheckCircle className="text-green-600" />
|
|
||||||
<div>
|
|
||||||
<p className="font-semibold">Upload Berhasil</p>
|
|
||||||
<p className="text-gray-500 text-sm">
|
|
||||||
{new Date(data.created_at).toLocaleString("id-ID")}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div className="grid grid-cols-3 gap-4">
|
||||||
|
{images.length === 0 && (
|
||||||
|
<p className="text-gray-500 col-span-3 text-center">
|
||||||
|
Tidak ada gambar.
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
|
||||||
{data.approved_at && (
|
{images.map((img) => (
|
||||||
|
<div
|
||||||
|
key={img.id}
|
||||||
|
className="relative h-32 w-full cursor-pointer group"
|
||||||
|
onClick={() => openFile(img.image_url)}
|
||||||
|
>
|
||||||
|
<Image
|
||||||
|
src={img.image_url}
|
||||||
|
alt={img.title}
|
||||||
|
fill
|
||||||
|
className="object-cover rounded-lg"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div className="absolute inset-0 bg-black/40 opacity-0 group-hover:opacity-100 text-white flex items-center justify-center text-sm transition">
|
||||||
|
Lihat File
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Title */}
|
||||||
|
|
||||||
|
{/* Deskripsi */}
|
||||||
|
|
||||||
|
{/* Tanggal Upload */}
|
||||||
|
<div>
|
||||||
|
<p className="font-medium text-sm text-gray-700">
|
||||||
|
Tanggal Upload
|
||||||
|
</p>
|
||||||
|
<p className="text-gray-600">
|
||||||
|
{new Date(data.created_at).toLocaleDateString("id-ID")}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Timeline */}
|
||||||
|
<div>
|
||||||
|
<p className="font-medium text-sm text-gray-700 mb-2">
|
||||||
|
Status Timeline
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div className="flex flex-col gap-3">
|
||||||
<div className="flex items-start gap-3">
|
<div className="flex items-start gap-3">
|
||||||
<CheckCircle className="text-green-600" />
|
<CheckCircle className="text-green-600" />
|
||||||
<div>
|
<div>
|
||||||
<p className="font-semibold">Disetujui oleh Approver</p>
|
<p className="font-semibold">Diupload Oleh :</p>
|
||||||
<p className="text-gray-500 text-sm">
|
<p className="text-gray-500 text-sm">
|
||||||
{new Date(data.approved_at).toLocaleString("id-ID")}
|
{new Date(data.created_at).toLocaleString("id-ID")}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
<div className="flex items-start gap-3">
|
||||||
|
<CheckCircle className="text-green-600" />
|
||||||
|
<div>
|
||||||
|
<p className="font-semibold">Disetujui Oleh :</p>
|
||||||
|
<p className="text-gray-500 text-sm">
|
||||||
|
{new Date(data.created_at).toLocaleString("id-ID")}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{data.approved_at && (
|
||||||
|
<div className="flex items-start gap-3">
|
||||||
|
<CheckCircle className="text-green-600" />
|
||||||
|
<div>
|
||||||
|
<p className="font-semibold">Disetujui oleh Approver</p>
|
||||||
|
<p className="text-gray-500 text-sm">
|
||||||
|
{new Date(data.approved_at).toLocaleString("id-ID")}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="border rounded-lg px-3 py-3">
|
||||||
|
<p>Comment : </p>
|
||||||
|
<div className="flex flex-row justify-between">
|
||||||
|
<button
|
||||||
|
onClick={handleOpenApproverHistory}
|
||||||
|
className="text-sm text-blue-600 hover:underline mt-2"
|
||||||
|
>
|
||||||
|
View Approver History
|
||||||
|
</button>
|
||||||
|
<p>Jaecoo - Approver | 10/11/2026</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* <DialogFooter className="px-6 pb-6">
|
||||||
|
<button
|
||||||
|
onClick={onClose}
|
||||||
|
className="bg-gray-300 text-gray-700 px-6 py-2 rounded-lg"
|
||||||
|
>
|
||||||
|
Tutup
|
||||||
|
</button>
|
||||||
|
</DialogFooter> */}
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
{openApproverHistory && (
|
||||||
|
<div
|
||||||
|
className="fixed inset-0 z-[60] flex items-center justify-center bg-black/50 p-4"
|
||||||
|
onClick={() => setOpenApproverHistory(false)}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className="bg-white rounded-2xl shadow-2xl max-w-3xl w-full overflow-hidden"
|
||||||
|
onClick={(e) => e.stopPropagation()}
|
||||||
|
>
|
||||||
|
{/* HEADER */}
|
||||||
|
<div className="bg-gradient-to-br from-[#1F6779] to-[#0F6C75] text-white px-6 py-5 relative">
|
||||||
|
<button
|
||||||
|
onClick={() => setOpenApproverHistory(false)}
|
||||||
|
className="absolute top-4 right-4 text-white/80 hover:text-white text-xl"
|
||||||
|
>
|
||||||
|
✕
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<h2 className="text-lg font-semibold">Approver History</h2>
|
||||||
|
|
||||||
|
<div className="flex items-center gap-2 mt-3">
|
||||||
|
<span className="bg-yellow-100 text-yellow-800 text-xs font-medium px-3 py-1 rounded-full">
|
||||||
|
Menunggu
|
||||||
|
</span>
|
||||||
|
<span className="bg-white text-[#0F6C75] text-xs font-medium px-3 py-1 rounded-full">
|
||||||
|
Banner
|
||||||
|
</span>
|
||||||
|
<span className="bg-white/20 text-white text-xs px-2 py-[2px] rounded-full">
|
||||||
|
1
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* BODY */}
|
||||||
|
<div className="p-6 grid grid-cols-[1fr_auto_1fr] gap-6 items-start">
|
||||||
|
{/* LEFT TIMELINE */}
|
||||||
|
<div className="relative space-y-6">
|
||||||
|
{/* Upload */}
|
||||||
|
<div className="flex flex-col items-center">
|
||||||
|
<span className="bg-[#C7DDE4] text-[#0F6C75] text-xs px-4 py-1 rounded-full">
|
||||||
|
Upload
|
||||||
|
</span>
|
||||||
|
<div className="w-px h-6 bg-gray-300" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Diterima */}
|
||||||
|
<div className="relative bg-[#1F6779] text-white rounded-xl p-4">
|
||||||
|
<h4 className="font-semibold text-sm mb-2">Diterima</h4>
|
||||||
|
<span className="inline-block bg-[#E3EFF4] text-[#0F6C75] text-xs px-3 py-1 rounded-full">
|
||||||
|
Direview oleh: approver-jaecoo1
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="w-px h-6 bg-gray-300 mx-auto" />
|
||||||
|
|
||||||
|
{/* Pending */}
|
||||||
|
<div className="relative bg-[#B36A00] text-white rounded-xl p-4">
|
||||||
|
<h4 className="font-semibold text-sm mb-2">Pending</h4>
|
||||||
|
<span className="inline-block bg-[#FFF6CC] text-[#7A4A00] text-xs px-3 py-1 rounded-full">
|
||||||
|
Direview oleh: approver-jaecoo1
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* ARROW */}
|
||||||
|
<div className="flex flex-col gap-20 text-gray-500 font-bold">
|
||||||
|
<span>></span>
|
||||||
|
<span>></span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* RIGHT NOTES */}
|
||||||
|
<div className="space-y-14">
|
||||||
|
<div>
|
||||||
|
<div className="bg-[#C7DDE4] text-sm px-4 py-2 rounded-lg">
|
||||||
|
Catatan:
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<div className="bg-[#FFF9C4] text-sm px-4 py-2 rounded-lg">
|
||||||
|
Catatan:
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* FOOTER */}
|
||||||
|
<div className="border-t bg-[#F2F7FA] text-center py-3">
|
||||||
|
<button
|
||||||
|
onClick={() => setOpenApproverHistory(false)}
|
||||||
|
className="text-[#0F6C75] font-medium hover:underline"
|
||||||
|
>
|
||||||
|
Tutup
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
<DialogFooter className="px-6 pb-6">
|
</>
|
||||||
<button
|
|
||||||
onClick={onClose}
|
|
||||||
className="bg-gray-300 text-gray-700 px-6 py-2 rounded-lg"
|
|
||||||
>
|
|
||||||
Tutup
|
|
||||||
</button>
|
|
||||||
</DialogFooter>
|
|
||||||
</DialogContent>
|
|
||||||
</Dialog>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ export default function PromoDetailDialog({
|
||||||
}: PromoDetailDialogProps) {
|
}: PromoDetailDialogProps) {
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [promo, setPromo] = useState<any>(null);
|
const [promo, setPromo] = useState<any>(null);
|
||||||
|
const [openApproverHistory, setOpenApproverHistory] = useState(false);
|
||||||
|
|
||||||
// FORMAT TANGGAL → DD-MM-YYYY
|
// FORMAT TANGGAL → DD-MM-YYYY
|
||||||
const formatDate = (dateStr: string) => {
|
const formatDate = (dateStr: string) => {
|
||||||
|
|
@ -33,7 +34,9 @@ export default function PromoDetailDialog({
|
||||||
return `${day}-${month}-${year}`;
|
return `${day}-${month}-${year}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
// FETCH API PROMO BY ID
|
const handleOpenApproverHistory = () => {
|
||||||
|
setOpenApproverHistory(true);
|
||||||
|
};
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!promoId || !open) return;
|
if (!promoId || !open) return;
|
||||||
|
|
||||||
|
|
@ -54,7 +57,7 @@ export default function PromoDetailDialog({
|
||||||
date: formatDate(res?.data?.data?.created_at),
|
date: formatDate(res?.data?.data?.created_at),
|
||||||
time: new Date(res?.data?.data?.created_at).toLocaleTimeString(
|
time: new Date(res?.data?.data?.created_at).toLocaleTimeString(
|
||||||
"id-ID",
|
"id-ID",
|
||||||
{ hour: "2-digit", minute: "2-digit" }
|
{ hour: "2-digit", minute: "2-digit" },
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -62,7 +65,7 @@ export default function PromoDetailDialog({
|
||||||
date: formatDate(res?.data?.data?.updated_at),
|
date: formatDate(res?.data?.data?.updated_at),
|
||||||
time: new Date(res?.data?.data?.updated_at).toLocaleTimeString(
|
time: new Date(res?.data?.data?.updated_at).toLocaleTimeString(
|
||||||
"id-ID",
|
"id-ID",
|
||||||
{ hour: "2-digit", minute: "2-digit" }
|
{ hour: "2-digit", minute: "2-digit" },
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
@ -82,92 +85,301 @@ export default function PromoDetailDialog({
|
||||||
if (!open) return null;
|
if (!open) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
<>
|
||||||
<DialogContent className="p-0 max-w-xl overflow-hidden rounded-2xl">
|
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||||
{/* HEADER */}
|
<DialogContent className="p-0 max-w-xl overflow-hidden rounded-2xl">
|
||||||
<div className="bg-gradient-to-r from-[#0f6c75] to-[#145f66] text-white px-6 py-5 relative">
|
{/* HEADER */}
|
||||||
<DialogHeader>
|
<div className="bg-gradient-to-r from-[#0f6c75] to-[#145f66] text-white px-6 py-5 relative">
|
||||||
<DialogTitle className="text-white text-xl font-semibold">
|
<DialogHeader>
|
||||||
Detail Promo
|
<DialogTitle className="text-white text-xl font-semibold">
|
||||||
</DialogTitle>
|
Detail Promo
|
||||||
</DialogHeader>
|
</DialogTitle>
|
||||||
|
</DialogHeader>
|
||||||
|
|
||||||
{/* STATUS BADGE */}
|
{/* STATUS BADGE */}
|
||||||
{promo && (
|
{promo && (
|
||||||
<div className="mt-2 bg-white/20 text-white px-4 py-[3px] rounded-full text-xs inline-flex items-center gap-2">
|
<div className="mt-2 bg-white/20 text-white px-4 py-[3px] rounded-full text-xs inline-flex items-center gap-2">
|
||||||
<span className="w-2 h-2 rounded-full bg-lime-300"></span>
|
<span className="w-2 h-2 rounded-full bg-lime-300"></span>
|
||||||
{promo.status}
|
{promo.status}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* BODY */}
|
||||||
|
<div className="p-6">
|
||||||
|
{loading ? (
|
||||||
|
<p className="text-Start text-gray-600">Memuat data...</p>
|
||||||
|
) : promo ? (
|
||||||
|
<>
|
||||||
|
{/* <div className="flex justify-center mb-4">
|
||||||
|
<div className="bg-[#E8F1F6] p-4 rounded-xl">
|
||||||
|
<FileText size={60} className="text-[#0f6c75]" />
|
||||||
|
</div>
|
||||||
|
</div> */}
|
||||||
|
|
||||||
|
<h2 className="text-xl font-semibold text-Start mb-6">
|
||||||
|
{promo.title}
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
<div className="space-y-4 text-sm">
|
||||||
|
<div>
|
||||||
|
<p className="text-gray-600">Ukuran File</p>
|
||||||
|
<p className="font-medium">{promo.fileSize}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<p className="text-gray-600">Tanggal Upload</p>
|
||||||
|
<p className="font-medium">{promo.uploadDate}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* TIMELINE */}
|
||||||
|
<div className="mt-4">
|
||||||
|
<p className="text-gray-600 mb-3 font-medium">
|
||||||
|
Status Timeline
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div className="space-y-4">
|
||||||
|
{promo.timeline.map((item: any, idx: number) => (
|
||||||
|
<div key={idx} className="flex gap-3 items-start">
|
||||||
|
<CheckCircle2
|
||||||
|
size={20}
|
||||||
|
className="text-green-600 shrink-0"
|
||||||
|
/>
|
||||||
|
<div>
|
||||||
|
<p className="font-medium">{item.label}</p>
|
||||||
|
<p className="text-gray-600 text-sm">
|
||||||
|
{item.date} • {item.time} WIB
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
<div className="border rounded-lg px-3 py-3 mt-3">
|
||||||
|
<p>Comment : </p>
|
||||||
|
<div className="flex flex-row justify-between">
|
||||||
|
<button
|
||||||
|
onClick={handleOpenApproverHistory}
|
||||||
|
className="text-sm text-blue-600 hover:underline mt-2"
|
||||||
|
>
|
||||||
|
View Approver History
|
||||||
|
</button>
|
||||||
|
<p>Jaecoo - Approver | 10/11/2026</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<p className="text-center text-gray-600">Data tidak ditemukan</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
{openApproverHistory && (
|
||||||
|
<div
|
||||||
|
className="fixed inset-0 z-[60] flex items-center justify-center bg-black/50 p-4"
|
||||||
|
onClick={() => setOpenApproverHistory(false)}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className="bg-white rounded-2xl shadow-2xl max-w-3xl w-full overflow-hidden"
|
||||||
|
onClick={(e) => e.stopPropagation()}
|
||||||
|
>
|
||||||
|
{/* HEADER */}
|
||||||
|
<div className="bg-gradient-to-br from-[#1F6779] to-[#0F6C75] text-white px-6 py-5 relative">
|
||||||
|
<button
|
||||||
|
onClick={() => setOpenApproverHistory(false)}
|
||||||
|
className="absolute top-4 right-4 text-white/80 hover:text-white text-xl"
|
||||||
|
>
|
||||||
|
✕
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<h2 className="text-lg font-semibold">Approver History</h2>
|
||||||
|
|
||||||
|
<div className="flex items-center gap-2 mt-3">
|
||||||
|
<span className="bg-yellow-100 text-yellow-800 text-xs font-medium px-3 py-1 rounded-full">
|
||||||
|
Menunggu
|
||||||
|
</span>
|
||||||
|
<span className="bg-white text-[#0F6C75] text-xs font-medium px-3 py-1 rounded-full">
|
||||||
|
Banner
|
||||||
|
</span>
|
||||||
|
<span className="bg-white/20 text-white text-xs px-2 py-[2px] rounded-full">
|
||||||
|
1
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* BODY */}
|
||||||
|
<div className="p-6 grid grid-cols-[1fr_auto_1fr] gap-6 items-start">
|
||||||
|
{/* LEFT TIMELINE */}
|
||||||
|
<div className="relative space-y-6">
|
||||||
|
{/* Upload */}
|
||||||
|
<div className="flex flex-col items-center">
|
||||||
|
<span className="bg-[#C7DDE4] text-[#0F6C75] text-xs px-4 py-1 rounded-full">
|
||||||
|
Upload
|
||||||
|
</span>
|
||||||
|
<div className="w-px h-6 bg-gray-300" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Diterima */}
|
||||||
|
<div className="relative bg-[#1F6779] text-white rounded-xl p-4">
|
||||||
|
<h4 className="font-semibold text-sm mb-2">Diterima</h4>
|
||||||
|
<span className="inline-block bg-[#E3EFF4] text-[#0F6C75] text-xs px-3 py-1 rounded-full">
|
||||||
|
Direview oleh: approver-jaecoo1
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="w-px h-6 bg-gray-300 mx-auto" />
|
||||||
|
|
||||||
|
{/* Pending */}
|
||||||
|
<div className="relative bg-[#B36A00] text-white rounded-xl p-4">
|
||||||
|
<h4 className="font-semibold text-sm mb-2">Pending</h4>
|
||||||
|
<span className="inline-block bg-[#FFF6CC] text-[#7A4A00] text-xs px-3 py-1 rounded-full">
|
||||||
|
Direview oleh: approver-jaecoo1
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* ARROW */}
|
||||||
|
<div className="flex flex-col gap-20 text-gray-500 font-bold">
|
||||||
|
<span>></span>
|
||||||
|
<span>></span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* RIGHT NOTES */}
|
||||||
|
<div className="space-y-14">
|
||||||
|
<div>
|
||||||
|
<div className="bg-[#C7DDE4] text-sm px-4 py-2 rounded-lg">
|
||||||
|
Catatan:
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<div className="bg-[#FFF9C4] text-sm px-4 py-2 rounded-lg">
|
||||||
|
Catatan:
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* FOOTER */}
|
||||||
|
<div className="border-t bg-[#F2F7FA] text-center py-3">
|
||||||
|
<button
|
||||||
|
onClick={() => setOpenApproverHistory(false)}
|
||||||
|
className="text-[#0F6C75] font-medium hover:underline"
|
||||||
|
>
|
||||||
|
Tutup
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
{/* FOOTER */}
|
||||||
|
<div className="bg-[#E3EFF4] text-center py-3">
|
||||||
|
<button
|
||||||
|
onClick={() => onOpenChange(false)}
|
||||||
|
className="text-[#0F6C75] font-medium hover:underline w-full"
|
||||||
|
>
|
||||||
|
Tutup
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
{openApproverHistory && (
|
||||||
|
<div
|
||||||
|
className="fixed inset-0 z-[60] flex items-center justify-center bg-black/50 p-4"
|
||||||
|
onClick={() => setOpenApproverHistory(false)}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className="bg-white rounded-2xl shadow-2xl max-w-3xl w-full overflow-hidden"
|
||||||
|
onClick={(e) => e.stopPropagation()}
|
||||||
|
>
|
||||||
|
{/* HEADER */}
|
||||||
|
<div className="bg-gradient-to-br from-[#1F6779] to-[#0F6C75] text-white px-6 py-5 relative">
|
||||||
|
<button
|
||||||
|
onClick={() => setOpenApproverHistory(false)}
|
||||||
|
className="absolute top-4 right-4 text-white/80 hover:text-white text-xl"
|
||||||
|
>
|
||||||
|
✕
|
||||||
|
</button>
|
||||||
|
|
||||||
{/* BODY */}
|
<h2 className="text-lg font-semibold">Approver History</h2>
|
||||||
<div className="p-6">
|
|
||||||
{loading ? (
|
<div className="flex items-center gap-2 mt-3">
|
||||||
<p className="text-center text-gray-600">Memuat data...</p>
|
<span className="bg-yellow-100 text-yellow-800 text-xs font-medium px-3 py-1 rounded-full">
|
||||||
) : promo ? (
|
Menunggu
|
||||||
<>
|
</span>
|
||||||
<div className="flex justify-center mb-4">
|
<span className="bg-white text-[#0F6C75] text-xs font-medium px-3 py-1 rounded-full">
|
||||||
<div className="bg-[#E8F1F6] p-4 rounded-xl">
|
Banner
|
||||||
<FileText size={60} className="text-[#0f6c75]" />
|
</span>
|
||||||
|
<span className="bg-white/20 text-white text-xs px-2 py-[2px] rounded-full">
|
||||||
|
1
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* BODY */}
|
||||||
|
<div className="p-6 grid grid-cols-[1fr_auto_1fr] gap-6 items-start">
|
||||||
|
{/* LEFT TIMELINE */}
|
||||||
|
<div className="relative space-y-6">
|
||||||
|
{/* Upload */}
|
||||||
|
<div className="flex flex-col items-center">
|
||||||
|
<span className="bg-[#C7DDE4] text-[#0F6C75] text-xs px-4 py-1 rounded-full">
|
||||||
|
Upload
|
||||||
|
</span>
|
||||||
|
<div className="w-px h-6 bg-gray-300" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Diterima */}
|
||||||
|
<div className="relative bg-[#1F6779] text-white rounded-xl p-4">
|
||||||
|
<h4 className="font-semibold text-sm mb-2">Diterima</h4>
|
||||||
|
<span className="inline-block bg-[#E3EFF4] text-[#0F6C75] text-xs px-3 py-1 rounded-full">
|
||||||
|
Direview oleh: approver-jaecoo1
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="w-px h-6 bg-gray-300 mx-auto" />
|
||||||
|
|
||||||
|
{/* Pending */}
|
||||||
|
<div className="relative bg-[#B36A00] text-white rounded-xl p-4">
|
||||||
|
<h4 className="font-semibold text-sm mb-2">Pending</h4>
|
||||||
|
<span className="inline-block bg-[#FFF6CC] text-[#7A4A00] text-xs px-3 py-1 rounded-full">
|
||||||
|
Direview oleh: approver-jaecoo1
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h2 className="text-xl font-semibold text-center mb-6">
|
{/* ARROW */}
|
||||||
{promo.title}
|
<div className="flex flex-col gap-20 text-gray-500 font-bold">
|
||||||
</h2>
|
<span>></span>
|
||||||
|
<span>></span>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="space-y-4 text-sm">
|
{/* RIGHT NOTES */}
|
||||||
|
<div className="space-y-14">
|
||||||
<div>
|
<div>
|
||||||
<p className="text-gray-600">Ukuran File</p>
|
<div className="bg-[#C7DDE4] text-sm px-4 py-2 rounded-lg">
|
||||||
<p className="font-medium">{promo.fileSize}</p>
|
Catatan:
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<p className="text-gray-600">Tanggal Upload</p>
|
<div className="bg-[#FFF9C4] text-sm px-4 py-2 rounded-lg">
|
||||||
<p className="font-medium">{promo.uploadDate}</p>
|
Catatan:
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* TIMELINE */}
|
|
||||||
<div className="mt-4">
|
|
||||||
<p className="text-gray-600 mb-3 font-medium">
|
|
||||||
Status Timeline
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<div className="space-y-4">
|
|
||||||
{promo.timeline.map((item: any, idx: number) => (
|
|
||||||
<div key={idx} className="flex gap-3 items-start">
|
|
||||||
<CheckCircle2
|
|
||||||
size={20}
|
|
||||||
className="text-green-600 shrink-0"
|
|
||||||
/>
|
|
||||||
<div>
|
|
||||||
<p className="font-medium">{item.label}</p>
|
|
||||||
<p className="text-gray-600 text-sm">
|
|
||||||
{item.date} • {item.time} WIB
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</div>
|
||||||
) : (
|
|
||||||
<p className="text-center text-gray-600">Data tidak ditemukan</p>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* FOOTER */}
|
{/* FOOTER */}
|
||||||
<div className="bg-[#E3EFF4] text-center py-3">
|
<div className="border-t bg-[#F2F7FA] text-center py-3">
|
||||||
<button
|
<button
|
||||||
onClick={() => onOpenChange(false)}
|
onClick={() => setOpenApproverHistory(false)}
|
||||||
className="text-[#0F6C75] font-medium hover:underline w-full"
|
className="text-[#0F6C75] font-medium hover:underline"
|
||||||
>
|
>
|
||||||
Tutup
|
Tutup
|
||||||
</button>
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</DialogContent>
|
)}
|
||||||
</Dialog>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,275 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
|
import { Upload, Plus, Settings, CheckCheck } from "lucide-react";
|
||||||
|
import Image from "next/image";
|
||||||
|
import { Input } from "@/components/ui/input";
|
||||||
|
import { Label } from "@/components/ui/label";
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import { Card, CardHeader, CardContent, CardTitle } from "@/components/ui/card";
|
||||||
|
import {
|
||||||
|
Dialog,
|
||||||
|
DialogContent,
|
||||||
|
DialogFooter,
|
||||||
|
DialogHeader,
|
||||||
|
DialogTitle,
|
||||||
|
} from "@/components/ui/dialog";
|
||||||
|
import { loading } from "@/config/swal";
|
||||||
|
import { Controller, useForm } from "react-hook-form";
|
||||||
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
|
import { useDropzone } from "react-dropzone";
|
||||||
|
import z from "zod";
|
||||||
|
import dynamic from "next/dynamic";
|
||||||
|
import { useParams } from "next/navigation";
|
||||||
|
import Cookies from "js-cookie";
|
||||||
|
import { getProductDataById } from "@/service/product";
|
||||||
|
import { getAgentById } from "@/service/agent";
|
||||||
|
import { Checkbox } from "@/components/ui/checkbox";
|
||||||
|
|
||||||
|
const ViewEditor = dynamic(
|
||||||
|
() => {
|
||||||
|
return import("@/components/editor/view-editor");
|
||||||
|
},
|
||||||
|
{ ssr: false },
|
||||||
|
);
|
||||||
|
const CustomEditor = dynamic(
|
||||||
|
() => {
|
||||||
|
return import("@/components/editor/custom-editor");
|
||||||
|
},
|
||||||
|
{ ssr: false },
|
||||||
|
);
|
||||||
|
|
||||||
|
interface FileWithPreview extends File {
|
||||||
|
preview: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface CategoryType {
|
||||||
|
id: number;
|
||||||
|
label: string;
|
||||||
|
value: number;
|
||||||
|
}
|
||||||
|
const categorySchema = z.object({
|
||||||
|
id: z.number(),
|
||||||
|
label: z.string(),
|
||||||
|
value: z.number(),
|
||||||
|
});
|
||||||
|
|
||||||
|
const AGENT_TYPES = [
|
||||||
|
{ key: "after-sales", label: "After Sales" },
|
||||||
|
{ key: "sales", label: "Sales" },
|
||||||
|
{ key: "spv", label: "SPV" },
|
||||||
|
{ key: "branch_manager", label: "Branch Manager" },
|
||||||
|
];
|
||||||
|
|
||||||
|
const createArticleSchema = z.object({
|
||||||
|
title: z.string().min(2, {
|
||||||
|
message: "Judul harus diisi",
|
||||||
|
}),
|
||||||
|
variant: z.string().min(2, {
|
||||||
|
message: "variant diisi",
|
||||||
|
}),
|
||||||
|
price: z.string().min(2, {
|
||||||
|
message: "Price harus diisi",
|
||||||
|
}),
|
||||||
|
category: z.array(categorySchema).nonempty({
|
||||||
|
message: "Kategori harus memiliki setidaknya satu item",
|
||||||
|
}),
|
||||||
|
tags: z.array(z.string()).nonempty({
|
||||||
|
message: "Minimal 1 tag",
|
||||||
|
}), // Array berisi string
|
||||||
|
});
|
||||||
|
|
||||||
|
export default function DetailAgentForm(props: { isDetail: boolean }) {
|
||||||
|
const { isDetail } = props;
|
||||||
|
const params = useParams();
|
||||||
|
const id = params?.id;
|
||||||
|
const [data, setData] = useState<any>(null);
|
||||||
|
const [openApproverHistory, setOpenApproverHistory] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
fetchData();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
async function fetchData() {
|
||||||
|
const res = await getAgentById(id);
|
||||||
|
setData(res?.data?.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!data) return null;
|
||||||
|
|
||||||
|
const handleOpenApproverHistory = () => {
|
||||||
|
setOpenApproverHistory(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Card className="w-full border-none shadow-md">
|
||||||
|
<CardHeader>
|
||||||
|
<CardTitle className="text-xl font-bold text-teal-900">
|
||||||
|
Detail Agen
|
||||||
|
</CardTitle>
|
||||||
|
</CardHeader>
|
||||||
|
|
||||||
|
<CardContent className="space-y-6">
|
||||||
|
{/* FORM */}
|
||||||
|
<div className="grid md:grid-cols-3 gap-4">
|
||||||
|
<div>
|
||||||
|
<Label className="mb-2">Nama Lengkap</Label>
|
||||||
|
<Input value={data.name} readOnly />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<Label className="mb-2">Jabatan</Label>
|
||||||
|
<Input value={data.job_title} readOnly />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<Label className="mb-2">No Telp</Label>
|
||||||
|
<Input value={data.phone} readOnly />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* JENIS AGEN */}
|
||||||
|
<div>
|
||||||
|
<Label className="mb-2 block">Jenis Agen</Label>
|
||||||
|
<div className="flex gap-6">
|
||||||
|
{AGENT_TYPES.map((item) => (
|
||||||
|
<div key={item.key} className="flex items-center gap-2">
|
||||||
|
<Checkbox checked={data.job_title === item.key} disabled />
|
||||||
|
<span>{item.label}</span>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* FOTO PROFILE */}
|
||||||
|
<div>
|
||||||
|
<Label className="mb-2 block">Foto Profile</Label>
|
||||||
|
<div className="w-24 h-24 rounded-lg overflow-hidden border">
|
||||||
|
<Image
|
||||||
|
src={data.profile_picture_url}
|
||||||
|
alt="Profile"
|
||||||
|
width={96}
|
||||||
|
height={96}
|
||||||
|
className="object-cover"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="border rounded-lg px-3 py-3">
|
||||||
|
<p>Comment : </p>
|
||||||
|
<div className="flex flex-row justify-between">
|
||||||
|
<button
|
||||||
|
onClick={handleOpenApproverHistory}
|
||||||
|
className="text-sm text-blue-600 hover:underline mt-2"
|
||||||
|
>
|
||||||
|
View Approver History
|
||||||
|
</button>
|
||||||
|
<p>Jaecoo - Approver | 10/11/2026</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/* <Button className=" bg-teal-800 hover:bg-teal-900 text-white py-3">
|
||||||
|
Submit
|
||||||
|
</Button> */}
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
{openApproverHistory && (
|
||||||
|
<div
|
||||||
|
className="fixed inset-0 z-[60] flex items-center justify-center bg-black/50 p-4"
|
||||||
|
onClick={() => setOpenApproverHistory(false)}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className="bg-white rounded-2xl shadow-2xl max-w-3xl w-full overflow-hidden"
|
||||||
|
onClick={(e) => e.stopPropagation()}
|
||||||
|
>
|
||||||
|
{/* HEADER */}
|
||||||
|
<div className="bg-gradient-to-br from-[#1F6779] to-[#0F6C75] text-white px-6 py-5 relative">
|
||||||
|
<button
|
||||||
|
onClick={() => setOpenApproverHistory(false)}
|
||||||
|
className="absolute top-4 right-4 text-white/80 hover:text-white text-xl"
|
||||||
|
>
|
||||||
|
✕
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<h2 className="text-lg font-semibold">Approver History</h2>
|
||||||
|
|
||||||
|
<div className="flex items-center gap-2 mt-3">
|
||||||
|
<span className="bg-yellow-100 text-yellow-800 text-xs font-medium px-3 py-1 rounded-full">
|
||||||
|
Menunggu
|
||||||
|
</span>
|
||||||
|
<span className="bg-white text-[#0F6C75] text-xs font-medium px-3 py-1 rounded-full">
|
||||||
|
Banner
|
||||||
|
</span>
|
||||||
|
<span className="bg-white/20 text-white text-xs px-2 py-[2px] rounded-full">
|
||||||
|
1
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* BODY */}
|
||||||
|
<div className="p-6 grid grid-cols-[1fr_auto_1fr] gap-6 items-start">
|
||||||
|
{/* LEFT TIMELINE */}
|
||||||
|
<div className="relative space-y-6">
|
||||||
|
{/* Upload */}
|
||||||
|
<div className="flex flex-col items-center">
|
||||||
|
<span className="bg-[#C7DDE4] text-[#0F6C75] text-xs px-4 py-1 rounded-full">
|
||||||
|
Upload
|
||||||
|
</span>
|
||||||
|
<div className="w-px h-6 bg-gray-300" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Diterima */}
|
||||||
|
<div className="relative bg-[#1F6779] text-white rounded-xl p-4">
|
||||||
|
<h4 className="font-semibold text-sm mb-2">Diterima</h4>
|
||||||
|
<span className="inline-block bg-[#E3EFF4] text-[#0F6C75] text-xs px-3 py-1 rounded-full">
|
||||||
|
Direview oleh: approver-jaecoo1
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="w-px h-6 bg-gray-300 mx-auto" />
|
||||||
|
|
||||||
|
{/* Pending */}
|
||||||
|
<div className="relative bg-[#B36A00] text-white rounded-xl p-4">
|
||||||
|
<h4 className="font-semibold text-sm mb-2">Pending</h4>
|
||||||
|
<span className="inline-block bg-[#FFF6CC] text-[#7A4A00] text-xs px-3 py-1 rounded-full">
|
||||||
|
Direview oleh: approver-jaecoo1
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* ARROW */}
|
||||||
|
<div className="flex flex-col gap-20 text-gray-500 font-bold">
|
||||||
|
<span>></span>
|
||||||
|
<span>></span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* RIGHT NOTES */}
|
||||||
|
<div className="space-y-14">
|
||||||
|
<div>
|
||||||
|
<div className="bg-[#C7DDE4] text-sm px-4 py-2 rounded-lg">
|
||||||
|
Catatan:
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<div className="bg-[#FFF9C4] text-sm px-4 py-2 rounded-lg">
|
||||||
|
Catatan:
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* FOOTER */}
|
||||||
|
<div className="border-t bg-[#F2F7FA] text-center py-3">
|
||||||
|
<button
|
||||||
|
onClick={() => setOpenApproverHistory(false)}
|
||||||
|
className="text-[#0F6C75] font-medium hover:underline"
|
||||||
|
>
|
||||||
|
Tutup
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -8,7 +8,6 @@ import {
|
||||||
FormField,
|
FormField,
|
||||||
FormItem,
|
FormItem,
|
||||||
FormLabel,
|
FormLabel,
|
||||||
FormMessage,
|
|
||||||
} from "@/components/ui/form";
|
} from "@/components/ui/form";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
import { Checkbox } from "@/components/ui/checkbox";
|
import { Checkbox } from "@/components/ui/checkbox";
|
||||||
|
|
@ -24,55 +23,49 @@ type AgentFormValues = {
|
||||||
position: string;
|
position: string;
|
||||||
phone: string;
|
phone: string;
|
||||||
roles: string[];
|
roles: string[];
|
||||||
profileImage: File | null;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const agentTypes = ["After Sales", "Sales", "Spv", "Branch Manager"];
|
const AGENT_TYPES = ["after-Sales", "sales", "spv", "branch_manager"];
|
||||||
|
|
||||||
export default function UpdateAgentForm({ id }: { id: number }) {
|
export default function UpdateAgentForm({ id }: { id: number }) {
|
||||||
const [loading, setLoading] = useState(true);
|
|
||||||
const [previewImg, setPreviewImg] = useState<string | null>(null);
|
|
||||||
const [agentData, setAgentData] = useState<any>(null);
|
|
||||||
const [file, setFile] = useState<File | null>(null);
|
|
||||||
const [preview, setPreview] = useState<string | null>(null);
|
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const MySwal = withReactContent(Swal);
|
const MySwal = withReactContent(Swal);
|
||||||
|
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [file, setFile] = useState<File | null>(null);
|
||||||
|
const [preview, setPreview] = useState<string | null>(null);
|
||||||
|
const [agentData, setAgentData] = useState<any>(null);
|
||||||
|
|
||||||
const form = useForm<AgentFormValues>({
|
const form = useForm<AgentFormValues>({
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
fullName: "",
|
fullName: "",
|
||||||
position: "",
|
position: "",
|
||||||
phone: "",
|
phone: "",
|
||||||
roles: [],
|
roles: [],
|
||||||
profileImage: null,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/* ================= FETCH DATA ================= */
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function fetchData() {
|
async function fetchData() {
|
||||||
try {
|
try {
|
||||||
const res = await getAgentById(id);
|
const res = await getAgentById(id);
|
||||||
|
const agent = res?.data?.data;
|
||||||
|
if (!agent) return;
|
||||||
|
|
||||||
if (!res || !res.data) {
|
setAgentData(agent);
|
||||||
console.error("DATA AGENT TIDAK DITEMUKAN");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setAgentData(res.data);
|
|
||||||
|
|
||||||
form.reset({
|
form.reset({
|
||||||
fullName: res?.data?.data?.name,
|
fullName: agent.name,
|
||||||
position: res?.data?.data?.job_title,
|
position: agent.job_title,
|
||||||
phone: res?.data?.data?.phone,
|
phone: agent.phone,
|
||||||
roles: res?.data?.data?.agent_type || [],
|
roles: agent.job_title ? [agent.job_title] : [],
|
||||||
profileImage: null,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("name", res?.data?.data?.name);
|
// ✅ FOTO DARI API
|
||||||
setPreviewImg(res.data.data.profile_picture_path || null);
|
setPreview(agent.profile_picture_url ?? null);
|
||||||
} catch (err) {
|
} catch (error) {
|
||||||
console.error("ERROR FETCH DATA AGENT:", err);
|
console.error("FETCH AGENT ERROR:", error);
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
@ -81,154 +74,133 @@ export default function UpdateAgentForm({ id }: { id: number }) {
|
||||||
fetchData();
|
fetchData();
|
||||||
}, [id, form]);
|
}, [id, form]);
|
||||||
|
|
||||||
const handleFileChange = (e: any) => {
|
/* ================= FILE HANDLER ================= */
|
||||||
const selected = e.target.files[0];
|
const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
if (selected) {
|
const selected = e.target.files?.[0];
|
||||||
setFile(selected);
|
if (!selected) return;
|
||||||
setPreview(URL.createObjectURL(selected));
|
|
||||||
}
|
setFile(selected);
|
||||||
|
setPreview(URL.createObjectURL(selected));
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleRemoveFile = () => {
|
const handleRemoveFile = () => {
|
||||||
setFile(null);
|
setFile(null);
|
||||||
setPreview(null);
|
setPreview(agentData?.profile_picture_url ?? null);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* ================= SUBMIT ================= */
|
||||||
const onSubmit = async (data: AgentFormValues) => {
|
const onSubmit = async (data: AgentFormValues) => {
|
||||||
try {
|
try {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
|
|
||||||
formData.append("name", data.fullName);
|
formData.append("name", data.fullName);
|
||||||
formData.append("job_title", data.position);
|
formData.append("job_title", data.roles[0]); // single role
|
||||||
formData.append("phone", data.phone);
|
formData.append("phone", data.phone);
|
||||||
|
|
||||||
data.roles.forEach((role) => {
|
|
||||||
formData.append("agent_type", role);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (file) {
|
if (file) {
|
||||||
formData.append("file", file);
|
formData.append("file", file);
|
||||||
}
|
}
|
||||||
|
|
||||||
await updateAgent(id, formData);
|
await updateAgent(id, formData);
|
||||||
|
|
||||||
successSubmit("/admin/agent");
|
MySwal.fire({
|
||||||
} catch (err) {
|
title: "Berhasil",
|
||||||
console.error("ERROR UPDATE AGENT:", err);
|
text: "Data agen berhasil diperbarui",
|
||||||
|
icon: "success",
|
||||||
|
}).then(() => router.push("/admin/agent"));
|
||||||
|
} catch (error) {
|
||||||
|
console.error("UPDATE AGENT ERROR:", error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function successSubmit(redirect: string) {
|
if (loading) return <p className="p-6">Loading...</p>;
|
||||||
MySwal.fire({
|
|
||||||
title: "Data Berhasil Diupdate",
|
|
||||||
icon: "success",
|
|
||||||
confirmButtonColor: "#3085d6",
|
|
||||||
confirmButtonText: "OK",
|
|
||||||
}).then((res) => {
|
|
||||||
if (res.isConfirmed) router.push(redirect);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (loading) {
|
|
||||||
return <div className="p-6 text-gray-600">Loading data...</div>;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="bg-white dark:bg-neutral-900 p-6 rounded-lg shadow-sm">
|
<div className="bg-white p-6 rounded-lg shadow-sm">
|
||||||
<h2 className="text-2xl font-bold text-teal-800 mb-6">Edit Agen</h2>
|
<h2 className="text-2xl font-bold text-teal-800 mb-6">Edit Agen</h2>
|
||||||
|
|
||||||
<Form {...form}>
|
<Form {...form}>
|
||||||
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-6">
|
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-6">
|
||||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-5">
|
{/* BASIC INFO */}
|
||||||
|
<div className="grid md:grid-cols-3 gap-4">
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="fullName"
|
name="fullName"
|
||||||
rules={{ required: true }}
|
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>Nama Lengkap *</FormLabel>
|
<FormLabel>Nama Lengkap</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input placeholder="Masukkan Nama" {...field} />
|
<Input {...field} />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Jabatan */}
|
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="position"
|
name="position"
|
||||||
rules={{ required: true }}
|
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>Jabatan *</FormLabel>
|
<FormLabel>Jabatan</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input placeholder="Contoh: Branch Manager" {...field} />
|
<Input {...field} readOnly />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Telepon */}
|
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="phone"
|
name="phone"
|
||||||
rules={{ required: true }}
|
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>No Telp *</FormLabel>
|
<FormLabel>No Telp</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input placeholder="Contoh: 0812xxxx" {...field} />
|
<Input {...field} />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* ROLES */}
|
{/* JENIS AGEN */}
|
||||||
<div>
|
<div>
|
||||||
<FormLabel>Pilih Jenis Agen *</FormLabel>
|
<FormLabel>Jenis Agen</FormLabel>
|
||||||
|
<div className="flex gap-6 mt-3">
|
||||||
<div className="flex flex-wrap gap-6 mt-3">
|
{AGENT_TYPES.map((role) => (
|
||||||
{agentTypes.map((role) => (
|
|
||||||
<FormField
|
<FormField
|
||||||
key={role}
|
key={role}
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="roles"
|
name="roles"
|
||||||
render={({ field }) => {
|
render={({ field }) => (
|
||||||
const selected = field.value || [];
|
<FormItem className="flex items-center gap-2">
|
||||||
return (
|
<FormControl>
|
||||||
<FormItem className="flex flex-row items-center space-x-2">
|
<Checkbox
|
||||||
<FormControl>
|
checked={field.value?.includes(role)}
|
||||||
<Checkbox
|
onCheckedChange={(checked) =>
|
||||||
checked={selected.includes(role)}
|
field.onChange(checked ? [role] : [])
|
||||||
onCheckedChange={(checked) => {
|
}
|
||||||
const updated = checked
|
/>
|
||||||
? [...selected, role]
|
</FormControl>
|
||||||
: selected.filter((i) => i !== role);
|
<span className="capitalize">
|
||||||
field.onChange(updated);
|
{role.replace("_", " ")}
|
||||||
}}
|
</span>
|
||||||
/>
|
</FormItem>
|
||||||
</FormControl>
|
)}
|
||||||
<FormLabel className="font-normal">{role}</FormLabel>
|
|
||||||
</FormItem>
|
|
||||||
);
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* FOTO */}
|
{/* FOTO */}
|
||||||
<div className="space-y-3">
|
<div>
|
||||||
<FormLabel>Foto Agen</FormLabel>
|
<FormLabel>Foto Agen</FormLabel>
|
||||||
|
|
||||||
<div className="flex items-center gap-5">
|
<div className="flex items-center gap-5 mt-3">
|
||||||
{preview && (
|
{preview && (
|
||||||
<div className="mt-3 relative w-28 h-28 rounded-md overflow-hidden border">
|
<div className="relative w-28 h-28 rounded-md overflow-hidden border">
|
||||||
<img
|
<img
|
||||||
src={preview}
|
src={preview}
|
||||||
alt="Preview"
|
alt="Foto Agen"
|
||||||
className="w-full h-full object-cover"
|
className="w-full h-full object-cover"
|
||||||
/>
|
/>
|
||||||
<button
|
<button
|
||||||
|
|
@ -243,8 +215,8 @@ export default function UpdateAgentForm({ id }: { id: number }) {
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
className="bg-teal-700 hover:bg-teal-800 text-white"
|
|
||||||
onClick={() => document.getElementById("upload-photo")?.click()}
|
onClick={() => document.getElementById("upload-photo")?.click()}
|
||||||
|
className="bg-teal-700 text-white"
|
||||||
>
|
>
|
||||||
Upload Baru
|
Upload Baru
|
||||||
</Button>
|
</Button>
|
||||||
|
|
@ -252,31 +224,29 @@ export default function UpdateAgentForm({ id }: { id: number }) {
|
||||||
<input
|
<input
|
||||||
id="upload-photo"
|
id="upload-photo"
|
||||||
type="file"
|
type="file"
|
||||||
className="hidden"
|
|
||||||
accept="image/*"
|
accept="image/*"
|
||||||
|
className="hidden"
|
||||||
onChange={handleFileChange}
|
onChange={handleFileChange}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* BUTTON */}
|
{/* BUTTON */}
|
||||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-4 pt-5">
|
<div className="grid md:grid-cols-3 gap-4 pt-6">
|
||||||
<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
className="bg-gray-300 text-gray-700 hover:bg-gray-400"
|
variant="secondary"
|
||||||
onClick={() => router.back()}
|
onClick={() => router.back()}
|
||||||
>
|
>
|
||||||
Batal
|
Batal
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<div className="md:col-span-2">
|
<Button
|
||||||
<Button
|
type="submit"
|
||||||
type="submit"
|
className="md:col-span-2 bg-teal-700 text-white"
|
||||||
className="w-full bg-teal-700 hover:bg-teal-800 text-white py-3"
|
>
|
||||||
>
|
Simpan Perubahan
|
||||||
Simpan Perubahan
|
</Button>
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</Form>
|
</Form>
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ export default function AddProductForm() {
|
||||||
const [file, setFile] = useState<File | null>(null);
|
const [file, setFile] = useState<File | null>(null);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const MySwal = withReactContent(Swal);
|
const MySwal = withReactContent(Swal);
|
||||||
|
const [priceDisplay, setPriceDisplay] = useState("");
|
||||||
|
|
||||||
const handleFileChange = (e: any) => {
|
const handleFileChange = (e: any) => {
|
||||||
const selected = e.target.files[0];
|
const selected = e.target.files[0];
|
||||||
|
|
@ -42,6 +43,7 @@ export default function AddProductForm() {
|
||||||
const {
|
const {
|
||||||
register,
|
register,
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
|
setValue,
|
||||||
formState: { errors },
|
formState: { errors },
|
||||||
} = useForm<z.infer<typeof formSchema>>({
|
} = useForm<z.infer<typeof formSchema>>({
|
||||||
resolver: zodResolver(formSchema),
|
resolver: zodResolver(formSchema),
|
||||||
|
|
@ -86,10 +88,21 @@ export default function AddProductForm() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handlePriceChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
const rawValue = e.target.value.replace(/\D/g, "");
|
||||||
|
setPriceDisplay(formatRupiah(rawValue));
|
||||||
|
setValue("price", rawValue ? Number(rawValue) : 0);
|
||||||
|
};
|
||||||
|
|
||||||
const handleAddColor = () => {
|
const handleAddColor = () => {
|
||||||
setColors((prev) => [...prev, { id: prev.length + 1 }]);
|
setColors((prev) => [...prev, { id: prev.length + 1 }]);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const formatRupiah = (value: string) => {
|
||||||
|
const number = value.replace(/\D/g, "");
|
||||||
|
return number ? `Rp ${Number(number).toLocaleString("id-ID")}` : "";
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card className="w-full max-w-full mx-auto shadow-md border-none">
|
<Card className="w-full max-w-full mx-auto shadow-md border-none">
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
|
|
@ -127,8 +140,10 @@ export default function AddProductForm() {
|
||||||
<Label>Harga Produk *</Label>
|
<Label>Harga Produk *</Label>
|
||||||
<Input
|
<Input
|
||||||
placeholder="Masukkan Harga Produk"
|
placeholder="Masukkan Harga Produk"
|
||||||
{...register("price")}
|
value={priceDisplay}
|
||||||
|
onChange={handlePriceChange}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{errors.price && (
|
{errors.price && (
|
||||||
<p className="text-sm text-red-500 mt-1">
|
<p className="text-sm text-red-500 mt-1">
|
||||||
{errors.price.message}
|
{errors.price.message}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,700 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
|
import { Upload, Plus, Settings, CheckCheck } from "lucide-react";
|
||||||
|
import Image from "next/image";
|
||||||
|
import { Input } from "@/components/ui/input";
|
||||||
|
import { Label } from "@/components/ui/label";
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import { Card, CardHeader, CardContent, CardTitle } from "@/components/ui/card";
|
||||||
|
import {
|
||||||
|
Dialog,
|
||||||
|
DialogContent,
|
||||||
|
DialogFooter,
|
||||||
|
DialogHeader,
|
||||||
|
DialogTitle,
|
||||||
|
} from "@/components/ui/dialog";
|
||||||
|
import { loading } from "@/config/swal";
|
||||||
|
import { Controller, useForm } from "react-hook-form";
|
||||||
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
|
import { useDropzone } from "react-dropzone";
|
||||||
|
import z from "zod";
|
||||||
|
import dynamic from "next/dynamic";
|
||||||
|
import { useParams } from "next/navigation";
|
||||||
|
import Cookies from "js-cookie";
|
||||||
|
import { getProductDataById } from "@/service/product";
|
||||||
|
|
||||||
|
const ViewEditor = dynamic(
|
||||||
|
() => {
|
||||||
|
return import("@/components/editor/view-editor");
|
||||||
|
},
|
||||||
|
{ ssr: false },
|
||||||
|
);
|
||||||
|
const CustomEditor = dynamic(
|
||||||
|
() => {
|
||||||
|
return import("@/components/editor/custom-editor");
|
||||||
|
},
|
||||||
|
{ ssr: false },
|
||||||
|
);
|
||||||
|
|
||||||
|
interface FileWithPreview extends File {
|
||||||
|
preview: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface CategoryType {
|
||||||
|
id: number;
|
||||||
|
label: string;
|
||||||
|
value: number;
|
||||||
|
}
|
||||||
|
const categorySchema = z.object({
|
||||||
|
id: z.number(),
|
||||||
|
label: z.string(),
|
||||||
|
value: z.number(),
|
||||||
|
});
|
||||||
|
|
||||||
|
const createArticleSchema = z.object({
|
||||||
|
title: z.string().min(2, {
|
||||||
|
message: "Judul harus diisi",
|
||||||
|
}),
|
||||||
|
variant: z.string().min(2, {
|
||||||
|
message: "variant diisi",
|
||||||
|
}),
|
||||||
|
price: z.string().min(2, {
|
||||||
|
message: "Price harus diisi",
|
||||||
|
}),
|
||||||
|
category: z.array(categorySchema).nonempty({
|
||||||
|
message: "Kategori harus memiliki setidaknya satu item",
|
||||||
|
}),
|
||||||
|
tags: z.array(z.string()).nonempty({
|
||||||
|
message: "Minimal 1 tag",
|
||||||
|
}), // Array berisi string
|
||||||
|
});
|
||||||
|
|
||||||
|
export default function DetailProductForm(props: { isDetail: boolean }) {
|
||||||
|
const { isDetail } = props;
|
||||||
|
const params = useParams();
|
||||||
|
const id = params?.id;
|
||||||
|
const username = Cookies.get("username");
|
||||||
|
const userId = Cookies.get("uie");
|
||||||
|
const [files, setFiles] = useState<FileWithPreview[]>([]);
|
||||||
|
const [useAi, setUseAI] = useState(false);
|
||||||
|
const [listCategory, setListCategory] = useState<CategoryType[]>([]);
|
||||||
|
const [tag, setTag] = useState("");
|
||||||
|
const [detailfiles, setDetailFiles] = useState<any>([]);
|
||||||
|
const [mainImage, setMainImage] = useState(0);
|
||||||
|
const [thumbnail, setThumbnail] = useState("");
|
||||||
|
const [diseId, setDiseId] = useState(0);
|
||||||
|
const [thumbnailImg, setThumbnailImg] = useState<File[]>([]);
|
||||||
|
const [selectedMainImage, setSelectedMainImage] = useState<number | null>(
|
||||||
|
null,
|
||||||
|
);
|
||||||
|
const [thumbnailValidation, setThumbnailValidation] = useState("");
|
||||||
|
// const { isOpen, onOpen, onOpenChange } = useDisclosure();
|
||||||
|
const [isOpen, setIsOpen] = useState(false);
|
||||||
|
const onOpen = () => setIsOpen(true);
|
||||||
|
const onOpenChange = () => setIsOpen((prev) => !prev);
|
||||||
|
const [approvalStatus, setApprovalStatus] = useState<number>(2);
|
||||||
|
const [approvalMessage, setApprovalMessage] = useState("");
|
||||||
|
const [detailData, setDetailData] = useState<any>();
|
||||||
|
const [startDateValue, setStartDateValue] = useState<any>(null);
|
||||||
|
const [timeValue, setTimeValue] = useState("00:00");
|
||||||
|
const [openApproverHistory, setOpenApproverHistory] = useState(false);
|
||||||
|
|
||||||
|
const { getRootProps, getInputProps } = useDropzone({
|
||||||
|
onDrop: (acceptedFiles) => {
|
||||||
|
setFiles((prevFiles) => [
|
||||||
|
...prevFiles,
|
||||||
|
...acceptedFiles.map((file) => Object.assign(file)),
|
||||||
|
]);
|
||||||
|
},
|
||||||
|
multiple: true,
|
||||||
|
accept: {
|
||||||
|
"image/*": [],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const formOptions = {
|
||||||
|
resolver: zodResolver(createArticleSchema),
|
||||||
|
defaultValues: { title: "", description: "", category: [], tags: [] },
|
||||||
|
};
|
||||||
|
type UserSettingSchema = z.infer<typeof createArticleSchema>;
|
||||||
|
const {
|
||||||
|
register,
|
||||||
|
control,
|
||||||
|
handleSubmit,
|
||||||
|
formState: { errors },
|
||||||
|
setValue,
|
||||||
|
getValues,
|
||||||
|
watch,
|
||||||
|
setError,
|
||||||
|
clearErrors,
|
||||||
|
} = useForm<UserSettingSchema>(formOptions);
|
||||||
|
const [specs, setSpecs] = useState([
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
title: "Jaecoo 7 SHS Teknologi dan Exterior",
|
||||||
|
images: ["/spec1.jpg", "/spec2.jpg", "/spec3.jpg", "/spec4.jpg"],
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
type ColorType = {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
preview: string;
|
||||||
|
colorSelected: string | null;
|
||||||
|
};
|
||||||
|
|
||||||
|
const [colors, setColors] = useState<ColorType[]>([
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
name: "",
|
||||||
|
preview: "/car-1.png",
|
||||||
|
colorSelected: null,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
name: "",
|
||||||
|
preview: "/car-2.png",
|
||||||
|
colorSelected: null,
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
const palette = [
|
||||||
|
"#1E4E52",
|
||||||
|
"#597E8D",
|
||||||
|
"#6B6B6B",
|
||||||
|
"#BEBEBE",
|
||||||
|
"#E2E2E2",
|
||||||
|
"#F4F4F4",
|
||||||
|
"#FFFFFF",
|
||||||
|
"#F9360A",
|
||||||
|
"#9A2A00",
|
||||||
|
"#7A1400",
|
||||||
|
"#4B0200",
|
||||||
|
"#B48B84",
|
||||||
|
"#FFA598",
|
||||||
|
];
|
||||||
|
|
||||||
|
const handleAddSpec = () => {
|
||||||
|
setSpecs((prev) => [
|
||||||
|
...prev,
|
||||||
|
{
|
||||||
|
id: prev.length + 1,
|
||||||
|
title: "",
|
||||||
|
images: [],
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleAddColor = () => {
|
||||||
|
setColors((p) => [
|
||||||
|
...p,
|
||||||
|
{
|
||||||
|
id: p.length + 1,
|
||||||
|
name: "",
|
||||||
|
preview: "/car-default.png",
|
||||||
|
colorSelected: null,
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
};
|
||||||
|
|
||||||
|
const [isUploadDialogOpen, setIsUploadDialogOpen] = useState(false);
|
||||||
|
const [uploadTarget, setUploadTarget] = useState<{
|
||||||
|
type: "spec" | "color";
|
||||||
|
index: number;
|
||||||
|
} | null>(null);
|
||||||
|
|
||||||
|
const fileInputId = "file-upload-input";
|
||||||
|
|
||||||
|
const handleFileSelected = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
const file = event.target.files?.[0];
|
||||||
|
if (!file || !uploadTarget) return;
|
||||||
|
|
||||||
|
const reader = new FileReader();
|
||||||
|
reader.onload = () => {
|
||||||
|
const fileUrl = reader.result as string;
|
||||||
|
|
||||||
|
if (uploadTarget.type === "spec") {
|
||||||
|
setSpecs((prev) => {
|
||||||
|
const updated = [...prev];
|
||||||
|
updated[uploadTarget.index].images.push(fileUrl);
|
||||||
|
return updated;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (uploadTarget.type === "color") {
|
||||||
|
setColors((prev) => {
|
||||||
|
const updated = [...prev];
|
||||||
|
updated[uploadTarget.index].preview = fileUrl;
|
||||||
|
return updated;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
reader.readAsDataURL(file);
|
||||||
|
setIsUploadDialogOpen(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
initState();
|
||||||
|
}, [listCategory]);
|
||||||
|
|
||||||
|
async function initState() {
|
||||||
|
const res = await getProductDataById(id);
|
||||||
|
const data = res?.data?.data;
|
||||||
|
|
||||||
|
if (!data) return;
|
||||||
|
|
||||||
|
setDetailData(data);
|
||||||
|
|
||||||
|
// form
|
||||||
|
setValue("title", data.title);
|
||||||
|
setValue("variant", data.variant);
|
||||||
|
setValue("price", formatRupiah(data.price));
|
||||||
|
|
||||||
|
// thumbnail
|
||||||
|
setThumbnail(data.thumbnail_url);
|
||||||
|
|
||||||
|
// colors
|
||||||
|
if (data.colors?.length) {
|
||||||
|
setColors(
|
||||||
|
data.colors.map((color: string, index: number) => ({
|
||||||
|
id: index + 1,
|
||||||
|
name: color,
|
||||||
|
preview: data.thumbnail_url,
|
||||||
|
colorSelected: color,
|
||||||
|
})),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleOpenApproverHistory = () => {
|
||||||
|
setOpenApproverHistory(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
const formatRupiah = (value: string) =>
|
||||||
|
"Rp " + Number(value).toLocaleString("id-ID");
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Card className="w-full border-none shadow-md">
|
||||||
|
<CardHeader>
|
||||||
|
<CardTitle className="text-xl font-bold text-teal-900">
|
||||||
|
Edit Produk
|
||||||
|
</CardTitle>
|
||||||
|
</CardHeader>
|
||||||
|
|
||||||
|
<CardContent className="space-y-8">
|
||||||
|
<div className="grid md:grid-cols-3 gap-4">
|
||||||
|
<div>
|
||||||
|
<Controller
|
||||||
|
control={control}
|
||||||
|
name="title"
|
||||||
|
render={({ field: { onChange, value } }) => (
|
||||||
|
<div className="w-full">
|
||||||
|
<label
|
||||||
|
htmlFor="title"
|
||||||
|
className="block text-sm font-medium mb-1"
|
||||||
|
>
|
||||||
|
Nama Produk <span className="text-red-500">*</span>
|
||||||
|
</label>
|
||||||
|
<Input
|
||||||
|
type="text"
|
||||||
|
id="title"
|
||||||
|
placeholder="Masukkan judul"
|
||||||
|
value={value ?? ""}
|
||||||
|
readOnly={isDetail}
|
||||||
|
onChange={onChange}
|
||||||
|
className="w-full border rounded-lg"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<Controller
|
||||||
|
control={control}
|
||||||
|
name="variant"
|
||||||
|
render={({ field: { onChange, value } }) => (
|
||||||
|
<div className="w-full">
|
||||||
|
<label
|
||||||
|
htmlFor="variant"
|
||||||
|
className="block text-sm font-medium mb-1"
|
||||||
|
>
|
||||||
|
Variant <span className="text-red-500">*</span>
|
||||||
|
</label>
|
||||||
|
<Input
|
||||||
|
type="text"
|
||||||
|
id="title"
|
||||||
|
placeholder="Masukkan judul"
|
||||||
|
value={value ?? ""}
|
||||||
|
readOnly={isDetail}
|
||||||
|
onChange={onChange}
|
||||||
|
className="w-full border rounded-lg"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<Controller
|
||||||
|
control={control}
|
||||||
|
name="price"
|
||||||
|
render={({ field: { onChange, value } }) => (
|
||||||
|
<div className="w-full">
|
||||||
|
<label
|
||||||
|
htmlFor="price"
|
||||||
|
className="block text-sm font-medium mb-1"
|
||||||
|
>
|
||||||
|
Variant <span className="text-red-500">*</span>
|
||||||
|
</label>
|
||||||
|
<Input
|
||||||
|
type="text"
|
||||||
|
id="price"
|
||||||
|
placeholder="Masukkan judul"
|
||||||
|
value={value ?? ""}
|
||||||
|
readOnly={isDetail}
|
||||||
|
onChange={onChange}
|
||||||
|
className="w-full border rounded-lg"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<Label className="font-semibold">Banner</Label>
|
||||||
|
<div className="mt-2 w-[120px] h-[80px] rounded-lg overflow-hidden border bg-gray-100">
|
||||||
|
{thumbnail ? (
|
||||||
|
<Image
|
||||||
|
src={thumbnail}
|
||||||
|
alt="Banner"
|
||||||
|
width={120}
|
||||||
|
height={80}
|
||||||
|
className="object-cover"
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<div className="flex items-center justify-center text-xs text-gray-400 h-full">
|
||||||
|
No Image
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<Label className="font-semibold">Warna Produk *</Label>
|
||||||
|
|
||||||
|
{colors.map((item, index) => (
|
||||||
|
<div key={item.id} className="mt-6 border-b pb-6">
|
||||||
|
<Label>Pilih Warna {index + 1}</Label>
|
||||||
|
<Input
|
||||||
|
placeholder="Contoh: Silver / #E2E2E2"
|
||||||
|
className="mt-1"
|
||||||
|
value={item.name}
|
||||||
|
readOnly
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div className="flex items-center gap-2 mt-3">
|
||||||
|
<div className="w-10 h-10 rounded-full flex items-center justify-center bg-teal-900">
|
||||||
|
<Settings className="w-5 h-5 text-white" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{palette.map((colorCode) => (
|
||||||
|
<button
|
||||||
|
key={colorCode}
|
||||||
|
type="button"
|
||||||
|
disabled={isDetail}
|
||||||
|
style={{ backgroundColor: colorCode }}
|
||||||
|
className={`w-10 h-10 rounded-full border-2
|
||||||
|
${
|
||||||
|
item.colorSelected === colorCode
|
||||||
|
? "border-teal-700 scale-110"
|
||||||
|
: "border-gray-300"
|
||||||
|
}
|
||||||
|
${isDetail ? "cursor-not-allowed opacity-70" : ""}
|
||||||
|
`}
|
||||||
|
onClick={() => {
|
||||||
|
setColors((prev) => {
|
||||||
|
const updated = [...prev];
|
||||||
|
updated[index].colorSelected = colorCode;
|
||||||
|
return updated;
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="mt-4">
|
||||||
|
<Label className="font-semibold">
|
||||||
|
Foto Produk Warna {index + 1}
|
||||||
|
</Label>
|
||||||
|
|
||||||
|
<div className="flex items-center gap-4 mt-2">
|
||||||
|
<Image
|
||||||
|
src={item.preview}
|
||||||
|
alt="car color"
|
||||||
|
width={120}
|
||||||
|
height={80}
|
||||||
|
className="object-cover rounded-md border"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
className="bg-teal-800 hover:bg-teal-900 text-white"
|
||||||
|
onClick={() => {
|
||||||
|
setUploadTarget({ type: "color", index });
|
||||||
|
setIsUploadDialogOpen(true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Upload File Baru
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
|
||||||
|
{/* <Button
|
||||||
|
type="button"
|
||||||
|
onClick={handleAddColor}
|
||||||
|
className="w-full bg-teal-800 hover:bg-teal-900 text-white mt-4"
|
||||||
|
>
|
||||||
|
<Plus className="w-4 h-4 mr-2" /> Tambah Warna Baru
|
||||||
|
</Button> */}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="mt-10">
|
||||||
|
<Label className="text-lg font-semibold text-teal-900">
|
||||||
|
Spesifikasi Produk <span className="text-red-500">*</span>
|
||||||
|
</Label>
|
||||||
|
|
||||||
|
{specs.map((spec, index) => (
|
||||||
|
<div key={spec.id} className="mt-6">
|
||||||
|
<Label className="font-semibold text-sm">
|
||||||
|
Judul Spesifikasi {index + 1}
|
||||||
|
</Label>
|
||||||
|
<Input
|
||||||
|
defaultValue={spec.title}
|
||||||
|
placeholder="Masukkan Judul Spesifikasi"
|
||||||
|
className="mt-1"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Label className="font-semibold text-sm mt-4 block">
|
||||||
|
Foto Spesifikasi {index + 1}
|
||||||
|
</Label>
|
||||||
|
|
||||||
|
<div className="flex flex-wrap gap-4 mt-2">
|
||||||
|
{spec.images.map((img, i) => (
|
||||||
|
<Image
|
||||||
|
key={i}
|
||||||
|
src={img}
|
||||||
|
width={120}
|
||||||
|
height={120}
|
||||||
|
alt="spec"
|
||||||
|
className="rounded-lg border object-cover"
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
|
||||||
|
{/* <Button
|
||||||
|
className="bg-teal-800 hover:bg-teal-900 text-white"
|
||||||
|
onClick={() => {
|
||||||
|
setUploadTarget({ type: "spec", index });
|
||||||
|
setIsUploadDialogOpen(true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Upload File Baru
|
||||||
|
</Button> */}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
|
||||||
|
{/* <Button
|
||||||
|
onClick={handleAddSpec}
|
||||||
|
className="w-full bg-teal-800 hover:bg-teal-900 text-white flex items-center justify-center gap-2 py-4 rounded-xl"
|
||||||
|
>
|
||||||
|
<Plus className="w-4 h-4" />
|
||||||
|
Tambahkan Spesifikasi Baru
|
||||||
|
</Button> */}
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<p>Status Timeline</p>
|
||||||
|
<div className="flex gap-3">
|
||||||
|
<div className="w-6 h-6 rounded-full bg-green-100 flex items-center justify-center">
|
||||||
|
<CheckCheck className="w-4 h-4 text-green-600" />
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<p className="font-medium text-gray-800">Diupload oleh</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="flex gap-3 mt-3">
|
||||||
|
<div className="w-6 h-6 rounded-full bg-green-100 flex items-center justify-center">
|
||||||
|
<CheckCheck className="w-4 h-4 text-green-600" />
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<p className="font-medium text-gray-800">Disetujui oleh</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="border rounded-lg px-3 py-3">
|
||||||
|
<p>Comment : </p>
|
||||||
|
<div className="flex flex-row justify-between">
|
||||||
|
<button
|
||||||
|
onClick={handleOpenApproverHistory}
|
||||||
|
className="text-sm text-blue-600 hover:underline mt-2"
|
||||||
|
>
|
||||||
|
View Approver History
|
||||||
|
</button>
|
||||||
|
<p>Jaecoo - Approver | 10/11/2026</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/* <Button className=" bg-teal-800 hover:bg-teal-900 text-white py-3">
|
||||||
|
Submit
|
||||||
|
</Button> */}
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
{openApproverHistory && (
|
||||||
|
<div
|
||||||
|
className="fixed inset-0 z-[60] flex items-center justify-center bg-black/50 p-4"
|
||||||
|
onClick={() => setOpenApproverHistory(false)}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className="bg-white rounded-2xl shadow-2xl max-w-3xl w-full overflow-hidden"
|
||||||
|
onClick={(e) => e.stopPropagation()}
|
||||||
|
>
|
||||||
|
{/* HEADER */}
|
||||||
|
<div className="bg-gradient-to-br from-[#1F6779] to-[#0F6C75] text-white px-6 py-5 relative">
|
||||||
|
<button
|
||||||
|
onClick={() => setOpenApproverHistory(false)}
|
||||||
|
className="absolute top-4 right-4 text-white/80 hover:text-white text-xl"
|
||||||
|
>
|
||||||
|
✕
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<h2 className="text-lg font-semibold">Approver History</h2>
|
||||||
|
|
||||||
|
<div className="flex items-center gap-2 mt-3">
|
||||||
|
<span className="bg-yellow-100 text-yellow-800 text-xs font-medium px-3 py-1 rounded-full">
|
||||||
|
Menunggu
|
||||||
|
</span>
|
||||||
|
<span className="bg-white text-[#0F6C75] text-xs font-medium px-3 py-1 rounded-full">
|
||||||
|
Banner
|
||||||
|
</span>
|
||||||
|
<span className="bg-white/20 text-white text-xs px-2 py-[2px] rounded-full">
|
||||||
|
1
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* BODY */}
|
||||||
|
<div className="p-6 grid grid-cols-[1fr_auto_1fr] gap-6 items-start">
|
||||||
|
{/* LEFT TIMELINE */}
|
||||||
|
<div className="relative space-y-6">
|
||||||
|
{/* Upload */}
|
||||||
|
<div className="flex flex-col items-center">
|
||||||
|
<span className="bg-[#C7DDE4] text-[#0F6C75] text-xs px-4 py-1 rounded-full">
|
||||||
|
Upload
|
||||||
|
</span>
|
||||||
|
<div className="w-px h-6 bg-gray-300" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Diterima */}
|
||||||
|
<div className="relative bg-[#1F6779] text-white rounded-xl p-4">
|
||||||
|
<h4 className="font-semibold text-sm mb-2">Diterima</h4>
|
||||||
|
<span className="inline-block bg-[#E3EFF4] text-[#0F6C75] text-xs px-3 py-1 rounded-full">
|
||||||
|
Direview oleh: approver-jaecoo1
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="w-px h-6 bg-gray-300 mx-auto" />
|
||||||
|
|
||||||
|
{/* Pending */}
|
||||||
|
<div className="relative bg-[#B36A00] text-white rounded-xl p-4">
|
||||||
|
<h4 className="font-semibold text-sm mb-2">Pending</h4>
|
||||||
|
<span className="inline-block bg-[#FFF6CC] text-[#7A4A00] text-xs px-3 py-1 rounded-full">
|
||||||
|
Direview oleh: approver-jaecoo1
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* ARROW */}
|
||||||
|
<div className="flex flex-col gap-20 text-gray-500 font-bold">
|
||||||
|
<span>></span>
|
||||||
|
<span>></span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* RIGHT NOTES */}
|
||||||
|
<div className="space-y-14">
|
||||||
|
<div>
|
||||||
|
<div className="bg-[#C7DDE4] text-sm px-4 py-2 rounded-lg">
|
||||||
|
Catatan:
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<div className="bg-[#FFF9C4] text-sm px-4 py-2 rounded-lg">
|
||||||
|
Catatan:
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* FOOTER */}
|
||||||
|
<div className="border-t bg-[#F2F7FA] text-center py-3">
|
||||||
|
<button
|
||||||
|
onClick={() => setOpenApproverHistory(false)}
|
||||||
|
className="text-[#0F6C75] font-medium hover:underline"
|
||||||
|
>
|
||||||
|
Tutup
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<Dialog open={isUploadDialogOpen} onOpenChange={setIsUploadDialogOpen}>
|
||||||
|
<DialogContent className="max-w-md">
|
||||||
|
<DialogHeader>
|
||||||
|
<DialogTitle className="text-teal-900 font-semibold">
|
||||||
|
Upload File
|
||||||
|
</DialogTitle>
|
||||||
|
</DialogHeader>
|
||||||
|
|
||||||
|
<div
|
||||||
|
className="border-2 border-dashed rounded-xl p-8 text-center cursor-pointer"
|
||||||
|
onClick={() => document.getElementById(fileInputId)?.click()}
|
||||||
|
>
|
||||||
|
<Upload className="w-10 h-10 text-gray-400 mx-auto mb-3" />
|
||||||
|
<p className="text-sm text-gray-500">
|
||||||
|
Klik untuk upload atau drag & drop
|
||||||
|
</p>
|
||||||
|
<p className="text-xs text-gray-400">PNG, JPG (max 2 MB)</p>
|
||||||
|
|
||||||
|
<input
|
||||||
|
id={fileInputId}
|
||||||
|
type="file"
|
||||||
|
accept="image/*"
|
||||||
|
className="hidden"
|
||||||
|
onChange={handleFileSelected}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<DialogFooter className="flex gap-3 pt-4">
|
||||||
|
<Button
|
||||||
|
variant="secondary"
|
||||||
|
className="bg-slate-200"
|
||||||
|
onClick={() => setIsUploadDialogOpen(false)}
|
||||||
|
>
|
||||||
|
Batal
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
onClick={() => document.getElementById(fileInputId)?.click()}
|
||||||
|
className="bg-teal-800 hover:bg-teal-900 text-white"
|
||||||
|
>
|
||||||
|
Pilih File
|
||||||
|
</Button>
|
||||||
|
</DialogFooter>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -11,6 +11,7 @@ import { usePathname } from "next/navigation";
|
||||||
import { motion, AnimatePresence } from "framer-motion";
|
import { motion, AnimatePresence } from "framer-motion";
|
||||||
import { useTheme } from "../layout/theme-context";
|
import { useTheme } from "../layout/theme-context";
|
||||||
import Option from "./option";
|
import Option from "./option";
|
||||||
|
import { LogOut } from "lucide-react";
|
||||||
|
|
||||||
interface RetractingSidebarProps {
|
interface RetractingSidebarProps {
|
||||||
sidebarData: boolean;
|
sidebarData: boolean;
|
||||||
|
|
@ -56,7 +57,7 @@ const sidebarSections = [
|
||||||
// link: "/admin/magazine",
|
// link: "/admin/magazine",
|
||||||
// },
|
// },
|
||||||
{
|
{
|
||||||
title: "Agen",
|
title: "Agent",
|
||||||
icon: () => <Icon icon="ic:people-outline" className="text-lg" />,
|
icon: () => <Icon icon="ic:people-outline" className="text-lg" />,
|
||||||
link: "/admin/agent",
|
link: "/admin/agent",
|
||||||
},
|
},
|
||||||
|
|
@ -365,10 +366,10 @@ const SidebarContent = ({
|
||||||
} p-3 rounded-xl bg-gradient-to-r from-slate-50 to-slate-100/50 hover:from-slate-100 hover:to-slate-200/50 transition-all duration-200 cursor-pointer group`}
|
} p-3 rounded-xl bg-gradient-to-r from-slate-50 to-slate-100/50 hover:from-slate-100 hover:to-slate-200/50 transition-all duration-200 cursor-pointer group`}
|
||||||
>
|
>
|
||||||
<div className="relative">
|
<div className="relative">
|
||||||
<div className="w-10 h-10 rounded-full bg-gradient-to-r from-blue-500 to-purple-500 flex items-center justify-center text-white font-semibold text-sm shadow-lg">
|
{/* <div className="w-10 h-10 rounded-full bg-gradient-to-r from-blue-500 to-purple-500 flex items-center justify-center text-white font-semibold text-sm shadow-lg">
|
||||||
A
|
A
|
||||||
</div>
|
</div>
|
||||||
<div className="absolute -bottom-1 -right-1 w-4 h-4 bg-[#1F6779] rounded-full border-2 border-white"></div>
|
<div className="absolute -bottom-1 -right-1 w-4 h-4 bg-[#1F6779] rounded-full border-2 border-white"></div> */}
|
||||||
</div>
|
</div>
|
||||||
{open && (
|
{open && (
|
||||||
<motion.div
|
<motion.div
|
||||||
|
|
@ -377,14 +378,17 @@ const SidebarContent = ({
|
||||||
transition={{ delay: 0.5 }}
|
transition={{ delay: 0.5 }}
|
||||||
className="flex-1 min-w-0"
|
className="flex-1 min-w-0"
|
||||||
>
|
>
|
||||||
<p className="text-sm font-medium text-slate-800 truncate">
|
{/* <p className="text-sm font-medium text-slate-800 truncate">
|
||||||
admin-mabes
|
Jaecoo
|
||||||
</p>
|
</p> */}
|
||||||
<Link href="/auth">
|
<div className="flex flex-row items-center gap-3 text-red-500">
|
||||||
<p className="text-xs text-slate-500 hover:text-blue-600 transition-colors duration-200">
|
<LogOut />
|
||||||
Sign out
|
<Link href="/auth">
|
||||||
</p>
|
<p className="text-xs text-red-500 hover:text-blue-600 transition-colors duration-200">
|
||||||
</Link>
|
Log Out
|
||||||
|
</p>
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
</motion.div>
|
</motion.div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -386,19 +386,9 @@ export default function AgentTable() {
|
||||||
|
|
||||||
{/* STATUS */}
|
{/* STATUS */}
|
||||||
<TableCell className="text-center">
|
<TableCell className="text-center">
|
||||||
{item.is_active === "true" ? (
|
<span className="bg-yellow-100 text-yellow-800 text-xs font-medium px-3 py-1 rounded-full">
|
||||||
<span className="bg-green-100 text-green-700 text-xs font-medium px-3 py-1 rounded-full">
|
Menunggu
|
||||||
Published
|
</span>
|
||||||
</span>
|
|
||||||
) : item.publishedStatus === "On Schedule" ? (
|
|
||||||
<span className="bg-gray-100 text-gray-600 text-xs font-medium px-3 py-1 rounded-full">
|
|
||||||
On Schedule
|
|
||||||
</span>
|
|
||||||
) : (
|
|
||||||
<span className="bg-red-100 text-red-600 text-xs font-medium px-3 py-1 rounded-full">
|
|
||||||
Cancel
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</TableCell>
|
</TableCell>
|
||||||
|
|
||||||
{/* AKSI */}
|
{/* AKSI */}
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ import CustomPagination from "../layout/custom-pagination";
|
||||||
import { EditBannerDialog } from "../form/banner-edit-dialog";
|
import { EditBannerDialog } from "../form/banner-edit-dialog";
|
||||||
import { deleteBanner, getBannerData, updateBanner } from "@/service/banner";
|
import { deleteBanner, getBannerData, updateBanner } from "@/service/banner";
|
||||||
import { CheckCheck, Eye } from "lucide-react";
|
import { CheckCheck, Eye } from "lucide-react";
|
||||||
|
import { useRouter } from "next/navigation";
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
{ name: "No", uid: "no" },
|
{ name: "No", uid: "no" },
|
||||||
|
|
@ -90,6 +91,15 @@ export default function ArticleTable() {
|
||||||
startDate: null,
|
startDate: null,
|
||||||
endDate: null,
|
endDate: null,
|
||||||
});
|
});
|
||||||
|
const [userLevelId, setUserLevelId] = useState<string | null>(null);
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
// 🔹 Ambil userlevelId dari cookies
|
||||||
|
useEffect(() => {
|
||||||
|
const ulne = Cookies.get("ulne"); // contoh: "3"
|
||||||
|
setUserLevelId(ulne ?? null);
|
||||||
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
initState();
|
initState();
|
||||||
|
|
@ -173,6 +183,17 @@ export default function ArticleTable() {
|
||||||
const [openViewDialog, setOpenViewDialog] = useState(false);
|
const [openViewDialog, setOpenViewDialog] = useState(false);
|
||||||
const [viewBanner, setViewBanner] = useState<any>(null);
|
const [viewBanner, setViewBanner] = useState<any>(null);
|
||||||
const [openApproverHistory, setOpenApproverHistory] = useState(false);
|
const [openApproverHistory, setOpenApproverHistory] = useState(false);
|
||||||
|
const [openCommentModal, setOpenCommentModal] = useState(false);
|
||||||
|
const [commentValue, setCommentValue] = useState("");
|
||||||
|
|
||||||
|
const handleSubmitComment = async () => {
|
||||||
|
// await api.post("/banner/comment", {
|
||||||
|
// bannerId: viewBanner.id,
|
||||||
|
// comment: commentValue,
|
||||||
|
// });
|
||||||
|
|
||||||
|
setOpenCommentModal(false);
|
||||||
|
};
|
||||||
|
|
||||||
const handleView = (item: any) => {
|
const handleView = (item: any) => {
|
||||||
setViewBanner(item);
|
setViewBanner(item);
|
||||||
|
|
@ -402,19 +423,19 @@ export default function ArticleTable() {
|
||||||
|
|
||||||
{/* STATUS */}
|
{/* STATUS */}
|
||||||
<TableCell className="text-center">
|
<TableCell className="text-center">
|
||||||
{item.status === "Disetujui" ? (
|
{/* {item.status === "Disetujui" ? (
|
||||||
<span className="bg-green-100 text-green-700 text-xs px-3 py-1 rounded-full font-medium">
|
<span className="bg-green-100 text-green-700 text-xs px-3 py-1 rounded-full font-medium">
|
||||||
Disetujui
|
Disetujui
|
||||||
</span>
|
</span>
|
||||||
) : item.status === "Menunggu" ? (
|
) : item.status === "Menunggu" ? ( */}
|
||||||
<span className="bg-yellow-100 text-yellow-700 text-xs px-3 py-1 rounded-full font-medium">
|
<span className="bg-yellow-100 text-yellow-700 text-xs px-3 py-1 rounded-full font-medium">
|
||||||
Menunggu
|
Menunggu
|
||||||
</span>
|
</span>
|
||||||
) : (
|
{/* ) : (
|
||||||
<span className="bg-red-100 text-red-700 text-xs px-3 py-1 rounded-full font-medium">
|
<span className="bg-red-100 text-red-700 text-xs px-3 py-1 rounded-full font-medium">
|
||||||
Ditolak
|
Ditolak
|
||||||
</span>
|
</span>
|
||||||
)}
|
)} */}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
|
|
||||||
{/* AKSI */}
|
{/* AKSI */}
|
||||||
|
|
@ -429,15 +450,17 @@ export default function ArticleTable() {
|
||||||
<Eye className="w-4 h-4 mr-1" />
|
<Eye className="w-4 h-4 mr-1" />
|
||||||
Lihat
|
Lihat
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
{userLevelId !== "3" && (
|
||||||
variant="ghost"
|
<Button
|
||||||
size="sm"
|
variant="ghost"
|
||||||
className="text-[#0F6C75] hover:bg-transparent hover:underline p-0"
|
size="sm"
|
||||||
onClick={() => handleEdit(item)}
|
className="text-[#0F6C75] hover:bg-transparent hover:underline p-0"
|
||||||
>
|
onClick={() => handleEdit(item)}
|
||||||
<CreateIconIon className="w-4 h-4 mr-1" />
|
>
|
||||||
Edit
|
<CreateIconIon className="w-4 h-4 mr-1" />
|
||||||
</Button>
|
Edit
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="sm"
|
size="sm"
|
||||||
|
|
@ -679,16 +702,27 @@ export default function ArticleTable() {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* FOOTER */}
|
{/* FOOTER */}
|
||||||
<div className="flex justify-between items-center gap-3 px-6 py-4 border-t bg-[#F2F7FA]">
|
{userLevelId !== "2" && (
|
||||||
<Button variant="secondary">Beri Tanggapan</Button>
|
<div className="flex justify-between items-center gap-3 px-6 py-4 border-t bg-[#F2F7FA]">
|
||||||
|
<Button
|
||||||
|
variant="secondary"
|
||||||
|
className="bg-blue-200 hover:bg-blue-400"
|
||||||
|
onClick={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
setOpenCommentModal(true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Beri Tanggapan
|
||||||
|
</Button>
|
||||||
|
|
||||||
<div className="flex gap-3">
|
<Button variant="destructive" className="w-[180]">
|
||||||
<Button variant="destructive">Reject</Button>
|
Reject
|
||||||
<Button className="bg-green-600 hover:bg-green-700 text-white">
|
</Button>
|
||||||
|
<Button className="bg-green-600 hover:bg-green-700 text-white w-[180]">
|
||||||
Approved
|
Approved
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
@ -790,6 +824,76 @@ export default function ArticleTable() {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
{openCommentModal && viewBanner && (
|
||||||
|
<div
|
||||||
|
className="fixed inset-0 z-[60] flex items-center justify-center bg-black/50 p-4"
|
||||||
|
onClick={() => setOpenCommentModal(false)}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className="bg-white rounded-2xl shadow-2xl max-w-lg w-full overflow-hidden"
|
||||||
|
onClick={(e) => e.stopPropagation()}
|
||||||
|
>
|
||||||
|
{/* HEADER */}
|
||||||
|
<div className="bg-gradient-to-br from-[#1F6779] to-[#0F6C75] text-white px-6 py-5 relative">
|
||||||
|
<button
|
||||||
|
onClick={() => setOpenCommentModal(false)}
|
||||||
|
className="absolute top-4 right-4 text-white/80 hover:text-white text-xl"
|
||||||
|
>
|
||||||
|
✕
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<h2 className="text-lg font-semibold">Beri Tanggapan</h2>
|
||||||
|
|
||||||
|
{/* Badge */}
|
||||||
|
<div className="flex items-center gap-2 mt-3">
|
||||||
|
<span className="bg-yellow-100 text-yellow-800 text-xs font-medium px-3 py-1 rounded-full">
|
||||||
|
Menunggu
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<span className="bg-white text-[#0F6C75] text-xs font-medium px-3 py-1 rounded-full">
|
||||||
|
Banner
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<span className="bg-white/20 text-white text-xs px-2 py-[2px] rounded-full">
|
||||||
|
{viewBanner.position}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* BODY */}
|
||||||
|
<div className="p-6 space-y-4">
|
||||||
|
<div>
|
||||||
|
<label className="block text-sm font-medium text-gray-500 mb-2">
|
||||||
|
Comment
|
||||||
|
</label>
|
||||||
|
<textarea
|
||||||
|
value={commentValue}
|
||||||
|
onChange={(e) => setCommentValue(e.target.value)}
|
||||||
|
placeholder="Masukkan komentar"
|
||||||
|
className="w-full min-h-[100px] border rounded-lg p-3 focus:outline-none focus:ring-2 focus:ring-[#0F6C75]"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* FOOTER */}
|
||||||
|
<div className="flex justify-between gap-3 px-6 py-4 border-t bg-[#F2F7FA]">
|
||||||
|
<button
|
||||||
|
onClick={() => setOpenCommentModal(false)}
|
||||||
|
className="flex-1 py-2 rounded-xl bg-blue-100 hover:bg-blue-200 text-gray-700 font-medium"
|
||||||
|
>
|
||||||
|
Batal
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button
|
||||||
|
onClick={handleSubmitComment}
|
||||||
|
className="flex-1 py-2 rounded-xl bg-[#1F6779] hover:bg-[#0F6C75] text-white font-medium"
|
||||||
|
>
|
||||||
|
Submit
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,8 @@ import {
|
||||||
import CustomPagination from "../layout/custom-pagination";
|
import CustomPagination from "../layout/custom-pagination";
|
||||||
import { EditBannerDialog } from "../form/banner-edit-dialog";
|
import { EditBannerDialog } from "../form/banner-edit-dialog";
|
||||||
import { deleteProduct, getProductPagination } from "@/service/product";
|
import { deleteProduct, getProductPagination } from "@/service/product";
|
||||||
import { CheckCheck } from "lucide-react";
|
import { CheckCheck, Eye } from "lucide-react";
|
||||||
|
import { useRouter } from "next/navigation";
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
{ name: "No", uid: "no" },
|
{ name: "No", uid: "no" },
|
||||||
|
|
@ -91,6 +92,15 @@ export default function ProductTable() {
|
||||||
startDate: null,
|
startDate: null,
|
||||||
endDate: null,
|
endDate: null,
|
||||||
});
|
});
|
||||||
|
const [userLevelId, setUserLevelId] = useState<string | null>(null);
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
// 🔹 Ambil userlevelId dari cookies
|
||||||
|
useEffect(() => {
|
||||||
|
const ulne = Cookies.get("ulne"); // contoh: "3"
|
||||||
|
setUserLevelId(ulne ?? null);
|
||||||
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
initState();
|
initState();
|
||||||
|
|
@ -318,6 +328,15 @@ export default function ProductTable() {
|
||||||
initState();
|
initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const formatRupiah = (value?: number | string) => {
|
||||||
|
if (!value) return "Rp 0";
|
||||||
|
|
||||||
|
const number =
|
||||||
|
typeof value === "string" ? Number(value.replace(/[^\d]/g, "")) : value;
|
||||||
|
|
||||||
|
return `Rp ${number.toLocaleString("id-ID")}`;
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="py-3">
|
<div className="py-3">
|
||||||
|
|
@ -371,7 +390,7 @@ export default function ProductTable() {
|
||||||
<TableCell className="font-semibold text-[#0F6C75]">
|
<TableCell className="font-semibold text-[#0F6C75]">
|
||||||
{item.title ?? "—"}
|
{item.title ?? "—"}
|
||||||
<div className="mt-1">
|
<div className="mt-1">
|
||||||
{item.isPublish ? (
|
{/* {item.isPublish ? (
|
||||||
<span className="text-xs bg-blue-100 text-blue-700 px-2 py-[2px] rounded-md">
|
<span className="text-xs bg-blue-100 text-blue-700 px-2 py-[2px] rounded-md">
|
||||||
Tampil di Landing
|
Tampil di Landing
|
||||||
</span>
|
</span>
|
||||||
|
|
@ -379,15 +398,13 @@ export default function ProductTable() {
|
||||||
<span className="text-xs bg-gray-100 text-gray-600 px-2 py-[2px] rounded-md">
|
<span className="text-xs bg-gray-100 text-gray-600 px-2 py-[2px] rounded-md">
|
||||||
Draft
|
Draft
|
||||||
</span>
|
</span>
|
||||||
)}
|
)} */}
|
||||||
</div>
|
</div>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
|
|
||||||
{/* HARGA PRODUK */}
|
{/* HARGA PRODUK */}
|
||||||
<TableCell className="font-medium">
|
<TableCell className="font-medium">
|
||||||
{item.price
|
{formatRupiah(item.price)}
|
||||||
? `Rp ${item.price.toLocaleString("id-ID")}`
|
|
||||||
: "Rp 0"}
|
|
||||||
</TableCell>
|
</TableCell>
|
||||||
|
|
||||||
{/* VARIAN */}
|
{/* VARIAN */}
|
||||||
|
|
@ -413,8 +430,8 @@ export default function ProductTable() {
|
||||||
Disetujui
|
Disetujui
|
||||||
</span>
|
</span>
|
||||||
) : (
|
) : (
|
||||||
<span className="bg-gray-100 text-gray-600 text-xs font-medium px-3 py-1 rounded-full">
|
<span className="bg-yellow-100 text-yellow-800 text-xs font-medium px-3 py-1 rounded-full">
|
||||||
Draft
|
Menunggu
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
|
|
@ -422,24 +439,27 @@ export default function ProductTable() {
|
||||||
{/* AKSI */}
|
{/* AKSI */}
|
||||||
<TableCell className="text-center">
|
<TableCell className="text-center">
|
||||||
<div className="flex items-center justify-center gap-3">
|
<div className="flex items-center justify-center gap-3">
|
||||||
<Button
|
<Link href={`/admin/product/detail/${item.id}`}>
|
||||||
variant="ghost"
|
|
||||||
size="sm"
|
|
||||||
className="text-[#0F6C75] hover:bg-transparent hover:underline p-0"
|
|
||||||
// onClick={() => handleEdit(item)}
|
|
||||||
>
|
|
||||||
<CheckCheck className="w-4 h-4 mr-1" />
|
|
||||||
Approve
|
|
||||||
</Button>
|
|
||||||
<Link href={"/admin/product/update"}>
|
|
||||||
<Button
|
<Button
|
||||||
className="text-[#0F6C75] hover:bg-transparent hover:underline p-0"
|
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="sm"
|
size="sm"
|
||||||
|
className="text-[#0F6C75] hover:bg-transparent hover:underline p-0"
|
||||||
>
|
>
|
||||||
<CreateIconIon className="w-4 h-4 mr-1" /> Edit
|
<Eye className="w-4 h-4 mr-1" />
|
||||||
|
Lihat
|
||||||
</Button>
|
</Button>
|
||||||
</Link>
|
</Link>
|
||||||
|
{userLevelId !== "3" && (
|
||||||
|
<Link href={"/admin/product/update"}>
|
||||||
|
<Button
|
||||||
|
className="text-[#0F6C75] hover:bg-transparent hover:underline p-0"
|
||||||
|
variant="ghost"
|
||||||
|
size="sm"
|
||||||
|
>
|
||||||
|
<CreateIconIon className="w-4 h-4 mr-1" /> Edit
|
||||||
|
</Button>
|
||||||
|
</Link>
|
||||||
|
)}
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="sm"
|
size="sm"
|
||||||
|
|
|
||||||
|
|
@ -378,19 +378,9 @@ export default function PromotionTable() {
|
||||||
|
|
||||||
{/* STATUS */}
|
{/* STATUS */}
|
||||||
<TableCell className="text-center">
|
<TableCell className="text-center">
|
||||||
{item.publishedStatus === "Published" ? (
|
<span className="bg-yellow-100 text-yellow-800 text-xs font-medium px-3 py-1 rounded-full">
|
||||||
<span className="bg-green-100 text-green-700 text-xs font-medium px-3 py-1 rounded-full">
|
Menunggu
|
||||||
Published
|
</span>
|
||||||
</span>
|
|
||||||
) : item.publishedStatus === "On Schedule" ? (
|
|
||||||
<span className="bg-gray-100 text-gray-600 text-xs font-medium px-3 py-1 rounded-full">
|
|
||||||
On Schedule
|
|
||||||
</span>
|
|
||||||
) : (
|
|
||||||
<span className="bg-red-100 text-red-600 text-xs font-medium px-3 py-1 rounded-full">
|
|
||||||
Cancel
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</TableCell>
|
</TableCell>
|
||||||
|
|
||||||
{/* AKSI */}
|
{/* AKSI */}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import {
|
||||||
httpPostInterceptor,
|
httpPostInterceptor,
|
||||||
httpPutInterceptor,
|
httpPutInterceptor,
|
||||||
} from "./http-config/http-interceptor-services";
|
} from "./http-config/http-interceptor-services";
|
||||||
|
import { httpGet } from "./http-config/http-base-services";
|
||||||
|
|
||||||
export async function getProductPagination(props: PaginationRequest) {
|
export async function getProductPagination(props: PaginationRequest) {
|
||||||
const { page, limit, search } = props;
|
const { page, limit, search } = props;
|
||||||
|
|
@ -28,6 +29,13 @@ export async function updateProduct(data: any, id: any) {
|
||||||
return await httpPutInterceptor(pathUrl, data);
|
return await httpPutInterceptor(pathUrl, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function getProductDataById(id: any) {
|
||||||
|
const headers = {
|
||||||
|
"content-type": "application/json",
|
||||||
|
};
|
||||||
|
return await httpGet(`/products/${id}`, headers);
|
||||||
|
}
|
||||||
|
|
||||||
export async function deleteProduct(id: string) {
|
export async function deleteProduct(id: string) {
|
||||||
const headers = {
|
const headers = {
|
||||||
"content-type": "application/json",
|
"content-type": "application/json",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue