@@ -118,13 +118,35 @@ impl Component for NewContributorComponent {
118
118
. send_message ( Msg :: SetContributorPushState ( FetchAction :: Fetching ) ) ;
119
119
false
120
120
}
121
- Msg :: ChangeFirstName ( first_name) => {
122
- self . contributor . first_name . neq_assign ( Some ( first_name) )
121
+ Msg :: ChangeFirstName ( value) => {
122
+ let first_name = match value. trim ( ) . is_empty ( ) {
123
+ true => None ,
124
+ false => Some ( value. trim ( ) . to_owned ( ) ) ,
125
+ } ;
126
+ self . contributor . first_name . neq_assign ( first_name)
127
+ }
128
+ Msg :: ChangeLastName ( last_name) => self
129
+ . contributor
130
+ . last_name
131
+ . neq_assign ( last_name. trim ( ) . to_owned ( ) ) ,
132
+ Msg :: ChangeFullName ( full_name) => self
133
+ . contributor
134
+ . full_name
135
+ . neq_assign ( full_name. trim ( ) . to_owned ( ) ) ,
136
+ Msg :: ChangeOrcid ( value) => {
137
+ let orcid = match value. trim ( ) . is_empty ( ) {
138
+ true => None ,
139
+ false => Some ( value. trim ( ) . to_owned ( ) ) ,
140
+ } ;
141
+ self . contributor . orcid . neq_assign ( orcid)
142
+ }
143
+ Msg :: ChangeWebsite ( value) => {
144
+ let website = match value. trim ( ) . is_empty ( ) {
145
+ true => None ,
146
+ false => Some ( value. trim ( ) . to_owned ( ) ) ,
147
+ } ;
148
+ self . contributor . website . neq_assign ( website)
123
149
}
124
- Msg :: ChangeLastName ( last_name) => self . contributor . last_name . neq_assign ( last_name) ,
125
- Msg :: ChangeFullName ( full_name) => self . contributor . full_name . neq_assign ( full_name) ,
126
- Msg :: ChangeOrcid ( orcid) => self . contributor . orcid . neq_assign ( Some ( orcid) ) ,
127
- Msg :: ChangeWebsite ( website) => self . contributor . website . neq_assign ( Some ( website) ) ,
128
150
Msg :: ChangeRoute ( r) => {
129
151
let route = Route :: from ( r) ;
130
152
self . router . send ( RouteRequest :: ChangeRoute ( route) ) ;
0 commit comments