diff --git a/src/components/DateInput.js b/src/components/DateInput.js index 720b5bb..7b73e88 100644 --- a/src/components/DateInput.js +++ b/src/components/DateInput.js @@ -18,7 +18,7 @@ const parseDate = (str) => { return new Date(parseInt(year), parseInt(month) - 1, parseInt(day)); }; -const DateInput = ({ label, value, onChange, placeholder = 'Saýla', maximumDate, minimumDate }) => { +const DateInput = ({ label, value, onChange, placeholder = 'Saýla', maximumDate, minimumDate, error = false }) => { const [show, setShow] = useState(false); const [tempDate, setTempDate] = useState(value ? (typeof value === 'string' ? parseDate(value) : value) : new Date()); @@ -43,8 +43,10 @@ const DateInput = ({ label, value, onChange, placeholder = 'Saýla', maximumDate return ( - {label && {label}} - + {label && ( + {label} + )} + {value || placeholder} @@ -101,6 +103,9 @@ const styles = StyleSheet.create({ color: COLORS.textPrimary, marginBottom: 8, }, + requiredLabel: { + color: COLORS.error, + }, selectBox: { flexDirection: 'row', alignItems: 'center', @@ -112,6 +117,9 @@ const styles = StyleSheet.create({ paddingHorizontal: 16, minHeight: 52, }, + error: { + borderColor: COLORS.error, + }, selectText: { fontSize: 16, color: COLORS.textPrimary, diff --git a/src/components/ImageInput.js b/src/components/ImageInput.js index fb80586..959a3fb 100644 --- a/src/components/ImageInput.js +++ b/src/components/ImageInput.js @@ -34,7 +34,9 @@ const ImageInput = ({ label, image, onChange, error = false }) => { return ( - {label && {label}} + {label && ( + {label} + )} {image ? ( @@ -59,6 +61,9 @@ const styles = StyleSheet.create({ color: COLORS.textPrimary, marginBottom: 8, }, + requiredLabel: { + color: COLORS.error, + }, box: { borderWidth: 1, borderColor: COLORS.gray[300], diff --git a/src/components/Input.js b/src/components/Input.js index fc75bab..b15d25f 100644 --- a/src/components/Input.js +++ b/src/components/Input.js @@ -27,7 +27,11 @@ const Input = forwardRef(({ return ( - {label && {label}} + {label && ( + + {label} + + )} - {label && {label}} + {label && ( + {label} + )} { const [cardMonth, setCardMonth] = useState(''); const [cardYear, setCardYear] = useState(''); + const [submitted, setSubmitted] = useState(false); + + const req = (l) => `${l} *`; + const [passportOne, setPassportOne] = useState(null); const [passportTwo, setPassportTwo] = useState(null); const [passportThree, setPassportThree] = useState(null); @@ -77,6 +81,13 @@ const CreateLoanOrderScreen = () => { return { value: year.toString(), label: year.toString() }; }); + const handleLoanAmountChange = (text) => { + const numValue = parseInt(text) || 0; + if (numValue <= 40000) { + setLoanAmount(text); + } + }; + const formatCardNumber = (text) => { const digits = text.replace(/[^0-9]/g, '').slice(0, 16); const parts = []; @@ -129,7 +140,8 @@ const CreateLoanOrderScreen = () => { const branchOptions = region && branchesByRegion[region] ? branchesByRegion[region].map((b) => ({ label: b.name, value: b.id })) : []; const handleSubmit = async () => { - if (!loanType || !loanAmount || !region || !branchId || !customerName || !customerSurname || !passportSerie || !passportId || !bornAt || !phone || !education || !marriageStatus || !passportAddress || !realAddress || !passportOne || !passportTwo || !passportThree || !passportFour || !cardNumber || !cardName || !cardMonth || !cardYear) { + setSubmitted(true); + if (!loanType || !loanAmount || !region || !branchId || !customerName || !customerSurname || !passportSerie || !passportId || !passportGivenAt || !passportGivenBy || !bornAt || !bornPlace || !phone || !phoneHome || !education || !marriageStatus || !passportAddress || !realAddress || !workCompany || !workCompanyAccNum || !workRegion || !workProvinceId || !workPosition || !workSalary || !workStartedAt || !passportOne || !passportTwo || !passportThree || !passportFour || !cardNumber || !cardName || !cardMonth || !cardYear) { Alert.alert('Error', 'Fill all required fields'); return; } @@ -231,54 +243,62 @@ const CreateLoanOrderScreen = () => { Täze karz sargyt + * bilen bellenilen meýdanlar hökmanydyr - - + + - { setRegion(val); setBranchId(''); }} placeholder="Saýla" /> - + { setRegion(val); setBranchId(''); }} placeholder="Saýla" error={submitted && !region} /> + - - + + - - - + + + - - + + - - - - - + + + + + - + - + - - - {setWorkRegion(val); setWorkProvinceId('');}} placeholder="Saýla" /> - ({label:b.name,value:b.id})) : []} onValueChange={setWorkProvinceId} placeholder="Saýla" disabled={!workRegion} /> - - - + + + {setWorkRegion(val); setWorkProvinceId('');}} placeholder="Saýla" error={submitted && !workRegion} /> + ({label:b.name,value:b.id})) : []} onValueChange={setWorkProvinceId} placeholder="Saýla" disabled={!workRegion} error={submitted && !workProvinceId} /> + + + {/* Card info */} - - - - + + + + - - - - + + + + @@ -293,6 +313,7 @@ const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: COLORS.backgroundSecondary, paddingTop: 40 }, backBtn: { marginBottom: 24, marginLeft: 24 }, title: { fontSize: 24, fontWeight: 'bold', color: COLORS.textPrimary, marginBottom: 24 }, + note: { fontSize: 14, color: COLORS.error, marginBottom: 24 }, submitBtn: { marginTop: 32, backgroundColor: COLORS.primary, paddingVertical: 16, borderRadius: 8, alignItems: 'center' }, submitText: { color: COLORS.white, fontSize: 16, fontWeight: '600' }, passportGrid: {