diff --git a/app/[locale]/(protected)/admin/broadcast/campaign-list/account-list/component/column.tsx b/app/[locale]/(protected)/admin/broadcast/campaign-list/account-list/component/column.tsx index f8dcfd54..1461ddbb 100644 --- a/app/[locale]/(protected)/admin/broadcast/campaign-list/account-list/component/column.tsx +++ b/app/[locale]/(protected)/admin/broadcast/campaign-list/account-list/component/column.tsx @@ -106,7 +106,7 @@ const columns: ColumnDef[] = [ Edit diff --git a/app/[locale]/(protected)/admin/broadcast/campaign-list/account-list/edit/[id]/page.tsx b/app/[locale]/(protected)/admin/broadcast/campaign-list/account-list/edit/[id]/page.tsx index 6d5e00cc..2f194f49 100644 --- a/app/[locale]/(protected)/admin/broadcast/campaign-list/account-list/edit/[id]/page.tsx +++ b/app/[locale]/(protected)/admin/broadcast/campaign-list/account-list/edit/[id]/page.tsx @@ -37,46 +37,74 @@ import { Checkbox } from "@/components/ui/checkbox"; import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"; import { useParams } from "next/navigation"; import { useEffect } from "react"; +import { + getUserById, + saveUserInternal, +} from "@/service/management-user/management-user"; + +// const FormSchema = z.object({ +// fullname: z.string({ +// required_error: "Required", +// }), +// // accountType: z +// // .array(z.string()) +// // .refine((value) => value.some((item) => item), { +// // message: "Required", +// // }), +// // accountCategory: z.enum(["polri", "jurnalis", "umum", "ksp"], { +// // required_error: "Required", +// // }), +// email: z.string({ +// required_error: "Required", +// }), +// phoneNumber: z.string({ +// required_error: "Required", +// }), +// }); const FormSchema = z.object({ - name: z.string({ - required_error: "Required", - }), - accountType: z - .array(z.string()) - .refine((value) => value.some((item) => item), { - message: "Required", - }), - accountCategory: z.enum(["polri", "jurnalis", "umumu", "ksp"], { - required_error: "Required", - }), - email: z.string({ - required_error: "Required", - }), - whatsapp: z.string({ - required_error: "Required", - }), + fullname: z.string({ required_error: "Required" }), + email: z.string({ required_error: "Required" }), + phoneNumber: z.string({ required_error: "Required" }), + username: z.string().optional(), + role: z.string().optional(), + level: z.string().optional(), + nrp: z.string().optional(), + address: z.string().optional(), + password: z.string().optional(), + confirmPassword: z.string().optional(), }); export default function EditAccountForBroadcast() { const id = useParams()?.id; + const MySwal = withReactContent(Swal); const router = useRouter(); const form = useForm>({ resolver: zodResolver(FormSchema), - defaultValues: { accountType: [] }, + // defaultValues: { accountType: [] }, }); useEffect(() => { async function getDetailData() { - const response = await getMediaBlastAccount(String(id)); + const response = await getUserById(String(id)); const details = response?.data?.data; - // console.log("new", details); - form.setValue("name", details.accountName); - form.setValue("email", details?.emailAddress); - form.setValue("whatsapp", details?.whatsappNumber); - form.setValue("accountCategory", details?.accountCategory); - form.setValue("accountType", details?.accountType.split(",")); + console.log("Response full:", response); + form.setValue("fullname", details?.fullname); + form.setValue("username", details?.username); + form.setValue("phoneNumber", details?.phoneNumber); + // form.setValue("nrp", details?.memberIdentity); + // form.setValue("address", details?.address); + form.setValue("email", details?.email); + form.setValue("role", details?.role?.code); + // form.setValue("level", String(details?.userLevelId)); + // form.setValue("name", details?.accountName); + // form.setValue("fullname", details?.fullname); + // form.setValue("email", details?.email); + // form.setValue("phoneNumber", details?.phoneNumber); + // form.setValue("whatsapp", details?.whatsappNumber); + // form.setValue("accountCategory", details?.accountCategory); + // form.setValue("accountType", details?.accountType.split(",")); } getDetailData(); @@ -106,7 +134,7 @@ export default function EditAccountForBroadcast() { confirmButtonText: "OK", }).then((result) => { if (result.isConfirmed) { - router.push("/admin/broadcast/campaign-list/account-list"); + router.push("/admin/broadcast/campaign-list"); } }); } @@ -114,15 +142,24 @@ export default function EditAccountForBroadcast() { const save = async (data: z.infer) => { const reqData = { id: String(id), - accountName: data.name, - accountType: data.accountType.join(","), - accountCategory: data.accountCategory, - emailAddress: data.email, - whatsappNumber: data.whatsapp, + // accountName: data.fullname, + // accountType: data.accountType.join(","), + // accountCategory: data.accountCategory, + // emailAddress: data.email, + phoneNumber: data.phoneNumber, + firstName: data.fullname, + username: data.username, + roleId: data.role, + // userLevelId: Number(data.level), + // memberIdentity: data.nrp, + // address: data.address, + email: data.email, + isDefault: false, + isAdmin: true, }; // console.log("data", data); - const response = await saveMediaBlastAccount(reqData); + const response = await saveUserInternal(reqData); if (response?.error) { error(response.message); return false; @@ -141,7 +178,7 @@ export default function EditAccountForBroadcast() {

Account

( Nama @@ -155,7 +192,7 @@ export default function EditAccountForBroadcast() { )} /> - ( @@ -227,8 +264,8 @@ export default function EditAccountForBroadcast() { )} - /> - */} + {/* ( @@ -269,13 +306,13 @@ export default function EditAccountForBroadcast() { )} - /> + /> */} ( - Nama + Email ( - Nama + Nomor Whatsapp diff --git a/app/[locale]/(protected)/admin/broadcast/campaign-list/component/column.tsx b/app/[locale]/(protected)/admin/broadcast/campaign-list/component/column.tsx index 51184795..2a8596f6 100644 --- a/app/[locale]/(protected)/admin/broadcast/campaign-list/component/column.tsx +++ b/app/[locale]/(protected)/admin/broadcast/campaign-list/component/column.tsx @@ -11,7 +11,6 @@ import { } from "@/components/ui/dropdown-menu"; import { Button } from "@/components/ui/button"; import { Badge } from "@/components/ui/badge"; - import { Link, useRouter } from "@/i18n/routing"; import { close, error, loading, success } from "@/config/swal"; import { deleteMediaBlastCampaign } from "@/service/broadcast/broadcast"; @@ -62,38 +61,47 @@ const columns: ColumnDef[] = [ { id: "actions", - accessorKey: "action", header: "Actions", - enableHiding: false, - cell: ({ row }) => { + cell: ({ row, onDeleteSuccess }: any) => { const MySwal = withReactContent(Swal); - const handleDelete = (id: any) => { + const handleDelete = (id: number) => { MySwal.fire({ title: "Apakah anda ingin menghapus data?", showCancelButton: true, confirmButtonColor: "#dc3545", confirmButtonText: "Iya", cancelButtonText: "Tidak", - }).then((result: any) => { + }).then((result) => { if (result.isConfirmed) { doDeleteAccount(id); } }); }; - async function doDeleteAccount(id: any) { + async function doDeleteAccount(id: number) { loading(); const response = await deleteMediaBlastCampaign(id); close(); + if (response.error) { error(response.message); return false; } - // success(); + console.log("Delete response:", response); + + MySwal.fire({ + icon: "success", + title: "Berhasil!", + text: "Data berhasil dihapus.", + confirmButtonColor: "#3085d6", + timer: 2000, + timerProgressBar: true, + }); + // ✅ panggil callback dari parent + onDeleteSuccess?.(id); } - return ( @@ -119,14 +127,99 @@ const columns: ColumnDef[] = [ Edit
- - Delete + handleDelete(row.original.id)} + className="p-2 border-b text-default-700 group focus:bg-default focus:text-primary-foreground rounded-none cursor-pointer" + > + Delete
); }, }, + + // { + // id: "actions", + // accessorKey: "action", + // header: "Actions", + // enableHiding: false, + // cell: ({ row, onDeleteSuccess }: any) => { + // const MySwal = withReactContent(Swal); + + // const handleDelete = (id: any) => { + // MySwal.fire({ + // title: "Apakah anda ingin menghapus data?", + // showCancelButton: true, + // confirmButtonColor: "#dc3545", + // confirmButtonText: "Iya", + // cancelButtonText: "Tidak", + // }).then((result: any) => { + // if (result.isConfirmed) { + // doDeleteAccount(id); + // } + // }); + // }; + + // async function doDeleteAccount(id: any) { + // loading(); + // const response = await deleteMediaBlastCampaign(id); + // close(); + + // if (response.error) { + // error(response.message); + // return false; + // } + // console.log("Delete response:", response); + + // MySwal.fire({ + // icon: "success", + // title: "Berhasil!", + // text: "Data berhasil dihapus.", + // confirmButtonColor: "#3085d6", + // timer: 2000, + // timerProgressBar: true, + // }); + // // ✅ langsung hapus dari state + // onDeleteSuccess?.(id); + // } + + // return ( + // + // + // + // + // + // + // + // Detail + // + // + // + // + // Edit + // + // + // handleDelete(row.original.id)} + // className="p-2 border-b text-default-700 group focus:bg-default focus:text-primary-foreground rounded-none cursor-pointer" + // > + // Delete + // + // + // + // ); + // }, + // }, ]; export default columns; diff --git a/app/[locale]/(protected)/admin/broadcast/campaign-list/component/table.tsx b/app/[locale]/(protected)/admin/broadcast/campaign-list/component/table.tsx index 06bccc62..1cdb3c71 100644 --- a/app/[locale]/(protected)/admin/broadcast/campaign-list/component/table.tsx +++ b/app/[locale]/(protected)/admin/broadcast/campaign-list/component/table.tsx @@ -89,6 +89,11 @@ const CampaignListTable = () => { const [page, setPage] = React.useState(1); const [totalPage, setTotalPage] = React.useState(1); + + function handleDeleteSuccess(id: number) { + setDataTable((prev) => prev.filter((item) => item.id !== id)); + } + const table = useReactTable({ data: dataTable, columns, @@ -189,7 +194,15 @@ const CampaignListTable = () => { > {row.getVisibleCells().map((cell) => ( - {flexRender(cell.column.columnDef.cell, cell.getContext())} + {/* {flexRender(cell.column.columnDef.cell, cell.getContext())} */} + {flexRender(cell.column.columnDef.cell, { + ...cell.getContext(), + onDeleteSuccess: (id: number) => { + setDataTable((prev) => + prev.filter((item) => item.id !== id) + ); + }, + })} ))} diff --git a/app/[locale]/(protected)/admin/management-user/internal/edit/[id]/page.tsx b/app/[locale]/(protected)/admin/management-user/internal/edit/[id]/page.tsx index d38a34ff..2bd2e459 100644 --- a/app/[locale]/(protected)/admin/management-user/internal/edit/[id]/page.tsx +++ b/app/[locale]/(protected)/admin/management-user/internal/edit/[id]/page.tsx @@ -221,7 +221,6 @@ export default function EditUserForm() { form.setValue("level", String(res?.userLevelId)); } else { initFetch(); - // console.log("sadad", res?.role?.code); form.setValue("fullname", res?.fullname); form.setValue("username", res?.username); form.setValue("phoneNumber", res?.phoneNumber); diff --git a/app/[locale]/(protected)/admin/settings/category/component/status.tsx b/app/[locale]/(protected)/admin/settings/category/component/status.tsx index f682348e..4700c209 100644 --- a/app/[locale]/(protected)/admin/settings/category/component/status.tsx +++ b/app/[locale]/(protected)/admin/settings/category/component/status.tsx @@ -10,15 +10,34 @@ export default function StatusToogle(props: { }) { const { id, initValue } = props; const router = useRouter(); + // const publishCategory = async (id: number, status: string) => { + // const response = await publishUnpublishCategory(id, status); + // console.log(response); + // if (response?.error) { + // error(response.message); + // return false; + // } + // router.push("/admin/settings/category?dataChange=true"); + // }; const publishCategory = async (id: number, status: string) => { const response = await publishUnpublishCategory(id, status); - // console.log(response); + console.log("API Response:", response); + + // cek error interceptor if (response?.error) { - error(response.message); + error(response.message || "Terjadi kesalahan"); return false; } + + // cek flag success asli dari backend + if (response?.data?.success === false) { + error(response?.data?.message || "Terjadi kesalahan"); + return false; + } + router.push("/admin/settings/category?dataChange=true"); }; + return ( + ); +} diff --git a/app/[locale]/(public)/regional/all-polda/document/all/page.tsx b/app/[locale]/(public)/regional/all-polda/document/all/page.tsx new file mode 100644 index 00000000..a56e2e67 --- /dev/null +++ b/app/[locale]/(public)/regional/all-polda/document/all/page.tsx @@ -0,0 +1,186 @@ +import AllContentPage from "@/components/landing-page/all-content-page"; + +const regions = [ + { name: "Polda Aceh", slug: "aceh", logo: "/logo/polda/polda-aceh.png" }, + { name: "Polda Bali", slug: "bali", logo: "/logo/polda/polda-bali.png" }, + { + name: "Polda Bangka Belitung", + slug: "bangka-belitung", + logo: "/logo/polda/polda-bangka-belitung.png", + }, + { + name: "Polda Banten", + slug: "banten", + logo: "/logo/polda/polda-banten.png", + }, + { + name: "Polda Bengkulu", + slug: "bengkulu", + logo: "/logo/polda/polda-bengkulu.png", + }, + { + name: "Polda DIY", + slug: "jogja", + logo: "/logo/polda/polda-jogja.png", + }, + { + name: "Polda Gorontalo", + slug: "gorontalo", + logo: "/logo/polda/polda-gorontalo.png", + }, + { name: "Polda Jambi", slug: "jambi", logo: "/logo/polda/polda-jambi.png" }, + { + name: "Polda Jawa Barat", + slug: "jawa-barat", + logo: "/logo/polda/polda-jawa-barat.png", + }, + { + name: "Polda Jawa Tengah", + slug: "jawa-tengah", + logo: "/logo/polda/polda-jawa-tengah.png", + }, + { + name: "Polda Jawa Timur", + slug: "jawa-timur", + logo: "/logo/polda/polda-jawa-timur.png", + }, + { + name: "Polda Kalimantan Barat", + slug: "kalimantan-barat", + logo: "/logo/polda/polda-kalimantan-barat.png", + }, + { + name: "Polda Kalimantan Selatan", + slug: "kalimantan-selatan", + logo: "/logo/polda/polda-kalimantan-selatan.png", + }, + { + name: "Polda Kalimantan Tengah", + slug: "kalimantan-tengah", + logo: "/logo/polda/polda-kalimantan-tengah.png", + }, + { + name: "Polda Kalimantan Timur", + slug: "kalimantan-timur", + logo: "/logo/polda/polda-kalimantan-timur.png", + }, + { + name: "Polda Kalimantan Utara", + slug: "kalimantan-utara", + logo: "/logo/polda/polda-kalimantan-utara.png", + }, + { + name: "Polda Kepulauan Riau", + slug: "kepulauan-riau", + logo: "/logo/polda/polda-kepulauan-riau.png", + }, + { + name: "Polda Lampung", + slug: "lampung", + logo: "/logo/polda/polda-lampung.png", + }, + { + name: "Polda Maluku", + slug: "maluku", + logo: "/logo/polda/polda-maluku.png", + }, + { + name: "Polda Maluku Utara", + slug: "maluku-utara", + logo: "/logo/polda/polda-maluku-utara.png", + }, + { + name: "Polda Metro Jaya", + slug: "metro-jaya", + logo: "/logo/polda/polda-metro-jaya.png", + }, + { + name: "Polda NTB", + slug: "ntb", + logo: "/logo/polda/polda-ntb.png", + }, + { + name: "Polda NTT", + slug: "ntt", + logo: "/logo/polda/polda-ntt.png", + }, + { name: "Polda Papua", slug: "papua", logo: "/logo/polda/polda-papua.png" }, + { + name: "Polda Papua Barat", + slug: "papua-barat", + logo: "/logo/polda/polda-papua-barat.png", + }, + { + name: "Polda Papua Barat Daya", + slug: "papua-barat-daya", + logo: "/logo/polda/polda-papua-barat-daya.png", + }, + { + name: "Polda Papua Tengah", + slug: "papua-tengah", + logo: "/logo/polda/polda-papua-tengah.png", + }, + { name: "Polda Riau", slug: "riau", logo: "/logo/polda/polda-riau.png" }, + { + name: "Polda Sulawesi Barat", + slug: "sulawesi-barat", + logo: "/logo/polda/polda-sulawesi-barat.png", + }, + { + name: "Polda Sulawesi Selatan", + slug: "sulawesi-selatan", + logo: "/logo/polda/polda-sulawesi-selatan.png", + }, + { + name: "Polda Sulawesi Tengah", + slug: "sulawesi-tengah", + logo: "/logo/polda/polda-sulawesi-tengah.png", + }, + { + name: "Polda Sulawesi Tenggara", + slug: "sulawesi-tenggara", + logo: "/logo/polda/polda-sulawesi-tenggara.png", + }, + { + name: "Polda Sulawesi Utara", + slug: "sulawesi-utara", + logo: "/logo/polda/polda-sulawesi-utara.png", + }, + { + name: "Polda Sumatera Barat", + slug: "sumatera-barat", + logo: "/logo/polda/polda-sumatera-barat.png", + }, + { + name: "Polda Sumatera Selatan", + slug: "sumatera-selatan", + logo: "/logo/polda/polda-sumatera-selatan.png", + }, + { + name: "Polda Sumatera Utara", + slug: "sumatera-utara", + logo: "/logo/polda/polda-sumatera-utara.png", + }, + // { + // name: "Satuan Kerja POLRI", + // slug: "satker-polri", + // logo: "/logo/satker/SATUAN-KERJA-POLRI.png", + // }, + // { + // name: "Internasional", + // slug: "internasional", + // logo: "/assets/polda/internasional.png", + // }, +]; + +export default function PoldaAllDocumentPage() { + return ( + + ); +} diff --git a/app/[locale]/(public)/regional/all-polda/image/all/page.tsx b/app/[locale]/(public)/regional/all-polda/image/all/page.tsx new file mode 100644 index 00000000..f00cceca --- /dev/null +++ b/app/[locale]/(public)/regional/all-polda/image/all/page.tsx @@ -0,0 +1,186 @@ +import AllContentPage from "@/components/landing-page/all-content-page"; + +const regions = [ + { name: "Polda Aceh", slug: "aceh", logo: "/logo/polda/polda-aceh.png" }, + { name: "Polda Bali", slug: "bali", logo: "/logo/polda/polda-bali.png" }, + { + name: "Polda Bangka Belitung", + slug: "bangka-belitung", + logo: "/logo/polda/polda-bangka-belitung.png", + }, + { + name: "Polda Banten", + slug: "banten", + logo: "/logo/polda/polda-banten.png", + }, + { + name: "Polda Bengkulu", + slug: "bengkulu", + logo: "/logo/polda/polda-bengkulu.png", + }, + { + name: "Polda DIY", + slug: "jogja", + logo: "/logo/polda/polda-jogja.png", + }, + { + name: "Polda Gorontalo", + slug: "gorontalo", + logo: "/logo/polda/polda-gorontalo.png", + }, + { name: "Polda Jambi", slug: "jambi", logo: "/logo/polda/polda-jambi.png" }, + { + name: "Polda Jawa Barat", + slug: "jawa-barat", + logo: "/logo/polda/polda-jawa-barat.png", + }, + { + name: "Polda Jawa Tengah", + slug: "jawa-tengah", + logo: "/logo/polda/polda-jawa-tengah.png", + }, + { + name: "Polda Jawa Timur", + slug: "jawa-timur", + logo: "/logo/polda/polda-jawa-timur.png", + }, + { + name: "Polda Kalimantan Barat", + slug: "kalimantan-barat", + logo: "/logo/polda/polda-kalimantan-barat.png", + }, + { + name: "Polda Kalimantan Selatan", + slug: "kalimantan-selatan", + logo: "/logo/polda/polda-kalimantan-selatan.png", + }, + { + name: "Polda Kalimantan Tengah", + slug: "kalimantan-tengah", + logo: "/logo/polda/polda-kalimantan-tengah.png", + }, + { + name: "Polda Kalimantan Timur", + slug: "kalimantan-timur", + logo: "/logo/polda/polda-kalimantan-timur.png", + }, + { + name: "Polda Kalimantan Utara", + slug: "kalimantan-utara", + logo: "/logo/polda/polda-kalimantan-utara.png", + }, + { + name: "Polda Kepulauan Riau", + slug: "kepulauan-riau", + logo: "/logo/polda/polda-kepulauan-riau.png", + }, + { + name: "Polda Lampung", + slug: "lampung", + logo: "/logo/polda/polda-lampung.png", + }, + { + name: "Polda Maluku", + slug: "maluku", + logo: "/logo/polda/polda-maluku.png", + }, + { + name: "Polda Maluku Utara", + slug: "maluku-utara", + logo: "/logo/polda/polda-maluku-utara.png", + }, + { + name: "Polda Metro Jaya", + slug: "metro-jaya", + logo: "/logo/polda/polda-metro-jaya.png", + }, + { + name: "Polda NTB", + slug: "ntb", + logo: "/logo/polda/polda-ntb.png", + }, + { + name: "Polda NTT", + slug: "ntt", + logo: "/logo/polda/polda-ntt.png", + }, + { name: "Polda Papua", slug: "papua", logo: "/logo/polda/polda-papua.png" }, + { + name: "Polda Papua Barat", + slug: "papua-barat", + logo: "/logo/polda/polda-papua-barat.png", + }, + { + name: "Polda Papua Barat Daya", + slug: "papua-barat-daya", + logo: "/logo/polda/polda-papua-barat-daya.png", + }, + { + name: "Polda Papua Tengah", + slug: "papua-tengah", + logo: "/logo/polda/polda-papua-tengah.png", + }, + { name: "Polda Riau", slug: "riau", logo: "/logo/polda/polda-riau.png" }, + { + name: "Polda Sulawesi Barat", + slug: "sulawesi-barat", + logo: "/logo/polda/polda-sulawesi-barat.png", + }, + { + name: "Polda Sulawesi Selatan", + slug: "sulawesi-selatan", + logo: "/logo/polda/polda-sulawesi-selatan.png", + }, + { + name: "Polda Sulawesi Tengah", + slug: "sulawesi-tengah", + logo: "/logo/polda/polda-sulawesi-tengah.png", + }, + { + name: "Polda Sulawesi Tenggara", + slug: "sulawesi-tenggara", + logo: "/logo/polda/polda-sulawesi-tenggara.png", + }, + { + name: "Polda Sulawesi Utara", + slug: "sulawesi-utara", + logo: "/logo/polda/polda-sulawesi-utara.png", + }, + { + name: "Polda Sumatera Barat", + slug: "sumatera-barat", + logo: "/logo/polda/polda-sumatera-barat.png", + }, + { + name: "Polda Sumatera Selatan", + slug: "sumatera-selatan", + logo: "/logo/polda/polda-sumatera-selatan.png", + }, + { + name: "Polda Sumatera Utara", + slug: "sumatera-utara", + logo: "/logo/polda/polda-sumatera-utara.png", + }, + // { + // name: "Satuan Kerja POLRI", + // slug: "satker-polri", + // logo: "/logo/satker/SATUAN-KERJA-POLRI.png", + // }, + // { + // name: "Internasional", + // slug: "internasional", + // logo: "/assets/polda/internasional.png", + // }, +]; + +export default function PoldaAllImagePage() { + return ( + + ); +} diff --git a/app/[locale]/(public)/regional/all-polda/video/all/page.tsx b/app/[locale]/(public)/regional/all-polda/video/all/page.tsx new file mode 100644 index 00000000..c39b75c7 --- /dev/null +++ b/app/[locale]/(public)/regional/all-polda/video/all/page.tsx @@ -0,0 +1,186 @@ +import AllContentPage from "@/components/landing-page/all-content-page"; + +const regions = [ + { name: "Polda Aceh", slug: "aceh", logo: "/logo/polda/polda-aceh.png" }, + { name: "Polda Bali", slug: "bali", logo: "/logo/polda/polda-bali.png" }, + { + name: "Polda Bangka Belitung", + slug: "bangka-belitung", + logo: "/logo/polda/polda-bangka-belitung.png", + }, + { + name: "Polda Banten", + slug: "banten", + logo: "/logo/polda/polda-banten.png", + }, + { + name: "Polda Bengkulu", + slug: "bengkulu", + logo: "/logo/polda/polda-bengkulu.png", + }, + { + name: "Polda DIY", + slug: "jogja", + logo: "/logo/polda/polda-jogja.png", + }, + { + name: "Polda Gorontalo", + slug: "gorontalo", + logo: "/logo/polda/polda-gorontalo.png", + }, + { name: "Polda Jambi", slug: "jambi", logo: "/logo/polda/polda-jambi.png" }, + { + name: "Polda Jawa Barat", + slug: "jawa-barat", + logo: "/logo/polda/polda-jawa-barat.png", + }, + { + name: "Polda Jawa Tengah", + slug: "jawa-tengah", + logo: "/logo/polda/polda-jawa-tengah.png", + }, + { + name: "Polda Jawa Timur", + slug: "jawa-timur", + logo: "/logo/polda/polda-jawa-timur.png", + }, + { + name: "Polda Kalimantan Barat", + slug: "kalimantan-barat", + logo: "/logo/polda/polda-kalimantan-barat.png", + }, + { + name: "Polda Kalimantan Selatan", + slug: "kalimantan-selatan", + logo: "/logo/polda/polda-kalimantan-selatan.png", + }, + { + name: "Polda Kalimantan Tengah", + slug: "kalimantan-tengah", + logo: "/logo/polda/polda-kalimantan-tengah.png", + }, + { + name: "Polda Kalimantan Timur", + slug: "kalimantan-timur", + logo: "/logo/polda/polda-kalimantan-timur.png", + }, + { + name: "Polda Kalimantan Utara", + slug: "kalimantan-utara", + logo: "/logo/polda/polda-kalimantan-utara.png", + }, + { + name: "Polda Kepulauan Riau", + slug: "kepulauan-riau", + logo: "/logo/polda/polda-kepulauan-riau.png", + }, + { + name: "Polda Lampung", + slug: "lampung", + logo: "/logo/polda/polda-lampung.png", + }, + { + name: "Polda Maluku", + slug: "maluku", + logo: "/logo/polda/polda-maluku.png", + }, + { + name: "Polda Maluku Utara", + slug: "maluku-utara", + logo: "/logo/polda/polda-maluku-utara.png", + }, + { + name: "Polda Metro Jaya", + slug: "metro-jaya", + logo: "/logo/polda/polda-metro-jaya.png", + }, + { + name: "Polda NTB", + slug: "ntb", + logo: "/logo/polda/polda-ntb.png", + }, + { + name: "Polda NTT", + slug: "ntt", + logo: "/logo/polda/polda-ntt.png", + }, + { name: "Polda Papua", slug: "papua", logo: "/logo/polda/polda-papua.png" }, + { + name: "Polda Papua Barat", + slug: "papua-barat", + logo: "/logo/polda/polda-papua-barat.png", + }, + { + name: "Polda Papua Barat Daya", + slug: "papua-barat-daya", + logo: "/logo/polda/polda-papua-barat-daya.png", + }, + { + name: "Polda Papua Tengah", + slug: "papua-tengah", + logo: "/logo/polda/polda-papua-tengah.png", + }, + { name: "Polda Riau", slug: "riau", logo: "/logo/polda/polda-riau.png" }, + { + name: "Polda Sulawesi Barat", + slug: "sulawesi-barat", + logo: "/logo/polda/polda-sulawesi-barat.png", + }, + { + name: "Polda Sulawesi Selatan", + slug: "sulawesi-selatan", + logo: "/logo/polda/polda-sulawesi-selatan.png", + }, + { + name: "Polda Sulawesi Tengah", + slug: "sulawesi-tengah", + logo: "/logo/polda/polda-sulawesi-tengah.png", + }, + { + name: "Polda Sulawesi Tenggara", + slug: "sulawesi-tenggara", + logo: "/logo/polda/polda-sulawesi-tenggara.png", + }, + { + name: "Polda Sulawesi Utara", + slug: "sulawesi-utara", + logo: "/logo/polda/polda-sulawesi-utara.png", + }, + { + name: "Polda Sumatera Barat", + slug: "sumatera-barat", + logo: "/logo/polda/polda-sumatera-barat.png", + }, + { + name: "Polda Sumatera Selatan", + slug: "sumatera-selatan", + logo: "/logo/polda/polda-sumatera-selatan.png", + }, + { + name: "Polda Sumatera Utara", + slug: "sumatera-utara", + logo: "/logo/polda/polda-sumatera-utara.png", + }, + // { + // name: "Satuan Kerja POLRI", + // slug: "satker-polri", + // logo: "/logo/satker/SATUAN-KERJA-POLRI.png", + // }, + // { + // name: "Internasional", + // slug: "internasional", + // logo: "/assets/polda/internasional.png", + // }, +]; + +export default function PoldaAllVideoPage() { + return ( + + ); +} diff --git a/components/form/content/image-form.tsx b/components/form/content/image-form.tsx index fa815a86..45355491 100644 --- a/components/form/content/image-form.tsx +++ b/components/form/content/image-form.tsx @@ -451,6 +451,7 @@ export default function FormImage() { "" ); const articleImagesData = articleData?.imagesUrl?.split(","); + setArticleBody(cleanArticleBody || ""); setValue("description", cleanArticleBody || ""); setDetailData(articleData); setSelectedArticleId(id); @@ -1738,7 +1739,7 @@ export default function FormImage() { {/* */} - {levelNumber !== "2" && levelNumber !== "3" && ( + {levelNumber !== "2" && ( diff --git a/components/form/content/spit-convert-form.tsx b/components/form/content/spit-convert-form.tsx index 50ca5c50..842338fa 100644 --- a/components/form/content/spit-convert-form.tsx +++ b/components/form/content/spit-convert-form.tsx @@ -7,8 +7,6 @@ import { useParams, useRouter } from "next/navigation"; import { useTranslations } from "next-intl"; import dynamic from "next/dynamic"; import Cookies from "js-cookie"; - -// UI Components import { Input } from "@/components/ui/input"; import { Button } from "@/components/ui/button"; import { Label } from "@/components/ui/label"; @@ -26,8 +24,6 @@ import { } from "@/components/ui/select"; import { Checkbox } from "@/components/ui/checkbox"; import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"; - -// Icons import { AlertCircle, FileText, @@ -44,8 +40,6 @@ import { CheckCircle, XCircle, } from "lucide-react"; - -// Swiper import { Swiper, SwiperSlide } from "swiper/react"; import { Swiper as SwiperType } from "swiper"; import "swiper/css"; @@ -54,8 +48,6 @@ import "swiper/css/navigation"; import "swiper/css/pagination"; import "swiper/css/thumbs"; import { FreeMode, Navigation, Pagination, Thumbs } from "swiper/modules"; - -// Services import { convertSPIT, deleteSPIT, @@ -64,15 +56,12 @@ import { listEnableCategory, } from "@/service/content/content"; import { generateDataRewrite, getDetailArticle } from "@/service/content/ai"; - -// Utils import { getCookiesDecrypt } from "@/lib/utils"; import { error } from "@/lib/swal"; import Swal from "sweetalert2"; import withReactContent from "sweetalert2-react-content"; import { close, loading } from "@/config/swal"; -// Types interface Category { id: number; name: string; @@ -289,9 +278,7 @@ export default function FormConvertSPIT() { try { const response = await getTagsBySubCategoryId(categoryId); if (response?.data?.data?.length > 0) { - // Extract tag names from the response objects const apiTags = response?.data?.data?.map((tag: any) => tag.tagName); - // Merge with existing tags, ensuring uniqueness const tagsMerge = Array.from(new Set([...tags, ...apiTags])); setTags(tagsMerge); } @@ -313,7 +300,6 @@ export default function FormConvertSPIT() { setDetail(details); - // <-- use API contentList objects directly --> const contentList: FileType[] = (details.contentList || []).map( (it: any) => ({ contentId: it.contentId, @@ -329,11 +315,9 @@ export default function FormConvertSPIT() { setFiles(contentList); setDetailThumb(contentList); - // Initialize file placements const fileCount = contentList.length || 0; setFilePlacements(Array(fileCount).fill([])); - // Set form values setValue("contentTitle", details.contentTitle || ""); setValue("contentDescription", details.contentDescription || ""); setValue("contentCreator", details.contentCreator || ""); @@ -342,16 +326,16 @@ export default function FormConvertSPIT() { (details as any).contentRewriteDescription || "" ); - // Set category and load category tags if (details.categoryId) { setSelectedCategoryId(details.categoryId); await loadTags(details.categoryId); } - // Set content tags and merge with category tags if (details.contentTag) { - const contentTags = details.contentTag.split(",").map((tag: string) => tag.trim()); - setTags(prev => Array.from(new Set([...prev, ...contentTags]))); + const contentTags = details.contentTag + .split(",") + .map((tag: string) => tag.trim()); + setTags((prev) => Array.from(new Set([...prev, ...contentTags]))); } } catch (error) { console.error("Failed to load detail:", error); @@ -552,14 +536,24 @@ export default function FormConvertSPIT() { ); }; - const getPlacementData = () => { + const getPlacementData = (type: string) => { const placementData: PlacementData[] = []; - for (let i = 0; i < filePlacements.length; i++) { - if (filePlacements[i].length > 0) { - const placements = filePlacements[i]; + if (type == "mabes") { + for (let i = 0; i < filePlacements.length; i++) { + if (filePlacements[i].length > 0) { + const placements = filePlacements[i]; + placementData.push({ + mediaFileId: files[i].contentId, + placements: placements.join(","), + }); + } + } + } else { + for (let i = 0; i < files.length; i++) { + placementData.push({ mediaFileId: files[i].contentId, - placements: placements.join(","), + placements: "polda", }); } } @@ -578,7 +572,6 @@ export default function FormConvertSPIT() { return temp; }; - // Form submission const onSubmit = async (data: FormData) => { const pnmhTags = tags.filter((tag) => tag.toLowerCase().includes("pnmh")); @@ -624,7 +617,9 @@ export default function FormConvertSPIT() { categoryId: selectedCategoryId, publishedFor: publishedFor.join(","), creator: data.contentCreator, - files: isUserMabesApprover ? getPlacementData() : [], + files: isUserMabesApprover + ? getPlacementData("mabes") + : getPlacementData("polda"), }; await convertSPIT(requestData); @@ -978,7 +973,10 @@ export default function FormConvertSPIT() { centeredSlides={true} > {detailThumb.map((item) => ( - + {item.contentType === "VIDEO" ? (
@@ -1000,10 +998,13 @@ export default function FormConvertSPIT() { src={item.contentFile} alt={`Media ${item.contentId}`} className="max-w-full max-h-full object-contain rounded-lg" - style={{ maxWidth: '100%', maxHeight: '100%' }} + style={{ + maxWidth: "100%", + maxHeight: "100%", + }} onError={(e) => { - console.error('Image load error:', e); - e.currentTarget.style.display = 'none'; + console.error("Image load error:", e); + e.currentTarget.style.display = "none"; }} /> @@ -1047,7 +1048,10 @@ export default function FormConvertSPIT() { preventClicksPropagation={false} > {detailThumb.map((item) => ( - + {item.contentType === "VIDEO" ? (
{/* use preload metadata so browser doesn't download full video */} @@ -1059,8 +1063,11 @@ export default function FormConvertSPIT() { playsInline tabIndex={-1} onError={(e) => { - console.error('Thumbnail video load error:', e); - e.currentTarget.style.display = 'none'; + console.error( + "Thumbnail video load error:", + e + ); + e.currentTarget.style.display = "none"; }} />
@@ -1081,8 +1088,11 @@ export default function FormConvertSPIT() { alt={`Thumbnail ${item.contentId}`} className="w-full h-full object-cover" onError={(e) => { - console.error('Thumbnail image load error:', e); - e.currentTarget.style.display = 'none'; + console.error( + "Thumbnail image load error:", + e + ); + e.currentTarget.style.display = "none"; }} />
@@ -1138,7 +1148,6 @@ export default function FormConvertSPIT() { key={file.contentId} className="flex gap-4 p-4 border rounded-lg" > - {/* show thumbnail or video preview */} {file.contentType === "VIDEO" ? (