add max age
This commit is contained in:
parent
e3fdd8e322
commit
4c95189481
@ -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>
|
||||
);
|
||||
|
||||
@ -27,13 +28,13 @@ const styles = StyleSheet.create({
|
||||
label: {
|
||||
color: 'black',
|
||||
marginLeft: 10,
|
||||
fontSize: 12
|
||||
fontSize: 12,
|
||||
},
|
||||
errorLabel: {
|
||||
color: 'red',
|
||||
marginLeft: 10,
|
||||
marginBottom: 5,
|
||||
fontSize: 10
|
||||
fontSize: 10,
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -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}}>
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user