2025-02-18 04:18:51 +00:00
|
|
|
"use client";
|
|
|
|
|
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";
|
|
|
|
|
import { useTranslations } from "next-intl";
|
|
|
|
|
|
|
|
|
|
export default function PerformancePoldaViz() {
|
|
|
|
|
const [hasMounted, setHasMounted] = useState(false);
|
|
|
|
|
const t = useTranslations("AnalyticsDashboard");
|
|
|
|
|
const levelName = getCookiesDecrypt("ulnae");
|
2025-04-24 15:57:36 +00:00
|
|
|
const state = Cookies.get("state");
|
2025-02-18 04:18:51 +00:00
|
|
|
const provState = Cookies.get("state-prov");
|
|
|
|
|
|
|
|
|
|
const [ticket1, setTicket1] = useState("");
|
|
|
|
|
const [ticket2, setTicket2] = useState("");
|
|
|
|
|
const [ticket3, setTicket3] = useState("");
|
|
|
|
|
const [ticket4, setTicket4] = useState("");
|
|
|
|
|
const [isInternational, setIsInternational] = useState([false, false, false]);
|
|
|
|
|
|
2025-07-20 13:44:44 +00:00
|
|
|
const baseUrl = "https://db-mediahub.polri.go.id/";
|
|
|
|
|
const url = "https://db-mediahub.polri.go.id/trusted/";
|
2025-02-18 04:18:51 +00:00
|
|
|
|
2025-04-24 15:57:36 +00:00
|
|
|
const safeLevelName = levelName ?? "";
|
|
|
|
|
|
2025-02-18 04:18:51 +00:00
|
|
|
const view1 =
|
|
|
|
|
levelName == "MABES POLRI"
|
|
|
|
|
? isInternational[0]
|
2025-07-20 15:28:05 +00:00
|
|
|
? "views/2023_04_MediaHUB-Viz-POLDA_Rev201/db-ranking-polda?"
|
2025-11-20 13:09:05 +00:00
|
|
|
: "views/2023_04_MediaHUB-Viz-POLDA_Rev201/db-ranking-polda?"
|
2025-04-24 15:57:36 +00:00
|
|
|
: `views/2023_09_db-ranking-polres-by-polda_rev100/db-ranking-by-polda?polda-selected=${state}&`;
|
2025-02-18 04:18:51 +00:00
|
|
|
|
2025-02-24 04:27:02 +00:00
|
|
|
const view2 =
|
|
|
|
|
levelName == "MABES POLRI"
|
|
|
|
|
? isInternational[0]
|
2025-07-20 15:28:05 +00:00
|
|
|
? "views/2023_09_db-ranking-polda_rev100/db-ranking-13?"
|
2025-11-20 13:09:05 +00:00
|
|
|
: "views/2023_09_db-ranking-polda_rev100/db-ranking-13?"
|
2025-04-24 15:57:36 +00:00
|
|
|
: safeLevelName.includes("POLDA")
|
|
|
|
|
? `views/2023_09_db-ranking-polres-by-polda_rev100/db-ranking-by-polda?polda-selected=${state}&`
|
|
|
|
|
: `views/2023_09_db-ranking-polres-by-polda_rev100/db-ranking-by-polda?polda-selected=${state}&`;
|
2025-02-24 04:27:02 +00:00
|
|
|
|
2025-07-20 15:00:55 +00:00
|
|
|
const param = ":embed=yes&:toolbar=yes&:iframeSizedToWindow=true";
|
2025-02-18 04:18:51 +00:00
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
async function initState() {
|
|
|
|
|
const response1 = await generateTicket();
|
|
|
|
|
setTicket1(response1?.data?.data);
|
2025-02-24 04:27:02 +00:00
|
|
|
|
|
|
|
|
const response2 = await generateTicket();
|
|
|
|
|
setTicket2(response2?.data?.data);
|
2025-02-18 04:18:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
initState();
|
|
|
|
|
}, [isInternational]);
|
|
|
|
|
|
|
|
|
|
// Hooks
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
setHasMounted(true);
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
// Render
|
|
|
|
|
if (!hasMounted) return null;
|
|
|
|
|
|
|
|
|
|
const handleInternational = (index: number, val: boolean) => {
|
|
|
|
|
const updatedIsInternational = [...isInternational];
|
|
|
|
|
|
|
|
|
|
updatedIsInternational[index] = val;
|
|
|
|
|
setIsInternational(updatedIsInternational);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
2025-09-04 14:58:03 +00:00
|
|
|
<div className="flex flex-col gap-2 bg-white dark:bg-black rounded-lg p-3">
|
2025-02-18 04:18:51 +00:00
|
|
|
<p className="text-lg">
|
2025-11-11 17:14:42 +00:00
|
|
|
<b>
|
|
|
|
|
{levelName == "MABES POLRI"
|
|
|
|
|
? "PERFORMANCE PER POLDA"
|
|
|
|
|
: "PERFORMANCE POLRES"}
|
|
|
|
|
</b>
|
2025-02-18 04:18:51 +00:00
|
|
|
</p>
|
|
|
|
|
<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>
|
2025-02-24 04:27:02 +00:00
|
|
|
<p className="text-lg">
|
|
|
|
|
<b>
|
|
|
|
|
{isInternational[0]
|
|
|
|
|
? "PUBLISH CONTENT PER POLDA"
|
|
|
|
|
: "PUBLISH KONTEN PER POLDA"}
|
|
|
|
|
</b>
|
|
|
|
|
</p>
|
|
|
|
|
<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>
|
2025-02-18 04:18:51 +00:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|