2025-01-08 15:25:03 +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 ManagementUserVisualization() {
|
|
|
|
|
const [ticket, setTicket] = useState("");
|
2025-04-16 06:28:10 +00:00
|
|
|
const baseUrl = "https://analytic.sitani.info/";
|
|
|
|
|
const url = "https://analytic.sitani.info/trusted/";
|
2025-04-24 15:57:36 +00:00
|
|
|
const view = "views/2023_04_MediaHUB-Viz-POLDA_Rev200/db-user-count?";
|
2025-04-25 00:33:06 +00:00
|
|
|
const param = ":embed=yes&:toolbar=no&:iframeSizedToWindow=true";
|
2025-01-08 15:25:03 +00:00
|
|
|
const [isInternational, setIsInternational] = useState(false);
|
|
|
|
|
const t = useTranslations("AnalyticsDashboard");
|
|
|
|
|
|
|
|
|
|
const userId = getCookiesDecrypt("uie");
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
const initState = async () => {
|
|
|
|
|
const response = await generateTicket();
|
|
|
|
|
console.log("Data :", response?.data?.data);
|
|
|
|
|
setTicket(response?.data?.data);
|
|
|
|
|
console.log(userId);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
initState();
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="flex flex-col gap-2 bg-white rounded-lg p-3">
|
|
|
|
|
{isInternational ? (
|
|
|
|
|
<p className="font-semibold">STATISTICS TO THE NUMBER OF USERS</p>
|
|
|
|
|
) : (
|
|
|
|
|
<p className="font-semibold">STATISTIK JUMLAH PENGGUNA</p>
|
|
|
|
|
)}
|
|
|
|
|
<div className="flex flex-col gap-1">
|
|
|
|
|
<p>{t("choose_category")}</p>
|
|
|
|
|
<div className="flex flex-row gap-1 border-2 w-fit">
|
|
|
|
|
<Button
|
|
|
|
|
onClick={() => setIsInternational(false)}
|
|
|
|
|
className={` hover:text-white rounded-none
|
|
|
|
|
${
|
|
|
|
|
isInternational
|
|
|
|
|
? "bg-white text-black "
|
|
|
|
|
: "bg-black text-white "
|
|
|
|
|
}`}
|
|
|
|
|
>
|
|
|
|
|
Indonesia
|
|
|
|
|
</Button>
|
|
|
|
|
<Button
|
|
|
|
|
onClick={() => setIsInternational(true)}
|
|
|
|
|
className={`hover:text-white rounded-none ${
|
|
|
|
|
isInternational ? "bg-black text-white " : "bg-white text-black "
|
|
|
|
|
}
|
|
|
|
|
`}
|
|
|
|
|
>
|
|
|
|
|
{t("international")}
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{ticket == undefined ? (
|
|
|
|
|
<iframe
|
|
|
|
|
src={`${baseUrl + view + param}`}
|
|
|
|
|
width="100%"
|
|
|
|
|
height="750"
|
|
|
|
|
frameBorder="0"
|
|
|
|
|
/>
|
|
|
|
|
) : (
|
|
|
|
|
<iframe
|
|
|
|
|
src={`${`${url + ticket}/${view}${param}`}`}
|
|
|
|
|
width="100%"
|
|
|
|
|
height="750"
|
|
|
|
|
frameBorder="0"
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|