From 12768604f489349774a92a035d051b8bf201bd79 Mon Sep 17 00:00:00 2001 From: Bagasbanuna02 Date: Fri, 14 Feb 2025 22:30:46 +0800 Subject: [PATCH] fix ui forum --- src/app_modules/forum/create/index.tsx | 38 +++++++++++--------------- src/app_modules/forum/main/layout.tsx | 21 ++------------ 2 files changed, 18 insertions(+), 41 deletions(-) diff --git a/src/app_modules/forum/create/index.tsx b/src/app_modules/forum/create/index.tsx index c63a11d3..dad20e62 100644 --- a/src/app_modules/forum/create/index.tsx +++ b/src/app_modules/forum/create/index.tsx @@ -1,12 +1,7 @@ "use client"; import ComponentGlobal_V2_LoadingPage from "@/app_modules/_global/loading_page_v2"; -import { - Button, - Group, - Paper, - Stack -} from "@mantine/core"; +import { Button, Group, Paper, Stack } from "@mantine/core"; import { useShallowEffect } from "@mantine/hooks"; import { useRouter } from "next/navigation"; import "react-quill/dist/quill.bubble.css"; @@ -30,7 +25,9 @@ import { MainColor, } from "@/app_modules/_global/color/color_pallet"; import mqtt_client from "@/util/mqtt_client"; +import CustomSkeleton from "@/app_modules/components/CustomSkeleton"; +const maxLength = 500; export default function Forum_Create() { const [value, setValue] = useState(""); const [totalLength, setTotalLength] = useState(0); @@ -40,12 +37,7 @@ export default function Forum_Create() { if (window && window.document) setReload(true); }, []); - if (!reload) - return ( - <> - - - ); + if (!reload) return ; return ( <> @@ -56,13 +48,19 @@ export default function Forum_Create() { placeholder="Apa yang sedang ingin dibahas ?" style={{ height: 150 }} onChange={(val) => { + const input = val; + const text = input.replace(/<[^>]+>/g, "").trim(); // Remove HTML tags and trim whitespace + if (text.length === 0) { + setValue(""); // Set value to an empty string + return; + } setValue(val); }} /> @@ -79,7 +77,7 @@ function ButtonAction({ value }: { value: string }) { const [loading, setLoading] = useState(false); async function onCreate() { - if (value.length > 500) { + if (value.length >= maxLength) { return null; } @@ -87,7 +85,7 @@ function ButtonAction({ value }: { value: string }) { if (create.status === 201) { setLoading(true); ComponentGlobal_NotifikasiBerhasil(create.message); - setTimeout(() => router.back(), 1000); + setTimeout(() => router.back(), 200); mqtt_client.publish( "Forum_create_new", @@ -102,16 +100,12 @@ function ButtonAction({ value }: { value: string }) {