-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!(frontend and backend): User can now view, add, and remove works…
…pace memebers successfully - still a couple of minor bugs to fix - but the functionalisty works. [2024-11-23] BREAKING CHANGE: User can now view, add, and remove workspace memebers successfully - still a couple of minor bugs to fix - but the functionalisty works.
- Loading branch information
1 parent
835a6d5
commit 2322e39
Showing
7 changed files
with
110 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
gridwalk-ui/src/app/workspace/[workspaceId]/actions/workspace/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
export * from "./members"; | ||
export * from "./get_members"; | ||
export * from "./remove_members"; | ||
export * from "./types"; |
43 changes: 43 additions & 0 deletions
43
gridwalk-ui/src/app/workspace/[workspaceId]/actions/workspace/remove_members.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
"use server"; | ||
import { getAuthToken } from "../lib/auth"; | ||
|
||
interface RemoveWorkspaceMemberRequest { | ||
workspace_id: string; | ||
email: string; | ||
} | ||
|
||
export async function removeWorkspaceMember( | ||
data: RemoveWorkspaceMemberRequest, | ||
): Promise<void> { | ||
const token = await getAuthToken(); | ||
|
||
// Validation | ||
if (!data.workspace_id) throw new Error("Workspace ID is required"); | ||
if (!data.email) throw new Error("Email is required"); | ||
|
||
try { | ||
const response = await fetch( | ||
`${process.env.GRIDWALK_API}/workspace/${data.workspace_id}/members/${data.email}`, | ||
{ | ||
method: "DELETE", | ||
headers: { | ||
"Content-Type": "application/json", | ||
Authorization: `Bearer ${token}`, | ||
}, | ||
body: JSON.stringify({ | ||
workspace_id: data.workspace_id, | ||
email: data.email, | ||
}), | ||
}, | ||
); | ||
|
||
if (!response.ok) { | ||
const errorText = await response.text(); | ||
if (response.status === 401) throw new Error("Authentication failed"); | ||
throw new Error(errorText || "Failed to remove workspace member"); | ||
} | ||
} catch (error) { | ||
console.error("Failed to remove workspace member:", error); | ||
throw error; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters