fix: fixing super admin

Deskripsi:
- tugas divisi
- kegiatan
- home
- filter

No Issues
This commit is contained in:
amel
2024-10-28 16:56:30 +08:00
parent 163e84c833
commit 16e62c7c09
22 changed files with 560 additions and 263 deletions

View File

@@ -2,7 +2,7 @@
import { LayoutNavbarNew, TEMA } from "@/module/_global";
import LayoutModal from "@/module/_global/layout/layout_modal";
import { useHookstate } from "@hookstate/core";
import { Box, Button, Group, rem, SimpleGrid, Skeleton, Stack, Text, TextInput } from "@mantine/core";
import { Box, Button, Flex, Group, rem, SimpleGrid, Skeleton, Stack, Text, TextInput } from "@mantine/core";
import { DatePicker } from "@mantine/dates";
import { useShallowEffect } from "@mantine/hooks";
import moment from "moment";
@@ -19,10 +19,12 @@ export default function EditDetailTask() {
const param = useParams<{ id: string, detail: string }>()
const [openModal, setOpenModal] = useState(false)
const [loading, setLoading] = useState(true)
const [loadingModal, setLoadingModal] = useState(false)
const [idTugas, setIdTugas] = useState("")
const tema = useHookstate(TEMA)
const [touched, setTouched] = useState({
title: false,
date: false
});
async function onSubmit() {
@@ -33,6 +35,7 @@ export default function EditDetailTask() {
return toast.error("Error! harus memasukkan judul tugas")
try {
setLoadingModal(true)
const res = await funEditDetailTask(param.detail, {
title: title,
dateStart: value[0],
@@ -48,6 +51,9 @@ export default function EditDetailTask() {
} catch (error) {
console.error(error);
toast.error("Gagal edit detail tugas divisi, coba lagi nanti");
} finally {
setOpenModal(false)
setLoadingModal(false)
}
}
@@ -94,9 +100,22 @@ export default function EditDetailTask() {
} else {
setTouched({ ...touched, title: false })
}
} else if (kategori == 'date') {
const array = val.split(",")
if (array[0] == '' || array[1] == '') {
setTouched({ ...touched, date: true })
} else {
setTouched({ ...touched, date: false })
}
}
}
useShallowEffect(() => {
onValidation('date', String(value))
}, [value])
return (
<Box>
<LayoutNavbarNew back="" title={"Edit Tanggal dan Tugas"} menu />
@@ -122,7 +141,9 @@ export default function EditDetailTask() {
<Skeleton height={45} mt={20} radius={10} />
:
<>
<Text>Tanggal Mulai</Text>
<Flex justify="flex-start" align="flex-start" direction="row" wrap="nowrap" gap={5}>
<Text fw={500}>Tanggal Mulai</Text> <Text c={"red"}>*</Text>
</Flex>
<Group
justify="center"
bg={"white"}
@@ -139,7 +160,9 @@ export default function EditDetailTask() {
<Skeleton height={45} mt={20} radius={10} />
:
<>
<Text c={tema.get().utama}>Tanggal Berakhir</Text>
<Flex justify="flex-start" align="flex-start" direction="row" wrap="nowrap" gap={5}>
<Text fw={500}>Tanggal Berakhir</Text> <Text c={"red"}>*</Text>
</Flex>
<Group
justify="center"
bg={"white"}
@@ -152,6 +175,12 @@ export default function EditDetailTask() {
}
</Box>
</SimpleGrid>
{
(!loading && touched && touched.date)
? <Text size="sm" c={"red"}>Tanggal Tidak Boleh Kosong</Text>
: <></>
}
<Stack pt={15} pb={100}>
{loading ?
<Skeleton height={40} mt={20} radius={10} />
@@ -163,15 +192,14 @@ export default function EditDetailTask() {
borderRadius: 10,
},
}}
label={"Judul Tahapan"}
label={"Judul Tugas"}
required
placeholder="Input Judul Tahapan"
placeholder="Input Judul Tugas"
size="md"
value={title}
error={
touched.title &&
(title == "" ? "Error! harus memasukkan Judul Tahapan" : ""
)
(title == "" ? "Judul Tugas Tidak Boleh Kosong" : "")
}
onChange={(e) => {
onValidation('title', e.target.value)
@@ -201,13 +229,14 @@ export default function EditDetailTask() {
}
</Box>
<LayoutModal opened={openModal} onClose={() => setOpenModal(false)}
<LayoutModal loading={loadingModal} opened={openModal} onClose={() => setOpenModal(false)}
description="Apakah Anda yakin ingin mengubah data?"
onYes={(val) => {
if (val) {
onSubmit()
} else {
setOpenModal(false)
}
setOpenModal(false)
}} />
</Box>
);