diff --git a/src/module/announcement/ui/edit_announcement.tsx b/src/module/announcement/ui/edit_announcement.tsx index 759fe5f..4e601b9 100644 --- a/src/module/announcement/ui/edit_announcement.tsx +++ b/src/module/announcement/ui/edit_announcement.tsx @@ -1,7 +1,7 @@ 'use client' import { LayoutNavbarNew, WARNA } from "@/module/_global"; import LayoutModal from "@/module/_global/layout/layout_modal"; -import { Box, Button, Flex, List, rem, Stack, Text, Textarea, TextInput } from "@mantine/core"; +import { Box, Button, Flex, List, rem, Skeleton, Stack, Text, Textarea, TextInput } from "@mantine/core"; import { useShallowEffect } from "@mantine/hooks"; import { useState } from "react"; import toast from "react-hot-toast"; @@ -17,10 +17,11 @@ export default function EditAnnouncement() { const [isOpen, setOpen] = useState(false) const [isChooseDivisi, setChooseDivisi] = useState(false) const param = useParams<{ id: string }>() + const [loading, setLoading] = useState(true) const [touched, setTouched] = useState({ title: false, desc: false - }); + }); const [body, setBody] = useState({ title: "", desc: "", @@ -30,6 +31,7 @@ export default function EditAnnouncement() { async function fetchOneAnnouncement() { try { + setLoading(true) memberGroup.set([]) const res = await funGetAnnouncementById(param.id) if (res.success) { @@ -62,9 +64,13 @@ export default function EditAnnouncement() { toast.error(res.message) } + setLoading(false) + } catch (error) { console.error(error) toast.error("Gagal mendapatkan pengumuman, coba lagi nanti") + } finally { + setLoading(false) } } @@ -110,61 +116,83 @@ export default function EditAnnouncement() { pt={30} px={20} > - { - setBody({ ...body, title: val.target.value }) - setTouched({ ...touched, title: false }) - }} - onBlur={() => setTouched({ ...touched, title: true })} - error={ - touched.title && ( - body.title == "" ? "Judul Tidak Boleh Kosong" : null - ) - } - /> -