feat: Added team page
Some checks failed
Build and Deploy / Deploy Web (push) Failing after 1s
Build and Deploy / Deploy Discord Bot (push) Failing after 1s

This commit is contained in:
2023-06-24 13:27:33 +02:00
parent 0588dd1c45
commit fbcd0d1bb9
11 changed files with 364 additions and 13 deletions

View File

@@ -12,16 +12,20 @@ export default defineEventHandler(async (event) => {
throw createError({ statusCode: 400, statusMessage: 'User already is in a team' })
}
const team = await TeamModel.findById(teamId).populate('members')
const team = await TeamModel.findByIdAndUpdate(teamId, {
$addToSet: {
members: user._id
}
}).populate('members')
if (!team) {
throw createError({ statusCode: 500, statusMessage: 'Team does not exist' })
}
team.members.push(userId)
user.team = team._id
user.teamInvites = []
team.save()
await user.save()
return team
})