upd: grup

Deskripsi;
- validasi tambah grup
- text error validasi tambah grup
- text error validasi edit grup

No Issues
This commit is contained in:
amel
2024-10-04 12:00:03 +08:00
parent 74198b97c9
commit b8de0beccf
2 changed files with 14 additions and 4 deletions

View File

@@ -45,8 +45,10 @@ export default function DrawerGroup({ onSuccess, }: { onSuccess: (val: boolean)
}
function onCheck() {
if (Object.values(touched).some((v) => v == true))
const cek = checkAll()
if (!cek) {
return false
}
createData()
}
@@ -58,7 +60,15 @@ export default function DrawerGroup({ onSuccess, }: { onSuccess: (val: boolean)
} else {
setTouched({ ...touched, name: false })
}
}
}
}
function checkAll() {
if (namaGroup == "" || namaGroup.length < 3) {
setTouched({ ...touched, name: true })
return false
}
return true
}
return (
@@ -102,7 +112,7 @@ export default function DrawerGroup({ onSuccess, }: { onSuccess: (val: boolean)
}}
error={
touched.name &&
(namaGroup == "" ? "Error! harus memasukkan grup" :
(namaGroup == "" ? "Grup Tidak Boleh Kosong" :
namaGroup.length < 3 ? "Masukkan Minimal 3 karakter" : ""
)
}

View File

@@ -162,7 +162,7 @@ export default function EditDrawerGroup({ onUpdated, id, isActive, }: { onUpdate
}}
error={
touched.name &&
(name == "" ? "Error! harus memasukkan grup" :
(name == "" ? "Grup Tidak Boleh Kosong" :
name.length < 3 ? "Masukkan Minimal 3 karakter" : ""
)
}