reffreal input

This commit is contained in:
Samandar Turgunboyev
2026-02-26 15:44:21 +05:00
parent 7aa130bdd6
commit ad0d0d796c
2 changed files with 34 additions and 30 deletions

View File

@@ -11,7 +11,16 @@ import { AxiosError } from 'axios';
import { Image } from 'expo-image';
import { LinearGradient } from 'expo-linear-gradient';
import { useRouter } from 'expo-router';
import { Building2, CheckIcon, Globe, Hash, Search, ShieldCheck, User, UserPlus } from 'lucide-react-native';
import {
Building2,
CheckIcon,
Globe,
Hash,
Search,
ShieldCheck,
User,
UserPlus,
} from 'lucide-react-native';
import React, { useCallback, useMemo, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
import {
@@ -125,15 +134,16 @@ export default function RegisterFormScreen() {
const selectedCountryName = useMemo(() => {
if (!selectedCountry) return t('Tanlang');
return countryResponse?.find((c: any) => c.flag?.toUpperCase() === selectedCountry)?.name || t('Tanlang');
return (
countryResponse?.find((c: any) => c.flag?.toUpperCase() === selectedCountry)?.name ||
t('Tanlang')
);
}, [selectedCountry, countryResponse, t]);
const filteredCountries = useMemo(() => {
if (!countrySearch.trim()) return countryResponse || [];
const q = countrySearch.toLowerCase().trim();
return (countryResponse || []).filter((c: any) =>
c.name?.toLowerCase().includes(q)
);
return (countryResponse || []).filter((c: any) => c.name?.toLowerCase().includes(q));
}, [countryResponse, countrySearch]);
const headerInfo = getHeaderInfo(personType);
@@ -176,17 +186,14 @@ export default function RegisterFormScreen() {
// data.entity.name.rows = [{ inn: "123456789", ... }, ...]
// Shu rows ichida joriy inn bor-yo'qligini tekshiramiz
// -------------------------------------------------------
const rows: Array<{ inn: string }> =
directorData?.data?.entity?.name?.rows ?? [];
const rows: Array<{ inn: string }> = directorData?.data?.entity?.name?.rows ?? [];
const innMatch = rows.some((row) => row.inn === inn);
if (!innMatch) {
// Director bu tashkilotga tegishli emas
setDirectorInfo(null);
setErrorDirectorInfo(
t("Bu direktor ko'rsatilgan tashkilotga tegishli emas")
);
setErrorDirectorInfo(t("Bu direktor ko'rsatilgan tashkilotga tegishli emas"));
setDirectorLoading(false);
return;
}
@@ -241,7 +248,10 @@ export default function RegisterFormScreen() {
const handlePassportSeriesChange = useCallback(
(text: string) => {
const v = text.toUpperCase().replace(/[^A-Z]/g, '').slice(0, 2);
const v = text
.toUpperCase()
.replace(/[^A-Z]/g, '')
.slice(0, 2);
setPassportSeries(v);
if (personType && passportNumber.length === 7 && jshshr.length === 14) {
setLoading(true);
@@ -510,8 +520,9 @@ export default function RegisterFormScreen() {
)}
{/* ---- LEGAL ENTITY: Kompaniya ma'lumoti ---- */}
{isLegal && info && (
hasValidName ? (
{isLegal &&
info &&
(hasValidName ? (
<View style={styles.infoBox}>
<Text style={styles.infoLabel}>{t('Tashkilot')}</Text>
<Text style={styles.infoText}>{info.fullName || info.name}</Text>
@@ -527,8 +538,7 @@ export default function RegisterFormScreen() {
<View style={styles.errorBox}>
<Text style={styles.errorText}>{t('Tashkilot topilmadi')}</Text>
</View>
)
)}
))}
{/* ---- LEGAL ENTITY: Direktor JSHSHR — faqat info kelganda ko'rinadi ---- */}
{isLegal && info && (
@@ -577,7 +587,6 @@ export default function RegisterFormScreen() {
<Hash size={18} color="#94a3b8" />
<TextInput
value={referal}
keyboardType="numeric"
placeholder={t('Referal kodi')}
placeholderTextColor="#94a3b8"
style={styles.textInput}
@@ -605,8 +614,9 @@ export default function RegisterFormScreen() {
</View>
{/* ---- YATT/BAND info ---- */}
{!isLegal && info && (
hasValidName ? (
{!isLegal &&
info &&
(hasValidName ? (
<View style={styles.infoBox}>
<Text style={styles.infoText}>{info.fullName || info.name}</Text>
</View>
@@ -620,8 +630,7 @@ export default function RegisterFormScreen() {
<View style={styles.errorBox}>
<Text style={styles.errorText}>{t('Foydalanuvchi topilmadi')}</Text>
</View>
)
)}
))}
{/* ---- Davom etish tugmasi ---- */}
<TouchableOpacity
@@ -687,10 +696,7 @@ export default function RegisterFormScreen() {
const flagCode = item.flag ? item.flag.toLowerCase() : '';
return (
<TouchableOpacity
style={[
styles.listItem,
isSelected && styles.selectedListItem,
]}
style={[styles.listItem, isSelected && styles.selectedListItem]}
onPress={() => {
setSelectedCountry(item.flag?.toUpperCase());
closeCountrySheet();
@@ -989,4 +995,4 @@ const styles = StyleSheet.create({
backgroundColor: '#f1f5f9', // disabled bo'lganda fon rangi
borderColor: '#e2e8f0', // disabled bo'lganda border rangi
},
});
});