Skip to content

Commit

Permalink
Fill in the memberId for the volunteer relationship if creating a new…
Browse files Browse the repository at this point in the history
… relationship.
  • Loading branch information
ocielliottc committed Oct 25, 2024
1 parent 9210c3b commit 6fed3b9
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 6fed3b9

Please sign in to comment.