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 { 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 { useEffect, useState } from "react";
|
||||
|
||||
export default function StaticPage() {
|
||||
const params = useParams();
|
||||
const slug = params.slug;
|
||||
const [htmlBody, setHtmlBody] = useState("");
|
||||
const [customData, setCustomData] = useState<any>();
|
||||
|
||||
useEffect(() => {
|
||||
setCustomData(undefined);
|
||||
initFetch();
|
||||
}, [slug]);
|
||||
|
||||
const initFetch = async () => {
|
||||
const res = await getCustomStaticDetailBySlug(slug ? String(slug) : "");
|
||||
const data = res?.data?.data;
|
||||
setHtmlBody(data?.htmlBody);
|
||||
setCustomData(data);
|
||||
};
|
||||
|
||||
const [hasMounted, setHasMounted] = useState(false);
|
||||
|
|
@ -30,9 +31,26 @@ export default function StaticPage() {
|
|||
if (!hasMounted) return null;
|
||||
return (
|
||||
<HumasLayout>
|
||||
<Card className="rounded-md p-2 md:p-16">
|
||||
<div dangerouslySetInnerHTML={{ __html: htmlBody }} />
|
||||
</Card>
|
||||
{customData ? (
|
||||
<>
|
||||
<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>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -158,7 +158,6 @@ export default function StaticPageBuilderEdit() {
|
|||
value={value}
|
||||
onChange={onChange}
|
||||
labelPlacement="outside"
|
||||
readOnly
|
||||
className="w-full"
|
||||
variant="bordered"
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -58,11 +58,11 @@ export default function NavbarHumas() {
|
|||
const token = Cookies.get("access_token");
|
||||
const isAuthenticated = Cookies.get("is_authenticated");
|
||||
|
||||
useEffect(() => {
|
||||
if (!isAuthenticated) {
|
||||
onLogout();
|
||||
}
|
||||
}, [token]);
|
||||
// useEffect(() => {
|
||||
// if (!isAuthenticated) {
|
||||
// onLogout();
|
||||
// }
|
||||
// }, [token]);
|
||||
|
||||
const onLogout = () => {
|
||||
Object.keys(Cookies.get()).forEach((cookieName) => {
|
||||
|
|
@ -191,7 +191,7 @@ export default function NavbarHumas() {
|
|||
</DropdownItem>
|
||||
<DropdownItem>
|
||||
<Link
|
||||
href="/profile-pimpinan-polri"
|
||||
href="/static/profile-kapolri"
|
||||
className="flex justify-between"
|
||||
>
|
||||
Profile Pimpinan POLRI
|
||||
|
|
@ -200,7 +200,7 @@ export default function NavbarHumas() {
|
|||
</DropdownItem>
|
||||
<DropdownItem>
|
||||
<Link
|
||||
href="/struktur-organisasi"
|
||||
href="/static/struktur-mabes"
|
||||
className="flex justify-between"
|
||||
>
|
||||
Struktur Organisasi
|
||||
|
|
@ -208,14 +208,17 @@ export default function NavbarHumas() {
|
|||
</Link>
|
||||
</DropdownItem>
|
||||
<DropdownItem>
|
||||
<Link href="/visi-misi" className="flex justify-between">
|
||||
<Link
|
||||
href="/static/visi-misi-polri"
|
||||
className="flex justify-between"
|
||||
>
|
||||
Visi & Misi
|
||||
<ChevronRightIcon />
|
||||
</Link>
|
||||
</DropdownItem>
|
||||
<DropdownItem>
|
||||
<Link
|
||||
href="/tugas-dan-fungsi"
|
||||
href="/static/tugas-dan-fungsi-polri"
|
||||
className="flex justify-between"
|
||||
>
|
||||
Tugas & Fungsi
|
||||
|
|
@ -223,7 +226,7 @@ export default function NavbarHumas() {
|
|||
</Link>
|
||||
</DropdownItem>
|
||||
<DropdownItem>
|
||||
<Link href="#" className="flex justify-between">
|
||||
<Link href="/static/logo" className="flex justify-between">
|
||||
Logo
|
||||
<ChevronRightIcon />
|
||||
</Link>
|
||||
|
|
|
|||
|
|
@ -95,12 +95,12 @@ export default function StaticPageBuilder() {
|
|||
}
|
||||
});
|
||||
}
|
||||
const title = watch("title");
|
||||
useEffect(() => {
|
||||
if (getValues("title")) {
|
||||
setValue("slug", createSlug(getValues("title")));
|
||||
}
|
||||
}, [title]);
|
||||
// const title = watch("title");
|
||||
// useEffect(() => {
|
||||
// if (getValues("title")) {
|
||||
// setValue("slug", createSlug(getValues("title")));
|
||||
// }
|
||||
// }, [title]);
|
||||
|
||||
return (
|
||||
<form
|
||||
|
|
@ -139,7 +139,6 @@ export default function StaticPageBuilder() {
|
|||
value={value}
|
||||
onChange={onChange}
|
||||
labelPlacement="outside"
|
||||
readOnly
|
||||
className="w-full"
|
||||
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