@@ -177,7 +177,17 @@ const VolunteerRelationships = ({ forceUpdate = () => {}, onlyMe = false }) => {
177177
178178 const formattedStartDate = startDate ? formatDate ( new Date ( startDate ) ) : null ;
179179 const formattedEndDate = endDate ? formatDate ( new Date ( endDate ) ) : null ;
180-
180+
181+ const data = {
182+ ...selectedRelationship ,
183+ startDate : formattedStartDate ,
184+ endDate : formattedEndDate
185+ } ;
186+ if ( ! id && ! data . memberId ) {
187+ // For new relationships, a memberId is required.
188+ data . memberId = currentUser . id ;
189+ }
190+
181191 const res = await resolve ( {
182192 method : id ? 'PUT' : 'POST' ,
183193 url : id ? `${ relationshipBaseUrl } /${ id } ` : relationshipBaseUrl ,
@@ -186,7 +196,7 @@ const VolunteerRelationships = ({ forceUpdate = () => {}, onlyMe = false }) => {
186196 Accept : 'application/json' ,
187197 'Content-Type' : 'application/json;charset=UTF-8' ,
188198 } ,
189- data : { ... selectedRelationship , startDate : formattedStartDate , endDate : formattedEndDate } ,
199+ data : data ,
190200 } ) ;
191201
192202 if ( res . error ) return ;
@@ -402,4 +412,4 @@ const VolunteerRelationships = ({ forceUpdate = () => {}, onlyMe = false }) => {
402412
403413VolunteerRelationships . propTypes = propTypes ;
404414
405- export default VolunteerRelationships ;
415+ export default VolunteerRelationships ;
0 commit comments