This commit is contained in:
hanif salafi 2025-09-13 13:34:11 +07:00
commit 5d4ea85934
7 changed files with 641 additions and 528 deletions

View File

@ -473,7 +473,7 @@ export default function DetailImage() {
className="object-fill h-full w-full rounded-md"
src={data.url}
controls
title={`Video ${data.id}`} // Mengganti alt dengan title
title={`Video ${data.id}`}
/>
</SwiperSlide>
))}

View File

@ -98,6 +98,12 @@ const QuestionsTable = (props: {
const [page, setPage] = React.useState(1);
const [totalPage, setTotalPage] = React.useState(1);
const [search, setSearch] = React.useState<string>("");
const [activeTab, setActiveTab] = React.useState<"publik" | "rutin">(
"publik"
);
const [reportType, setReportType] = React.useState<"general" | "routine">(
"general"
);
const roleId = getCookiesDecrypt("urie");
@ -136,13 +142,21 @@ const QuestionsTable = (props: {
}
}, [searchParams]);
// React.useEffect(() => {
// fetchData();
// setPagination({
// pageIndex: 0,
// pageSize: Number(showData),
// });
// }, [page, showData]);
// ✅ update useEffect, tambahin reportType supaya reload saat tab diganti
React.useEffect(() => {
fetchData();
setPagination({
pageIndex: 0,
pageSize: Number(showData),
});
}, [page, showData]);
}, [page, showData, reportType]);
let typingTimer: any;
const doneTypingInterval = 1500;
@ -160,6 +174,52 @@ const QuestionsTable = (props: {
fetchData();
}
// async function fetchData() {
// const typeNow =
// title === "comment"
// ? "1"
// : title === "facebook"
// ? "2"
// : title === "instagram"
// ? "3"
// : title === "x"
// ? "4"
// : title === "youtube"
// ? "5"
// : title === "emergency"
// ? "6"
// : title === "email"
// ? "7"
// : title === "inbox"
// ? "8"
// : title === "whatsapp"
// ? "9"
// : title === "tiktok"
// ? "10"
// : "";
// try {
// const res = await getQuestionPagination(
// search,
// page - 1,
// typeNow,
// showData
// );
// const data = res?.data?.data;
// const contentData = data?.page?.content;
// console.log("contentDatassss : ", data);
// contentData.forEach((item: any, index: number) => {
// item.no = (page - 1) * Number(showData) + index + 1;
// });
// setDataTable(contentData);
// props.statisticData(data?.statistic);
// setTotalData(data?.page?.totalElements);
// setTotalPage(data?.page?.totalPages);
// } catch (error) {
// console.error("Error fetching tasks:", error);
// }
// }
async function fetchData() {
const typeNow =
title === "comment"
@ -185,12 +245,15 @@ const QuestionsTable = (props: {
: "";
try {
// ⬇️ tambahan param khusus untuk emergency
const res = await getQuestionPagination(
search,
page - 1,
typeNow,
showData
showData,
title === "emergency" ? reportType : undefined
);
const data = res?.data?.data;
const contentData = data?.page?.content;
// console.log("contentDatassss : ", data);
@ -198,6 +261,7 @@ const QuestionsTable = (props: {
contentData.forEach((item: any, index: number) => {
item.no = (page - 1) * Number(showData) + index + 1;
});
setDataTable(contentData);
props.statisticData(data?.statistic);
setTotalData(data?.page?.totalElements);
@ -267,6 +331,23 @@ const QuestionsTable = (props: {
</DropdownMenuContent>
</DropdownMenu>
</div>
{title === "emergency" && (
<div className="flex gap-2 mt-4">
<Button
variant={reportType === "general" ? "default" : "outline"}
onClick={() => setReportType("general")}
>
Laporan Publik
</Button>
<Button
variant={reportType === "routine" ? "default" : "outline"}
onClick={() => setReportType("routine")}
>
Laporan Rutin
</Button>
</div>
)}
<Table className="overflow-hidden mt-3">
<TableHeader>
{table.getHeaderGroups().map((headerGroup) => (

View File

@ -80,7 +80,12 @@ export default function TicketingTable() {
async function fetchData() {
try {
const res = await ticketingPagination(search, pageSize, page - 1, mediaId == 'all' ? "" : mediaId as string);
const res = await ticketingPagination(
search,
pageSize,
page - 1,
mediaId == "all" ? "" : (mediaId as string)
);
const data = res?.data?.data;
const content = data?.content || [];
const mapped: Issue[] = content.map((it: any, idx: number) => ({
@ -413,7 +418,7 @@ export default function TicketingTable() {
<AvatarFallback>{src.short}</AvatarFallback>
</Avatar>
<div>
<div className="text-sm font-medium">
{/* <div className="text-sm font-medium">
{(it.title ?? "")
.split(" ")
.slice(0, 25)
@ -421,6 +426,11 @@ export default function TicketingTable() {
((it.title ?? "").split(" ").length > 25
? "..."
: "")}
</div> */}
<div className="text-sm font-medium">
{(it.title ?? "").length > 60
? (it.title ?? "").substring(0, 60) + "..."
: it.title}
</div>
<div className="text-xs text-muted-foreground flex items-center gap-2">

View File

@ -1,476 +1,480 @@
// "use client";
"use client";
// import { useParams, usePathname } from "next/navigation";
// import React, { useEffect, useState } from "react";
// import { Icon } from "@iconify/react/dist/iconify.js";
// import {
// checkWishlistStatus,
// deleteWishlist,
// getDetail,
// saveWishlist,
// } from "@/service/landing/landing";
// import VideoPlayer from "@/utils/video-player";
// import NewContent from "@/components/landing-page/new-content";
// import { Link, useRouter } from "@/i18n/routing";
// import { Textarea } from "@/components/ui/textarea";
// import { getCookiesDecrypt } from "@/lib/utils";
// import { close, error, loading } from "@/config/swal";
// import { useToast } from "@/components/ui/use-toast";
// import { postActivityLog } from "@/service/content/content";
// const DetailVideo = () => {
// const [selectedSize, setSelectedSize] = useState<string>("L");
// const [selectedTab, setSelectedTab] = useState("video");
// const router = useRouter();
// const pathname = usePathname();
// const params = useParams();
// const slug = String(params?.slug);
// const [detailDataVideo, setDetailDataVideo] = useState<any>();
// const [isSaved, setIsSaved] = useState(false);
// const [wishlistId, setWishlistId] = useState();
// const { toast } = useToast();
// const [isDownloadAll, setIsDownloadAll] = useState(false);
// const [downloadProgress, setDownloadProgress] = useState(0);
// const [isFromSPIT, setIsFromSPIT] = useState(false);
// const [main, setMain] = useState<any>();
// const [resolutionSelected, setResolutionSelected] = useState("720");
// const [selectedVideo, setSelectedVideo] = useState(0);
// const userId = getCookiesDecrypt("uie");
// useEffect(() => {
// initFetch();
// checkWishlist();
// sendActivityLog(2);
// }, []);
// const initFetch = async () => {
// const response = await getDetail(String(slug));
// console.log("detailVideo", response);
// setIsFromSPIT(response?.data?.data?.isFromSPIT);
// setMain({
// id: response?.data?.data?.files[0]?.id,
// type: response?.data?.data?.fileType.name,
// url:
// Number(response?.data?.data?.fileType?.id) == 4
// ? response?.data?.data?.files[0]?.secondaryUrl
// : Number(response?.data?.data?.fileType?.id) == 2
// ? `${process.env.NEXT_PUBLIC_API}/media/view?id=${response?.data?.data?.files[0]?.id}&operation=file&type=video`
// : response?.data?.data?.files[0]?.url,
// thumbnailFileUrl: response?.data?.data?.files[0]?.thumbnailFileUrl,
// names: response?.data?.data?.files[0]?.fileName,
// format: response?.data?.data?.files[0]?.format,
// widthPixel: response?.data?.data?.files[0]?.widthPixel,
// heightPixel: response?.data?.data?.files[0]?.heightPixel,
// size: response?.data?.data?.files[0]?.size,
// caption: response?.data?.data?.files[0]?.caption,
// });
// setDetailDataVideo(response?.data?.data);
// };
// const doBookmark = async () => {
// if (userId) {
// const data = {
// mediaUploadId: slug?.split("-")?.[0],
// };
// loading();
// const res = await saveWishlist(data);
// if (res?.error) {
// error(res.message);
// return false;
// }
// close();
// toast({
// title: "Konten berhasil disimpan",
// });
// checkWishlist();
// } else {
// router.push("/auth");
// }
// };
// async function checkWishlist() {
// if (userId) {
// const res = await checkWishlistStatus(slug.split("-")?.[0]);
// console.log(res?.data?.data);
// const isAlreadyOnWishlist = res?.data?.data !== "-1";
// setWishlistId(res?.data?.data);
// setIsSaved(isAlreadyOnWishlist);
// }
// }
// const handleDeleteWishlist = async () => {
// if (userId) {
// loading();
// const res = await deleteWishlist(wishlistId);
// if (res?.error) {
// error(res.message);
// return false;
// }
// toast({
// title: "Konten berhasil dihapus",
// });
// close();
// checkWishlist();
// } else {
// router.push("/auth");
// }
// };
// const sizes = [
// { label: "XL", value: "3198 x 1798 px" },
// { label: "L", value: "2399 x 1349 px" },
// { label: "M", value: "1599 x 899 px" },
// { label: "S", value: "1066 x 599 px" },
// { label: "XS", value: "800 x 450 px" },
// ];
// async function sendActivityLog(activityTypeId: number) {
// const data = {
// activityTypeId,
// mediaId: slug.split("-")?.[0],
// url: window.location.href,
// };
// // set activity
// await postActivityLog(data);
// }
// const handleDownload = () => {
// if (downloadProgress === 0) {
// if (!userId) {
// router.push("/auth");
// } else {
// sendActivityLog(2);
// sendActivityLog(3);
// if (isDownloadAll) {
// let url: string;
// const baseId = slug.split("-")?.[0];
// // if (type === "1") {
// url = `${process.env.NEXT_PUBLIC_API}/media/file/download-zip?id=${baseId}&resolution=${resolutionSelected}`;
// // } else if (type === "2") {
// // url = `${process.env.NEXT_PUBLIC_API}/media/file/download-zip?id=${baseId}&resolution=${imageSizeSelected}`;
// // } else {
// // url = `${process.env.NEXT_PUBLIC_API}/media/file/download-zip?id=${baseId}`;
// // }
// downloadFile(url, "FileDownload.zip");
// } else {
// if (isFromSPIT && main?.url?.includes("spit.humas")) {
// downloadFile(`${main?.url}`, `${main.names}`);
// } else {
// const url = `${process.env.NEXT_PUBLIC_API}/media/view?id=${main?.id}&operation=file&type=video&resolution=${resolutionSelected}p`;
// downloadFile(url, `${main.names}`);
// }
// }
// // } else if (type === "1" && resolutionSelected?.length > 0) {
// // if (isFromSPIT && main?.url?.includes("spit.humas")) {
// // downloadFile(`${main?.url}`, `${main.names}`);
// // } else {
// // const url = `${process.env.NEXT_PUBLIC_API}/media/view?id=${main?.id}&operation=file&type=video&resolution=${resolutionSelected}p`;
// // downloadFile(url, `${main.names}`);
// // }
// // } else if (type === "2" && imageSizeSelected?.length > 0) {
// // const url = `${process.env.NEXT_PUBLIC_API}/media/view?id=${main?.id}&operation=file&type=image&resolution=${imageSizeSelected}`;
// // downloadFile(url, `${main.names}`);
// // } else if (type === "3" || type === "4") {
// // downloadFile(`${main?.url}`, `${main.names}`);
// // }
// }
// }
// };
// const downloadFile = (fileUrl: string, name: string) => {
// const xhr = new XMLHttpRequest();
// xhr.open("GET", fileUrl, true);
// xhr.responseType = "blob";
// xhr.addEventListener("progress", (event) => {
// if (event.lengthComputable) {
// const percentCompleted = Math.round((event.loaded / event.total) * 100);
// setDownloadProgress(percentCompleted);
// }
// });
// xhr.addEventListener("readystatechange", () => {
// if (xhr.readyState === 4 && xhr.status === 200) {
// const contentType =
// xhr.getResponseHeader("content-type") || "application/octet-stream";
// const extension = contentType.split("/")[1];
// const filename = `${name}.${extension}`;
// const blob = new Blob([xhr.response], {
// type: contentType,
// });
// const downloadUrl = URL.createObjectURL(blob);
// const a = document.createElement("a");
// a.href = downloadUrl;
// a.download = filename;
// document.body.append(a);
// a.click();
// a.remove();
// }
// });
// xhr.onloadend = () => {
// setDownloadProgress(0);
// };
// xhr.send();
// };
// return (
// <>
// <div className="px-4 md:px-24 py-4">
// {/* Container Utama */}
// <div className="rounded-md overflow-hidden md:flex">
// {/* Bagian Kiri */}
// <div className="md:w-3/4">
// {/* <div className="relative">
// <VideoPlayer url={detailDataVideo?.files[0]?.url} />
// <div className="absolute top-4 left-4"></div>
// </div> */}
// <div className="relative max-h-screen overflow-hidden">
// <div className="w-full max-h-screen aspect-video">
// <div className="w-full h-full object-contain">
// <VideoPlayer
// url={detailDataVideo?.files[selectedVideo]?.url}
// />
// </div>
// </div>
// <div className="absolute top-4 left-4"></div>
// </div>
// <div className="py-4 flex flex-row gap-3">
// {detailDataVideo?.files?.map((file: any, index: number) => (
// <div
// key={file?.id}
// onClick={() => setSelectedVideo(index)}
// className="cursor-pointer flex flex-col items-center gap-1"
// >
// <img
// src={file?.thumbnailFileUrl}
// alt={file?.fileName}
// className="w-32 h-20 object-cover rounded"
// />
// {/* <p className="text-sm text-center">{file?.fileName}</p> */}
// </div>
// ))}
// </div>
// {/* Footer Informasi */}
// <div className="text-sm text-gray-500 flex justify-between items-center border-t mt-4">
// <p className="flex flex-row items-center mt-3">
// oleh&nbsp;
// <span className="font-semibold text-black">
// {detailDataVideo?.uploadedBy?.userLevel?.name}
// </span>
// &nbsp;|&nbsp;Diupdate pada {detailDataVideo?.updatedAt}{" "}
// WIB&nbsp;|&nbsp;
// <Icon icon="formkit:eye" width="15" height="15" />
// &nbsp;
// {detailDataVideo?.clickCount}
// </p>
// <p className="mt-3">Kreator: {detailDataVideo?.creatorName}</p>
// </div>
// {/* Keterangan */}
// <div className="w-full">
// <h1 className="flex flex-row font-bold text-2xl my-8">
// {detailDataVideo?.title}
// </h1>
// <div
// className="font-light text-justify"
// dangerouslySetInnerHTML={{
// __html: detailDataVideo?.htmlDescription,
// }}
// />
// </div>
// </div>
// {/* Bagian Kanan */}
// <div className="md:w-1/4 p-4 bg-[#f7f7f7] rounded-lg mx-4 h-fit">
// {isSaved ? (
// <a
// onClick={() => handleDeleteWishlist()}
// className="flex flex-col mb-3 items-center justify-center cursor-pointer"
// >
// <Icon icon="material-symbols:bookmark" width={40} />
// <p className="text-base lg:text-lg">Hapus</p>
// </a>
// ) : (
// <a
// onClick={() => doBookmark()}
// className="flex flex-col mb-3 items-center justify-center cursor-pointer"
// >
// <Icon icon="material-symbols:bookmark-outline" width={40} />
// <p className="text-base lg:text-lg">Simpan</p>
// </a>
// )}
// {/* garis */}
// <div className="border-t border-black my-4"></div>
// <Link
// href={`/all/filter?title=polda&category=${detailDataVideo?.category.id}`}
// className="bg-red-600 text-white text-xs font-bold px-3 py-3 my-3 flex justify-center items-center rounded"
// >
// {detailDataVideo?.categoryName}
// </Link>
// <div className="flex justify-center flex-wrap gap-2 mb-4">
// {detailDataVideo?.tags.split(",").map((tag: string) => (
// <a
// onClick={() => router.push(`/all/filter?tag=${tag}`)}
// key={tag}
// className="bg-gray-200 text-gray-700 text-xs px-3 py-1 rounded-full cursor-pointer hover:bg-gray-500 hover:text-white"
// >
// {tag}
// </a>
// ))}
// </div>
// <div className="border-t border-black my-4"></div>
// {/* Opsi Ukuran Foto */}
// <h4 className="flex text-lg justify-center items-center font-semibold my-3">
// Opsi Ukuran Audio Visual
// </h4>
// <div className="border-t border-black my-4"></div>
// <div className="space-y-2">
// {sizes.map((size: any) => (
// <div className="flex flex-row justify-between">
// <div
// key={size.label}
// className="items-center flex flex-row gap-2 cursor-pointer"
// >
// <input
// type="radio"
// name="size"
// value={size.label}
// checked={selectedSize === size.label}
// onChange={() => setSelectedSize(size.label)}
// className="text-red-600 focus:ring-red-600"
// />
// <div className="text-sm">{size.label}</div>
// </div>
// <div className="">
// <div className="text-sm">{size.value}</div>
// </div>
// </div>
// ))}
// </div>
// {/* Download Semua */}
// <div className="mt-4">
// <label className="flex items-center space-x-2 text-sm">
// <input
// type="checkbox"
// className="text-red-600 focus:ring-red-600"
// onChange={() => setIsDownloadAll(!isDownloadAll)}
// />
// <span>Download Semua File?</span>
// </label>
// </div>
// {/* Tombol Download */}
// <button
// onClick={handleDownload}
// className="mt-4 bg-red-600 text-white w-full py-2 flex justify-center items-center gap-1 rounded-md text-sm hover:bg-red-700"
// >
// <svg
// xmlns="http://www.w3.org/2000/svg"
// width="1em"
// height="1em"
// viewBox="0 0 24 24"
// >
// <path
// fill="white"
// d="m12 16l-5-5l1.4-1.45l2.6 2.6V4h2v8.15l2.6-2.6L17 11zm-6 4q-.825 0-1.412-.587T4 18v-3h2v3h12v-3h2v3q0 .825-.587 1.413T18 20z"
// />
// </svg>
// Download
// </button>
// </div>
// </div>
// </div>
// <div className="w-full mb-8">
// {/* Comment */}
// <div className="flex flex-col my-16 p-10 bg-[#f7f7f7]">
// <div className="gap-5 flex flex-col px-4 lg:px-14">
// <p className="flex items-start text-lg">Berikan Komentar</p>
// <Textarea
// placeholder="Type your comments here."
// className="flex w-full"
// />
// <button className="flex items-start bg-[#bb3523] text-white rounded-lg w-fit px-4 py-1">
// Kirim
// </button>
// </div>
// </div>
// {/* Konten Serupa */}
// <div className="px-4 lg:px-24">
// <NewContent group="polda" type={"similar"} />
// </div>
// </div>
// </>
// );
// };
// export default DetailVideo;
import { useParams, usePathname } from "next/navigation";
import React, { useEffect, useState } from "react";
import { Icon } from "@iconify/react/dist/iconify.js";
import {
checkWishlistStatus,
createPublicSuggestion,
deletePublicSuggestion,
deleteWishlist,
getDetail,
getDetailMetaData,
getPublicSuggestionList,
saveWishlist,
} from "@/service/landing/landing";
import { Metadata } from "next";
import DetailImage from "@/components/main/image-detail";
import DetailVideo from "@/components/main/video-detail";
import VideoPlayer from "@/utils/video-player";
import NewContent from "@/components/landing-page/new-content";
import { Link, useRouter } from "@/i18n/routing";
import { Textarea } from "@/components/ui/textarea";
import { getCookiesDecrypt } from "@/lib/utils";
import { close, error, loading } from "@/config/swal";
import { useToast } from "@/components/ui/use-toast";
import { postActivityLog } from "@/service/content/content";
interface Size {
label: string;
value: string;
}
const DetailVideo = () => {
const [selectedSize, setSelectedSize] = useState<string>("L");
const [selectedTab, setSelectedTab] = useState("video");
const router = useRouter();
const pathname = usePathname();
const params = useParams();
const slug = String(params?.slug);
const [detailDataVideo, setDetailDataVideo] = useState<any>();
const [isSaved, setIsSaved] = useState(false);
const [wishlistId, setWishlistId] = useState();
const { toast } = useToast();
const [isDownloadAll, setIsDownloadAll] = useState(false);
const [downloadProgress, setDownloadProgress] = useState(0);
const [isFromSPIT, setIsFromSPIT] = useState(false);
const [main, setMain] = useState<any>();
const [resolutionSelected, setResolutionSelected] = useState("720");
const [selectedVideo, setSelectedVideo] = useState(0);
type Props = {
params: {
title: string;
slug: string;
description: string;
thumbnailLink: string;
const userId = getCookiesDecrypt("uie");
useEffect(() => {
initFetch();
checkWishlist();
sendActivityLog(2);
}, []);
const initFetch = async () => {
const response = await getDetail(String(slug));
console.log("detailVideo", response);
setIsFromSPIT(response?.data?.data?.isFromSPIT);
setMain({
id: response?.data?.data?.files[0]?.id,
type: response?.data?.data?.fileType.name,
url:
Number(response?.data?.data?.fileType?.id) == 4
? response?.data?.data?.files[0]?.secondaryUrl
: Number(response?.data?.data?.fileType?.id) == 2
? `${process.env.NEXT_PUBLIC_API}/media/view?id=${response?.data?.data?.files[0]?.id}&operation=file&type=video`
: response?.data?.data?.files[0]?.url,
thumbnailFileUrl: response?.data?.data?.files[0]?.thumbnailFileUrl,
names: response?.data?.data?.files[0]?.fileName,
format: response?.data?.data?.files[0]?.format,
widthPixel: response?.data?.data?.files[0]?.widthPixel,
heightPixel: response?.data?.data?.files[0]?.heightPixel,
size: response?.data?.data?.files[0]?.size,
caption: response?.data?.data?.files[0]?.caption,
});
setDetailDataVideo(response?.data?.data);
};
const doBookmark = async () => {
if (userId) {
const data = {
mediaUploadId: slug?.split("-")?.[0],
};
loading();
const res = await saveWishlist(data);
if (res?.error) {
error(res.message);
return false;
}
close();
toast({
title: "Konten berhasil disimpan",
});
checkWishlist();
} else {
router.push("/auth");
}
};
async function checkWishlist() {
if (userId) {
const res = await checkWishlistStatus(slug.split("-")?.[0]);
console.log(res?.data?.data);
const isAlreadyOnWishlist = res?.data?.data !== "-1";
setWishlistId(res?.data?.data);
setIsSaved(isAlreadyOnWishlist);
}
}
const handleDeleteWishlist = async () => {
if (userId) {
loading();
const res = await deleteWishlist(wishlistId);
if (res?.error) {
error(res.message);
return false;
}
toast({
title: "Konten berhasil dihapus",
});
close();
checkWishlist();
} else {
router.push("/auth");
}
};
const sizes = [
{ label: "FULL HD", value: "1920 x 1080 px" },
{ label: "HD", value: "1280 x 720 px" },
{ label: "SD", value: "720 x 480 px" },
{ label: "WEB", value: "640 x 360 px" },
];
async function sendActivityLog(activityTypeId: number) {
const data = {
activityTypeId,
mediaId: slug.split("-")?.[0],
url: window.location.href,
};
// set activity
await postActivityLog(data);
}
const handleDownload = () => {
if (downloadProgress === 0) {
if (!userId) {
router.push("/auth");
} else {
sendActivityLog(2);
sendActivityLog(3);
if (isDownloadAll) {
let url: string;
const baseId = slug.split("-")?.[0];
// if (type === "1") {
url = `${process.env.NEXT_PUBLIC_API}/media/file/download-zip?id=${baseId}&resolution=${resolutionSelected}`;
// } else if (type === "2") {
// url = `${process.env.NEXT_PUBLIC_API}/media/file/download-zip?id=${baseId}&resolution=${imageSizeSelected}`;
// } else {
// url = `${process.env.NEXT_PUBLIC_API}/media/file/download-zip?id=${baseId}`;
// }
downloadFile(url, "FileDownload.zip");
} else {
if (isFromSPIT && main?.url?.includes("spit.humas")) {
downloadFile(`${main?.url}`, `${main.names}`);
} else {
const url = `${process.env.NEXT_PUBLIC_API}/media/view?id=${main?.id}&operation=file&type=video&resolution=${resolutionSelected}p`;
downloadFile(url, `${main.names}`);
}
}
// } else if (type === "1" && resolutionSelected?.length > 0) {
// if (isFromSPIT && main?.url?.includes("spit.humas")) {
// downloadFile(`${main?.url}`, `${main.names}`);
// } else {
// const url = `${process.env.NEXT_PUBLIC_API}/media/view?id=${main?.id}&operation=file&type=video&resolution=${resolutionSelected}p`;
// downloadFile(url, `${main.names}`);
// }
// } else if (type === "2" && imageSizeSelected?.length > 0) {
// const url = `${process.env.NEXT_PUBLIC_API}/media/view?id=${main?.id}&operation=file&type=image&resolution=${imageSizeSelected}`;
// downloadFile(url, `${main.names}`);
// } else if (type === "3" || type === "4") {
// downloadFile(`${main?.url}`, `${main.names}`);
// }
}
}
};
const downloadFile = (fileUrl: string, name: string) => {
const xhr = new XMLHttpRequest();
xhr.open("GET", fileUrl, true);
xhr.responseType = "blob";
xhr.addEventListener("progress", (event) => {
if (event.lengthComputable) {
const percentCompleted = Math.round((event.loaded / event.total) * 100);
setDownloadProgress(percentCompleted);
}
});
xhr.addEventListener("readystatechange", () => {
if (xhr.readyState === 4 && xhr.status === 200) {
const contentType =
xhr.getResponseHeader("content-type") || "application/octet-stream";
const extension = contentType.split("/")[1];
const filename = `${name}.${extension}`;
const blob = new Blob([xhr.response], {
type: contentType,
});
const downloadUrl = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = downloadUrl;
a.download = filename;
document.body.append(a);
a.click();
a.remove();
}
});
xhr.onloadend = () => {
setDownloadProgress(0);
};
xhr.send();
};
return (
<>
<div className="px-4 md:px-24 py-4">
{/* Container Utama */}
<div className="rounded-md overflow-hidden md:flex">
{/* Bagian Kiri */}
<div className="md:w-3/4">
{/* <div className="relative">
<VideoPlayer url={detailDataVideo?.files[0]?.url} />
<div className="absolute top-4 left-4"></div>
</div> */}
<div className="relative max-h-[600px] overflow-hidden">
<div className="w-full max-h-[600px] aspect-video">
<div className="w-full h-[600px] object-contain">
{/* <VideoPlayer
url={detailDataVideo?.files[selectedVideo]?.url}
/> */}
<video
className="object-fill h-full w-full rounded-md"
src={detailDataVideo?.files[0]?.url}
controls
/>
</div>
</div>
<div className="absolute top-4 left-4"></div>
</div>
<div className="py-4 flex flex-row gap-3">
{detailDataVideo?.files?.map((file: any, index: number) => (
<div
key={file?.id}
onClick={() => setSelectedVideo(index)}
className="cursor-pointer flex flex-col items-center gap-1"
>
<img
src={file?.thumbnailFileUrl}
alt={file?.fileName}
className="w-32 h-20 object-cover rounded"
/>
{/* <p className="text-sm text-center">{file?.fileName}</p> */}
</div>
))}
</div>
{/* Footer Informasi */}
<div className="text-sm text-gray-500 flex justify-between items-center border-t mt-4">
<p className="flex flex-row items-center mt-3">
oleh&nbsp;
<span className="font-semibold text-black">
{detailDataVideo?.uploadedBy?.userLevel?.name}
</span>
&nbsp;|&nbsp;Diupdate pada {detailDataVideo?.updatedAt}{" "}
WIB&nbsp;|&nbsp;
<Icon icon="formkit:eye" width="15" height="15" />
&nbsp;
{detailDataVideo?.clickCount}
</p>
<p className="mt-3">Kreator: {detailDataVideo?.creatorName}</p>
</div>
{/* Keterangan */}
<div className="w-full">
<h1 className="flex flex-row font-bold text-2xl my-8">
{detailDataVideo?.title}
</h1>
<div
className="font-light text-justify"
dangerouslySetInnerHTML={{
__html: detailDataVideo?.htmlDescription,
}}
/>
</div>
</div>
{/* Bagian Kanan */}
<div className="md:w-1/4 p-4 bg-[#f7f7f7] rounded-lg mx-4 h-fit">
{isSaved ? (
<a
onClick={() => handleDeleteWishlist()}
className="flex flex-col mb-3 items-center justify-center cursor-pointer"
>
<Icon icon="material-symbols:bookmark" width={40} />
<p className="text-base lg:text-lg">Hapus</p>
</a>
) : (
<a
onClick={() => doBookmark()}
className="flex flex-col mb-3 items-center justify-center cursor-pointer"
>
<Icon icon="material-symbols:bookmark-outline" width={40} />
<p className="text-base lg:text-lg">Simpan</p>
</a>
)}
{/* garis */}
<div className="border-t border-black my-4"></div>
<Link
href={`/all/filter?title=polda&category=${detailDataVideo?.category.id}`}
className="bg-red-600 text-white text-xs font-bold px-3 py-3 my-3 flex justify-center items-center rounded"
>
{detailDataVideo?.categoryName}
</Link>
<div className="flex justify-center flex-wrap gap-2 mb-4">
{detailDataVideo?.tags.split(",").map((tag: string) => (
<a
onClick={() => router.push(`/all/filter?tag=${tag}`)}
key={tag}
className="bg-gray-200 text-gray-700 text-xs px-3 py-1 rounded-full cursor-pointer hover:bg-gray-500 hover:text-white"
>
{tag}
</a>
))}
</div>
<div className="border-t border-black my-4"></div>
{/* Opsi Ukuran Foto */}
<h4 className="flex text-lg justify-center items-center font-semibold my-3">
Opsi Ukuran Audio Visual
</h4>
<div className="border-t border-black my-4"></div>
<div className="space-y-2">
{sizes.map((size: any) => (
<div className="flex flex-row justify-between">
<div
key={size.label}
className="items-center flex flex-row gap-2 cursor-pointer"
>
<input
type="radio"
name="size"
value={size.label}
checked={selectedSize === size.label}
onChange={() => setSelectedSize(size.label)}
className="text-red-600 focus:ring-red-600"
/>
<div className="text-sm">{size.label}</div>
</div>
<div className="">
<div className="text-sm">{size.value}</div>
</div>
</div>
))}
</div>
{/* Download Semua */}
<div className="mt-4">
<label className="flex items-center space-x-2 text-sm">
<input
type="checkbox"
className="text-red-600 focus:ring-red-600"
onChange={() => setIsDownloadAll(!isDownloadAll)}
/>
<span>Download Semua File?</span>
</label>
</div>
{/* Tombol Download */}
<button
onClick={handleDownload}
className="mt-4 bg-red-600 text-white w-full py-2 flex justify-center items-center gap-1 rounded-md text-sm hover:bg-red-700"
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="1em"
height="1em"
viewBox="0 0 24 24"
>
<path
fill="white"
d="m12 16l-5-5l1.4-1.45l2.6 2.6V4h2v8.15l2.6-2.6L17 11zm-6 4q-.825 0-1.412-.587T4 18v-3h2v3h12v-3h2v3q0 .825-.587 1.413T18 20z"
/>
</svg>
Download
</button>
</div>
</div>
</div>
<div className="w-full mb-8">
{/* Comment */}
<div className="flex flex-col my-16 p-10 bg-[#f7f7f7]">
<div className="gap-5 flex flex-col px-4 lg:px-14">
<p className="flex items-start text-lg">Berikan Komentar</p>
<Textarea
placeholder="Type your comments here."
className="flex w-full"
/>
<button className="flex items-start bg-[#bb3523] text-white rounded-lg w-fit px-4 py-1">
Kirim
</button>
</div>
</div>
{/* Konten Serupa */}
<div className="px-4 lg:px-24">
<NewContent group="polda" type={"similar"} />
</div>
</div>
</>
);
};
export async function generateMetadata({ params }: any): Promise<Metadata> {
const slug = String(params?.slug);
const res = await getDetailMetaData(String(slug));
const video = res?.data?.data;
// console.log("video", video);
return {
title: video.title,
description: video.description,
openGraph: {
title: video?.title,
description: video?.description,
videos: [`${video?.smallThumbnailLink}`],
},
};
}
export default DetailVideo;
// import React, { useEffect, useState } from "react";
// import {
// checkWishlistStatus,
// createPublicSuggestion,
// deletePublicSuggestion,
// deleteWishlist,
// getDetail,
// getDetailMetaData,
// getPublicSuggestionList,
// saveWishlist,
// } from "@/service/landing/landing";
// import { Metadata } from "next";
// import DetailImage from "@/components/main/image-detail";
// import DetailVideo from "@/components/main/video-detail";
export default async function DetailInfo({ params }: Props) {
return <DetailVideo />;
}
// interface Size {
// label: string;
// value: string;
// }
// type Props = {
// params: {
// title: string;
// slug: string;
// description: string;
// thumbnailLink: string;
// };
// };
// export async function generateMetadata({ params }: any): Promise<Metadata> {
// const slug = String(params?.slug);
// const res = await getDetailMetaData(String(slug));
// const video = res?.data?.data;
// // console.log("video", video);
// return {
// title: video.title,
// description: video.description,
// openGraph: {
// title: video?.title,
// description: video?.description,
// videos: [`${video?.smallThumbnailLink}`],
// },
// };
// }
// export default async function DetailInfo({ params }: Props) {
// return <DetailVideo />;
// }

View File

@ -709,9 +709,9 @@ export default function FormDetailTicketing({ id }: Props) {
};
return (
<section className="flex-1 flex flex-col bg-white">
<section className="flex flex-col h-full bg-white">
{/* Header */}
<div className="border-b px-4 py-3">
<div className="border-b px-4 py-3 shrink-0">
<div className="flex items-center gap-3">
<div className="text-sm font-medium">
{(detail?.title ?? "").split(" ").slice(0, 25).join(" ") +
@ -723,12 +723,13 @@ export default function FormDetailTicketing({ id }: Props) {
</div>
</div>
{/* Chat Messages */}
<div className="flex-1 overflow-auto p-4 space-y-3 bg-gray-50">
{/* Chat Messages (scrollable only this part) */}
<div className="flex-1 overflow-y-auto p-4 space-y-3 bg-gray-50">
{!detail ? (
<div className="h-full flex items-center justify-center text-muted-foreground">
<div className="text-center">
<div className="mb-4">
{/* Icon kosong */}
<svg
width="72"
height="72"
@ -783,7 +784,7 @@ export default function FormDetailTicketing({ id }: Props) {
</div>
{/* Input Box */}
<div className="border-t px-4 py-3 bg-white">
<div className="border-t px-4 py-3 bg-white shrink-0">
<div className="flex flex-col gap-2 max-w-full mx-auto">
<textarea
placeholder='Enter your reply or type "/" to insert a quick reply'

View File

@ -3181,20 +3181,20 @@ export function getMenuList(pathname: string, t: any): Group[] {
}
} else if (Number(roleId) == 9) {
menusSelected = [
{
groupLabel: t("apps"),
id: "dashboard",
menus: [
{
id: "dashboard",
href: "/dashboard",
label: t("dashboard"),
active: pathname.includes("/dashboard"),
icon: "material-symbols:dashboard",
submenus: [],
},
],
},
// {
// groupLabel: t("apps"),
// id: "dashboard",
// menus: [
// {
// id: "dashboard",
// href: "/dashboard",
// label: t("dashboard"),
// active: pathname.includes("/dashboard"),
// icon: "material-symbols:dashboard",
// submenus: [],
// },
// ],
// },
{
groupLabel: "",
id: "ticketing",
@ -3214,54 +3214,62 @@ export function getMenuList(pathname: string, t: any): Group[] {
children: [],
},
{
href: "/supervisor/ticketing/3",
label: "Instagram",
active: pathname.includes("/ticketing/3"),
icon: "ri:chat-private-line",
children: [],
},
{
href: "/supervisor/ticketing/2",
label: "Facebook",
active: pathname.includes("/ticketing/2"),
href: "/supervisor/ticketing/6",
label: "Emergency Issues",
active: pathname.includes("/ticketing/6"),
icon: "ri:share-forward-2-fill",
children: [],
},
{
href: "/supervisor/ticketing/5",
label: "Youtube",
active: pathname.includes("/ticketing/5"),
href: "/supervisor/ticketing/9",
label: "Whatsapp",
active: pathname.includes("/ticketing/9"),
icon: "ri:share-forward-2-fill",
children: [],
},
{
href: "/supervisor/ticketing/1",
label: "Komentar Konten",
active: pathname.includes("/ticketing/1"),
icon: "ri:share-forward-2-fill",
children: [],
},
{
href: "/supervisor/ticketing/7",
label: "Email",
active: pathname.includes("/ticketing/7"),
icon: "ri:share-forward-2-fill",
children: [],
},
{
href: "/supervisor/ticketing/8",
label: "Pesan Masuk",
active: pathname.includes("/ticketing/8"),
icon: "ri:share-forward-2-fill",
children: [],
},
// {
// href: "/",
// label: "Tiktok",
// active: pathname.includes("/ticketing/tiktok"),
// href: "/supervisor/ticketing/3",
// label: "Instagram",
// active: pathname.includes("/ticketing/3"),
// icon: "ri:chat-private-line",
// children: [],
// },
// {
// href: "/supervisor/ticketing/2",
// label: "Facebook",
// active: pathname.includes("/ticketing/2"),
// icon: "ri:share-forward-2-fill",
// children: [],
// },
// {
// href: "/",
// label: "Kolom Komentar",
// active: pathname.includes("/ticketing/comment"),
// icon: "ri:share-forward-2-fill",
// children: [],
// },
// {
// href: "/",
// label: "Hubungi Kami",
// active: pathname.includes("/ticketing/contact-us"),
// icon: "ri:share-forward-2-fill",
// children: [],
// },
// {
// href: "/",
// label: "Play Store",
// active: pathname.includes("/ticketing/play-store"),
// href: "/supervisor/ticketing/5",
// label: "Youtube",
// active: pathname.includes("/ticketing/5"),
// icon: "ri:share-forward-2-fill",
// children: [],
// },
// {
// href: "/",
// label: "App Store",
@ -3283,13 +3291,7 @@ export function getMenuList(pathname: string, t: any): Group[] {
// icon: "ri:share-forward-2-fill",
// children: [],
// },
{
href: "/supervisor/ticketing/6",
label: "Emergency Issues",
active: pathname.includes("/ticketing/6"),
icon: "ri:share-forward-2-fill",
children: [],
},
// {
// href: "/",
// label: "Campaignpool",

View File

@ -122,13 +122,28 @@ export async function deleteCollabDiscussion(id: string | number) {
return httpDeleteInterceptor(url);
}
// export async function getQuestionPagination(
// title = "",
// page: number,
// typeId: string,
// size: string
// ) {
// const url = `question/pagination?enablePage=1&size=${size}&title=${title}&page=${page}&typeId=${typeId}`;
// return httpGetInterceptor(url);
// }
export async function getQuestionPagination(
title = "",
page: number,
typeId: string,
size: string
size: string,
reportType?: string
) {
const url = `question/pagination?enablePage=1&size=${size}&title=${title}&page=${page}&typeId=${typeId}`;
let url = `question/pagination?enablePage=1&size=${size}&title=${title}&page=${page}&typeId=${typeId}`;
if (reportType) {
url += `&reportType=${reportType}`;
}
return httpGetInterceptor(url);
}