feat : update validation
This commit is contained in:
@@ -36,6 +36,10 @@ export default function CreateDivision() {
|
||||
name: "",
|
||||
desc: "",
|
||||
});
|
||||
const [touched, setTouched] = useState({
|
||||
idGroup: false,
|
||||
name: false,
|
||||
});
|
||||
|
||||
async function loadData() {
|
||||
const loadGroup = await funGetAllGroup('?active=true')
|
||||
@@ -86,7 +90,7 @@ export default function CreateDivision() {
|
||||
loadData();
|
||||
}, []);
|
||||
|
||||
|
||||
|
||||
|
||||
if (isChooseAdmin) return <NavbarAdminDivision data={body} onSuccess={(val) => {
|
||||
if (val) {
|
||||
@@ -124,7 +128,12 @@ export default function CreateDivision() {
|
||||
onChange={(val) => {
|
||||
onChooseGroup(val)
|
||||
}}
|
||||
|
||||
onBlur={() => setTouched({ ...touched, idGroup: true })}
|
||||
error={
|
||||
touched.idGroup && (
|
||||
body.idGroup == "" ? "Grup Tidak Boleh Kosong" : null
|
||||
)
|
||||
}
|
||||
value={body.idGroup}
|
||||
/>
|
||||
)
|
||||
@@ -137,6 +146,12 @@ export default function CreateDivision() {
|
||||
radius={40}
|
||||
value={body.name}
|
||||
onChange={(val) => { setBody({ ...body, name: val.target.value }) }}
|
||||
onBlur={() => setTouched({ ...touched, name: true })}
|
||||
error={
|
||||
touched.name && (
|
||||
body.name == "" ? "Nama Tidak Boleh Kosong" : null
|
||||
)
|
||||
}
|
||||
/>
|
||||
<Textarea size="md" placeholder="Deskripsi" label="Deskripsi" value={body.desc} radius={10} onChange={(val) => { setBody({ ...body, desc: val.currentTarget.value }) }} />
|
||||
<Box onClick={() => { onToChooseAnggota() }}>
|
||||
|
||||
@@ -22,12 +22,9 @@ export default function EditDivision() {
|
||||
desc: "",
|
||||
});
|
||||
|
||||
function onTrue(val: boolean) {
|
||||
if (val) {
|
||||
toast.success("Sukses! Data tersimpan");
|
||||
}
|
||||
setOpenModal(false)
|
||||
}
|
||||
const [touched, setTouched] = useState({
|
||||
name: false,
|
||||
});
|
||||
|
||||
|
||||
async function getOneData() {
|
||||
@@ -88,30 +85,47 @@ export default function EditDivision() {
|
||||
required
|
||||
radius={40}
|
||||
value={body.name}
|
||||
onChange={(e) => { setBody({ ...body, name: e.target.value }) }}
|
||||
onChange={(e) => {
|
||||
setBody({ ...body, name: e.target.value })
|
||||
setTouched({ ...touched, name: false })
|
||||
}}
|
||||
onBlur={() => setTouched({ ...touched, name: true })}
|
||||
error={
|
||||
touched.name && (
|
||||
body.name == "" ? "Judul Tidak Boleh Kosong" : null
|
||||
)
|
||||
}
|
||||
/>
|
||||
<Textarea placeholder="Deskripsi" label="Deskripsi" size="md" radius={10}
|
||||
value={body.desc}
|
||||
onChange={(e) => { setBody({ ...body, desc: e.currentTarget.value }) }}
|
||||
styles={{
|
||||
input: {
|
||||
height: "40vh"
|
||||
height: "40vh"
|
||||
}
|
||||
}}
|
||||
}}
|
||||
/>
|
||||
</Stack>
|
||||
<Box pos={"absolute"} bottom={10} left={0} right={0} p={20}>
|
||||
<Button
|
||||
color="white"
|
||||
bg={WARNA.biruTua}
|
||||
size="lg"
|
||||
radius={30}
|
||||
fullWidth
|
||||
onClick={() => { setOpenModal(true) }}
|
||||
>
|
||||
Simpan
|
||||
</Button>
|
||||
</Box>
|
||||
<Box pos={"absolute"} bottom={10} left={0} right={0} p={20}>
|
||||
<Button
|
||||
color="white"
|
||||
bg={WARNA.biruTua}
|
||||
size="lg"
|
||||
radius={30}
|
||||
fullWidth
|
||||
onClick={() => {
|
||||
if (
|
||||
body.name !== ""
|
||||
) {
|
||||
setOpenModal(true)
|
||||
} else {
|
||||
toast.error("Judul Tidak Boleh Kosong")
|
||||
}
|
||||
}}
|
||||
>
|
||||
Simpan
|
||||
</Button>
|
||||
</Box>
|
||||
</Box>
|
||||
<LayoutModal opened={openModal} onClose={() => setOpenModal(false)} description='Apakah Anda yakin ingin edit data'
|
||||
onYes={(val) => {
|
||||
|
||||
@@ -7,12 +7,14 @@ import EchartPaiReport from './echart_pai_report';
|
||||
import EchartBarReport from './echart_bar_report';
|
||||
import EventReport from './event_report';
|
||||
import DiscussionReport from './discussion_report';
|
||||
import { useParams } from 'next/navigation';
|
||||
|
||||
export default function ReportDivisionId() {
|
||||
const [value, setValue] = useState<Date | null>(null);
|
||||
const param = useParams<{ id: string }>()
|
||||
return (
|
||||
<Box>
|
||||
<LayoutNavbarNew back="/division/1" title="Report Divisi" menu />
|
||||
<LayoutNavbarNew back={`/division/${param.id}`} title="Report Divisi" menu />
|
||||
<Box p={20}>
|
||||
<Stack>
|
||||
<DateInput
|
||||
|
||||
Reference in New Issue
Block a user