@@ -85,121 +85,95 @@ class AddCatalogPriceForm extends React.Component {
85
85
}
86
86
render ( ) {
87
87
const hasValidationErrors = this . state . validationErrors . length > 0 ;
88
+ let currency ;
89
+ let title ;
90
+
91
+ switch ( this . state . catalog ) {
92
+ case 'michel' :
93
+ case 'yvert' :
94
+ currency = '\u20AC' ;
95
+ title = 'EUR' ;
96
+ break ;
97
+ case 'scott' :
98
+ currency = '$' ;
99
+ title = 'USD' ;
100
+ break ;
101
+ case 'gibbons' :
102
+ currency = '\u00A3' ;
103
+ title = 'GBP' ;
104
+ break ;
105
+ case 'solovyov' :
106
+ case 'zagorski' :
107
+ currency = '\u20BD' ;
108
+ title = 'RUB' ;
109
+ break ;
110
+ }
111
+
88
112
return (
89
- < div className = " col-sm-12 form-group" >
113
+ < div className = ' col-sm-12 form-group' >
90
114
< form className = { `form-horizontal ${ hasValidationErrors ? 'has-error' : '' } ` } onSubmit = { this . handleSubmit } >
91
115
< div
92
- id = " add-catalog-price-failed-msg"
116
+ id = ' add-catalog-price-failed-msg'
93
117
className = { `alert alert-danger text-center col-sm-8 col-sm-offset-2 ${ this . state . hasServerError ? '' : 'hidden' } ` } >
94
118
{ this . props . l10n [ 't_server_error' ] || 'Server error' }
95
119
</ div >
96
- < div className = " form-group form-group-sm" >
97
- < label className = " control-label col-sm-3" >
120
+ < div className = ' form-group form-group-sm' >
121
+ < label className = ' control-label col-sm-3' >
98
122
{ this . props . l10n [ 't_catalog' ] || 'Catalog' }
99
123
</ label >
100
- < div className = " col-sm-6" >
124
+ < div className = ' col-sm-6' >
101
125
< select
102
- id = " catalog-name"
103
- name = " catalogName"
104
- className = " form-control"
126
+ id = ' catalog-name'
127
+ name = ' catalogName'
128
+ className = ' form-control'
105
129
onChange = { this . handleChangeCatalog } >
106
- < option value = " michel" >
130
+ < option value = ' michel' >
107
131
{ this . props . l10n [ 't_michel' ] || 'Michel' }
108
132
</ option >
109
- < option value = " scott" >
133
+ < option value = ' scott' >
110
134
{ this . props . l10n [ 't_scott' ] || 'Scott' }
111
135
</ option >
112
- < option value = " yvert" >
136
+ < option value = ' yvert' >
113
137
{ this . props . l10n [ 't_yvert' ] || 'Yvert et Tellier' }
114
138
</ option >
115
- < option value = " gibbons" >
139
+ < option value = ' gibbons' >
116
140
{ this . props . l10n [ 't_sg' ] || 'Stanley Gibbons' }
117
141
</ option >
118
- < option value = " solovyov" >
142
+ < option value = ' solovyov' >
119
143
{ this . props . l10n [ 't_solovyov' ] || 'Solovyov' }
120
144
</ option >
121
- < option value = " zagorski" >
145
+ < option value = ' zagorski' >
122
146
{ this . props . l10n [ 't_zagorski' ] || 'Zagorski' }
123
147
</ option >
124
148
</ select >
125
149
</ div >
126
150
</ div >
127
- < div className = " form-group form-group-sm" >
128
- < label className = " control-label col-sm-3" >
151
+ < div className = ' form-group form-group-sm' >
152
+ < label className = ' control-label col-sm-3' >
129
153
{ this . props . l10n [ 't_price' ] || 'Price' }
130
154
</ label >
131
- < div className = "col-sm-6" >
132
- { this . state . catalog === "michel" && < div className = "col-xs-6 input-group" >
133
- < span className = "input-group-addon" > €</ span >
134
- < input
135
- type = "text"
136
- className = "form-control js-with-tooltip"
137
- size = "5"
138
- title = "EUR"
139
- required = "required"
140
- onChange = { this . handleChangePrice } />
141
- </ div > }
142
- { this . state . catalog === "scott" && < div className = "col-xs-6 input-group" >
143
- < span className = "input-group-addon" > $</ span >
144
- < input
145
- type = "text"
146
- className = "form-control js-with-tooltip"
147
- size = "5"
148
- title = "USD"
149
- required = "required"
150
- onChange = { this . handleChangePrice } />
151
- </ div > }
152
- { this . state . catalog === "yvert" && < div className = "col-xs-6 input-group " >
153
- < span className = "input-group-addon" > €</ span >
154
- < input
155
- type = "text"
156
- className = "form-control js-with-tooltip"
157
- size = "5"
158
- title = "EUR"
159
- required = "required"
160
- onChange = { this . handleChangePrice } />
161
- </ div > }
162
- { this . state . catalog === "gibbons" && < div className = "col-xs-6 input-group" >
163
- < span className = "input-group-addon" > £</ span >
164
- < input
165
- type = "text"
166
- className = "form-control js-with-tooltip"
167
- size = "5"
168
- title = "GBP"
169
- required = "required"
170
- onChange = { this . handleChangePrice } />
171
- </ div > }
172
- { this . state . catalog === "solovyov" && < div className = "col-xs-6 input-group" >
173
- < span className = "input-group-addon" > ₽</ span >
174
- < input
175
- type = "text"
176
- className = "form-control js-with-tooltip"
177
- size = "5"
178
- title = "RUB"
179
- required = "required"
180
- onChange = { this . handleChangePrice } />
181
- </ div > }
182
- { this . state . catalog === "zagorski" && < div className = "col-xs-6 input-group" >
183
- < span className = "input-group-addon" > ₽</ span >
155
+ < div className = 'col-sm-6' >
156
+ < div className = 'col-xs-6 input-group' >
157
+ < span className = 'input-group-addon' > { currency } </ span >
184
158
< input
185
- type = " text"
186
- className = " form-control"
187
- size = "5"
188
- title = "RUB"
189
- required = " required"
159
+ type = ' text'
160
+ className = ' form-control js-with-tooltip'
161
+ size = '5'
162
+ title = { title }
163
+ required = ' required'
190
164
onChange = { this . handleChangePrice } />
191
- </ div > }
165
+ </ div >
192
166
</ div >
193
167
</ div >
194
- < div className = " col-sm-offset-3 col-sm-4" >
168
+ < div className = ' col-sm-offset-3 col-sm-4' >
195
169
< span
196
- id = " catalog-price.errors"
170
+ id = ' catalog-price.errors'
197
171
className = { `help-block ${ hasValidationErrors ? '' : 'hidden' } ` } >
198
172
{ this . state . validationErrors . join ( ', ' ) }
199
173
</ span >
200
174
< button
201
- type = " submit"
202
- className = " btn btn-primary btn-sm"
175
+ type = ' submit'
176
+ className = ' btn btn-primary btn-sm'
203
177
disabled = { this . state . isDisabled } >
204
178
{ this . props . l10n [ 't_add' ] || 'Add' }
205
179
</ button >
0 commit comments