bug fixes
This commit is contained in:
@@ -21,6 +21,12 @@ const yearOptions = Array.from({ length: 60 }).map((_, i) => {
|
||||
|
||||
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'];
|
||||
|
||||
// Helper to format card number 9999 9999 9999 9999
|
||||
const formatCardNumber = (value) => {
|
||||
const digits = value.replace(/[^0-9]/g, '').slice(0, 16);
|
||||
return (digits.match(/.{1,4}/g) || []).join(' ');
|
||||
};
|
||||
|
||||
const CreateCardTransactionOrderScreen = () => {
|
||||
const navigation = useNavigation();
|
||||
const [cardNumber, setCardNumber] = useState('');
|
||||
@@ -35,16 +41,25 @@ const CreateCardTransactionOrderScreen = () => {
|
||||
if (user) {
|
||||
if (user.passport_serie) setPassportSerie(user.passport_serie);
|
||||
if (user.passport_id) setPassportId(String(user.passport_id));
|
||||
|
||||
if (user.card_number) setCardNumber(formatCardNumber(String(user.card_number)));
|
||||
if (user.card_month) setCardMonth(String(user.card_month).padStart(2,'0'));
|
||||
if (user.card_year) setCardYear(String(user.card_year));
|
||||
}
|
||||
}, [user]);
|
||||
|
||||
const handleCardNumberChange = (val) => {
|
||||
setCardNumber(formatCardNumber(val));
|
||||
};
|
||||
|
||||
const handleSubmit = async () => {
|
||||
if (!cardNumber.trim() || !cardMonth || !cardYear || !passportSerie || !passportId.trim()) {
|
||||
Alert.alert('Error', 'All fields are required');
|
||||
return;
|
||||
}
|
||||
setLoading(true);
|
||||
const res = await apiService.createCardTransactionOrder(cardNumber.trim(), cardMonth, cardYear, passportSerie, passportId.trim());
|
||||
const rawCard = cardNumber.replace(/\s+/g, '').trim();
|
||||
const res = await apiService.createCardTransactionOrder(rawCard, cardMonth, cardYear, passportSerie, passportId.trim());
|
||||
setLoading(false);
|
||||
if (res.success) {
|
||||
Alert.alert('Success', res.message || 'Order created successfully', [
|
||||
@@ -85,10 +100,11 @@ const CreateCardTransactionOrderScreen = () => {
|
||||
label="*Kart belgisi"
|
||||
placeholder="9934..."
|
||||
value={cardNumber}
|
||||
onChangeText={setCardNumber}
|
||||
onChangeText={handleCardNumberChange}
|
||||
keyboardType="numeric"
|
||||
autoCapitalize="none"
|
||||
autoCorrect={false}
|
||||
maxLength={19}
|
||||
/>
|
||||
|
||||
<SelectInput
|
||||
|
||||
Reference in New Issue
Block a user