add max age

This commit is contained in:
nochill 2023-06-07 09:34:37 +07:00
parent e3fdd8e322
commit 4c95189481
3 changed files with 14 additions and 9 deletions

View File

@ -11,6 +11,7 @@ const DefaultTextInput = props => (
keyboardType={props.keyboardType}
/>
{props.isFilled && <Text style={styles.errorLabel}>Wajib diisi</Text>}
{props.maxValue && <Text style={styles.errorLabel}>Umur maximum 100</Text>}
</View>
);
@ -25,15 +26,15 @@ const styles = StyleSheet.create({
borderRadius: 10,
},
label: {
color: 'black',
marginLeft: 10,
fontSize: 12
color: 'black',
marginLeft: 10,
fontSize: 12,
},
errorLabel: {
color: 'red',
marginLeft: 10,
marginBottom: 5,
fontSize: 10
color: 'red',
marginLeft: 10,
marginBottom: 5,
fontSize: 10,
},
});

View File

@ -13,6 +13,7 @@ const ContactDetail = ({route, navigation}) => {
let isEmpty = false;
if (
form.age.trim() === '' ||
Number(form.age) > 100 ||
form.firstName.trim() === '' ||
form.lastName.trim() === '' ||
(image.foto == null && image.fileUri == null)
@ -62,10 +63,13 @@ const ContactDetail = ({route, navigation}) => {
<DefaultTextInput
onChangeText={val => onChangeInput('age', val)}
label="Age (*)"
containerStyle={{height: form.age.trim() === '' ? 80 : 60}}
containerStyle={{
height: form.age.trim() === '' || Number(form.age) > 100 ? 80 : 60,
}}
value={form.age}
isFilled={form.age.trim() === ''}
keyboardType="number-pad"
maxValue={Number(form.age) > 100}
/>
</View>
<View style={{marginBottom: 20}}>

View File

@ -44,7 +44,7 @@ const useContactDetail = (data, navigation) => {
const payload = {
firstName: form.firstName,
lastName: form.lastName,
age: Number(form.age),
age: form.age,
photo: image.file ? `data:image/png;base64,${image.file}` : image.foto,
};
if (data) {