Skip to content

Commit c9ce043

Browse files
authored
Merge pull request #2668 from objectcomputing/bugfix-2667/volunteer-relationship
Fill in the memberId for the volunteer relationship if creating a new one
2 parents 2570406 + 6fed3b9 commit c9ce043

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

web-ui/src/components/volunteer/VolunteerRelationships.jsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

403413
VolunteerRelationships.propTypes = propTypes;
404414

405-
export default VolunteerRelationships;
415+
export default VolunteerRelationships;

0 commit comments

Comments
 (0)