From 14e61dedf3dc9fb9093481f1c0fa8385fd78ea6e Mon Sep 17 00:00:00 2001 From: amel Date: Tue, 29 Oct 2024 17:11:02 +0800 Subject: [PATCH] fix: update Deskripsi: - update jarak button grup - update jarak form edit jabatan No Issues --- src/module/group/ui/drawer_group.tsx | 10 ++++-- src/module/group/ui/edit_drawer_group.tsx | 24 ++++++-------- src/module/group/ui/list_group_active.tsx | 33 +++++++------------ .../position/ui/drawer_detail_position.tsx | 2 +- 4 files changed, 30 insertions(+), 39 deletions(-) diff --git a/src/module/group/ui/drawer_group.tsx b/src/module/group/ui/drawer_group.tsx index 99d70c3..b53a39d 100644 --- a/src/module/group/ui/drawer_group.tsx +++ b/src/module/group/ui/drawer_group.tsx @@ -12,6 +12,7 @@ export default function DrawerGroup({ onSuccess, }: { onSuccess: (val: boolean) const [namaGroup, setNamaGroup] = useState(""); const tema = useHookstate(TEMA) const refresh = useHookstate(globalRefreshGroup) + const [loading, setLoading] = useState(false) const [touched, setTouched] = useState({ name: false, }); @@ -19,8 +20,8 @@ export default function DrawerGroup({ onSuccess, }: { onSuccess: (val: boolean) async function createData() { try { + setLoading(true) const response = await funCreateGroup({ name: namaGroup }) - if (response.success) { toast.success(response.message); refresh.set(!refresh.get()) @@ -33,6 +34,8 @@ export default function DrawerGroup({ onSuccess, }: { onSuccess: (val: boolean) } catch (error) { console.error(error); toast.error("Gagal menambahkan grup, coba lagi nanti"); + } finally { + setLoading(false) } } @@ -85,7 +88,7 @@ export default function DrawerGroup({ onSuccess, }: { onSuccess: (val: boolean) onClose={() => setOpenDrawerGroup(false)} title={"Tambah Grup"} > - + - + diff --git a/src/module/group/ui/edit_drawer_group.tsx b/src/module/group/ui/edit_drawer_group.tsx index cc34ea3..f5c7e48 100644 --- a/src/module/group/ui/edit_drawer_group.tsx +++ b/src/module/group/ui/edit_drawer_group.tsx @@ -2,15 +2,7 @@ import { LayoutDrawer, TEMA } from "@/module/_global"; import LayoutModal from "@/module/_global/layout/layout_modal"; import { useHookstate } from "@hookstate/core"; -import { - Box, - Button, - Flex, - SimpleGrid, - Stack, - Text, - TextInput -} from "@mantine/core"; +import { Box, Button, Flex, SimpleGrid, Stack, Text, TextInput } from "@mantine/core"; import { useShallowEffect } from "@mantine/hooks"; import { useState } from "react"; import toast from "react-hot-toast"; @@ -23,6 +15,7 @@ export default function EditDrawerGroup({ onUpdated, id, isActive, }: { onUpdate const [isModal, setModal] = useState(false); const [name, setName] = useState(""); const [loading, setLoading] = useState(false); + const [loadingModal, setLoadingModal] = useState(false) const refresh = useHookstate(globalRefreshGroup) const tema = useHookstate(TEMA) const [touched, setTouched] = useState({ @@ -90,6 +83,7 @@ export default function EditDrawerGroup({ onUpdated, id, isActive, }: { onUpdate async function nonActive(val: boolean) { try { if (val) { + setLoadingModal(true) const res = await funEditStatusGroup(id, { isActive: isActive }); if (res.success) { toast.success(res.message); @@ -99,11 +93,12 @@ export default function EditDrawerGroup({ onUpdated, id, isActive, }: { onUpdate toast.error(res.message) } } - setModal(false); } catch (error) { - setModal(false); console.error(error); toast.error("Edit grup gagal, coba lagi nanti"); + } finally { + setLoadingModal(false) + setModal(false); } } @@ -146,7 +141,7 @@ export default function EditDrawerGroup({ onUpdated, id, isActive, }: { onUpdate onClose={() => setOpenDrawerGroup(false)} title={"Edit Grup"} > - + { onValidation('name', e.target.value) @@ -171,7 +166,7 @@ export default function EditDrawerGroup({ onUpdated, id, isActive, }: { onUpdate label="Grup" required /> - +