fix : group

Deskripsi:
- validasi tambah group
- validasi edit group
- load refresh modal

No Issues
This commit is contained in:
2025-08-05 15:34:40 +08:00
parent 308fda6920
commit 7470e8a9c2
3 changed files with 32 additions and 19 deletions

View File

@@ -42,14 +42,9 @@ export default function Index() {
const dispatch = useDispatch()
const update = useSelector((state: any) => state.groupUpdate)
const [data11, setData1] = useState(Array.from({ length: 20 }, (_, i) => `Item ${i}`));
const renderItem = ({ item }: { item: string }) => (
<View style={{ padding: 20, borderBottomWidth: 1, borderColor: '#ccc' }}>
<Text>{item}</Text>
</View>
);
const [error, setError] = useState({
title: false,
});
async function handleEdit() {
@@ -109,6 +104,17 @@ export default function Index() {
setRefreshing(false)
};
function validationForm(val: any, cat: 'title') {
if (cat === 'title') {
setTitleChoose(val)
if (val == "" || val.length < 3) {
setError((prev) => ({ ...prev, title: true }))
} else {
setError((prev) => ({ ...prev, title: false }))
}
}
}
return (
<SafeAreaView>
@@ -207,10 +213,18 @@ export default function Index() {
<DrawerBottom animation="none" keyboard height={30} isVisible={isVisibleEdit} setVisible={() => setVisibleEdit(false)} title="Edit Lembaga Desa">
<View style={{ flex: 1 }}>
<View>
<InputForm type="default" placeholder="Nama Lembaga Desa" required label="Lembaga Desa" value={titleChoose} onChange={setTitleChoose} />
<InputForm
type="default"
placeholder="Nama Lembaga Desa"
required
label="Lembaga Desa"
value={titleChoose}
error={error.title}
errorText="Lembaga Desa tidak boleh kosong & minimal 3 karakter"
onChange={(val) => { validationForm(val, 'title') }} />
</View>
<View>
<ButtonForm text="SIMPAN" onPress={() => { handleEdit() }} />
<ButtonForm text="SIMPAN" disabled={Object.values(error).some((v) => v == true) || titleChoose == ""} onPress={() => { handleEdit() }} />
</View>
</View>
</DrawerBottom>