diff --git a/app/docs/layout.tsx b/app/docs/layout.tsx
index 905fcf5..8583c51 100644
--- a/app/docs/layout.tsx
+++ b/app/docs/layout.tsx
@@ -1,6 +1,6 @@
"use client";
-import { HumasLayout } from "@/components/layout/humas-layout";
+import HumasLayout from "@/components/layout/humas-layout";
export default function DocsLayout({
children,
diff --git a/app/e-majalah-polri/daftar-majalah/page.tsx b/app/e-majalah-polri/daftar-majalah/page.tsx
index e8309b4..dc9442e 100644
--- a/app/e-majalah-polri/daftar-majalah/page.tsx
+++ b/app/e-majalah-polri/daftar-majalah/page.tsx
@@ -1,4 +1,4 @@
-import { HumasLayout } from "@/components/layout/humas-layout";
+import HumasLayout from "@/components/layout/humas-layout";
import ListEnewsPolri from "@/components/table/tabel-emajalah-polri";
export default function ListEnewsPage() {
diff --git a/app/e-majalah-polri/detail/[id]/layout.tsx b/app/e-majalah-polri/detail/[id]/layout.tsx
index f474361..864f491 100644
--- a/app/e-majalah-polri/detail/[id]/layout.tsx
+++ b/app/e-majalah-polri/detail/[id]/layout.tsx
@@ -1,4 +1,4 @@
-import { HumasLayout } from "@/components/layout/humas-layout";
+import HumasLayout from "@/components/layout/humas-layout";
export default function DetailEMajalahLayout({
children,
diff --git a/app/e-majalah-polri/detail/[id]/page.tsx b/app/e-majalah-polri/detail/[id]/page.tsx
index bd5d0bb..c12234d 100644
--- a/app/e-majalah-polri/detail/[id]/page.tsx
+++ b/app/e-majalah-polri/detail/[id]/page.tsx
@@ -1,5 +1,5 @@
"use client";
-import { HumasLayout } from "@/components/layout/humas-layout";
+import HumasLayout from "@/components/layout/humas-layout";
import EMagazineDetail from "@/components/main/detail/e-magazine-detail";
import React, { Suspense, useEffect, useState } from "react";
diff --git a/app/form-permohonan-informasi/layout.tsx b/app/form-permohonan-informasi/layout.tsx
index bd15370..1376b9b 100644
--- a/app/form-permohonan-informasi/layout.tsx
+++ b/app/form-permohonan-informasi/layout.tsx
@@ -1,5 +1,5 @@
"use client";
-import { HumasLayout } from "@/components/layout/humas-layout";
+import HumasLayout from "@/components/layout/humas-layout";
export default function ApplicationLayout({
children,
diff --git a/app/kontak-kami/layout.tsx b/app/kontak-kami/layout.tsx
index 27bb561..ae0cbbc 100644
--- a/app/kontak-kami/layout.tsx
+++ b/app/kontak-kami/layout.tsx
@@ -1,5 +1,5 @@
"use client";
-import { HumasLayout } from "@/components/layout/humas-layout";
+import HumasLayout from "@/components/layout/humas-layout";
export default function KontakLayout({
children,
diff --git a/app/news/all/page.tsx b/app/news/all/page.tsx
index 0d7cd26..a221e6b 100644
--- a/app/news/all/page.tsx
+++ b/app/news/all/page.tsx
@@ -1,7 +1,7 @@
"use client";
import ListNews from "@/components/main/detail/list-news";
import React, { useEffect, useState } from "react";
-import { HumasLayout } from "@/components/layout/humas-layout";
+import HumasLayout from "@/components/layout/humas-layout";
export default function ListNewsPage() {
const [hasMounted, setHasMounted] = useState(false);
diff --git a/app/news/detail/[id]/page.tsx b/app/news/detail/[id]/page.tsx
index 2328cf7..008878a 100644
--- a/app/news/detail/[id]/page.tsx
+++ b/app/news/detail/[id]/page.tsx
@@ -1,5 +1,4 @@
-"use server";
-import { HumasLayout } from "@/components/layout/humas-layout";
+import HumasLayout from "@/components/layout/humas-layout";
import DetailPage from "@/components/main/detail/new-detail";
import { getArticleById } from "@/services/article";
import { Metadata } from "next";
diff --git a/app/news/polda/[name]/page.tsx b/app/news/polda/[name]/page.tsx
index 52de9f9..ccdb2de 100644
--- a/app/news/polda/[name]/page.tsx
+++ b/app/news/polda/[name]/page.tsx
@@ -1,6 +1,6 @@
import ListNews from "@/components/main/detail/list-news";
import React from "react";
-import { HumasLayout } from "@/components/layout/humas-layout";
+import HumasLayout from "@/components/layout/humas-layout";
export default function PoldaNewsPage() {
// return ;
diff --git a/app/news/satker/[name]/page.tsx b/app/news/satker/[name]/page.tsx
index 52de9f9..ccdb2de 100644
--- a/app/news/satker/[name]/page.tsx
+++ b/app/news/satker/[name]/page.tsx
@@ -1,6 +1,6 @@
import ListNews from "@/components/main/detail/list-news";
import React from "react";
-import { HumasLayout } from "@/components/layout/humas-layout";
+import HumasLayout from "@/components/layout/humas-layout";
export default function PoldaNewsPage() {
// return ;
diff --git a/app/profile-pimpinan-polri/layout.tsx b/app/profile-pimpinan-polri/layout.tsx
index ccfac43..58dd028 100644
--- a/app/profile-pimpinan-polri/layout.tsx
+++ b/app/profile-pimpinan-polri/layout.tsx
@@ -1,5 +1,5 @@
"use client";
-import { HumasLayout } from "@/components/layout/humas-layout";
+import HumasLayout from "@/components/layout/humas-layout";
export default function PropimLayout({
children,
diff --git a/app/static/[slug]/page.tsx b/app/static/[slug]/page.tsx
index 177927f..bcb5150 100644
--- a/app/static/[slug]/page.tsx
+++ b/app/static/[slug]/page.tsx
@@ -1,6 +1,6 @@
"use client";
-import { HumasLayout } from "@/components/layout/humas-layout";
+import HumasLayout from "@/components/layout/humas-layout";
import { getCustomStaticDetailBySlug } from "@/services/static-page-service";
import { Card, CircularProgress } from "@heroui/react";
import { useParams } from "next/navigation";
diff --git a/app/struktur-organisasi/layout.tsx b/app/struktur-organisasi/layout.tsx
index 5fb8463..5b4dfc1 100644
--- a/app/struktur-organisasi/layout.tsx
+++ b/app/struktur-organisasi/layout.tsx
@@ -1,5 +1,5 @@
"use client";
-import { HumasLayout } from "@/components/layout/humas-layout";
+import HumasLayout from "@/components/layout/humas-layout";
export default function StrukturLayout({
children,
diff --git a/app/tentang-humas-polri/layout.tsx b/app/tentang-humas-polri/layout.tsx
index 6bf0907..6141cc4 100644
--- a/app/tentang-humas-polri/layout.tsx
+++ b/app/tentang-humas-polri/layout.tsx
@@ -1,5 +1,5 @@
"use client";
-import { HumasLayout } from "@/components/layout/humas-layout";
+import HumasLayout from "@/components/layout/humas-layout";
export default function AboutLayout({
children,
diff --git a/app/tugas-dan-fungsi/layout.tsx b/app/tugas-dan-fungsi/layout.tsx
index 8cb8a88..d0f8d2d 100644
--- a/app/tugas-dan-fungsi/layout.tsx
+++ b/app/tugas-dan-fungsi/layout.tsx
@@ -1,5 +1,5 @@
"use client";
-import { HumasLayout } from "@/components/layout/humas-layout";
+import HumasLayout from "@/components/layout/humas-layout";
export default function TaskLayout({
children,
diff --git a/app/visi-misi/layout.tsx b/app/visi-misi/layout.tsx
index f0fa52d..7f02f90 100644
--- a/app/visi-misi/layout.tsx
+++ b/app/visi-misi/layout.tsx
@@ -1,5 +1,5 @@
"use client";
-import { HumasLayout } from "@/components/layout/humas-layout";
+import HumasLayout from "@/components/layout/humas-layout";
export default function VisiMisiLayout({
children,
diff --git a/components/landing/footer-new.tsx b/components/landing/footer-new.tsx
index 0b80f3a..d3b70e0 100644
--- a/components/landing/footer-new.tsx
+++ b/components/landing/footer-new.tsx
@@ -20,7 +20,11 @@ import Cookies from "js-cookie";
export default function FooterNew(props: { margin?: boolean }) {
const [emailValue, setEmailValue] = useState("");
- const accessToken = Cookies.get("access_token");
+ const [accessToken, setAccessToken] = useState();
+ useEffect(() => {
+ const accessToken = Cookies.get("access_token");
+ setAccessToken(accessToken);
+ }, []);
const doSubscribe = async () => {
const isValidEmail = (email: string): boolean => {
diff --git a/components/layout/humas-layout.tsx b/components/layout/humas-layout.tsx
index c46cab3..4f9f3a2 100644
--- a/components/layout/humas-layout.tsx
+++ b/components/layout/humas-layout.tsx
@@ -9,8 +9,7 @@ import FooterNew from "../landing/footer-new";
interface Props {
children: React.ReactNode;
}
-
-export const HumasLayout = ({ children }: Props) => {
+const HumasLayout = ({ children }: Props) => {
const [hasMounted, setHasMounted] = useState(false);
useEffect(() => {
@@ -32,3 +31,5 @@ export const HumasLayout = ({ children }: Props) => {
);
};
+
+export default HumasLayout;
diff --git a/components/layout/navbar/NavbarHumas.tsx b/components/layout/navbar/NavbarHumas.tsx
index d5a414b..7adddc3 100644
--- a/components/layout/navbar/NavbarHumas.tsx
+++ b/components/layout/navbar/NavbarHumas.tsx
@@ -61,19 +61,16 @@ export default function NavbarHumas(props: { size: string }) {
const [isOpen, setIsOpen] = useState(false);
const router = useRouter();
// const t = useTranslations("Navbar");
- const token = Cookies.get("access_token");
- const isAuthenticated = Cookies.get("is_authenticated");
const [isScrolled, setIsScrolled] = useState(false);
const [search, setSearch] = useState("");
-
+ const [token, setToken] = useState();
const language = storedLanguage((state) => state.locale);
const setLanguage = storedLanguage((state) => state.setLocale);
- // useEffect(() => {
- // if (!isAuthenticated) {
- // onLogout();
- // }
- // }, [token]);
+ useEffect(() => {
+ const token = Cookies.get("access_token");
+ setToken(token);
+ }, []);
const onLogout = () => {
Object.keys(Cookies.get()).forEach((cookieName) => {
diff --git a/components/main/detail/comment.tsx b/components/main/detail/comment.tsx
index 4c70935..134580a 100644
--- a/components/main/detail/comment.tsx
+++ b/components/main/detail/comment.tsx
@@ -23,9 +23,6 @@ import { SendIcon, TimesIcon } from "@/components/icons";
import { saveActivity } from "@/services/activity-log";
import { usePathname } from "next/navigation";
-const userId = getCookiesDecrypt("uie");
-const token = Cookies.get("access_token");
-
const commentSchema = z.object({
name: z.string().min(1, {
message: "Judul harus diisi",
@@ -54,6 +51,16 @@ export default function Comment(props: { id: string | null }) {
const [editCommentId, setEditCommentId] = useState(0);
const [replyValue, setReplyValue] = useState("");
const [editValue, setEditValue] = useState("");
+
+ const [userId, setUserId] = useState();
+ const [token, setToken] = useState();
+
+ useEffect(() => {
+ const userId = getCookiesDecrypt("uie");
+ const token = Cookies.get("access_token");
+ setUserId(userId);
+ setToken(token);
+ }, []);
const formOptions = {
resolver: zodResolver(commentSchema),
};
diff --git a/components/main/detail/new-detail.tsx b/components/main/detail/new-detail.tsx
index 90f2857..f2e039b 100644
--- a/components/main/detail/new-detail.tsx
+++ b/components/main/detail/new-detail.tsx
@@ -14,16 +14,18 @@ import Cookies from "js-cookie";
import Head from "next/head";
import { getCookiesDecrypt } from "@/utils/global";
-const token = Cookies.get("access_token");
-const uid = getCookiesDecrypt("uie");
-
export default function NewsDetailPage(props: { datas: any }) {
const params = useParams();
const id: any = params?.id;
const pathname = usePathname();
const [detailArticle, setDetailArticle] = useState();
const [articles, setArticles] = useState([]);
+ const [uid, setUid] = useState("");
+ useEffect(() => {
+ const uid = getCookiesDecrypt("uie");
+ setUid(uid);
+ }, []);
useEffect(() => {
getArticles();
sendActivity();
@@ -43,6 +45,7 @@ export default function NewsDetailPage(props: { datas: any }) {
if (uid) {
req.userId = Number(uid);
}
+ const token = Cookies.get("access_token");
const resActivity = await saveActivity(req, token);
};
diff --git a/components/page/detail-news.tsx b/components/page/detail-news.tsx
index b26aadb..951f8df 100644
--- a/components/page/detail-news.tsx
+++ b/components/page/detail-news.tsx
@@ -28,9 +28,6 @@ import Cookies from "js-cookie";
import { saveActivity } from "@/services/activity-log";
import { Accordion, AccordionItem, Image } from "@heroui/react";
-const token = Cookies.get("access_token");
-const uid = getCookiesDecrypt("uie");
-
export default function DetailNews(props: { data: any; listArticle: any }) {
const { data, listArticle } = props;
const [prevArticle, setPrevArticle] = useState("");
@@ -40,6 +37,15 @@ export default function DetailNews(props: { data: any; listArticle: any }) {
const params = useParams();
const id: any = params?.id;
const shareText = "Humas Polri";
+ const [uid, setUid] = useState("");
+ const [token, setToken] = useState("");
+
+ useEffect(() => {
+ const token = Cookies.get("access_token");
+ const uid = getCookiesDecrypt("uie");
+ setToken(token);
+ setUid(uid);
+ }, []);
const handleShare = async (platform: string) => {
let shareLink = "";
diff --git a/components/page/related-news.tsx b/components/page/related-news.tsx
index 976485d..6841a0b 100644
--- a/components/page/related-news.tsx
+++ b/components/page/related-news.tsx
@@ -18,7 +18,6 @@ export default function RelatedNews(props: { categories: any }) {
useEffect(() => {
async function getArticle() {
- console.log("categories", categories);
const idString = categories.map((item: any) => item.id).join(",");
const req = {
diff --git a/tsconfig.json b/tsconfig.json
index 16afa53..f6b1494 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -19,7 +19,6 @@
"name": "next"
}
],
- "types": ["node", "minimatch"],
"paths": {
"@/*": ["./*"]
},