Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/components/account/AddAccountAddress.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class AddAccountAddress extends Component {

renderRegions = () => {
const theme = this.context;
const { countryId, countries } = this.props;
const { countryId, countries, region } = this.props;
if (countryId && countryId.length && countries && countries.length) {
const country = countries.find(item => item.id === countryId);
if (country && country.available_regions) {
Expand All @@ -131,11 +131,16 @@ class AddAccountAddress extends Component {
key: value.id,
}));

const label = region?.region
? region?.region
: translate('common.region');

return (
<ModalSelect
withLabel={false}
disabled={data.length === 0}
key="regions"
label={translate('common.region')}
label={label}
attribute="Region"
value="Region"
data={data}
Expand Down Expand Up @@ -187,6 +192,7 @@ class AddAccountAddress extends Component {

return (
<ModalSelect
withLabel={false}
disabled={data.length === 0}
key="countries"
label={label}
Expand Down
17 changes: 14 additions & 3 deletions src/components/checkout/CheckoutCustomerAccount.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class CheckoutCustomerAccount extends Component {
}

renderRegions() {
const { countryId, countries } = this.props;
const { countryId, countries, region } = this.props;
if (countryId && countryId.length && countries && countries.length) {
const country = countries.find(item => item.id === countryId);
if (country && country.available_regions) {
Expand All @@ -193,11 +193,16 @@ class CheckoutCustomerAccount extends Component {
key: value.id,
}));

const label = region?.region
? region?.region
: translate('common.region');

return (
<ModalSelect
withLabel={false}
disabled={data.length === 0}
key="regions"
label={translate('common.region')}
label={label}
attribute={translate('common.region')}
value={translate('common.region')}
data={data}
Expand Down Expand Up @@ -240,11 +245,17 @@ class CheckoutCustomerAccount extends Component {
key: value.id,
}));

const country = countries.find(item => item.id === countryId);
const label = country
? country.full_name_locale
: translate('common.country');

return (
<ModalSelect
withLabel={false}
disabled={data.length === 0}
key="countries"
label={translate('common.country')}
label={label}
attribute={translate('common.country')}
value={translate('common.country')}
data={data}
Expand Down
16 changes: 10 additions & 6 deletions src/components/common/ModalSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@ import ModalSelector from 'react-native-modal-selector';
import PropTypes from 'prop-types';
import { Input } from './Input';

const ModalSelect = ({ data, disabled, label, onChange, attribute, style }) => {
const ModalSelect = ({
data,
disabled,
label,
onChange,
attribute,
style,
withLabel = true,
}) => {
const [value, setValue] = useState('');

const _onChange = option => {
setValue(
attribute === 'CurrencyCode'
? option.label
: `${label} : ${option.label}`,
);
setValue(!withLabel ? option.label : `${label} : ${option.label}`);

if (onChange) {
onChange(attribute, option.key);
Expand Down
1 change: 1 addition & 0 deletions src/components/home/CurrencyPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const CurrencyPicker = ({
disabled={data.length === 0}
label={selectedCurrencyCode}
attribute="CurrencyCode"
withLabel={false}
data={data}
onChange={onChange}
style={styles.currencyContainer}
Expand Down