From 9c30619d9ef54e9cdd4048869320dfd549b94eed Mon Sep 17 00:00:00 2001 From: samankittani Date: Thu, 29 Jan 2026 00:04:43 -0600 Subject: [PATCH] feat(client): add routes for joining and leaving groups --- dist/bundle.js | 12 ++++++++++++ dist/client.js | 12 ++++++++++++ src/client.ts | 14 ++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/dist/bundle.js b/dist/bundle.js index 9cba5cc..0cc9153 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -1004,6 +1004,18 @@ const response = await this.fetch(`/groups/id/${encodeURIComponent(group_id)}/assignments/id/${encodeURIComponent(assignment_id)}/submissions/id/${encodeURIComponent(id)}/xml/`); return await response.text(); } + async redeemJoinCode(code) { + const body = { code }; + const response = await this.post(`/users/${this.username}/memberships/`, body); + const user = await response.json(); + this.groupId = user.groupId; + return user; + } + async leaveGroup() { + const response = await this.delete(`/users/${this.username}/memberships/`); + this.groupId = null; + return await response.json(); + } // Cloud: user messages (to be overridden) message(string) { alert(string); diff --git a/dist/client.js b/dist/client.js index e8256b1..e890901 100644 --- a/dist/client.js +++ b/dist/client.js @@ -1004,6 +1004,18 @@ const response = await this.fetch(`/groups/id/${encodeURIComponent(group_id)}/assignments/id/${encodeURIComponent(assignment_id)}/submissions/id/${encodeURIComponent(id)}/xml/`); return await response.text(); } + async redeemJoinCode(code) { + const body = { code }; + const response = await this.post(`/users/${this.username}/memberships/`, body); + const user = await response.json(); + this.groupId = user.groupId; + return user; + } + async leaveGroup() { + const response = await this.delete(`/users/${this.username}/memberships/`); + this.groupId = null; + return await response.json(); + } // Cloud: user messages (to be overridden) message(string) { alert(string); diff --git a/src/client.ts b/src/client.ts index 23fb164..b95a8e1 100644 --- a/src/client.ts +++ b/src/client.ts @@ -702,6 +702,20 @@ export default class Cloud { return await response.text(); } + async redeemJoinCode(code: string) { + const body = { code }; + const response = await this.post(`/users/${this.username}/memberships/`, body); + const user = await response.json(); + this.groupId = user.groupId; + return user; + } + + async leaveGroup() { + const response = await this.delete(`/users/${this.username}/memberships/`); + this.groupId = null; + return await response.json(); + } + // Cloud: user messages (to be overridden) message(string) {