bug fixes
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import React, { useState } from 'react';
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { View, Text, StyleSheet, TouchableOpacity, ActivityIndicator, Alert, SafeAreaView } from 'react-native';
|
||||
import { Ionicons } from '@expo/vector-icons';
|
||||
import { useNavigation } from '@react-navigation/native';
|
||||
@@ -6,19 +6,33 @@ import apiService from '../../services/apiService';
|
||||
import { COLORS } from '../../constants/colors';
|
||||
import Input from '../../components/Input';
|
||||
import { StatusBar } from 'expo-status-bar';
|
||||
import SelectInput from '../../components/SelectInput';
|
||||
import { useAuth } from '../../contexts/AuthContext';
|
||||
|
||||
const CreateLoanRemainingOrderScreen = () => {
|
||||
const navigation = useNavigation();
|
||||
const [accountNumber, setAccountNumber] = useState('');
|
||||
const [passportSerie, setPassportSerie] = useState('');
|
||||
const [passportId, setPassportId] = useState('');
|
||||
const [loading, setLoading] = useState(false);
|
||||
const { user } = useAuth();
|
||||
|
||||
useEffect(() => {
|
||||
if (user) {
|
||||
if (user.passport_serie) setPassportSerie(user.passport_serie);
|
||||
if (user.passport_id) setPassportId(String(user.passport_id));
|
||||
}
|
||||
}, [user]);
|
||||
|
||||
const PASSPORT_SERIES = ['I-AS','I-MR','II-MR','I-AH','II-AH','I-LB','II-LB','I-BN','II-BN','I-DZ','II-DZ'];
|
||||
|
||||
const handleSubmit = async () => {
|
||||
if (accountNumber.trim().length === 0) {
|
||||
Alert.alert('Error', 'Account number is required');
|
||||
if (accountNumber.trim().length === 0 || !passportSerie || passportId.trim().length === 0) {
|
||||
Alert.alert('Error', 'All fields are required');
|
||||
return;
|
||||
}
|
||||
setLoading(true);
|
||||
const res = await apiService.createLoanRemainingOrder(accountNumber.trim());
|
||||
const res = await apiService.createLoanRemainingOrder(accountNumber.trim(), passportSerie, passportId.trim());
|
||||
setLoading(false);
|
||||
if (res.success) {
|
||||
Alert.alert('Success', res.message || 'Order created successfully', [
|
||||
@@ -40,6 +54,22 @@ const CreateLoanRemainingOrderScreen = () => {
|
||||
|
||||
<Text style={styles.title}>Täze sargyt</Text>
|
||||
|
||||
<SelectInput
|
||||
label="*Passport seriýasy"
|
||||
value={passportSerie}
|
||||
onValueChange={setPassportSerie}
|
||||
options={PASSPORT_SERIES.map((v) => ({ label: v, value: v }))}
|
||||
placeholder="Saýla"
|
||||
/>
|
||||
|
||||
<Input
|
||||
label="*Passport belgisi"
|
||||
placeholder="123456"
|
||||
value={passportId}
|
||||
onChangeText={setPassportId}
|
||||
keyboardType="numeric"
|
||||
/>
|
||||
|
||||
<Input
|
||||
label="Karz hasaby"
|
||||
placeholder="1420..."
|
||||
|
||||
Reference in New Issue
Block a user