diff --git a/webv2/app.vue b/webv2/app.vue index a003353..ede345e 100644 --- a/webv2/app.vue +++ b/webv2/app.vue @@ -5,3 +5,9 @@ + + diff --git a/webv2/components/body/Connectminecraft.vue b/webv2/components/body/Connectminecraft.vue index b209b74..e5ddd09 100644 --- a/webv2/components/body/Connectminecraft.vue +++ b/webv2/components/body/Connectminecraft.vue @@ -1,6 +1,6 @@ diff --git a/webv2/components/team/None.vue b/webv2/components/team/None.vue new file mode 100644 index 0000000..d527841 --- /dev/null +++ b/webv2/components/team/None.vue @@ -0,0 +1,118 @@ + + + diff --git a/webv2/pages/index.vue b/webv2/pages/index.vue index 358a12d..4d17071 100644 --- a/webv2/pages/index.vue +++ b/webv2/pages/index.vue @@ -10,7 +10,7 @@ Welkom, {{ user.username }}

- Happy to see you again + Veel plezier met Polarcraft S5

diff --git a/webv2/pages/team.vue b/webv2/pages/team.vue new file mode 100644 index 0000000..209bad2 --- /dev/null +++ b/webv2/pages/team.vue @@ -0,0 +1,15 @@ + + + diff --git a/webv2/server/api/teams/[id]/members/index.post.ts b/webv2/server/api/teams/[id]/members/index.post.ts index a861293..aad0806 100644 --- a/webv2/server/api/teams/[id]/members/index.post.ts +++ b/webv2/server/api/teams/[id]/members/index.post.ts @@ -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 }) diff --git a/webv2/server/api/users/[id]/teamInvites.get.ts b/webv2/server/api/users/[id]/teamInvites.get.ts new file mode 100644 index 0000000..328f416 --- /dev/null +++ b/webv2/server/api/users/[id]/teamInvites.get.ts @@ -0,0 +1,9 @@ +export default defineEventHandler(async (event) => { + const userId: string = event.context.params ? event.context.params.id : '@me' + + const user = await getUser(userId, event) + + const { teamInvites } = await UserModel.findById(user._id).populate('teamInvites') + + return teamInvites +}) diff --git a/webv2/server/api/users/[id]/teamInvites.post.ts b/webv2/server/api/users/[id]/teamInvites.post.ts index 805199f..1de4098 100644 --- a/webv2/server/api/users/[id]/teamInvites.post.ts +++ b/webv2/server/api/users/[id]/teamInvites.post.ts @@ -1,6 +1,8 @@ export default defineEventHandler(async (event) => { const { teamId } = await readBody(event) + console.log(teamId) + const userId: string = event.context.params ? event.context.params.id : '@me' if (userId === '@me') { @@ -9,11 +11,11 @@ export default defineEventHandler(async (event) => { const user = await getUser(userId, event) - const { teamInvites } = await UserModel.findByIdAndUpdate(user._id, { + await UserModel.findByIdAndUpdate(user._id, { $addToSet: { teamInvites: teamId } - }) ?? { teamInvites: [] } + }) - return teamInvites + return user }) diff --git a/webv2/types/global.d.ts b/webv2/types/global.d.ts index 8fae7bb..2dee46d 100644 --- a/webv2/types/global.d.ts +++ b/webv2/types/global.d.ts @@ -36,7 +36,7 @@ declare global { _id: types.ObjectId, name: string, color: string, - members: string[], + members: IUser[], textChannelId: string, voiceChannelId: string }