diff --git a/app/[locale]/(protected)/contributor/agenda-setting/calender-view.tsx b/app/[locale]/(protected)/contributor/agenda-setting/calender-view.tsx index 851d9a9b..00ba5260 100644 --- a/app/[locale]/(protected)/contributor/agenda-setting/calender-view.tsx +++ b/app/[locale]/(protected)/contributor/agenda-setting/calender-view.tsx @@ -244,21 +244,23 @@ const CalendarView = ({ categories }: CalendarViewProps) => { return ( <> -

{title}

-

Create By: {createdByName}

+

{title}

+

+ Create By: {createdByName} +

); }; const handleClassName = (arg: EventContentArg) => { if (arg.event.extendedProps.calendar === "mabes") { - return "primary"; + return "bg-yellow-500 border-none"; } else if (arg.event.extendedProps.calendar === "polda") { - return "success"; + return "bg-blue-400 border-none"; } else if (arg.event.extendedProps.calendar === "polres") { - return "destructive"; + return "bg-slate-400 border-none"; } else if (arg.event.extendedProps.calendar === "international") { - return "info"; + return "bg-green-400 border-none"; } else { return "primary"; } diff --git a/app/[locale]/(protected)/contributor/content/audio/components/columns.tsx b/app/[locale]/(protected)/contributor/content/audio/components/columns.tsx index 0141d66d..01386b47 100644 --- a/app/[locale]/(protected)/contributor/content/audio/components/columns.tsx +++ b/app/[locale]/(protected)/contributor/content/audio/components/columns.tsx @@ -153,7 +153,7 @@ const columns: ColumnDef[] = [ View - + Edit diff --git a/app/[locale]/(protected)/contributor/content/image/components/table-image.tsx b/app/[locale]/(protected)/contributor/content/image/components/table-image.tsx index 0e0c52e7..95f2522f 100644 --- a/app/[locale]/(protected)/contributor/content/image/components/table-image.tsx +++ b/app/[locale]/(protected)/contributor/content/image/components/table-image.tsx @@ -26,6 +26,7 @@ import { } from "@/components/ui/table"; import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; import { + ChevronDown, ChevronLeft, ChevronRight, Eye, @@ -39,6 +40,7 @@ import { import { cn, getCookiesDecrypt } from "@/lib/utils"; import { DropdownMenu, + DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, @@ -176,7 +178,7 @@ const TableImage = () => { /> -
+
{ } className="max-w-sm " /> +
+ + + + + + {table + .getAllColumns() + .filter((column) => column.getCanHide()) + .map((column) => { + return ( + + column.toggleVisibility(!!value) + } + > + {column.id} + + ); + })} + + +
diff --git a/components/form/content/audio-detail-form.tsx b/components/form/content/audio-detail-form.tsx index ecd07ab4..952611d6 100644 --- a/components/form/content/audio-detail-form.tsx +++ b/components/form/content/audio-detail-form.tsx @@ -55,6 +55,7 @@ import { getCookiesDecrypt } from "@/lib/utils"; import { Icon } from "@iconify/react/dist/iconify.js"; import { error } from "@/lib/swal"; import dynamic from "next/dynamic"; +import ReactAudioPlayer from "react-audio-player"; const imageSchema = z.object({ title: z.string().min(1, { message: "Judul diperlukan" }), @@ -137,6 +138,7 @@ export default function FormAudioDetail() { const [files, setFiles] = useState([]); const [rejectedFiles, setRejectedFiles] = useState([]); const [isMabesApprover, setIsMabesApprover] = useState(false); + const [audioPlaying, setAudioPlaying] = useState(null); let fileTypeId = "4"; @@ -336,6 +338,14 @@ export default function FormAudioDetail() { return false; }; + const handleAudioPlayPause = (audioSrc: string) => { + if (audioPlaying === audioSrc) { + setAudioPlaying(null); // Pause if the same audio is clicked + } else { + setAudioPlaying(audioSrc); // Play the new audio + } + }; + const submitApprovalSuccesss = () => { MySwal.fire({ title: "Sukses", @@ -427,30 +437,23 @@ export default function FormAudioDetail() { className="w-full" > {detailThumb?.map((data: any) => { - const isAudio = - data.endsWith(".webm") || - data.endsWith(".mp3") || - data.endsWith(".ogg"); return ( - {isAudio ? ( - ); })} -
+ + {/*
{detailThumb?.map((data: any) => { - const isAudio = - data.endsWith(".webm") || - data.endsWith(".mp3") || - data.endsWith(".ogg"); return ( - {isAudio ? ( - ); })} -
+
*/} diff --git a/components/form/content/audio-form.tsx b/components/form/content/audio-form.tsx index 32e3c1bc..4e1983d9 100644 --- a/components/form/content/audio-form.tsx +++ b/components/form/content/audio-form.tsx @@ -53,15 +53,6 @@ import { error, loading } from "@/config/swal"; import { Item } from "@radix-ui/react-dropdown-menu"; import dynamic from "next/dynamic"; -const imageSchema = z.object({ - title: z.string().min(1, { message: "Judul diperlukan" }), - description: z - .string() - .min(2, { message: "Narasi Penugasan harus lebih dari 2 karakter." }), - creatorName: z.string().min(1, { message: "Creator diperlukan" }), - // tags: z.string().min(1, { message: "Judul diperlukan" }), -}); - interface FileWithPreview extends File { preview: string; } @@ -87,7 +78,7 @@ export default function FormAudio() { const MySwal = withReactContent(Swal); const router = useRouter(); const editor = useRef(null); - type ImageSchema = z.infer; + type AudioSchema = z.infer; const [selectedFiles, setSelectedFiles] = useState([]); const taskId = Cookies.get("taskId"); @@ -155,13 +146,28 @@ export default function FormAudio() { }, }); + const audioSchema = z.object({ + title: z.string().min(1, { message: "Judul diperlukan" }), + description: z + .string() + .min(2, { message: "Narasi Penugasan harus lebih dari 2 karakter." }) + .or( + z.literal(articleBody || "").refine((val) => val.length > 0, { + message: "Deskripsi diperlukan.", + }) + ), + creatorName: z.string().min(1, { message: "Creator diperlukan" }), + // tags: z.string().min(1, { message: "Judul diperlukan" }), + }); + const { control, handleSubmit, + getValues, setValue, formState: { errors }, - } = useForm({ - resolver: zodResolver(imageSchema), + } = useForm({ + resolver: zodResolver(audioSchema), }); const doGenerateMainKeyword = async () => { @@ -424,15 +430,21 @@ export default function FormAudio() { } }; - const save = async (data: ImageSchema) => { + const save = async (data: AudioSchema) => { loading(); const finalTags = tags.join(", "); const finalTitle = isSwitchOn ? title : data.title; + const finalDescription = articleBody || data.description; + if (!finalDescription.trim()) { + MySwal.fire("Error", "Deskripsi tidak boleh kosong.", "error"); + return; + } + const requestData = { ...data, title: finalTitle, - description: data.description, - htmlDescription: data.description, + description: finalDescription, + htmlDescription: finalDescription, fileTypeId, categoryId: selectedCategory, subCategoryId: selectedCategory, @@ -489,7 +501,7 @@ export default function FormAudio() { // MySwal.fire("Sukses", "Data berhasil disimpan.", "success"); }; - const onSubmit = (data: ImageSchema) => { + const onSubmit = (data: AudioSchema) => { MySwal.fire({ title: "Simpan Data", text: "Apakah Anda yakin ingin menyimpan data ini?", @@ -651,6 +663,13 @@ export default function FormAudio() { setFiles([]); }; + useEffect(() => { + // Jika input title kosong, isi dengan hasil generate title + if (!getValues("title") && title) { + setValue("title", title); + } + }, [title, getValues, setValue]); + return (
@@ -871,6 +890,7 @@ export default function FormAudio() { color="primary" onClick={handleGenerateArtikel} size="sm" + type="button" > Generate Article diff --git a/components/form/content/audio-update-form.tsx b/components/form/content/audio-update-form.tsx index f104309e..af65d77a 100644 --- a/components/form/content/audio-update-form.tsx +++ b/components/form/content/audio-update-form.tsx @@ -31,6 +31,9 @@ import { import { detailMedia } from "@/service/curated-content/curated-content"; import { Badge } from "@/components/ui/badge"; import { MailIcon } from "lucide-react"; +import { Swiper, SwiperSlide } from "swiper/react"; +import ReactAudioPlayer from "react-audio-player"; +import { FreeMode, Navigation, Thumbs } from "swiper/modules"; const imageSchema = z.object({ title: z.string().min(1, { message: "Judul diperlukan" }), @@ -81,7 +84,8 @@ export default function FormAudioUpdate() { const [detail, setDetail] = useState(); const [refresh, setRefresh] = useState(false); const [selectedPublishers, setSelectedPublishers] = useState([]); - + const [detailThumb, setDetailThumb] = useState([]); + const [thumbsSwiper, setThumbsSwiper] = useState(null); const [selectedTarget, setSelectedTarget] = useState(""); const [unitSelection, setUnitSelection] = useState({ allUnit: false, @@ -190,7 +194,13 @@ export default function FormAudioUpdate() { setSelectedTarget(matchingCategory.name); } - setSelectedTarget(details.categoryId); // Untuk dropdown + setSelectedTarget(details.categoryId); + + const filesData = details.files || []; + const fileUrls = filesData.map((file: { secondaryUrl: string }) => + file.secondaryUrl ? file.secondaryUrl : "default-image.jpg" + ); + setDetailThumb(fileUrls); } } initState(); @@ -251,7 +261,7 @@ export default function FormAudioUpdate() {
-

Form Konten Foto

+

Form Konten Audio

{/* Input Title */}
@@ -319,6 +329,63 @@ export default function FormAudioUpdate() {

)}
+ +
+ + {detailThumb?.map((data: any) => { + return ( + +
+ + {/* */} +
+
+ ); + })} +
+ + {/*
+ + {detailThumb?.map((data: any) => { + return ( + +
+ + +
+
+ ); + })} +
+
*/} +
diff --git a/components/form/content/image-form.tsx b/components/form/content/image-form.tsx index 8a172700..a9736127 100644 --- a/components/form/content/image-form.tsx +++ b/components/form/content/image-form.tsx @@ -55,15 +55,6 @@ import { data } from "jquery"; import { options } from "@fullcalendar/core/preact.js"; import dynamic from "next/dynamic"; -const imageSchema = z.object({ - title: z.string().min(1, { message: "Judul diperlukan" }), - description: z - .string() - .min(2, { message: "Narasi Penugasan harus lebih dari 2 karakter." }), - creatorName: z.string().min(1, { message: "Creator diperlukan" }), - // tags: z.string().min(1, { message: "Judul diperlukan" }), -}); - interface FileWithPreview extends File { preview: string; } @@ -161,9 +152,24 @@ export default function FormImage() { }, }); + const imageSchema = z.object({ + title: z.string().min(1, { message: "Judul diperlukan" }), + description: z + .string() + .min(2, { message: "Narasi Penugasan harus lebih dari 2 karakter." }) + .or( + z.literal(articleBody || "").refine((val) => val.length > 0, { + message: "Deskripsi diperlukan.", + }) + ), + creatorName: z.string().min(1, { message: "Creator diperlukan" }), + // tags: z.string().min(1, { message: "Judul diperlukan" }), + }); + const { control, handleSubmit, + getValues, setValue, formState: { errors }, } = useForm({ @@ -434,11 +440,16 @@ export default function FormImage() { loading(); const finalTags = tags.join(", "); const finalTitle = isSwitchOn ? title : data.title; + const finalDescription = articleBody || data.description; + if (!finalDescription.trim()) { + MySwal.fire("Error", "Deskripsi tidak boleh kosong.", "error"); + return; + } const requestData = { ...data, title: finalTitle, - description: data.description, - htmlDescription: data.description, + description: finalDescription, + htmlDescription: finalDescription, fileTypeId, categoryId: selectedCategory, subCategoryId: selectedCategory, @@ -662,6 +673,13 @@ export default function FormImage() { setFiles([]); }; + useEffect(() => { + // Jika input title kosong, isi dengan hasil generate title + if (!getValues("title") && title) { + setValue("title", title); + } + }, [title, getValues, setValue]); + return (
diff --git a/components/form/content/teks-detail-form.tsx b/components/form/content/teks-detail-form.tsx index b85527b5..9e26a5e3 100644 --- a/components/form/content/teks-detail-form.tsx +++ b/components/form/content/teks-detail-form.tsx @@ -243,9 +243,11 @@ export default function FormTeksDetail() { setSelectedTarget(details.categoryId); // Untuk dropdown const filesData = details.files || []; - const fileUrls = filesData.map((file: { url: string }) => - file.url ? file.url : "default-image.jpg" - ); + const fileUrls = filesData.map((file: any) => ({ + url: file.secondaryUrl || "default-image.jpg", + format: file.format, + fileName: file.fileName, + })); setDetailThumb(fileUrls); } } @@ -427,30 +429,42 @@ export default function FormTeksDetail() { navigation={false} className="w-full" > - {detailThumb?.map((data: any) => ( - + {detailThumb?.map((data: any, index: number) => ( + {[".jpg", ".jpeg", ".png", ".webp"].includes( data.format ) ? ( + // Menampilkan gambar {data.fileName} - ) : [".pdf", ".docx", ".txt"].includes(data.format) ? ( + ) : data.format === ".pdf" ? ( + // Menampilkan PDF menggunakan iframe