import React, { Component } from 'react'; import { View, Text, StyleSheet, TextInput, ScrollView } from 'react-native'; import Button from '../../components/Button'; import { CountryDropCode, GetCountryList } from '../../components/CountryIcon'; import Dropdown from '../../components/Dropdown'; export default class EditAddress extends Component { constructor(props) { super(props); this.state = { addressDto: { countryCode: "", city: "", street: "", zipCode: "", houseNumber: "" } }; } componentDidMount() { const address = userInfo.address ?? {} if (!address.countryCode) { address.countryCode = "SG" } this.setState({ addressDto: address, countryList: [], }) userInfo.editAddress = false; GetCountryList(list => { this.setState({ countryList: list }) }) } changeCountry(value, index) { this.state.addressDto.countryCode = value; this.setState({ addressDto: this.state.addressDto }) } saveInfo() { const dto = this.state.addressDto if (!dto.city) { toastShort($t('profile.plsInputCity')); return; } if (!dto.street) { toastShort($t('profile.plsInputStreet')); return; } if (!dto.houseNumber) { toastShort($t('profile.plsInputUnitNo')); return; } if (!dto.zipCode) { toastShort($t('profile.plsInputPostal')); return; } userInfo.address = dto; userInfo.addressLine = dto.houseNumber + ', ' + dto.street + ', ' + dto.zipCode console.log(userInfo.addressLine); userInfo.editAddress = true; goBack(); } render() { return ( {$t('sign.labelCountry')} this.changeCountry(value, index)} customerItemView={ (item, index, onClick) => }/> {$t('profile.labelCity')} this.state.addressDto.city = text} /> {$t('profile.street')} this.state.addressDto.street = text} /> {$t('profile.unitNumber')} this.state.addressDto.houseNumber = text} /> {$t('profile.postalCode')} this.state.addressDto.zipCode = text} />