Skip to content

Commit

Permalink
Merge pull request #2668 from objectcomputing/bugfix-2667/volunteer-r…
Browse files Browse the repository at this point in the history
…elationship

Fill in the memberId for the volunteer relationship if creating a new one
  • Loading branch information
mkimberlin authored Oct 25, 2024
2 parents 2570406 + 6fed3b9 commit c9ce043
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions web-ui/src/components/volunteer/VolunteerRelationships.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,17 @@ const VolunteerRelationships = ({ forceUpdate = () => {}, onlyMe = false }) => {

const formattedStartDate = startDate ? formatDate(new Date(startDate)) : null;
const formattedEndDate = endDate ? formatDate(new Date(endDate)) : null;


const data = {
...selectedRelationship,
startDate: formattedStartDate,
endDate: formattedEndDate
};
if (!id && !data.memberId) {
// For new relationships, a memberId is required.
data.memberId = currentUser.id;
}

const res = await resolve({
method: id ? 'PUT' : 'POST',
url: id ? `${relationshipBaseUrl}/${id}` : relationshipBaseUrl,
Expand All @@ -186,7 +196,7 @@ const VolunteerRelationships = ({ forceUpdate = () => {}, onlyMe = false }) => {
Accept: 'application/json',
'Content-Type': 'application/json;charset=UTF-8',
},
data: { ...selectedRelationship, startDate: formattedStartDate, endDate: formattedEndDate },
data: data,
});

if (res.error) return;
Expand Down Expand Up @@ -402,4 +412,4 @@ const VolunteerRelationships = ({ forceUpdate = () => {}, onlyMe = false }) => {

VolunteerRelationships.propTypes = propTypes;

export default VolunteerRelationships;
export default VolunteerRelationships;

0 comments on commit c9ce043

Please sign in to comment.