2024-12-13 04:10:59 +00:00
|
|
|
"use client";
|
2024-12-12 18:38:15 +00:00
|
|
|
import Cookies from "js-cookie";
|
|
|
|
|
import { useEffect, useState } from "react";
|
|
|
|
|
import { getCookiesDecrypt } from "@/lib/utils";
|
|
|
|
|
import { generateTicket } from "@/service/tableau/tableau-service";
|
|
|
|
|
import { Button } from "../ui/button";
|
2024-12-13 04:10:59 +00:00
|
|
|
import { useTranslations } from "next-intl";
|
2024-12-12 18:38:15 +00:00
|
|
|
|
|
|
|
|
export default function DashboardVisualization() {
|
|
|
|
|
const levelName = getCookiesDecrypt("ulnae");
|
|
|
|
|
const poldaState = Cookies.get("state");
|
2024-12-13 04:10:59 +00:00
|
|
|
const t = useTranslations("AnalyticsDashboard");
|
2024-12-12 18:38:15 +00:00
|
|
|
|
|
|
|
|
const [ticket1, setTicket1] = useState("");
|
|
|
|
|
const [ticket2, setTicket2] = useState("");
|
|
|
|
|
const [ticket3, setTicket3] = useState("");
|
|
|
|
|
const [isInternational, setIsInternational] = useState([false, false, false]);
|
2025-02-24 04:27:02 +00:00
|
|
|
const baseUrl = "https://db-mediahub.polri.go.id/";
|
|
|
|
|
const url = "https://db-mediahub.polri.go.id/trusted/";
|
2024-12-12 18:38:15 +00:00
|
|
|
|
|
|
|
|
const view1 =
|
|
|
|
|
levelName == "MABES POLRI"
|
|
|
|
|
? isInternational[0]
|
|
|
|
|
? "views/2023_04_MediaHUB-Viz_INTL_Rev202/db-content-monitor?"
|
|
|
|
|
: "views/2023_09_MediaHUB-Viz-POLDA-content-monitor_Rev100/db-content-monitor?"
|
|
|
|
|
: `views/2023_09_MediaHUB-Viz-ADMIN-POLDA-content-monitor_Rev100/db-content-monitor?provinsi-polda=${poldaState}&`;
|
|
|
|
|
|
|
|
|
|
const view2 =
|
|
|
|
|
levelName == "MABES POLRI"
|
|
|
|
|
? isInternational[1]
|
|
|
|
|
? "views/2023_04_MediaHUB-Viz_INTL_Rev202/db-content-interaction-konten?"
|
|
|
|
|
: "views/2023_04_MediaHUB-Viz-POLDA_Rev201/db-content-interaction-konten?"
|
|
|
|
|
: `views/2023_04_MediaHUB-Viz-POLDA_Rev201/db-content-interaction-konten-polda?provinsi-polda=${poldaState}&`;
|
|
|
|
|
|
|
|
|
|
const view3 =
|
|
|
|
|
levelName == "MABES POLRI"
|
|
|
|
|
? isInternational[2]
|
|
|
|
|
? "views/2023_04_MediaHUB-Viz_INTL_Rev202/db-penugasan?"
|
|
|
|
|
: "views/2023_09_db-penugasan_rev100/db-penugasan?"
|
|
|
|
|
: `views/2023_04_MediaHUB-Viz-POLDA_Rev201/db-penugasan-polda?provinsi-polda=${poldaState}&`;
|
|
|
|
|
|
|
|
|
|
const param = ":embed=yes&:toolbar=yes&:iframeSizedToWindow=true";
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
async function initState() {
|
|
|
|
|
const response1 = await generateTicket();
|
2025-01-01 23:29:50 +00:00
|
|
|
setTicket1(response1?.data?.data);
|
2024-12-12 18:38:15 +00:00
|
|
|
console.log("response", response1);
|
|
|
|
|
const response2 = await generateTicket();
|
2025-01-01 23:29:50 +00:00
|
|
|
setTicket2(response2?.data?.data);
|
2024-12-12 18:38:15 +00:00
|
|
|
|
|
|
|
|
const response3 = await generateTicket();
|
2025-01-01 23:29:50 +00:00
|
|
|
setTicket3(response3?.data?.data);
|
2024-12-12 18:38:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
initState();
|
|
|
|
|
}, [isInternational]);
|
|
|
|
|
|
|
|
|
|
const handleInternational = (index: number, val: boolean) => {
|
|
|
|
|
const updatedIsInternational = [...isInternational];
|
|
|
|
|
|
|
|
|
|
updatedIsInternational[index] = val;
|
|
|
|
|
setIsInternational(updatedIsInternational);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
async function fetchUrl() {
|
|
|
|
|
console.log("Fetch tableau");
|
|
|
|
|
const urlView = `${url + ticket1}/${view1}${param}`;
|
|
|
|
|
console.log("Fetch tableau ", urlView);
|
|
|
|
|
const urlRender = await fetch(urlView)
|
|
|
|
|
.then((response) => {
|
|
|
|
|
console.log("Tableau res : ", response);
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
console.log("Tableau error: ", error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fetchUrl();
|
|
|
|
|
}, [ticket1]);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="flex flex-col gap-2 bg-white rounded-lg p-3">
|
|
|
|
|
<p className="text-lg">
|
|
|
|
|
<b>
|
|
|
|
|
{isInternational[0]
|
|
|
|
|
? "COMMULATION OF USERS, CONTENTS AND INTERACTIONS"
|
|
|
|
|
: "KUMULASI PENGGUNA, KONTEN, DAN INTERAKSI"}
|
|
|
|
|
</b>
|
|
|
|
|
</p>
|
|
|
|
|
{levelName === "MABES POLRI" ? (
|
|
|
|
|
<div className="flex flex-col gap-1">
|
2024-12-13 04:10:59 +00:00
|
|
|
<p>{t("choose_category")}</p>
|
2024-12-12 18:38:15 +00:00
|
|
|
<div className="flex flex-row gap-1 border-2 w-fit">
|
|
|
|
|
<Button
|
|
|
|
|
onClick={() => handleInternational(0, false)}
|
|
|
|
|
className={` hover:text-white rounded-none
|
|
|
|
|
${
|
|
|
|
|
isInternational[0]
|
|
|
|
|
? "bg-white text-black "
|
|
|
|
|
: "bg-black text-white "
|
|
|
|
|
}`}
|
|
|
|
|
>
|
|
|
|
|
Indonesia
|
|
|
|
|
</Button>
|
|
|
|
|
<Button
|
|
|
|
|
onClick={() => handleInternational(0, true)}
|
|
|
|
|
className={`hover:text-white rounded-none ${
|
|
|
|
|
isInternational[0]
|
|
|
|
|
? "bg-black text-white "
|
|
|
|
|
: "bg-white text-black "
|
|
|
|
|
}
|
|
|
|
|
`}
|
|
|
|
|
>
|
2024-12-13 04:10:59 +00:00
|
|
|
{t("international")}
|
2024-12-12 18:38:15 +00:00
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
) : (
|
|
|
|
|
""
|
|
|
|
|
)}
|
|
|
|
|
<div className="my-5">
|
|
|
|
|
{ticket1 == "" ? (
|
|
|
|
|
<iframe
|
|
|
|
|
src={`${baseUrl + view1 + param}`}
|
|
|
|
|
width="100%"
|
|
|
|
|
height="750"
|
|
|
|
|
frameBorder="0"
|
|
|
|
|
/>
|
|
|
|
|
) : (
|
|
|
|
|
<iframe
|
|
|
|
|
src={`${`${url + ticket1}/${view1}${param}`}`}
|
|
|
|
|
width="100%"
|
|
|
|
|
height="750"
|
|
|
|
|
frameBorder="0"
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
<p className="text-lg">
|
|
|
|
|
<b>
|
|
|
|
|
{isInternational[1]
|
|
|
|
|
? "ADDITION OF CONTENT AND INTERACTION"
|
|
|
|
|
: "PENAMBAHAN KONTEN DAN INTERAKSI"}
|
|
|
|
|
</b>
|
|
|
|
|
</p>
|
|
|
|
|
{levelName === "MABES POLRI" ? (
|
|
|
|
|
<div className="flex flex-col gap-1">
|
2024-12-13 04:10:59 +00:00
|
|
|
<p>{t("choose_category")}</p>
|
2024-12-12 18:38:15 +00:00
|
|
|
<div className="flex flex-row gap-1 border-2 w-fit">
|
|
|
|
|
<Button
|
|
|
|
|
onClick={() => handleInternational(1, false)}
|
|
|
|
|
className={` hover:text-white rounded-none
|
|
|
|
|
${
|
|
|
|
|
isInternational[1]
|
|
|
|
|
? "bg-white text-black "
|
|
|
|
|
: "bg-black text-white "
|
|
|
|
|
}`}
|
|
|
|
|
>
|
|
|
|
|
Indonesia
|
|
|
|
|
</Button>
|
|
|
|
|
<Button
|
|
|
|
|
onClick={() => handleInternational(1, true)}
|
|
|
|
|
className={`hover:text-white rounded-none ${
|
|
|
|
|
isInternational[1]
|
|
|
|
|
? "bg-black text-white "
|
|
|
|
|
: "bg-white text-black "
|
|
|
|
|
}
|
|
|
|
|
`}
|
|
|
|
|
>
|
2024-12-13 04:10:59 +00:00
|
|
|
{t("international")}
|
2024-12-12 18:38:15 +00:00
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
) : (
|
|
|
|
|
""
|
|
|
|
|
)}
|
|
|
|
|
<div className="my-5">
|
|
|
|
|
{ticket2 == "" ? (
|
|
|
|
|
<iframe
|
|
|
|
|
src={`${baseUrl + view2 + param}`}
|
|
|
|
|
width="100%"
|
|
|
|
|
height="750"
|
|
|
|
|
frameBorder="0"
|
|
|
|
|
/>
|
|
|
|
|
) : (
|
|
|
|
|
<iframe
|
|
|
|
|
src={`${`${url + ticket2}/${view2}${param}`}`}
|
|
|
|
|
width="100%"
|
|
|
|
|
height="750"
|
|
|
|
|
frameBorder="0"
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
<p className="text-lg">
|
|
|
|
|
<b>{isInternational[2] ? "ASSIGNMENT" : "PENUGASAN"}</b>
|
|
|
|
|
</p>
|
|
|
|
|
{levelName === "MABES POLRI" ? (
|
|
|
|
|
<div className="flex flex-col gap-1">
|
2024-12-13 04:10:59 +00:00
|
|
|
<p>{t("choose_category")}</p>
|
2024-12-12 18:38:15 +00:00
|
|
|
<div className="flex flex-row gap-1 border-2 w-fit">
|
|
|
|
|
<Button
|
|
|
|
|
onClick={() => handleInternational(2, false)}
|
|
|
|
|
className={` hover:text-white rounded-none
|
|
|
|
|
${
|
|
|
|
|
isInternational[2]
|
|
|
|
|
? "bg-white text-black "
|
|
|
|
|
: "bg-black text-white "
|
|
|
|
|
}`}
|
|
|
|
|
>
|
|
|
|
|
Indonesia
|
|
|
|
|
</Button>
|
|
|
|
|
<Button
|
|
|
|
|
onClick={() => handleInternational(2, true)}
|
|
|
|
|
className={`hover:text-white rounded-none ${
|
|
|
|
|
isInternational[1]
|
|
|
|
|
? "bg-black text-white "
|
|
|
|
|
: "bg-white text-black "
|
|
|
|
|
}
|
|
|
|
|
`}
|
|
|
|
|
>
|
2024-12-13 04:10:59 +00:00
|
|
|
{t("international")}
|
2024-12-12 18:38:15 +00:00
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
) : (
|
|
|
|
|
""
|
|
|
|
|
)}
|
|
|
|
|
<div className="my-5">
|
|
|
|
|
{ticket3 == "" ? (
|
|
|
|
|
<iframe
|
|
|
|
|
src={`${baseUrl + view3 + param}`}
|
|
|
|
|
width="100%"
|
|
|
|
|
height="750"
|
|
|
|
|
frameBorder="0"
|
|
|
|
|
/>
|
|
|
|
|
) : (
|
|
|
|
|
<iframe
|
|
|
|
|
src={`${`${url + ticket3}/${view3}${param}`}`}
|
|
|
|
|
width="100%"
|
|
|
|
|
height="750"
|
|
|
|
|
frameBorder="0"
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|