TouchableOpacity,
TextInput,
} from 'react-native';
import React, {useEffect} from 'react';
import {arizaType} from '../data/mainData';
import {postAriza} from '../data/axios';
import DateTimePicker from '@react-native-community/datetimepicker';
import dayjs from 'dayjs';
const Arizachi = () => {
const [focusedKey, setFocusedKey] = React.useState(2);
const [id, setId] = React.useState(2);
const [pasport, setPasport] = React.useState('');
const [series, setSeries] = React.useState('');
const [number, setNumber] = React.useState('');
const [open, setOpen] = React.useState(false);
const [date, setDate] = React.useState();
const handler = (key, i) => {
setFocusedKey(key);
setId(i);
};
const handleChange = passport => {
const passport_series = passport.substring(0, 2).toUpperCase();
const passport_number = passport.substring(2);
setPasport(passport_series + passport_number);
setSeries(passport_series);
setNumber(passport_number);
};
useEffect(() => {
postAriza(series, number)
.then(res => console.log(res))
.catch(error => console.log(error));
}, []);
function onSelectDate(value) {
value?.nativeEvent?.timestamp ? setDate(value.nativeEvent.timestamp) : '';
setOpen(false);
}
return (
<>
<View style={styles.container}>
<View style={styles.wrapper}>
<View>
<View style={styles.label}></View>
<Text style={styles.labelText}>Arizachi</Text>
</View>
<View>
<View style={styles.focusedLabel}></View>
<Text style={styles.labelText}>Manzil</Text>
</View>
<View>
<View style={styles.focusedLabel}></View>
<Text style={styles.labelText}>Harajatlar</Text>
</View>
<View>
<View style={styles.focusedLabel}></View>
<Text style={styles.labelText}>Daromadlar</Text>
</View>
<View>
<View style={styles.focusedLabel}></View>
<Text style={styles.labelText}>Natija</Text>
</View>
</View>
<View style={styles.ariza}>
<Text style={styles.arizaHeading}>Ariza beruvchining turi</Text>
{arizaType.map((ariza, i) => {
return (
<TouchableOpacity key={i} onPress={() => handler(ariza.key, i)}>
<View style={styles.arizaContent}>
<View
style={
id === i ? styles.arizaContentRow : styles.arizaLabel
}></View>
<Text>{ariza.name}</Text>
</View>
</TouchableOpacity>
);
})}
<View style={styles.enter}>
<Text style={styles.enterText}>pasport yoki ID raqam:</Text>
<TextInput
style={styles.enterInput}
placeholder="AA 1234567"
placeholderTextColor={'#B5B5B5'}
onChangeText={value => handleChange(value)}
maxLength={9}
value={pasport}
/>
</View>
<View style={styles.enter}>
<Text style={styles.enterText}>tug'ilgan sanasi:</Text>
<TouchableOpacity onPress={() => setOpen(true)}>
<Text style={styles.enterDateInput}>
{date ? dayjs(date).format('YYYY-MM-DD') : 'DD-MM-YYYY'}
</Text>
</TouchableOpacity>
</View>
{open ? (
<DateTimePicker
mode="date"
display={Platform.OS === 'ios' ? 'spinner' : 'default'}
onChange={value => onSelectDate(value)}
value={new Date()}
/>
) : null}
</View>
</View>
</>
);
};
А че не весь проект сюда кинул?
действительно почему
Обсуждают сегодня