diff --git a/components/dialog/galery-detail-dialog.tsx b/components/dialog/galery-detail-dialog.tsx index 4842120..4d94e4f 100644 --- a/components/dialog/galery-detail-dialog.tsx +++ b/components/dialog/galery-detail-dialog.tsx @@ -126,193 +126,221 @@ export function DialogDetailGaleri({ open, onClose, data }: any) { return ( <> -
- - - {/* Header */} -
- Detail Galeri + + + {/* Header */} +
+ Detail Galeri +
+ + {data?.status_id === 1 + ? "Menunggu" + : data?.status_id === 2 + ? "Disetujui" + : data?.status_id === 3 + ? "Ditolak" + : "Tidak Diketahui"} + + + + Galeri + + + {/* + {promo.position} + */} +
+
+ +
+ {/* Images List */} +
+

+ {data.title} +

+
+

Deskripsi

+

{data.description}

+
+
+ {images.length === 0 && ( +

+ Tidak ada gambar. +

+ )} + + {images.map((img) => ( +
openFile(img.image_url)} + > + {img.title} + +
+ Lihat File +
+
+ ))} +
-
- {/* Images List */} -
-

- {data.title} -

-
-

Deskripsi

-

{data.description}

-
-
- {images.length === 0 && ( -

- Tidak ada gambar. + {/* Title */} + + {/* Deskripsi */} + + {/* Tanggal Upload */} +

+

+ Tanggal Upload +

+

+ {new Date(data.created_at).toLocaleDateString("id-ID")} +

+
+ + {/* Timeline */} +
+

+ Status Timeline +

+ +
+
+
+ +
+
+

+ Diupload oleh Operator

- )} - - {images.map((img) => ( -
openFile(img.image_url)} - > - {img.title} - -
- Lihat File -
-
- ))} +

+ {convertDateFormat(data?.created_at)} WIB +

+
-
- {/* Title */} - - {/* Deskripsi */} - - {/* Tanggal Upload */} -
-

- Tanggal Upload -

-

- {new Date(data.created_at).toLocaleDateString("id-ID")} -

-
- - {/* Timeline */} -
-

- Status Timeline -

- -
-
-
+
+
+ {data?.status_id === 1 ? ( + + ) : data?.status_id === 2 ? ( -
-
-

- Diupload oleh Operator -

-

- {convertDateFormat(data?.created_at)} WIB -

-
+ ) : ( + + )}
-
-
+

+ {data?.status_id === 1 + ? "Menunggu disetujui oleh Approver" + : data?.status_id === 2 + ? "Disetujui oleh Approver" + : "Ditolak oleh Approver"} +

+ +

+ {convertDateFormat(data?.updated_at)} WIB +

+
+
+ +
+

Comment :

+
+
- -
-

- {data?.status_id === 1 - ? "Menunggu disetujui oleh Approver" - : data?.status_id === 2 - ? "Disetujui oleh Approver" - : "Ditolak oleh Approver"} -

- -

- {convertDateFormat(data?.updated_at)} WIB -

-
-
- -
-

Comment :

-
- -

Jaecoo - Approver | 10/11/2026

-
+ View Approver History + +

Jaecoo - Approver | 10/11/2026

- {userRoleId !== "2" && data && ( -
- {data.status_id === 1 ? ( - <> - - - - - {userRoleId === "1" && ( - - )} - - ) : ( +
+ {userRoleId !== "2" && data && ( +
+ {data.status_id === 1 ? ( + <> - )} -
- )} -
- {/* + + + {userRoleId === "1" && ( + + )} + + ) : ( + + )} +
+ )} +
+ + {/*
-
+
+
{openApproverHistory && (
- Detail Promo + Detail Promoaa - {/* STATUS BADGE */} - {promo && ( -
- - {promo.status} -
- )} +
+ + {promo?.status_id === 1 + ? "Menunggu" + : promo?.status_id === 2 + ? "Disetujui" + : promo?.status_id === 3 + ? "Ditolak" + : "Tidak Diketahui"} + + + + Promo + + + {/* + {promo.position} + */} +
{/* BODY */} diff --git a/components/form/agent/agent-form.tsx b/components/form/agent/agent-form.tsx index 51901b1..19b415d 100644 --- a/components/form/agent/agent-form.tsx +++ b/components/form/agent/agent-form.tsx @@ -22,9 +22,10 @@ import { UploadCloud } from "lucide-react"; type AgentFormValues = { fullName: string; + job_title: string; position: string; phone: string; - roles: string[]; + agent_type: string[]; profileImage: File | null; }; @@ -40,9 +41,10 @@ export default function AddAgentForm() { const form = useForm({ defaultValues: { fullName: "", + job_title: "", position: "", phone: "", - roles: [], + agent_type: [], profileImage: null, }, }); @@ -60,13 +62,13 @@ export default function AddAgentForm() { const onSubmit = async (data: AgentFormValues) => { try { const formData = new FormData(); + formData.append("name", data.fullName); - formData.append("job_title", data.position); + formData.append("job_title", data.job_title); formData.append("phone", data.phone); - data.roles.forEach((role) => { - formData.append("agent_type[]", role); - }); + // ✅ FIX UTAMA + formData.append("agent_type", JSON.stringify(data.agent_type)); if (file) { formData.append("file", file); @@ -122,7 +124,7 @@ export default function AddAgentForm() { ( @@ -169,7 +171,7 @@ export default function AddAgentForm() { { const selected = field.value || []; return ( diff --git a/components/form/agent/detail-agent-form.tsx b/components/form/agent/detail-agent-form.tsx index e1f61cb..334f3dc 100644 --- a/components/form/agent/detail-agent-form.tsx +++ b/components/form/agent/detail-agent-form.tsx @@ -218,7 +218,16 @@ export default function DetailAgentForm(props: { isDetail: boolean }) {
{AGENT_TYPES.map((item) => (
- + v.toLowerCase()) + .includes(item.label.toLowerCase()) + } + disabled + /> + {item.label}
))} @@ -230,7 +239,7 @@ export default function DetailAgentForm(props: { isDetail: boolean }) {
Profile { try { const formData = new FormData(); + formData.append("name", data.fullName); - formData.append("job_title", data.roles[0]); // single role + formData.append("job_title", data.job_title); formData.append("phone", data.phone); + // ✅ MULTI agent_type + formData.append("agent_type", JSON.stringify(data.roles)); + if (file) { formData.append("file", file); } + // DEBUG + for (const pair of formData.entries()) { + console.log(pair[0], pair[1]); + } + await updateAgent(id, formData); MySwal.fire({ @@ -137,12 +147,12 @@ export default function UpdateAgentForm({ id }: { id: number }) { ( Jabatan - + )} @@ -171,21 +181,27 @@ export default function UpdateAgentForm({ id }: { id: number }) { key={role} control={form.control} name="roles" - render={({ field }) => ( - - - - field.onChange(checked ? [role] : []) - } - /> - - - {role.replace("_", " ")} - - - )} + render={({ field }) => { + const selected = field.value || []; + + return ( + + + { + const updated = checked + ? [...selected, role] // ➕ tambah + : selected.filter((r) => r !== role); // ➖ hapus + + field.onChange(updated); + }} + /> + + {role} + + ); + }} /> ))}
diff --git a/components/form/product/detail-product-form.tsx b/components/form/product/detail-product-form.tsx index ffc36d0..c200ab7 100644 --- a/components/form/product/detail-product-form.tsx +++ b/components/form/product/detail-product-form.tsx @@ -365,7 +365,7 @@ export default function DetailProductForm(props: { isDetail: boolean }) { - Edit Produk + Detail Produk diff --git a/components/landing-page/option.tsx b/components/landing-page/option.tsx index 512232d..e141927 100644 --- a/components/landing-page/option.tsx +++ b/components/landing-page/option.tsx @@ -11,7 +11,15 @@ export type OptionProps = { active?: boolean; }; -const Option = ({ Icon, title, selected, setSelected, open, notifs, active }: OptionProps) => { +const Option = ({ + Icon, + title, + selected, + setSelected, + open, + notifs, + active, +}: OptionProps) => { const [hovered, setHovered] = useState(false); const isActive = active ?? selected === title; @@ -22,8 +30,8 @@ const Option = ({ Icon, title, selected, setSelected, open, notifs, active }: Op onMouseEnter={() => setHovered(true)} onMouseLeave={() => setHovered(false)} className={`relative flex h-12 w-full px-3 items-center rounded-xl transition-all duration-200 cursor-pointer group ${ - isActive - ? "bg-gradient-to-r from-emerald-500 to-green-500 text-white shadow-lg shadow-emerald-500/25" + isActive + ? "bg-gradient-to-r from-[#1F6779] to-[#1F6779] text-white shadow-lg shadow-emerald-500/25" : "text-slate-600 hover:bg-gradient-to-r hover:from-slate-100 hover:to-slate-200/50 hover:text-slate-800" }`} whileHover={{ scale: 1.02 }} @@ -40,27 +48,29 @@ const Option = ({ Icon, title, selected, setSelected, open, notifs, active }: Op /> )} - -
+
{open && ( - {notifs} diff --git a/components/landing-page/retracting-sidedar.tsx b/components/landing-page/retracting-sidedar.tsx index 6348692..a2d8948 100644 --- a/components/landing-page/retracting-sidedar.tsx +++ b/components/landing-page/retracting-sidedar.tsx @@ -242,9 +242,9 @@ const SidebarContent = ({ >

JAECOO{" "} - + {/* {userRoleId != null ? roleLabel[userRoleId] : ""} - + */}

{/* Admin Panel */} diff --git a/components/table/agent-table.tsx b/components/table/agent-table.tsx index f7d52ff..8b800b4 100644 --- a/components/table/agent-table.tsx +++ b/components/table/agent-table.tsx @@ -381,7 +381,7 @@ export default function AgentTable() {
{/* Header */}
- Daftar Product + Daftar Agen
{/* Table */} diff --git a/components/table/costumer-service-table.tsx b/components/table/costumer-service-table.tsx index 15cb47c..fadf300 100644 --- a/components/table/costumer-service-table.tsx +++ b/components/table/costumer-service-table.tsx @@ -104,14 +104,14 @@ export default function CostumerServiceTable() { endDate: null, }); - const [userLevelId, setUserLevelId] = useState(null); + const [userRoleId, setUserRoleId] = useState(null); const router = useRouter(); // 🔹 Ambil userlevelId dari cookies useEffect(() => { - const ulne = Cookies.get("ulne"); // contoh: "3" - setUserLevelId(ulne ?? null); + const urie = Cookies.get("urie"); // contoh: "3" + setUserRoleId(urie ?? null); }, []); useEffect(() => { @@ -354,7 +354,7 @@ export default function CostumerServiceTable() { Sales - {userLevelId !== "3" && ( + {userRoleId !== "1" && (