diff --git a/app/[locale]/(public)/(polda)/polda/[polda_name]/audio/detail/[slug]/page.tsx b/app/[locale]/(public)/(polda)/polda/[polda_name]/audio/detail/[slug]/page.tsx index 3f1e5ddf..46e77a78 100644 --- a/app/[locale]/(public)/(polda)/polda/[polda_name]/audio/detail/[slug]/page.tsx +++ b/app/[locale]/(public)/(polda)/polda/[polda_name]/audio/detail/[slug]/page.tsx @@ -16,6 +16,7 @@ import { checkMaliciousText, getPublicLocaleTimestamp } from "@/utils/globals"; import withReactContent from "sweetalert2-react-content"; import Swal from "sweetalert2"; import parse from "html-react-parser"; +import { postActivityLog } from "@/service/content/content"; const DetailAudio = () => { @@ -47,6 +48,7 @@ const DetailAudio = () => { useEffect(() => { initFetch(); checkWishlist(); + sendActivityLog(2); }, []); const initFetch = async () => { @@ -131,8 +133,7 @@ const DetailAudio = () => { url: window.location.href, }; // set activity - // const response = await postActivityLog(data, token); - // console.log(response); + await postActivityLog(data); } const handleDownload = () => { diff --git a/app/[locale]/(public)/(polda)/polda/[polda_name]/document/detail/[slug]/page.tsx b/app/[locale]/(public)/(polda)/polda/[polda_name]/document/detail/[slug]/page.tsx index 0c0e9ecc..c3f4d657 100644 --- a/app/[locale]/(public)/(polda)/polda/[polda_name]/document/detail/[slug]/page.tsx +++ b/app/[locale]/(public)/(polda)/polda/[polda_name]/document/detail/[slug]/page.tsx @@ -20,6 +20,7 @@ import { Button } from "@/components/ui/button"; import { useSearchParams } from "next/navigation"; import { sendMediaUploadToEmail } from "@/service/media-tracking/media-tracking"; import parse from "html-react-parser"; +import { postActivityLog } from "@/service/content/content"; const DetailDocument = () => { const [selectedSize, setSelectedSize] = useState("L"); @@ -59,6 +60,7 @@ const DetailDocument = () => { useEffect(() => { initFetch(); checkWishlist(); + sendActivityLog(2); }, []); const initFetch = async () => { @@ -151,8 +153,7 @@ const DetailDocument = () => { url: window.location.href, }; // set activity - // const response = await postActivityLog(data, token); - // console.log(response); + await postActivityLog(data); } const handleDownload = () => { diff --git a/app/[locale]/(public)/(polda)/polda/[polda_name]/image/detail/[slug]/page.tsx b/app/[locale]/(public)/(polda)/polda/[polda_name]/image/detail/[slug]/page.tsx index 02be3577..1fcb2322 100644 --- a/app/[locale]/(public)/(polda)/polda/[polda_name]/image/detail/[slug]/page.tsx +++ b/app/[locale]/(public)/(polda)/polda/[polda_name]/image/detail/[slug]/page.tsx @@ -17,6 +17,7 @@ import withReactContent from "sweetalert2-react-content"; import Swal from "sweetalert2"; import { useSearchParams } from "next/navigation"; import parse from "html-react-parser"; +import { postActivityLog } from "@/service/content/content"; const DetailInfo = () => { const MySwal = withReactContent(Swal); @@ -57,6 +58,7 @@ const DetailInfo = () => { useEffect(() => { initFetch(); checkWishlist(); + sendActivityLog(2); }, []); const initFetch = async () => { @@ -155,8 +157,7 @@ const DetailInfo = () => { url: window.location.href, }; // set activity - // const response = await postActivityLog(data, token); - // console.log(response); + await postActivityLog(data); } function addDefaultProfile(ev: any) { diff --git a/app/[locale]/(public)/(polda)/polda/[polda_name]/video/detail/[slug]/page.tsx b/app/[locale]/(public)/(polda)/polda/[polda_name]/video/detail/[slug]/page.tsx index d993ec4e..f5f7637f 100644 --- a/app/[locale]/(public)/(polda)/polda/[polda_name]/video/detail/[slug]/page.tsx +++ b/app/[locale]/(public)/(polda)/polda/[polda_name]/video/detail/[slug]/page.tsx @@ -11,6 +11,7 @@ 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("L"); @@ -34,6 +35,7 @@ const DetailVideo = () => { useEffect(() => { initFetch(); checkWishlist(); + sendActivityLog(2); }, []); const initFetch = async () => { @@ -126,8 +128,7 @@ const DetailVideo = () => { url: window.location.href, }; // set activity - // const response = await postActivityLog(data, token); - // console.log(response); + await postActivityLog(data); } const handleDownload = () => { diff --git a/app/[locale]/(public)/(polda)/tbnews/[polda_name]/image/detail/[slug]/page.tsx b/app/[locale]/(public)/(polda)/tbnews/[polda_name]/image/detail/[slug]/page.tsx index 84bcd98a..a0a0da29 100644 --- a/app/[locale]/(public)/(polda)/tbnews/[polda_name]/image/detail/[slug]/page.tsx +++ b/app/[locale]/(public)/(polda)/tbnews/[polda_name]/image/detail/[slug]/page.tsx @@ -160,6 +160,7 @@ import parse from "html-react-parser"; import { Skeleton } from "@/components/ui/skeleton"; import { useTranslations } from "next-intl"; import Image from "next/image"; +import { postActivityLog } from "@/service/content/content"; interface Size { label: string; @@ -215,6 +216,7 @@ const DetailInfo = () => { useEffect(() => { initFetch(); checkWishlist(); + sendActivityLog(2); }, []); const initFetch = async () => { @@ -333,8 +335,7 @@ const DetailInfo = () => { url: window.location.href, }; // set activity - // const response = await postActivityLog(data, token); - // console.log(response); + await postActivityLog(data); } const handleDownload = () => { diff --git a/app/[locale]/(public)/(satker)/satker/[satker_name]/audio/detail/[slug]/page.tsx b/app/[locale]/(public)/(satker)/satker/[satker_name]/audio/detail/[slug]/page.tsx index 0926b251..12999527 100644 --- a/app/[locale]/(public)/(satker)/satker/[satker_name]/audio/detail/[slug]/page.tsx +++ b/app/[locale]/(public)/(satker)/satker/[satker_name]/audio/detail/[slug]/page.tsx @@ -11,6 +11,7 @@ import { useToast } from "@/components/ui/use-toast"; import { checkWishlistStatus, deleteWishlist, getDetail, saveWishlist } from "@/service/landing/landing"; import { getCookiesDecrypt } from "@/lib/utils"; import { close, error, loading } from "@/config/swal"; +import { postActivityLog } from "@/service/content/content"; const DetailAudio = () => { const [selectedSize, setSelectedSize] = useState("L"); @@ -35,6 +36,7 @@ const DetailAudio = () => { useEffect(() => { initFetch(); checkWishlist(); + sendActivityLog(2); }, []); const initFetch = async () => { @@ -119,8 +121,7 @@ const DetailAudio = () => { url: window.location.href, }; // set activity - // const response = await postActivityLog(data, token); - // console.log(response); + await postActivityLog(data); } const handleDownload = () => { diff --git a/app/[locale]/(public)/(satker)/satker/[satker_name]/document/detail/[slug]/page.tsx b/app/[locale]/(public)/(satker)/satker/[satker_name]/document/detail/[slug]/page.tsx index 45792ef2..b9117d4f 100644 --- a/app/[locale]/(public)/(satker)/satker/[satker_name]/document/detail/[slug]/page.tsx +++ b/app/[locale]/(public)/(satker)/satker/[satker_name]/document/detail/[slug]/page.tsx @@ -10,6 +10,7 @@ import { checkWishlistStatus, deleteWishlist, getDetail, saveWishlist } from "@/ import { close, error, loading } from "@/config/swal"; import { useToast } from "@/components/ui/use-toast"; import { Link, useRouter } from "@/i18n/routing"; +import { postActivityLog } from "@/service/content/content"; const DetailDocument = () => { const [selectedSize, setSelectedSize] = useState("L"); @@ -35,6 +36,7 @@ const DetailDocument = () => { useEffect(() => { initFetch(); checkWishlist(); + sendActivityLog(2); }, []); const initFetch = async () => { @@ -127,8 +129,7 @@ const DetailDocument = () => { url: window.location.href, }; // set activity - // const response = await postActivityLog(data, token); - // console.log(response); + await postActivityLog(data); } const handleDownload = () => { diff --git a/app/[locale]/(public)/(satker)/satker/[satker_name]/image/detail/[slug]/page.tsx b/app/[locale]/(public)/(satker)/satker/[satker_name]/image/detail/[slug]/page.tsx index aa899d42..ab1460c1 100644 --- a/app/[locale]/(public)/(satker)/satker/[satker_name]/image/detail/[slug]/page.tsx +++ b/app/[locale]/(public)/(satker)/satker/[satker_name]/image/detail/[slug]/page.tsx @@ -10,6 +10,7 @@ import { getCookiesDecrypt } from "@/lib/utils"; import { close, error, loading } from "@/config/swal"; import { checkWishlistStatus, deleteWishlist, getDetail, saveWishlist } from "@/service/landing/landing"; import { Link, useRouter } from "@/i18n/routing"; +import { postActivityLog } from "@/service/content/content"; const DetailInfo = () => { const [selectedSize, setSelectedSize] = useState("L"); @@ -35,6 +36,7 @@ const DetailInfo = () => { useEffect(() => { initFetch(); checkWishlist(); + sendActivityLog(2); }, []); const initFetch = async () => { @@ -127,7 +129,7 @@ const DetailInfo = () => { url: window.location.href, }; // set activity - // const response = await postActivityLog(data, token); + await postActivityLog(data); // console.log(response); } diff --git a/app/[locale]/(public)/(satker)/satker/[satker_name]/video/detail/[slug]/page.tsx b/app/[locale]/(public)/(satker)/satker/[satker_name]/video/detail/[slug]/page.tsx index 335ee69f..8f6d744c 100644 --- a/app/[locale]/(public)/(satker)/satker/[satker_name]/video/detail/[slug]/page.tsx +++ b/app/[locale]/(public)/(satker)/satker/[satker_name]/video/detail/[slug]/page.tsx @@ -11,6 +11,7 @@ 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("L"); @@ -34,6 +35,7 @@ const DetailVideo = () => { useEffect(() => { initFetch(); checkWishlist(); + sendActivityLog(2); }, []); const initFetch = async () => { @@ -126,8 +128,7 @@ const DetailVideo = () => { url: window.location.href, }; // set activity - // const response = await postActivityLog(data, token); - // console.log(response); + postActivityLog(data); } const handleDownload = () => { diff --git a/app/[locale]/(public)/audio/detail/[slug]/page.tsx b/app/[locale]/(public)/audio/detail/[slug]/page.tsx index 1cf117e1..143cb1c7 100644 --- a/app/[locale]/(public)/audio/detail/[slug]/page.tsx +++ b/app/[locale]/(public)/audio/detail/[slug]/page.tsx @@ -21,6 +21,7 @@ import { checkMaliciousText, formatDateToIndonesian, getPublicLocaleTimestamp } import parse from "html-react-parser"; import $ from "jquery"; import { useTranslations } from "next-intl"; +import { postActivityLog } from "@/service/content/content"; const formWaveSurferOptions = (ref: any) => ({ container: ref, @@ -74,6 +75,7 @@ const DetailAudio = () => { useEffect(() => { initFetch(); checkWishlist(); + sendActivityLog(2); }, []); const initFetch = async () => { @@ -163,8 +165,7 @@ const DetailAudio = () => { url: window.location.href, }; // set activity - // const response = await postActivityLog(data, token); - // console.log(response); + await postActivityLog(data); } const handleDownload = () => { diff --git a/app/[locale]/(public)/document/detail/[slug]/page.tsx b/app/[locale]/(public)/document/detail/[slug]/page.tsx index a9d3a4ce..c777388c 100644 --- a/app/[locale]/(public)/document/detail/[slug]/page.tsx +++ b/app/[locale]/(public)/document/detail/[slug]/page.tsx @@ -19,6 +19,7 @@ import withReactContent from "sweetalert2-react-content"; import Swal from "sweetalert2"; import parse from "html-react-parser"; import { useTranslations } from "next-intl"; +import { postActivityLog } from "@/service/content/content"; const DetailDocument = () => { const [selectedSize, setSelectedSize] = useState("L"); @@ -58,6 +59,7 @@ const DetailDocument = () => { useEffect(() => { initFetch(); checkWishlist(); + sendActivityLog(2); }, []); const initFetch = async () => { @@ -161,8 +163,7 @@ const DetailDocument = () => { url: window.location.href, }; // set activity - // const response = await postActivityLog(data, token); - // console.log(response); + await postActivityLog(data); } const handleDownload = () => { diff --git a/app/[locale]/(public)/image/detail/[slug]/page.tsx b/app/[locale]/(public)/image/detail/[slug]/page.tsx index bd7b3e1d..44e9748c 100644 --- a/app/[locale]/(public)/image/detail/[slug]/page.tsx +++ b/app/[locale]/(public)/image/detail/[slug]/page.tsx @@ -37,6 +37,7 @@ import parse from "html-react-parser"; import { Skeleton } from "@/components/ui/skeleton"; import { useTranslations } from "next-intl"; import Image from "next/image"; +import { postActivityLog } from "@/service/content/content"; interface Size { label: string; @@ -96,6 +97,7 @@ const DetailInfo = () => { useEffect(() => { initFetch(); checkWishlist(); + sendActivityLog(2); }, []); const initFetch = async () => { @@ -214,8 +216,7 @@ const DetailInfo = () => { url: window.location.href, }; // set activity - // const response = await postActivityLog(data, token); - // console.log(response); + await postActivityLog(data); } const handleDownload = () => { diff --git a/app/[locale]/(public)/video/detail/[slug]/page.tsx b/app/[locale]/(public)/video/detail/[slug]/page.tsx index a02a0e84..171bfb9b 100644 --- a/app/[locale]/(public)/video/detail/[slug]/page.tsx +++ b/app/[locale]/(public)/video/detail/[slug]/page.tsx @@ -21,6 +21,7 @@ import Swal from "sweetalert2"; import parse from "html-react-parser"; import { useTranslations } from "next-intl"; import Image from "next/image"; +import { postActivityLog } from "@/service/content/content"; interface Size { label: string; @@ -62,6 +63,7 @@ const DetailVideo = () => { useEffect(() => { initFetch(); checkWishlist(); + sendActivityLog(2); }, []); const initFetch = async () => { @@ -158,8 +160,7 @@ const DetailVideo = () => { url: window.location.href, }; // set activity - // const response = await postActivityLog(data, token); - // console.log(response); + await postActivityLog(data); } const handleDownload = () => { diff --git a/service/content/content.ts b/service/content/content.ts index af2da4a4..257c24f1 100644 --- a/service/content/content.ts +++ b/service/content/content.ts @@ -1,3 +1,4 @@ +import { httpPost } from "../http-config/http-base-service"; import { httpDeleteInterceptor, httpGetInterceptor, @@ -225,3 +226,11 @@ export async function deleteSPIT(id: any) { const url = `media/spit?id=${id}`; return httpDeleteInterceptor(url); } + +export async function postActivityLog(data: any) { + const url = `activity`; + const headers = { + "content-type": "application/json", + }; + return httpPost(url, headers, data); +} \ No newline at end of file diff --git a/service/http-config/http-base-service.ts b/service/http-config/http-base-service.ts index 2d4ed979..3290e120 100644 --- a/service/http-config/http-base-service.ts +++ b/service/http-config/http-base-service.ts @@ -7,6 +7,7 @@ import { getCsrfToken } from "../auth"; export async function httpPost(pathUrl: any, headers: any, data?: any) { const resCsrf = await getCsrfToken(); const csrfToken = resCsrf?.data?.token; + const authToken = Cookies.get("access_token"); const defaultHeaders = { "Content-Type": "application/json", @@ -16,6 +17,7 @@ export async function httpPost(pathUrl: any, headers: any, data?: any) { ...defaultHeaders, ...headers, ...(csrfToken ? { "X-XSRF-TOKEN": csrfToken } : {}), + ...(authToken ? { "Authorization" : `Bearer ${authToken}`} : {}), }; const response = await axiosBaseInstance