bug fixed
This commit is contained in:
@@ -26,12 +26,10 @@ import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
ActivityIndicator,
|
||||
Keyboard,
|
||||
ScrollView,
|
||||
StyleSheet,
|
||||
Text,
|
||||
TextInput,
|
||||
TouchableOpacity,
|
||||
TouchableWithoutFeedback,
|
||||
View
|
||||
} from 'react-native';
|
||||
import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view';
|
||||
@@ -110,6 +108,7 @@ export default function RegisterFormScreen() {
|
||||
});
|
||||
|
||||
const openCountrySheet = useCallback(() => {
|
||||
Keyboard.dismiss();
|
||||
setTimeout(() => {
|
||||
countrySheetRef.current?.snapToIndex(0);
|
||||
}, 100);
|
||||
@@ -162,7 +161,6 @@ export default function RegisterFormScreen() {
|
||||
onSuccess: (res) => {
|
||||
setInfo(res.data.data);
|
||||
setLoading(false);
|
||||
// INN o'zgarganda director ma'lumotlarini tozalash
|
||||
setDirectorJshshr('');
|
||||
setDirectorInfo(null);
|
||||
setErrorDirectorInfo(null);
|
||||
@@ -180,26 +178,16 @@ export default function RegisterFormScreen() {
|
||||
mutationFn: (body: { value: string }) => auth_api.get_director_info(body),
|
||||
onSuccess: (res) => {
|
||||
const directorData = res.data;
|
||||
|
||||
// -------------------------------------------------------
|
||||
// INN TEKSHIRUVI
|
||||
// Director response strukturasi:
|
||||
// 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 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"));
|
||||
setDirectorLoading(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// INN mos keldi — director ma'lumotini saqlash
|
||||
setDirectorInfo(directorData);
|
||||
setDirectorLoading(false);
|
||||
setErrorDirectorInfo(null);
|
||||
@@ -326,7 +314,7 @@ export default function RegisterFormScreen() {
|
||||
inn.length === 9 &&
|
||||
info &&
|
||||
directorJshshr.length === 14 &&
|
||||
directorInfo // faqat INN mos kelganda to'ldiriladi
|
||||
directorInfo
|
||||
);
|
||||
}
|
||||
|
||||
@@ -334,7 +322,6 @@ export default function RegisterFormScreen() {
|
||||
})();
|
||||
|
||||
const handleContinue = () => {
|
||||
// Director to'liq ismi directorInfo dan olinadi
|
||||
const directorFullName = isLegal
|
||||
? (directorInfo?.data?.entrepreneur?.rows[0]?.entrepreneur ?? '')
|
||||
: `${info?.firstname ?? ''} ${info?.lastname ?? ''} ${info?.middlename ?? ''}`.trim();
|
||||
@@ -361,14 +348,22 @@ export default function RegisterFormScreen() {
|
||||
};
|
||||
|
||||
return (
|
||||
<KeyboardAwareScrollView
|
||||
showsVerticalScrollIndicator={false}
|
||||
keyboardShouldPersistTaps="handled"
|
||||
enableOnAndroid
|
||||
extraScrollHeight={120}
|
||||
>
|
||||
<TouchableWithoutFeedback onPress={Keyboard.dismiss}>
|
||||
<View style={styles.container}>
|
||||
// ✅ Fragment — BottomSheet tashqarida bo'lishi uchun
|
||||
<>
|
||||
<KeyboardAwareScrollView
|
||||
enableOnAndroid
|
||||
enableAutomaticScroll
|
||||
extraScrollHeight={120}
|
||||
style={styles.keyboardScroll}
|
||||
>
|
||||
{/* ✅ TouchableWithoutFeedback yo'q — onStartShouldSetResponder ishlatildi */}
|
||||
<View
|
||||
style={styles.container}
|
||||
onStartShouldSetResponder={() => {
|
||||
Keyboard.dismiss();
|
||||
return false; // false — child elementlar (buttonlar) ham ishlaydi
|
||||
}}
|
||||
>
|
||||
<LinearGradient
|
||||
colors={['#0f172a', '#1e293b', '#334155']}
|
||||
start={{ x: 0, y: 0 }}
|
||||
@@ -380,13 +375,9 @@ export default function RegisterFormScreen() {
|
||||
|
||||
<AuthHeader />
|
||||
|
||||
{/* ✅ SafeAreaView va ichki ScrollView yo'q — to'g'ridan View */}
|
||||
<SafeAreaView style={{ flex: 1 }} edges={['bottom']}>
|
||||
|
||||
<ScrollView
|
||||
contentContainerStyle={styles.scrollContent}
|
||||
showsVerticalScrollIndicator={false}
|
||||
keyboardShouldPersistTaps="handled"
|
||||
>
|
||||
<View style={styles.scrollContent}>
|
||||
<View style={styles.header}>
|
||||
<View style={styles.iconContainer}>
|
||||
<LinearGradient
|
||||
@@ -408,43 +399,6 @@ export default function RegisterFormScreen() {
|
||||
|
||||
<View style={styles.card}>
|
||||
<View style={styles.formGap}>
|
||||
{/* ---- Davlat (Country) ---- */}
|
||||
{/* <View>
|
||||
<Text style={styles.label}>{t('Davlat')}</Text>
|
||||
<TouchableOpacity
|
||||
style={[
|
||||
styles.input,
|
||||
styles.inputDisabled,
|
||||
]}
|
||||
onPress={openCountrySheet}
|
||||
activeOpacity={0.7}
|
||||
testID="country-select"
|
||||
disabled
|
||||
>
|
||||
{countryLoading ? (
|
||||
<ActivityIndicator size="small" color="#3b82f6" style={{ flex: 1 }} />
|
||||
) : (
|
||||
<>
|
||||
<Image
|
||||
source={{ uri: `https://flagcdn.com/w320/${selectedCountry.toLowerCase()}.png` }}
|
||||
style={{ width: 30, height: 15 }}
|
||||
resizeMode="cover"
|
||||
/>
|
||||
<Text
|
||||
style={[
|
||||
styles.textInput,
|
||||
// { color: selectedCountry === 'all' ? '#94a3b8' : '#1e293b' },
|
||||
{ color: '#94a3b8' },
|
||||
]}
|
||||
numberOfLines={1}
|
||||
>
|
||||
{selectedCountryName}
|
||||
</Text>
|
||||
</>
|
||||
)}
|
||||
<ChevronDown size={18} color={'#cbd5e1'} />
|
||||
</TouchableOpacity>
|
||||
</View> */}
|
||||
{/* ---- YATT / BAND ---- */}
|
||||
{isYattOrBand && (
|
||||
<>
|
||||
@@ -544,7 +498,7 @@ export default function RegisterFormScreen() {
|
||||
</View>
|
||||
))}
|
||||
|
||||
{/* ---- LEGAL ENTITY: Direktor JSHSHR — faqat info kelganda ko'rinadi ---- */}
|
||||
{/* ---- LEGAL ENTITY: Direktor JSHSHR ---- */}
|
||||
{isLegal && info && (
|
||||
<View>
|
||||
<Text style={styles.label}>{t('Direktor JSHSHR')}</Text>
|
||||
@@ -565,7 +519,6 @@ export default function RegisterFormScreen() {
|
||||
)}
|
||||
</View>
|
||||
|
||||
{/* ---- Direktor ma'lumoti (INN mos kelgan holda) ---- */}
|
||||
{directorInfo && (
|
||||
<View style={[styles.infoBox, { marginTop: 8 }]}>
|
||||
<Text style={styles.infoLabel}>{t('Direktor')}</Text>
|
||||
@@ -575,7 +528,6 @@ export default function RegisterFormScreen() {
|
||||
</View>
|
||||
)}
|
||||
|
||||
{/* ---- Xato: INN mos kelmasa yoki server xatosi ---- */}
|
||||
{directorInfoError && (
|
||||
<View style={[styles.errorBox, { marginTop: 8 }]}>
|
||||
<Text style={styles.errorText}>{directorInfoError}</Text>
|
||||
@@ -648,98 +600,103 @@ export default function RegisterFormScreen() {
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
</View>
|
||||
</ScrollView>
|
||||
</View>
|
||||
</SafeAreaView>
|
||||
|
||||
{/* ---- Country BottomSheet ---- */}
|
||||
<BottomSheet
|
||||
ref={countrySheetRef}
|
||||
index={-1}
|
||||
snapPoints={snapPoints}
|
||||
enablePanDownToClose={true}
|
||||
enableDynamicSizing={false}
|
||||
enableOverDrag={false}
|
||||
backdropComponent={renderBackdrop}
|
||||
backgroundStyle={styles.bottomSheetBg}
|
||||
handleIndicatorStyle={styles.handleIndicator}
|
||||
android_keyboardInputMode="adjustResize"
|
||||
keyboardBehavior="interactive"
|
||||
keyboardBlurBehavior="restore"
|
||||
>
|
||||
<View style={styles.sheetHeader}>
|
||||
<Text style={styles.sheetTitle}>{t('Davlat')}</Text>
|
||||
</View>
|
||||
|
||||
{/* Search input */}
|
||||
<View style={styles.searchContainer}>
|
||||
<Search size={16} color="#94a3b8" />
|
||||
<BottomSheetTextInput
|
||||
value={countrySearch}
|
||||
onChangeText={setCountrySearch}
|
||||
placeholder={t('Qidirish...')}
|
||||
placeholderTextColor="#94a3b8"
|
||||
style={styles.searchInput}
|
||||
clearButtonMode="while-editing"
|
||||
autoCorrect={false}
|
||||
/>
|
||||
</View>
|
||||
|
||||
<BottomSheetFlatList
|
||||
data={filteredCountries}
|
||||
keyExtractor={(item: any) => item.id?.toString()}
|
||||
contentContainerStyle={styles.listContainer}
|
||||
showsVerticalScrollIndicator={false}
|
||||
keyboardShouldPersistTaps="handled"
|
||||
ListEmptyComponent={
|
||||
<View style={styles.emptyList}>
|
||||
<Text style={styles.emptyListText}>{t('Natija topilmadi')}</Text>
|
||||
</View>
|
||||
}
|
||||
renderItem={({ item }: { item: any }) => {
|
||||
const isSelected = item.flag?.toUpperCase() === selectedCountry;
|
||||
const flagCode = item.flag ? item.flag.toLowerCase() : '';
|
||||
return (
|
||||
<TouchableOpacity
|
||||
style={[styles.listItem, isSelected && styles.selectedListItem]}
|
||||
onPress={() => {
|
||||
setSelectedCountry(item.flag?.toUpperCase());
|
||||
closeCountrySheet();
|
||||
}}
|
||||
activeOpacity={0.7}
|
||||
>
|
||||
<View style={{ flexDirection: 'row', alignItems: 'center', gap: 10, flex: 1 }}>
|
||||
{flagCode ? (
|
||||
<Image
|
||||
source={{ uri: `https://flagcdn.com/w320/${flagCode}.png` }}
|
||||
style={{ width: 34, height: 22, borderRadius: 2 }}
|
||||
/>
|
||||
) : (
|
||||
<Globe size={20} color={isSelected ? '#2563eb' : '#94a3b8'} />
|
||||
)}
|
||||
<Text style={[styles.listItemText, isSelected && styles.selectedListItemText]}>
|
||||
{item.name}
|
||||
</Text>
|
||||
</View>
|
||||
{isSelected && (
|
||||
<View style={styles.checkmark}>
|
||||
<CheckIcon color="#3b82f6" strokeWidth={2.5} size={16} />
|
||||
</View>
|
||||
)}
|
||||
</TouchableOpacity>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
</BottomSheet>
|
||||
</View>
|
||||
</TouchableWithoutFeedback>
|
||||
</KeyboardAwareScrollView>
|
||||
</KeyboardAwareScrollView>
|
||||
|
||||
{/* ✅ BottomSheet KeyboardAwareScrollView TASHQARISIDA */}
|
||||
<BottomSheet
|
||||
ref={countrySheetRef}
|
||||
index={-1}
|
||||
snapPoints={snapPoints}
|
||||
enablePanDownToClose={true}
|
||||
enableDynamicSizing={false}
|
||||
enableOverDrag={false}
|
||||
backdropComponent={renderBackdrop}
|
||||
backgroundStyle={styles.bottomSheetBg}
|
||||
handleIndicatorStyle={styles.handleIndicator}
|
||||
android_keyboardInputMode="adjustResize"
|
||||
keyboardBehavior="interactive"
|
||||
keyboardBlurBehavior="restore"
|
||||
>
|
||||
<View style={styles.sheetHeader}>
|
||||
<Text style={styles.sheetTitle}>{t('Davlat')}</Text>
|
||||
</View>
|
||||
|
||||
<View style={styles.searchContainer}>
|
||||
<Search size={16} color="#94a3b8" />
|
||||
<BottomSheetTextInput
|
||||
value={countrySearch}
|
||||
onChangeText={setCountrySearch}
|
||||
placeholder={t('Qidirish...')}
|
||||
placeholderTextColor="#94a3b8"
|
||||
style={styles.searchInput}
|
||||
clearButtonMode="while-editing"
|
||||
autoCorrect={false}
|
||||
/>
|
||||
</View>
|
||||
|
||||
<BottomSheetFlatList
|
||||
data={filteredCountries}
|
||||
keyExtractor={(item: any) => item.id?.toString()}
|
||||
contentContainerStyle={styles.listContainer}
|
||||
showsVerticalScrollIndicator={false}
|
||||
keyboardShouldPersistTaps="handled"
|
||||
ListEmptyComponent={
|
||||
<View style={styles.emptyList}>
|
||||
<Text style={styles.emptyListText}>{t('Natija topilmadi')}</Text>
|
||||
</View>
|
||||
}
|
||||
renderItem={({ item }: { item: any }) => {
|
||||
const isSelected = item.flag?.toUpperCase() === selectedCountry;
|
||||
const flagCode = item.flag ? item.flag.toLowerCase() : '';
|
||||
return (
|
||||
<TouchableOpacity
|
||||
style={[styles.listItem, isSelected && styles.selectedListItem]}
|
||||
onPress={() => {
|
||||
setSelectedCountry(item.flag?.toUpperCase());
|
||||
closeCountrySheet();
|
||||
}}
|
||||
activeOpacity={0.7}
|
||||
>
|
||||
<View style={{ flexDirection: 'row', alignItems: 'center', gap: 10, flex: 1 }}>
|
||||
{flagCode ? (
|
||||
<Image
|
||||
source={{ uri: `https://flagcdn.com/w320/${flagCode}.png` }}
|
||||
style={{ width: 34, height: 22, borderRadius: 2 }}
|
||||
/>
|
||||
) : (
|
||||
<Globe size={20} color={isSelected ? '#2563eb' : '#94a3b8'} />
|
||||
)}
|
||||
<Text style={[styles.listItemText, isSelected && styles.selectedListItemText]}>
|
||||
{item.name}
|
||||
</Text>
|
||||
</View>
|
||||
{isSelected && (
|
||||
<View style={styles.checkmark}>
|
||||
<CheckIcon color="#3b82f6" strokeWidth={2.5} size={16} />
|
||||
</View>
|
||||
)}
|
||||
</TouchableOpacity>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
</BottomSheet>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
// ✅ KeyboardAwareScrollView uchun style
|
||||
keyboardScroll: {
|
||||
flex: 1,
|
||||
backgroundColor: '#0f172a',
|
||||
},
|
||||
container: {
|
||||
flex: 1,
|
||||
backgroundColor: '#0f172a',
|
||||
minHeight: '100%',
|
||||
},
|
||||
scrollContent: {
|
||||
flexGrow: 1,
|
||||
@@ -969,15 +926,6 @@ const styles = StyleSheet.create({
|
||||
fontWeight: '800' as const,
|
||||
fontSize: 16,
|
||||
},
|
||||
footer: {
|
||||
marginTop: 20,
|
||||
alignItems: 'center',
|
||||
},
|
||||
footerText: {
|
||||
color: '#94a3b8',
|
||||
fontSize: 14,
|
||||
fontWeight: '600' as const,
|
||||
},
|
||||
decorCircle1: {
|
||||
position: 'absolute',
|
||||
top: -150,
|
||||
@@ -997,7 +945,7 @@ const styles = StyleSheet.create({
|
||||
backgroundColor: 'rgba(16, 185, 129, 0.08)',
|
||||
},
|
||||
inputDisabled: {
|
||||
backgroundColor: '#f1f5f9', // disabled bo'lganda fon rangi
|
||||
borderColor: '#e2e8f0', // disabled bo'lganda border rangi
|
||||
backgroundColor: '#f1f5f9',
|
||||
borderColor: '#e2e8f0',
|
||||
},
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user