@@ -33,21 +33,6 @@ class AddCatalogPriceForm extends React.PureComponent {
33
33
} ) ;
34
34
}
35
35
36
- getCurrencyByCatalogName ( catalog ) {
37
- switch ( catalog ) {
38
- case 'michel' :
39
- case 'yvert' :
40
- return [ '\u20AC' , 'EUR' ] ;
41
- case 'scott' :
42
- return [ '$' , 'USD' ] ;
43
- case 'gibbons' :
44
- return [ '\u00A3' , 'GBP' ] ;
45
- case 'solovyov' :
46
- case 'zagorski' :
47
- return [ '\u20BD' , 'RUB' ] ;
48
- }
49
- }
50
-
51
36
handleSubmit ( event ) {
52
37
event . preventDefault ( ) ;
53
38
@@ -100,15 +85,48 @@ class AddCatalogPriceForm extends React.PureComponent {
100
85
} ) ;
101
86
}
102
87
render ( ) {
103
- const hasValidationErrors = this . state . validationErrors . length > 0 ;
104
- const [ currencySymbol , currencyName ] = this . getCurrencyByCatalogName ( this . state . catalog ) ;
105
-
88
+
89
+ return (
90
+ < AddCatalogPriceFormView
91
+ l10n = { this . props . l10n }
92
+ handleSubmit = { this . handleSubmit }
93
+ hasServerError = { this . state . hasServerError }
94
+ handleChangeCatalog = { this . handleChangeCatalog }
95
+ catalog = { this . state . catalog }
96
+ handleChangePrice = { this . handleChangePrice }
97
+ validationErrors = { this . state . validationErrors }
98
+ isDisabled = { this . state . isDisabled }
99
+ />
100
+ ) ;
101
+ }
102
+ }
103
+
104
+ class AddCatalogPriceFormView extends React . PureComponent {
105
+
106
+ getCurrencyByCatalogName ( catalog ) {
107
+ switch ( catalog ) {
108
+ case 'michel' :
109
+ case 'yvert' :
110
+ return [ '\u20AC' , 'EUR' ] ;
111
+ case 'scott' :
112
+ return [ '$' , 'USD' ] ;
113
+ case 'gibbons' :
114
+ return [ '\u00A3' , 'GBP' ] ;
115
+ case 'solovyov' :
116
+ case 'zagorski' :
117
+ return [ '\u20BD' , 'RUB' ] ;
118
+ }
119
+ }
120
+ render ( ) {
121
+ const { handleSubmit, hasServerError, handleChangeCatalog, handleChangePrice, validationErrors, isDisabled, catalog} = this . props ;
122
+ const hasValidationErrors = validationErrors . length > 0 ;
123
+ const [ currencySymbol , currencyName ] = this . getCurrencyByCatalogName ( catalog ) ;
106
124
return (
107
125
< div className = "col-sm-12 form-group" >
108
- < form className = { `form-horizontal ${ hasValidationErrors ? 'has-error' : '' } ` } onSubmit = { this . handleSubmit } >
126
+ < form className = { `form-horizontal ${ hasValidationErrors ? 'has-error' : '' } ` } onSubmit = { handleSubmit } >
109
127
< div
110
128
id = "add-catalog-price-failed-msg"
111
- className = { `alert alert-danger text-center col-sm-8 col-sm-offset-2 ${ this . state . hasServerError ? '' : 'hidden' } ` } >
129
+ className = { `alert alert-danger text-center col-sm-8 col-sm-offset-2 ${ hasServerError ? '' : 'hidden' } ` } >
112
130
{ this . props . l10n [ 't_server_error' ] || 'Server error' }
113
131
</ div >
114
132
< div className = "form-group form-group-sm" >
@@ -120,7 +138,7 @@ class AddCatalogPriceForm extends React.PureComponent {
120
138
id = "catalog-name"
121
139
name = "catalogName"
122
140
className = "form-control"
123
- onChange = { this . handleChangeCatalog } >
141
+ onChange = { handleChangeCatalog } >
124
142
< option value = "michel" >
125
143
{ this . props . l10n [ 't_michel' ] || 'Michel' }
126
144
</ option >
@@ -156,20 +174,20 @@ class AddCatalogPriceForm extends React.PureComponent {
156
174
size = "5"
157
175
title = { currencyName }
158
176
required = "required"
159
- onChange = { this . handleChangePrice } />
177
+ onChange = { handleChangePrice } />
160
178
</ div >
161
179
</ div >
162
180
</ div >
163
181
< div className = "col-sm-offset-3 col-sm-4" >
164
182
< span
165
183
id = "catalog-price.errors"
166
184
className = { `help-block ${ hasValidationErrors ? '' : 'hidden' } ` } >
167
- { this . state . validationErrors . join ( ', ' ) }
185
+ { validationErrors . join ( ', ' ) }
168
186
</ span >
169
187
< button
170
188
type = "submit"
171
189
className = "btn btn-primary btn-sm"
172
- disabled = { this . state . isDisabled } >
190
+ disabled = { isDisabled } >
173
191
{ this . props . l10n [ 't_add' ] || 'Add' }
174
192
</ button >
175
193
</ div >
0 commit comments