Skip to content

Commit fe50152

Browse files
committed
refactor: use destructure for l10n.
1 parent 108acf7 commit fe50152

File tree

5 files changed

+35
-59
lines changed

5 files changed

+35
-59
lines changed

src/main/frontend/src/components/AddCatalogNumbersForm.js

+11-23
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class AddCatalogNumbersForm extends React.PureComponent {
100100

101101
class AddCatalogNumbersFormView extends React.PureComponent {
102102
render() {
103-
const {handleSubmit, hasServerError, handleChangeCatalog, handleChangeNumbers, validationErrors, isDisabled} = this.props;
103+
const {handleSubmit, hasServerError, handleChangeCatalog, handleChangeNumbers, validationErrors, isDisabled, l10n} = this.props;
104104
const hasValidationErrors = validationErrors.length > 0;
105105

106106
return (
@@ -109,42 +109,30 @@ class AddCatalogNumbersFormView extends React.PureComponent {
109109
<div
110110
id="add-catalog-numbers-failed-msg"
111111
className={ `alert alert-danger text-center col-sm-8 col-sm-offset-2 ${hasServerError ? '' : 'hidden'}` }>
112-
{ this.props.l10n['t_server_error'] || 'Server error' }
112+
{ l10n['t_server_error'] || 'Server error' }
113113
</div>
114114
<div className="form-group form-group-sm">
115115
<label className="control-label col-sm-3">
116-
{ this.props.l10n['t_catalog'] || 'Catalog' }
116+
{ l10n['t_catalog'] || 'Catalog' }
117117
</label>
118118
<div className="col-sm-6">
119119
<select
120120
id="catalog-name"
121121
name="catalogName"
122122
className="form-control"
123123
onChange={ handleChangeCatalog }>
124-
<option value="michel">
125-
{ this.props.l10n['t_michel'] || 'Michel' }
126-
</option>
127-
<option value="scott">
128-
{ this.props.l10n['t_scott'] || 'Scott' }
129-
</option>
130-
<option value="yvert">
131-
{ this.props.l10n['t_yvert'] || 'Yvert et Tellier' }
132-
</option>
133-
<option value="gibbons">
134-
{ this.props.l10n['t_sg'] || 'Stanley Gibbons' }
135-
</option>
136-
<option value="solovyov">
137-
{ this.props.l10n['t_solovyov'] || 'Solovyov' }
138-
</option>
139-
<option value="zagorski">
140-
{ this.props.l10n['t_zagorski'] || 'Zagorski' }
141-
</option>
124+
<option value="michel">{ l10n['t_michel'] || 'Michel' }</option>
125+
<option value="scott">{ l10n['t_scott'] || 'Scott' }</option>
126+
<option value="yvert">{ l10n['t_yvert'] || 'Yvert et Tellier' }</option>
127+
<option value="gibbons">{ l10n['t_sg'] || 'Stanley Gibbons' }</option>
128+
<option value="solovyov">{ l10n['t_solovyov'] || 'Solovyov' }</option>
129+
<option value="zagorski">{ l10n['t_zagorski'] || 'Zagorski' }</option>
142130
</select>
143131
</div>
144132
</div>
145133
<div className="form-group form-group-sm">
146134
<label className="control-label col-sm-3">
147-
{ this.props.l10n['t_numbers'] || 'Numbers' }
135+
{ l10n['t_numbers'] || 'Numbers' }
148136
</label>
149137
<div className="row">
150138
<div className="col-sm-6">
@@ -168,7 +156,7 @@ class AddCatalogNumbersFormView extends React.PureComponent {
168156
type="submit"
169157
className="btn btn-primary btn-sm"
170158
disabled={ isDisabled }>
171-
{ this.props.l10n['t_add'] || 'Add' }
159+
{ l10n['t_add'] || 'Add' }
172160
</button>
173161
</div>
174162
</form>

src/main/frontend/src/components/AddCatalogPriceForm.js

+11-23
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class AddCatalogPriceFormView extends React.PureComponent {
118118
}
119119
}
120120
render() {
121-
const {handleSubmit, hasServerError, handleChangeCatalog, handleChangePrice, validationErrors, isDisabled, catalog} = this.props;
121+
const {handleSubmit, hasServerError, handleChangeCatalog, handleChangePrice, validationErrors, isDisabled, catalog, l10n} = this.props;
122122
const hasValidationErrors = validationErrors.length > 0;
123123
const [currencySymbol, currencyName] = this.getCurrencyByCatalogName(catalog);
124124
return (
@@ -127,42 +127,30 @@ class AddCatalogPriceFormView extends React.PureComponent {
127127
<div
128128
id="add-catalog-price-failed-msg"
129129
className={ `alert alert-danger text-center col-sm-8 col-sm-offset-2 ${hasServerError ? '' : 'hidden'}` }>
130-
{ this.props.l10n['t_server_error'] || 'Server error' }
130+
{ l10n['t_server_error'] || 'Server error' }
131131
</div>
132132
<div className="form-group form-group-sm">
133133
<label className="control-label col-sm-3">
134-
{ this.props.l10n['t_catalog'] || 'Catalog' }
134+
{ l10n['t_catalog'] || 'Catalog' }
135135
</label>
136136
<div className="col-sm-6">
137137
<select
138138
id="catalog-name"
139139
name="catalogName"
140140
className="form-control"
141141
onChange={ handleChangeCatalog }>
142-
<option value="michel">
143-
{ this.props.l10n['t_michel'] || 'Michel' }
144-
</option>
145-
<option value="scott">
146-
{ this.props.l10n['t_scott'] || 'Scott' }
147-
</option>
148-
<option value="yvert">
149-
{ this.props.l10n['t_yvert'] || 'Yvert et Tellier' }
150-
</option>
151-
<option value="gibbons">
152-
{ this.props.l10n['t_sg'] || 'Stanley Gibbons' }
153-
</option>
154-
<option value="solovyov">
155-
{ this.props.l10n['t_solovyov'] || 'Solovyov' }
156-
</option>
157-
<option value="zagorski">
158-
{ this.props.l10n['t_zagorski'] || 'Zagorski' }
159-
</option>
142+
<option value="michel">{ l10n['t_michel'] || 'Michel' }</option>
143+
<option value="scott">{ l10n['t_scott'] || 'Scott' }</option>
144+
<option value="yvert">{ l10n['t_yvert'] || 'Yvert et Tellier' }</option>
145+
<option value="gibbons">{ l10n['t_sg'] || 'Stanley Gibbons' }</option>
146+
<option value="solovyov">{ l10n['t_solovyov'] || 'Solovyov' }</option>
147+
<option value="zagorski">{ l10n['t_zagorski'] || 'Zagorski' }</option>
160148
</select>
161149
</div>
162150
</div>
163151
<div className="form-group form-group-sm">
164152
<label className="control-label col-sm-3">
165-
{ this.props.l10n['t_price'] || 'Price' }
153+
{ l10n['t_price'] || 'Price' }
166154
</label>
167155
<div className="col-sm-3">
168156
<div className="input-group">
@@ -188,7 +176,7 @@ class AddCatalogPriceFormView extends React.PureComponent {
188176
type="submit"
189177
className="btn btn-primary btn-sm"
190178
disabled={ isDisabled }>
191-
{ this.props.l10n['t_add'] || 'Add' }
179+
{ l10n['t_add'] || 'Add' }
192180
</button>
193181
</div>
194182
</form>

src/main/frontend/src/components/AddCommentForm.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -88,19 +88,19 @@ class AddCommentForm extends React.PureComponent {
8888

8989
class AddCommentFormView extends React.PureComponent {
9090
render() {
91-
const {handleSubmit, hasServerError, handleChange, validationErrors, isDisabled} = this.props;
91+
const {handleSubmit, hasServerError, handleChange, validationErrors, isDisabled, l10n} = this.props;
9292
const hasValidationErrors = validationErrors.length > 0;
9393
return (
9494
<div className="col-sm-12 form-group">
9595
<form className={ `form-horizontal ${hasValidationErrors ? 'has-error' : ''}` } onSubmit={ handleSubmit }>
9696
<div
9797
id="add-comment-failed-msg"
9898
className={ `alert alert-danger text-center col-sm-8 col-sm-offset-2 ${hasServerError ? '' : 'hidden'}` }>
99-
{ this.props.l10n['t_server_error'] || 'Server error' }
99+
{ l10n['t_server_error'] || 'Server error' }
100100
</div>
101101
<div className="form-group form-group-sm">
102102
<label className="control-label col-sm-3">
103-
{ this.props.l10n['t_comment'] || 'Comment' }
103+
{ l10n['t_comment'] || 'Comment' }
104104
</label>
105105
<div className="col-sm-6">
106106
<textarea
@@ -123,7 +123,7 @@ class AddCommentFormView extends React.PureComponent {
123123
type="submit"
124124
className="btn btn-primary btn-sm"
125125
disabled={ isDisabled }>
126-
{ this.props.l10n['t_add'] || 'Add' }
126+
{ l10n['t_add'] || 'Add' }
127127
</button>
128128
</div>
129129
</form>

src/main/frontend/src/components/AddReleaseYearForm.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class AddReleaseYearFormView extends React.PureComponent {
9999
}
100100

101101
render() {
102-
const {handleSubmit, hasServerError, handleChange, validationErrors, isDisabled, sinceYear, tillYear} = this.props;
102+
const {handleSubmit, hasServerError, handleChange, validationErrors, isDisabled, sinceYear, tillYear, l10n} = this.props;
103103
const hasValidationErrors = validationErrors.length > 0;
104104
const rangeOfYears = this.generateRange(sinceYear, tillYear);
105105

@@ -109,11 +109,11 @@ class AddReleaseYearFormView extends React.PureComponent {
109109
<div
110110
id="add-release-year-failed-msg"
111111
className={ `alert alert-danger text-center col-sm-8 col-sm-offset-2 ${hasServerError ? '' : 'hidden' }` }>
112-
{ this.props.l10n['t_server_error'] || 'Server error' }
112+
{ l10n['t_server_error'] || 'Server error' }
113113
</div>
114114
<div className="form-group form-group-sm">
115115
<label className="control-label col-sm-3">
116-
{ this.props.l10n['t_release_year'] || 'Release year' }
116+
{ l10n['t_release_year'] || 'Release year' }
117117
</label>
118118
<div className="col-sm-6">
119119
<select
@@ -141,7 +141,7 @@ class AddReleaseYearFormView extends React.PureComponent {
141141
type="submit"
142142
className="btn btn-primary btn-sm"
143143
disabled={ isDisabled }>
144-
{ this.props.l10n['t_add'] || 'Add' }
144+
{ l10n['t_add'] || 'Add' }
145145
</button>
146146
</div>
147147
</form>

src/main/frontend/src/components/SeriesSaleImportForm.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class SeriesSaleImportForm extends React.PureComponent {
110110

111111
class SeriesSaleImportFormView extends React.PureComponent {
112112
render() {
113-
const { hasServerError, handleSubmit, url, handleChange, isDisabled, validationErrors} = this.props;
113+
const { hasServerError, handleSubmit, url, handleChange, isDisabled, validationErrors, l10n} = this.props;
114114
const hasValidationErrors = validationErrors.length > 0;
115115

116116
return (
@@ -119,14 +119,14 @@ class SeriesSaleImportFormView extends React.PureComponent {
119119
<div className="row">
120120
<div className="col-sm-12">
121121
<h5>
122-
{ this.props.l10n['t_import_info_who_selling_series'] || 'Import info about selling this series' }
122+
{ l10n['t_import_info_who_selling_series'] || 'Import info about selling this series' }
123123
</h5>
124124
</div>
125125
</div>
126126
<div className="row">
127127
<div id="import-series-sale-failed-msg"
128128
className={ `alert alert-danger text-center col-sm-8 col-sm-offset-2 ${hasServerError ? '' : 'hidden'}` }>
129-
{ this.props.l10n['t_could_not_import_info'] || 'Could not import information from this page' }
129+
{ l10n['t_could_not_import_info'] || 'Could not import information from this page' }
130130
</div>
131131
</div>
132132
<div className="row">
@@ -137,7 +137,7 @@ class SeriesSaleImportFormView extends React.PureComponent {
137137

138138
<div className="form-group form-group-sm">
139139
<label htmlFor="series-sale-url" className="control-label col-sm-3">
140-
{ this.props.l10n['t_url'] || 'URL' }
140+
{ l10n['t_url'] || 'URL' }
141141
<span className="required_field"> *</span>
142142
</label>
143143
<div className="col-sm-6">
@@ -161,7 +161,7 @@ class SeriesSaleImportFormView extends React.PureComponent {
161161
<button type="submit"
162162
className="btn btn-primary btn-sm"
163163
disabled={ isDisabled }>
164-
{ this.props.l10n['t_import_info'] || 'Import info' }
164+
{ l10n['t_import_info'] || 'Import info' }
165165
</button>
166166
</div>
167167
</div>

0 commit comments

Comments
 (0)