Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix hint inconsistent zipcode format #17144

Merged
Merged
Show file tree
Hide file tree
Changes from 3 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
3 changes: 1 addition & 2 deletions src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,8 @@ export default {
areYouSure: 'Are you sure?',
verify: 'Verify',
yesContinue: 'Yes, continue',
zipCodeExample: 'e.g. 12345, 12345-1234, 12345 1234',
websiteExample: 'e.g. https://www.expensify.com',
format: ({zipSampleFormat}) => (zipSampleFormat ? `Format: ${zipSampleFormat}` : ''),
format: ({zipSampleFormat}) => (zipSampleFormat ? `e.g. ${zipSampleFormat}` : ''),
getusha marked this conversation as resolved.
Show resolved Hide resolved
},
attachmentPicker: {
cameraPermissionRequired: 'Camera access',
Expand Down
3 changes: 1 addition & 2 deletions src/languages/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,8 @@ export default {
areYouSure: '¿Estás seguro?',
verify: 'Verifique',
yesContinue: 'Sí, Continuar',
zipCodeExample: 'p. ej. 12345, 12345-1234, 12345 1234',
websiteExample: 'p. ej. https://www.expensify.com',
format: ({zipSampleFormat}) => (zipSampleFormat ? `Formato: ${zipSampleFormat}` : ''),
format: ({zipSampleFormat}) => (zipSampleFormat ? `p. ej. ${zipSampleFormat}` : ''),
},
attachmentPicker: {
cameraPermissionRequired: 'Permiso para acceder a la cámara',
Expand Down
2 changes: 1 addition & 1 deletion src/pages/ReimbursementAccount/AddressForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ const AddressForm = props => (
onChangeText={value => props.onFieldChange({zipCode: value})}
errorText={props.errors.zipCode ? props.translate('bankAccount.error.zipCode') : ''}
maxLength={CONST.BANK_ACCOUNT.MAX_LENGTH.ZIP_CODE}
hint={props.translate('common.zipCodeExample')}
hint={props.translate('common.format', {zipSampleFormat: CONST.COUNTRY_ZIP_REGEX_DATA.US.samples})}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@getusha should we use samples based on the country? (similar to AddressPage)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rushatgabhane i don't think i see country picker on these places.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

Copy link
Member

@rushatgabhane rushatgabhane Apr 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: On Home Adress page, there is no hint displayed by default.
It only appears when you use address search to select an address.

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rushatgabhane i can reproduce the same on prod. can you add more details?
Screenshot 2023-04-10 at 7 25 27 AM

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

/>
</>
);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/settings/Payments/AddDebitCardPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class DebitCardPage extends Component {
label={this.props.translate('common.zip')}
keyboardType={CONST.KEYBOARD_TYPE.NUMBER_PAD}
maxLength={CONST.BANK_ACCOUNT.MAX_LENGTH.ZIP_CODE}
hint={this.props.translate('common.zipCodeExample')}
hint={this.props.translate('common.format', {zipSampleFormat: CONST.COUNTRY_ZIP_REGEX_DATA.US.samples})}
containerStyles={[styles.mt4]}
/>
<View style={styles.mt4}>
Expand Down
6 changes: 4 additions & 2 deletions src/pages/settings/Profile/PersonalDetails/AddressPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ class AddressPage extends Component {
this.updateAddress = this.updateAddress.bind(this);
this.onCountryUpdate = this.onCountryUpdate.bind(this);

const currentCountry = lodashGet(props.privatePersonalDetails, 'address.country') || '';
const zipSampleFormat = lodashGet(CONST.COUNTRY_ZIP_REGEX_DATA, [currentCountry, 'samples'], '');
const currentCountry = lodashGet(this.props.privatePersonalDetails, 'address.country') || '';
const currentCountryISO = PersonalDetails.getCountryISO(currentCountry);
const targetCountryISO = !_.isEmpty(currentCountryISO) ? currentCountryISO : CONST.COUNTRY.US;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we combine these two lines like so?

Suggested change
const targetCountryISO = !_.isEmpty(currentCountryISO) ? currentCountryISO : CONST.COUNTRY.US;
const currentCountryISO = PersonalDetails.getCountryISO(currentCountry) || CONST.COUNTRY.US;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if we change to this it will show empty hint

  1. Open the Home Details page
  2. Pick a country
  3. Close the drawer
  4. and come back
    because currentCountry will be defined in that case.

Copy link
Member

@rushatgabhane rushatgabhane Apr 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. Why is that?

@puneetlath's code suggestion is logically the same, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rushatgabhane i think i tested the wrong file, the issue is not appearing after applying the suggestion. is it? i will push the suggestion now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved can you check? @puneetlath

const zipSampleFormat = lodashGet(CONST.COUNTRY_ZIP_REGEX_DATA, [targetCountryISO, 'samples'], '');
this.state = {
isUsaForm: (currentCountry === CONST.COUNTRY.US || currentCountry === CONST.USA_COUNTRY_NAME),
zipFormat: this.props.translate('common.format', {zipSampleFormat}),
Expand Down