diff --git a/src/screens/Loan/CreateLoanOrderScreen.js b/src/screens/Loan/CreateLoanOrderScreen.js
index 16df066..143e7cb 100644
--- a/src/screens/Loan/CreateLoanOrderScreen.js
+++ b/src/screens/Loan/CreateLoanOrderScreen.js
@@ -9,11 +9,13 @@ import DateInput from '../../components/DateInput';
import { API_CONFIG } from '../../constants/api';
import apiService from '../../services/apiService';
import { useAuth } from '../../contexts/AuthContext';
+import { useBaseEnums } from '../../contexts/BaseEnumsContext';
import { StatusBar } from 'expo-status-bar';
const CreateLoanOrderScreen = () => {
const navigation = useNavigation();
const { user } = useAuth();
+ const { getOptions } = useBaseEnums();
const [loanType, setLoanType] = useState('');
const [loanAmount, setLoanAmount] = useState('');
@@ -31,6 +33,25 @@ const CreateLoanOrderScreen = () => {
const [loanTypeOptions, setLoanTypeOptions] = useState([]);
const [regionOptions, setRegionOptions] = useState([]);
const [passportSeriesOptions, setPassportSeriesOptions] = useState([]);
+ const [educationOptions, setEducationOptions] = useState([]);
+ const [marriageOptions, setMarriageOptions] = useState([]);
+ const [education, setEducation] = useState('');
+ const [marriageStatus, setMarriageStatus] = useState('');
+ const [passportAddress, setPassportAddress] = useState('');
+ const [realAddress, setRealAddress] = useState('');
+ const [passportGivenAt, setPassportGivenAt] = useState('');
+ const [passportGivenBy, setPassportGivenBy] = useState('');
+ const [bornPlace, setBornPlace] = useState('');
+ const [email, setEmail] = useState('');
+ const [phoneAdditional, setPhoneAdditional] = useState('');
+ const [phoneHome, setPhoneHome] = useState('');
+ const [workCompany, setWorkCompany] = useState('');
+ const [workCompanyAccNum, setWorkCompanyAccNum] = useState('');
+ const [workRegion, setWorkRegion] = useState('');
+ const [workProvinceId, setWorkProvinceId] = useState('');
+ const [workPosition, setWorkPosition] = useState('');
+ const [workSalary, setWorkSalary] = useState('');
+ const [workStartedAt, setWorkStartedAt] = useState('');
const [branchesByRegion, setBranchesByRegion] = useState({});
useEffect(() => {
@@ -46,24 +67,17 @@ const CreateLoanOrderScreen = () => {
}
}
- const fetchEnums = async () => {
- try {
- const res = await fetch(`${API_CONFIG.BASE_URL}/base-app-enums`);
- const enums = await res.json();
- const regions = Object.entries(enums.regions || {}).map(([value, label]) => ({ value, label }));
- setRegionOptions(regions);
- const pSeries = Object.keys(enums.passport_series || {}).map((key) => ({ value: key, label: key }));
- setPassportSeriesOptions(pSeries);
- } catch {}
- };
+ const baseRegions = getOptions('regions');
+ const pSeries = getOptions('passport_series');
+ const loanTypes = getOptions('loan_types');
+ const educ = getOptions('educations');
+ const marriages = getOptions('marriage_statuses');
- const fetchLoanTypes = async () => {
- try {
- const res = await fetch(`${API_CONFIG.BASE_URL}/loan-types`);
- const list = await res.json();
- setLoanTypeOptions(list.map((lt) => ({ value: lt.id, label: lt.name })));
- } catch {}
- };
+ setRegionOptions(baseRegions);
+ setPassportSeriesOptions(pSeries);
+ setLoanTypeOptions(loanTypes);
+ setEducationOptions(educ);
+ setMarriageOptions(marriages);
const fetchBranches = async () => {
try {
@@ -73,15 +87,13 @@ const CreateLoanOrderScreen = () => {
} catch {}
};
- fetchEnums();
- fetchLoanTypes();
fetchBranches();
}, []);
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) {
+ if (!loanType || !loanAmount || !region || !branchId || !customerName || !customerSurname || !passportSerie || !passportId || !bornAt || !phone || !education || !marriageStatus || !passportAddress || !realAddress) {
Alert.alert('Error', 'Fill all required fields');
return;
}
@@ -94,10 +106,27 @@ const CreateLoanOrderScreen = () => {
customer_name: customerName,
customer_surname: customerSurname,
customer_patronic_name: customerPatro || null,
+ education,
+ marriage_status: marriageStatus,
+ passport_address: passportAddress,
+ real_address: realAddress,
passport_serie: passportSerie,
passport_id: passportId.trim(),
+ passport_given_at: passportGivenAt,
+ passport_given_by: passportGivenBy,
+ born_place: bornPlace,
born_at: bornAt,
phone: parseInt(phone),
+ email: email || null,
+ phone_additional: phoneAdditional ? parseInt(phoneAdditional) : null,
+ phone_home: phoneHome || null,
+ work_company: workCompany || null,
+ work_company_accountant_number: workCompanyAccNum || null,
+ work_region: workRegion || null,
+ work_province_id: workProvinceId ? parseInt(workProvinceId) : null,
+ work_position: workPosition || null,
+ work_salary: workSalary ? parseInt(workSalary) : null,
+ work_started_at: workStartedAt || null,
};
setLoading(true);
@@ -130,11 +159,31 @@ const CreateLoanOrderScreen = () => {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {setWorkRegion(val); setWorkProvinceId('');}} placeholder="Saýla" />
+ ({label:b.name,value:b.id})) : []} onValueChange={setWorkProvinceId} placeholder="Saýla" disabled={!workRegion} />
+
+
+
{loading ? : Ýatda sakla}
diff --git a/src/screens/Loan/LoanOrdersScreen.js b/src/screens/Loan/LoanOrdersScreen.js
index 50b34ea..5a1735a 100644
--- a/src/screens/Loan/LoanOrdersScreen.js
+++ b/src/screens/Loan/LoanOrdersScreen.js
@@ -43,8 +43,8 @@ const LoanOrdersScreen = () => {
};
const renderItem = ({ item }) => {
- const passportLine = `Pasport: ${item.passport_serie} ${item.passport_id}`;
- const amountLine = `Karz mukdary:`;
+ const amountLine = `Karz mukdary: `;
+ const amount = (item.loan_amount + ' TMT') || '-';
const created = item.created_at ? new Date(item.created_at).toLocaleDateString() : '';
return (
@@ -53,9 +53,11 @@ const LoanOrdersScreen = () => {
{item.id}
- {passportLine}
- {amountLine}
- {item.loan_amount || '-'}
+ {item.loan_type}
+ {amountLine}
+ {amount}
+
+
{created}
@@ -125,7 +127,7 @@ const styles = StyleSheet.create({
passportText: { fontWeight: '700', color: COLORS.textPrimary, marginBottom: 4 },
accountLabel: { color: COLORS.textSecondary, fontSize: 14 },
accountValue: { color: COLORS.textPrimary, marginBottom: 4 },
- dateText: { color: COLORS.textSecondary, fontSize: 12 },
+ dateText: { color: COLORS.textSecondary, fontSize: 12, textAlign: 'right' },
emptyContainer: { flex: 1, justifyContent: 'center', alignItems: 'center' },
emptyText: { fontSize: 16, color: COLORS.textSecondary },
fab: {