feat(web): wire workspaces settings page to real API (MS21-UI-003) (#574)
All checks were successful
ci/woodpecker/push/web Pipeline was successful

Co-authored-by: Jason Woltje <jason@diversecanvas.com>
Co-committed-by: Jason Woltje <jason@diversecanvas.com>
This commit was merged in pull request #574.
This commit is contained in:
2026-02-28 20:48:24 +00:00
committed by jason.woltje
parent 127bf61fe2
commit 20c9e68e1b
4 changed files with 207 additions and 117 deletions

View File

@@ -3,7 +3,8 @@
* User-scoped workspace discovery — does NOT require X-Workspace-Id header.
*/
import { apiGet } from "./client";
import type { WorkspaceMemberRole } from "@mosaic/shared";
import { apiGet, apiPost } from "./client";
/**
* A workspace entry from the user's membership list.
@@ -13,10 +14,24 @@ export interface UserWorkspace {
id: string;
name: string;
ownerId: string;
role: string;
role: WorkspaceMemberRole;
createdAt: string;
}
export interface CreateWorkspaceDto {
name: string;
}
export interface CreatedWorkspace {
id: string;
name: string;
ownerId: string;
settings: Record<string, unknown>;
createdAt: string;
updatedAt: string;
memberCount: number;
}
/**
* Fetch all workspaces the authenticated user is a member of.
* The API auto-provisions a default workspace if the user has none.
@@ -24,3 +39,10 @@ export interface UserWorkspace {
export async function fetchUserWorkspaces(): Promise<UserWorkspace[]> {
return apiGet<UserWorkspace[]>("/api/workspaces");
}
/**
* Create a workspace through the admin endpoint.
*/
export async function createWorkspace(dto: CreateWorkspaceDto): Promise<CreatedWorkspace> {
return apiPost<CreatedWorkspace>("/api/admin/workspaces", dto);
}