fix : group
Deskripsi: - validasi tambah group - validasi edit group - load refresh modal No Issues
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user