feat:all static page
This commit is contained in:
parent
6286b5c297
commit
85309da98e
|
|
@ -2,23 +2,24 @@
|
||||||
|
|
||||||
import { HumasLayout } from "@/components/layout/humas-layout";
|
import { HumasLayout } from "@/components/layout/humas-layout";
|
||||||
import { getCustomStaticDetailBySlug } from "@/service/static-page-service";
|
import { getCustomStaticDetailBySlug } from "@/service/static-page-service";
|
||||||
import { Card } from "@nextui-org/react";
|
import { Card, CircularProgress } from "@nextui-org/react";
|
||||||
import { useParams } from "next/navigation";
|
import { useParams } from "next/navigation";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
|
|
||||||
export default function StaticPage() {
|
export default function StaticPage() {
|
||||||
const params = useParams();
|
const params = useParams();
|
||||||
const slug = params.slug;
|
const slug = params.slug;
|
||||||
const [htmlBody, setHtmlBody] = useState("");
|
const [customData, setCustomData] = useState<any>();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
setCustomData(undefined);
|
||||||
initFetch();
|
initFetch();
|
||||||
}, [slug]);
|
}, [slug]);
|
||||||
|
|
||||||
const initFetch = async () => {
|
const initFetch = async () => {
|
||||||
const res = await getCustomStaticDetailBySlug(slug ? String(slug) : "");
|
const res = await getCustomStaticDetailBySlug(slug ? String(slug) : "");
|
||||||
const data = res?.data?.data;
|
const data = res?.data?.data;
|
||||||
setHtmlBody(data?.htmlBody);
|
setCustomData(data);
|
||||||
};
|
};
|
||||||
|
|
||||||
const [hasMounted, setHasMounted] = useState(false);
|
const [hasMounted, setHasMounted] = useState(false);
|
||||||
|
|
@ -30,9 +31,26 @@ export default function StaticPage() {
|
||||||
if (!hasMounted) return null;
|
if (!hasMounted) return null;
|
||||||
return (
|
return (
|
||||||
<HumasLayout>
|
<HumasLayout>
|
||||||
<Card className="rounded-md p-2 md:p-16">
|
{customData ? (
|
||||||
<div dangerouslySetInnerHTML={{ __html: htmlBody }} />
|
<>
|
||||||
</Card>
|
<div className="flex justify-center items-center">
|
||||||
|
<div className="pt-4 hidden md:block">
|
||||||
|
<img src="/al.png" alt="" className="" />
|
||||||
|
</div>
|
||||||
|
<div className="font-bold text-lg md:text-2xl text-[#DD8306]">
|
||||||
|
{customData?.title}
|
||||||
|
</div>
|
||||||
|
<div className="hidden md:block absolute pb-10 pl-[310px]">
|
||||||
|
<img src="spark.png" alt="" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="rounded-md p-2 md:px-10 ">
|
||||||
|
<div dangerouslySetInnerHTML={{ __html: customData?.htmlBody }} />
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<div className="w-full justify-center flex">NO DATA</div>
|
||||||
|
)}
|
||||||
</HumasLayout>
|
</HumasLayout>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -158,7 +158,6 @@ export default function StaticPageBuilderEdit() {
|
||||||
value={value}
|
value={value}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
labelPlacement="outside"
|
labelPlacement="outside"
|
||||||
readOnly
|
|
||||||
className="w-full"
|
className="w-full"
|
||||||
variant="bordered"
|
variant="bordered"
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -58,11 +58,11 @@ export default function NavbarHumas() {
|
||||||
const token = Cookies.get("access_token");
|
const token = Cookies.get("access_token");
|
||||||
const isAuthenticated = Cookies.get("is_authenticated");
|
const isAuthenticated = Cookies.get("is_authenticated");
|
||||||
|
|
||||||
useEffect(() => {
|
// useEffect(() => {
|
||||||
if (!isAuthenticated) {
|
// if (!isAuthenticated) {
|
||||||
onLogout();
|
// onLogout();
|
||||||
}
|
// }
|
||||||
}, [token]);
|
// }, [token]);
|
||||||
|
|
||||||
const onLogout = () => {
|
const onLogout = () => {
|
||||||
Object.keys(Cookies.get()).forEach((cookieName) => {
|
Object.keys(Cookies.get()).forEach((cookieName) => {
|
||||||
|
|
@ -191,7 +191,7 @@ export default function NavbarHumas() {
|
||||||
</DropdownItem>
|
</DropdownItem>
|
||||||
<DropdownItem>
|
<DropdownItem>
|
||||||
<Link
|
<Link
|
||||||
href="/profile-pimpinan-polri"
|
href="/static/profile-kapolri"
|
||||||
className="flex justify-between"
|
className="flex justify-between"
|
||||||
>
|
>
|
||||||
Profile Pimpinan POLRI
|
Profile Pimpinan POLRI
|
||||||
|
|
@ -200,7 +200,7 @@ export default function NavbarHumas() {
|
||||||
</DropdownItem>
|
</DropdownItem>
|
||||||
<DropdownItem>
|
<DropdownItem>
|
||||||
<Link
|
<Link
|
||||||
href="/struktur-organisasi"
|
href="/static/struktur-mabes"
|
||||||
className="flex justify-between"
|
className="flex justify-between"
|
||||||
>
|
>
|
||||||
Struktur Organisasi
|
Struktur Organisasi
|
||||||
|
|
@ -208,14 +208,17 @@ export default function NavbarHumas() {
|
||||||
</Link>
|
</Link>
|
||||||
</DropdownItem>
|
</DropdownItem>
|
||||||
<DropdownItem>
|
<DropdownItem>
|
||||||
<Link href="/visi-misi" className="flex justify-between">
|
<Link
|
||||||
|
href="/static/visi-misi-polri"
|
||||||
|
className="flex justify-between"
|
||||||
|
>
|
||||||
Visi & Misi
|
Visi & Misi
|
||||||
<ChevronRightIcon />
|
<ChevronRightIcon />
|
||||||
</Link>
|
</Link>
|
||||||
</DropdownItem>
|
</DropdownItem>
|
||||||
<DropdownItem>
|
<DropdownItem>
|
||||||
<Link
|
<Link
|
||||||
href="/tugas-dan-fungsi"
|
href="/static/tugas-dan-fungsi-polri"
|
||||||
className="flex justify-between"
|
className="flex justify-between"
|
||||||
>
|
>
|
||||||
Tugas & Fungsi
|
Tugas & Fungsi
|
||||||
|
|
@ -223,7 +226,7 @@ export default function NavbarHumas() {
|
||||||
</Link>
|
</Link>
|
||||||
</DropdownItem>
|
</DropdownItem>
|
||||||
<DropdownItem>
|
<DropdownItem>
|
||||||
<Link href="#" className="flex justify-between">
|
<Link href="/static/logo" className="flex justify-between">
|
||||||
Logo
|
Logo
|
||||||
<ChevronRightIcon />
|
<ChevronRightIcon />
|
||||||
</Link>
|
</Link>
|
||||||
|
|
|
||||||
|
|
@ -95,12 +95,12 @@ export default function StaticPageBuilder() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const title = watch("title");
|
// const title = watch("title");
|
||||||
useEffect(() => {
|
// useEffect(() => {
|
||||||
if (getValues("title")) {
|
// if (getValues("title")) {
|
||||||
setValue("slug", createSlug(getValues("title")));
|
// setValue("slug", createSlug(getValues("title")));
|
||||||
}
|
// }
|
||||||
}, [title]);
|
// }, [title]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form
|
<form
|
||||||
|
|
@ -139,7 +139,6 @@ export default function StaticPageBuilder() {
|
||||||
value={value}
|
value={value}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
labelPlacement="outside"
|
labelPlacement="outside"
|
||||||
readOnly
|
|
||||||
className="w-full"
|
className="w-full"
|
||||||
variant="bordered"
|
variant="bordered"
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 36 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 279 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 63 KiB |
Loading…
Reference in New Issue