Skip to content

Commit 5e34313

Browse files
committed
fix: checkout country/region picker label
1 parent d1f49b8 commit 5e34313

File tree

4 files changed

+27
-5
lines changed

4 files changed

+27
-5
lines changed

src/components/account/AddAccountAddress.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ class AddAccountAddress extends Component {
137137

138138
return (
139139
<ModalSelect
140+
withLabel={false}
140141
disabled={data.length === 0}
141142
key="regions"
142143
label={label}
@@ -191,6 +192,7 @@ class AddAccountAddress extends Component {
191192

192193
return (
193194
<ModalSelect
195+
withLabel={false}
194196
disabled={data.length === 0}
195197
key="countries"
196198
label={label}

src/components/checkout/CheckoutCustomerAccount.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ class CheckoutCustomerAccount extends Component {
184184
}
185185

186186
renderRegions() {
187-
const { countryId, countries } = this.props;
187+
const { countryId, countries, region } = this.props;
188188
if (countryId && countryId.length && countries && countries.length) {
189189
const country = countries.find(item => item.id === countryId);
190190
if (country && country.available_regions) {
@@ -193,11 +193,16 @@ class CheckoutCustomerAccount extends Component {
193193
key: value.id,
194194
}));
195195

196+
const label = region?.region
197+
? region?.region
198+
: translate('common.region');
199+
196200
return (
197201
<ModalSelect
202+
withLabel={false}
198203
disabled={data.length === 0}
199204
key="regions"
200-
label={translate('common.region')}
205+
label={label}
201206
attribute={translate('common.region')}
202207
value={translate('common.region')}
203208
data={data}
@@ -240,11 +245,17 @@ class CheckoutCustomerAccount extends Component {
240245
key: value.id,
241246
}));
242247

248+
const country = countries.find(item => item.id === countryId);
249+
const label = country
250+
? country.full_name_locale
251+
: translate('common.country');
252+
243253
return (
244254
<ModalSelect
255+
withLabel={false}
245256
disabled={data.length === 0}
246257
key="countries"
247-
label={translate('common.country')}
258+
label={label}
248259
attribute={translate('common.country')}
249260
value={translate('common.country')}
250261
data={data}

src/components/common/ModalSelect.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,19 @@ import ModalSelector from 'react-native-modal-selector';
44
import PropTypes from 'prop-types';
55
import { Input } from './Input';
66

7-
const ModalSelect = ({ data, disabled, label, onChange, attribute, style }) => {
7+
const ModalSelect = ({
8+
data,
9+
disabled,
10+
label,
11+
onChange,
12+
attribute,
13+
style,
14+
withLabel = true,
15+
}) => {
816
const [value, setValue] = useState('');
917

1018
const _onChange = option => {
11-
setValue(option.label);
19+
setValue(!withLabel ? option.label : `${label} : ${option.label}`);
1220

1321
if (onChange) {
1422
onChange(attribute, option.key);

src/components/home/CurrencyPicker.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const CurrencyPicker = ({
3434
disabled={data.length === 0}
3535
label={selectedCurrencyCode}
3636
attribute="CurrencyCode"
37+
withLabel={false}
3738
data={data}
3839
onChange={onChange}
3940
style={styles.currencyContainer}

0 commit comments

Comments
 (0)