From 4c951894817d69292c6d5cb01a8fc852345d9e7f Mon Sep 17 00:00:00 2001 From: nochill Date: Wed, 7 Jun 2023 09:34:37 +0700 Subject: [PATCH] add max age --- src/components/Input/DefaultText/index.js | 15 ++++++++------- src/scenes/ContactDetail/index.js | 6 +++++- src/scenes/ContactDetail/useContactDetail.js | 2 +- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/components/Input/DefaultText/index.js b/src/components/Input/DefaultText/index.js index f500d17..52cba9f 100644 --- a/src/components/Input/DefaultText/index.js +++ b/src/components/Input/DefaultText/index.js @@ -11,6 +11,7 @@ const DefaultTextInput = props => ( keyboardType={props.keyboardType} /> {props.isFilled && Wajib diisi} + {props.maxValue && Umur maximum 100} ); @@ -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, }, }); diff --git a/src/scenes/ContactDetail/index.js b/src/scenes/ContactDetail/index.js index 2a6a8ac..5eabd6e 100644 --- a/src/scenes/ContactDetail/index.js +++ b/src/scenes/ContactDetail/index.js @@ -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}) => { 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} /> diff --git a/src/scenes/ContactDetail/useContactDetail.js b/src/scenes/ContactDetail/useContactDetail.js index a7cff7f..bb90792 100644 --- a/src/scenes/ContactDetail/useContactDetail.js +++ b/src/scenes/ContactDetail/useContactDetail.js @@ -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) {