Improve validation copy texts

This commit is contained in:
Kimmo Puputti 2017-03-20 11:00:16 +02:00
parent 49723dbf3e
commit 5956a00539
2 changed files with 12 additions and 8 deletions

View file

@ -137,21 +137,24 @@ class EditListingForm extends Component {
saveActionMsg = 'Save listing',
submitting,
} = this.props;
const requiredStr = intl.formatMessage({ id: 'EditListingForm.required' });
const maxLengthStr = intl.formatMessage(
const titleRequiredMessage = intl.formatMessage({ id: 'EditListingForm.titleRequired' });
const maxLengthMessage = intl.formatMessage(
{ id: 'EditListingForm.maxLength' },
{
maxLength: TITLE_MAX_LENGTH,
}
);
const maxLength60 = maxLength(maxLengthStr, TITLE_MAX_LENGTH);
const imageRequiredStr = intl.formatMessage({ id: 'EditListingForm.imageRequired' });
const maxLength60Message = maxLength(maxLengthMessage, TITLE_MAX_LENGTH);
const imageRequiredMessage = intl.formatMessage({ id: 'EditListingForm.imageRequired' });
const locationRequiredMessage = intl.formatMessage({
id: 'EditListingForm.locationRequired',
});
const locationNotRecognizedMessage = intl.formatMessage({
id: 'EditListingForm.locationNotRecognized',
});
const descriptionRequiredMessage = intl.formatMessage({
id: 'EditListingForm.descriptionRequired',
});
return (
<form onSubmit={handleSubmit}>
@ -160,7 +163,7 @@ class EditListingForm extends Component {
label="Title"
component={enhancedField('input')}
type="text"
validate={[required(requiredStr), maxLength60]}
validate={[required(titleRequiredMessage), maxLength60Message]}
/>
<h3>Images</h3>
@ -188,7 +191,7 @@ class EditListingForm extends Component {
}}
name="images"
type="hidden"
validate={[noEmptyArray(imageRequiredStr)]}
validate={[noEmptyArray(imageRequiredMessage)]}
/>
</AddImages>
@ -207,7 +210,7 @@ class EditListingForm extends Component {
name="description"
label="Description"
component={enhancedField('textarea')}
validate={[required(requiredStr)]}
validate={[required(descriptionRequiredMessage)]}
/>
<button type="submit" disabled={pristine || submitting || disabled}>{saveActionMsg}</button>
</form>

View file

@ -5,11 +5,12 @@
"HeroSearchForm.search": "Search",
"HeroSection.subTitle": "The largest online community to rent music studios",
"HeroSection.title": "Book Studiotime anywhere",
"EditListingForm.required": "Required",
"EditListingForm.titleRequired": "You need to add a title.",
"EditListingForm.imageRequired": "You need to add at least one image.",
"EditListingForm.maxLength": "Must be {maxLength} characters or less",
"EditListingForm.locationRequired": "You need to provide a location",
"EditListingForm.locationNotRecognized": "We didn't recognize this location. Please try another location.",
"EditListingForm.descriptionRequired": "You need to add a description.",
"ListingPage.loadingListingData": "Loading listing data",
"ListingPage.noListingData": "Could not find listing data",
"PageLayout.authInfoFailed": "Could not get authentication information.",