diff --git a/packages/component-invite/src/helpers/Collection.js b/packages/component-invite/src/helpers/Collection.js index da805647f2381691090bc339e83badde97c35073..39ca1d2af015eeafb262b3a20f7b4391c62488fc 100644 --- a/packages/component-invite/src/helpers/Collection.js +++ b/packages/component-invite/src/helpers/Collection.js @@ -26,4 +26,12 @@ module.exports = { collection.assignedPeople = assignedPeople await collection.save() }, + updateAssignedPeople: async (collection, email) => { + const assignedPerson = collection.assignedPeople.find( + person => person.email === email, + ) + assignedPerson.hasAnswer = true + assignedPerson.isAccepted = true + await collection.save() + }, } diff --git a/packages/component-invite/src/routes/postHandleInvitation.js b/packages/component-invite/src/routes/postHandleInvitation.js index 6d8951e1cf6f4f6b2589c03e56a005623898aeed..605e4fb0c76ebf6651387ca275d3a938a39c28b0 100644 --- a/packages/component-invite/src/routes/postHandleInvitation.js +++ b/packages/component-invite/src/routes/postHandleInvitation.js @@ -42,6 +42,7 @@ module.exports = models => async (req, res) => { matchingInvitation.hasAnswer = true if (accept === true) { matchingInvitation.isAccepted = true + await collectionHelper.updateAssignedPeople(collection, user.email) try { const users = await models.User.all()