File tree Expand file tree Collapse file tree 2 files changed +18
-5
lines changed
app/components/Client/Create Expand file tree Collapse file tree 2 files changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ class Client extends React.Component
1111 constructor ( props , context ) {
1212 super ( props , context ) ;
1313 this . handleSubmit = this . handleSubmit . bind ( this ) ;
14+ this . formatFormData = this . formatFormData . bind ( this ) ;
1415 this . state = {
1516 error : '' ,
1617 areas : null ,
@@ -30,13 +31,20 @@ class Client extends React.Component
3031 } ) ;
3132 }
3233
34+ formatFormData ( data ) {
35+ let client = { }
36+ for ( let i in data ) {
37+ client [ i ] = data [ i ] . value ;
38+ }
39+
40+ client . area = this . state . areas . filter ( ( area ) => client [ 'area' ] == area . _id ) . shift ( ) ;
41+ return client ;
42+ }
43+
3344 handleSubmit ( e ) {
3445 e . preventDefault ( ) ;
3546
36- let client = { }
37- for ( let i in this . refs ) {
38- client [ i ] = this . refs [ i ] . value ;
39- }
47+ let client = this . formatFormData ( this . refs ) ;
4048
4149 this . setState ( { client : client } ) ;
4250
Original file line number Diff line number Diff line change @@ -194,7 +194,12 @@ describe('Test Create Client', () => {
194194 city : 'city' ,
195195 frequency : 'frequency' ,
196196 ability : 'ability' ,
197- area : 'Center' ,
197+ area : {
198+ _id : "Center" ,
199+ parent : "" ,
200+ __v : 0 ,
201+ ancestors : [ ]
202+ } ,
198203 } ;
199204
200205 mockAdapter
You can’t perform that action at this time.
0 commit comments