Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

feat(workspaces): restore Teams service, types, store state, and settings tab

Gabriel Steinf583d573c457
diff --git a/src/components/settings/WorkspaceSection.tsx b/src/components/settings/WorkspaceSection.tsx
index 2bac1f14f..8dd67162c 100644
--- a/src/components/settings/WorkspaceSection.tsx
+++ b/src/components/settings/WorkspaceSection.tsx
@@ -23,11 +23,12 @@ import {
} from "../ui/dropdown-menu";
import { cn } from "../lib/utils";
import WorkspaceMembersTab from "./WorkspaceMembersTab";
+import WorkspaceTeamsTab from "./WorkspaceTeamsTab";
import WorkspaceBillingTab from "./WorkspaceBillingTab";
import WorkspaceDeveloperTab from "./WorkspaceDeveloperTab";
import type { Workspace } from "../../types/electron";
-const SUB_TABS = ["general", "members", "billing", "developer"] as const;
+const SUB_TABS = ["general", "members", "teams", "billing", "developer"] as const;
type WorkspaceTab = (typeof SUB_TABS)[number];
interface Props {
@@ -210,6 +211,7 @@ export default function WorkspaceSection({ initialSubTab }: Props) {
onNavigateToBilling={() => setStoredTab("billing")}
/>
)}
+ {tab === "teams" && <WorkspaceTeamsTab workspace={workspace} />}
{tab === "billing" && <WorkspaceBillingTab workspace={workspace} />}
{tab === "developer" && canManage && <WorkspaceDeveloperTab workspace={workspace} />}
</div>
diff --git a/src/components/settings/WorkspaceTeamsTab.tsx b/src/components/settings/WorkspaceTeamsTab.tsx
new file mode 100644
index 000000000..db867726b
--- /dev/null
+++ b/src/components/settings/WorkspaceTeamsTab.tsx
@@ -0,0 +1,203 @@
+import React, { useEffect, useState } from "react";
+import { useTranslation } from "react-i18next";
+import { Plus, Users, Trash2 } from "lucide-react";
+import { useWorkspaceStore } from "../../stores/workspaceStore";
+import { TeamsService } from "../../services/TeamsService";
+import { Button } from "../ui/button";
+import { Input } from "../ui/input";
+import { Label } from "../ui/label";
+import { useToast } from "../ui/useToast";
+import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from "../ui/dialog";
+import type { Workspace, Team } from "../../types/electron";
+
+interface Props {
+ workspace: Workspace;
+}
+
+export default function WorkspaceTeamsTab({ workspace }: Props) {
+ const { t } = useTranslation();
+ const { toast } = useToast();
+ const teams = useWorkspaceStore((s) => s.teams);
+ const refreshTeams = useWorkspaceStore((s) => s.refreshTeams);
+ const [createOpen, setCreateOpen] = useState(false);
+ const [name, setName] = useState("");
+ const [description, setDescription] = useState("");
+ const [submitting, setSubmitting] = useState(false);
+ const [teamsLoading, setTeamsLoading] = useState(false);
+ const [teamsError, setTeamsError] = useState(false);
+ const canManage = workspace.role === "owner" || workspace.role === "admin";
+
+ async function loadTeams() {
+ setTeamsLoading(true);
+ setTeamsError(false);
+ try {
+ await refreshTeams(workspace.id);
+ } catch {
+ setTeamsError(true);
+ } finally {
+ setTeamsLoading(false);
+ }
+ }
+
+ useEffect(() => {
+ void loadTeams();
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [workspace.id]);
+
+ async function handleCreate(e: React.FormEvent) {
+ e.preventDefault();
+ if (!name.trim()) return;
+ setSubmitting(true);
+ try {
+ await TeamsService.create(workspace.id, {
+ name: name.trim(),
+ description: description.trim() || undefined,
+ });
+ await refreshTeams(workspace.id);
+ setName("");
+ setDescription("");
+ setCreateOpen(false);
+ } catch (error) {
+ toast({
+ title: t("common.error"),
+ description: error instanceof Error ? error.message : t("common.unknownError"),
+ variant: "destructive",
+ });
+ } finally {
+ setSubmitting(false);
+ }
+ }
+
+ async function handleDelete(team: Team) {
+ try {
+ await TeamsService.remove(team.id);
+ await refreshTeams(workspace.id);
+ } catch (error) {
+ toast({
+ title: t("common.error"),
+ description: error instanceof Error ? error.message : t("common.unknownError"),
+ variant: "destructive",
+ });
+ }
+ }
+
+ return (
+ <div className="space-y-4">
+ <div className="flex items-center justify-between">
+ <div>
+ <h3 className="text-xs font-semibold text-foreground">
+ {t("settingsPage.workspace.teams.title")}
+ </h3>
+ <p className="text-xs text-muted-foreground/80 mt-0.5">
+ {t("settingsPage.workspace.teams.description")}
+ </p>
+ </div>
+ {canManage && (
+ <Button size="sm" onClick={() => setCreateOpen(true)}>
+ <Plus className="mr-1.5 h-3.5 w-3.5" />
+ {t("settingsPage.workspace.teams.new")}
+ </Button>
+ )}
+ </div>
+
+ {teamsLoading && teams.length === 0 ? (
+ <div className="h-24 rounded-lg bg-foreground/5 dark:bg-white/5 animate-pulse" />
+ ) : teamsError && teams.length === 0 ? (
+ <div className="rounded-lg border border-border/50 dark:border-border-subtle/70 bg-card/50 dark:bg-surface-2/50 px-4 py-6 flex items-center justify-between gap-2">
+ <p className="text-xs text-muted-foreground">
+ {t("settingsPage.workspace.teams.loadError")}
+ </p>
+ <Button variant="outline" size="sm" onClick={() => void loadTeams()}>
+ {t("settingsPage.workspace.loadError.retry")}
+ </Button>
+ </div>
+ ) : (
+ <div className="rounded-lg border border-border/50 dark:border-border-subtle/70 divide-y divide-border/30 dark:divide-border-subtle/50 bg-card/50 dark:bg-surface-2/50">
+ {teams.length === 0 && (
+ <div className="py-10 text-center">
+ <Users className="w-5 h-5 text-muted-foreground/60 mx-auto mb-2" />
+ <p className="text-xs text-muted-foreground mb-3">
+ {t("settingsPage.workspace.teams.empty")}
+ </p>
+ {canManage && (
+ <Button size="sm" variant="outline" onClick={() => setCreateOpen(true)}>
+ {t("settingsPage.workspace.teams.createFirst")}
+ </Button>
+ )}
+ </div>
+ )}
+ {teams.map((team) => (
+ <div key={team.id} className="flex items-center gap-3 px-4 h-14">
+ <div className="flex-1 min-w-0">
+ <p className="text-xs font-medium text-foreground truncate">{team.name}</p>
+ {team.description && (
+ <p className="text-xs text-muted-foreground truncate">{team.description}</p>
+ )}
+ </div>
+ <span className="text-xs text-muted-foreground">
+ {t("settingsPage.workspace.teams.memberCount", { count: team.member_count ?? 0 })}
+ </span>
+ {canManage && (
+ <button
+ type="button"
+ onClick={() => handleDelete(team)}
+ aria-label={t("common.delete")}
+ className="p-1 rounded-md text-muted-foreground hover:text-destructive hover:bg-destructive/8 transition-colors outline-none focus-visible:ring-1 focus-visible:ring-primary/30"
+ >
+ <Trash2 className="w-3.5 h-3.5" />
+ </button>
+ )}
+ </div>
+ ))}
+ </div>
+ )}
+
+ <Dialog open={createOpen} onOpenChange={setCreateOpen}>
+ <DialogContent className="max-w-md">
+ <DialogHeader>
+ <DialogTitle>{t("settingsPage.workspace.teams.createTitle")}</DialogTitle>
+ </DialogHeader>
+ <form onSubmit={handleCreate} className="space-y-3">
+ <div className="space-y-1.5">
+ <Label htmlFor="team-name" className="text-xs font-medium">
+ {t("settingsPage.workspace.teams.nameLabel")}
+ </Label>
+ <Input
+ id="team-name"
+ value={name}
+ onChange={(e) => setName(e.target.value)}
+ autoFocus
+ maxLength={80}
+ required
+ />
+ </div>
+ <div className="space-y-1.5">
+ <Label htmlFor="team-description" className="text-xs font-medium">
+ {t("settingsPage.workspace.teams.descriptionLabel")}
+ </Label>
+ <Input
+ id="team-description"
+ value={description}
+ onChange={(e) => setDescription(e.target.value)}
+ maxLength={280}
+ />
+ </div>
+ <DialogFooter className="pt-2">
+ <Button
+ type="button"
+ variant="ghost"
+ onClick={() => setCreateOpen(false)}
+ disabled={submitting}
+ >
+ {t("common.cancel")}
+ </Button>
+ <Button type="submit" disabled={!name.trim() || submitting}>
+ {submitting ? t("common.saving") : t("common.create")}
+ </Button>
+ </DialogFooter>
+ </form>
+ </DialogContent>
+ </Dialog>
+ </div>
+ );
+}
diff --git a/src/locales/de/translation.json b/src/locales/de/translation.json
index a831d6ea2..1f16f7ab3 100644
--- a/src/locales/de/translation.json
+++ b/src/locales/de/translation.json
@@ -1197,6 +1197,7 @@
"tab": {
"general": "Allgemein",
"members": "Mitglieder",
+ "teams": "Teams",
"billing": "Abrechnung",
"developer": "Entwickler"
},
@@ -1248,6 +1249,18 @@
"description": "{{name}} wird Inhaber von {{workspace}}. Ihre Rolle ändert sich zu Administrator und nur der neue Inhaber kann das Eigentum zurückübertragen."
}
},
+ "teams": {
+ "title": "Teams",
+ "description": "Mitglieder gruppieren für gezieltes Teilen.",
+ "new": "Neues Team",
+ "empty": "Noch keine Teams.",
+ "createFirst": "Erstellen Sie Ihr erstes Team",
+ "createTitle": "Team erstellen",
+ "nameLabel": "Team-Name",
+ "descriptionLabel": "Beschreibung",
+ "memberCount": "{{count}} Mitglieder",
+ "loadError": "Teams konnten nicht geladen werden."
+ },
"invites": {
"title": "Ausstehende Einladungen",
"expiresIn_one": "Läuft in {{count}} Tag ab",
@@ -2155,10 +2168,6 @@
"liquidai_lfm2_2_6b_q4_k_m": "Ausgewogenes LFM2 für hochwertigere Bereinigung",
"liquidai_lfm2_5_350m_q8_0": "Ultraleichtes Modell für schnelle Diktatbereinigung",
"liquidai_lfm2_5_230m_q8_0": "Winziges Modell, sofortige Bereinigung auf bescheidener Hardware"
- },
- "diarization": {
- "segmentation": "Sprachgrenzerkennung für die Sprecherzuordnung",
- "embedding_en": "Stimmerkennung zur Sprecheridentifikation"
}
}
},
diff --git a/src/locales/en/translation.json b/src/locales/en/translation.json
index 105f09657..49657d022 100644
--- a/src/locales/en/translation.json
+++ b/src/locales/en/translation.json
@@ -1197,6 +1197,7 @@
"tab": {
"general": "General",
"members": "Members",
+ "teams": "Teams",
"billing": "Billing",
"developer": "Developer"
},
@@ -1248,6 +1249,18 @@
"description": "{{name}} becomes the owner of {{workspace}}. Your role changes to admin and only the new owner can transfer it back."
}
},
+ "teams": {
+ "title": "Teams",
+ "description": "Group members for scoped sharing.",
+ "new": "New team",
+ "empty": "No teams yet.",
+ "createFirst": "Create your first team",
+ "createTitle": "Create team",
+ "nameLabel": "Team name",
+ "descriptionLabel": "Description",
+ "memberCount": "{{count}} members",
+ "loadError": "Couldn't load teams."
+ },
"invites": {
"title": "Pending invitations",
"expiresIn_one": "Expires in {{count}} day",
diff --git a/src/locales/es/translation.json b/src/locales/es/translation.json
index 0886e3c55..da24feb19 100644
--- a/src/locales/es/translation.json
+++ b/src/locales/es/translation.json
@@ -1850,6 +1850,7 @@
"tab": {
"general": "General",
"members": "Miembros",
+ "teams": "Equipos",
"billing": "Facturación",
"developer": "Desarrollador"
},
@@ -1901,6 +1902,18 @@
"description": "{{name}} pasa a ser el propietario de {{workspace}}. Tu rol cambia a administrador y solo el nuevo propietario puede transferirla de vuelta."
}
},
+ "teams": {
+ "title": "Equipos",
+ "description": "Agrupa miembros para compartir con alcance limitado.",
+ "new": "Nuevo equipo",
+ "empty": "Aún no hay equipos.",
+ "createFirst": "Crea tu primer equipo",
+ "createTitle": "Crear equipo",
+ "nameLabel": "Nombre del equipo",
+ "descriptionLabel": "Descripción",
+ "memberCount": "{{count}} miembros",
+ "loadError": "No se pudieron cargar los equipos."
+ },
"invites": {
"title": "Invitaciones pendientes",
"expiresIn_one": "Expira en {{count}} día",
diff --git a/src/locales/fr/translation.json b/src/locales/fr/translation.json
index b0445655d..414053a82 100644
--- a/src/locales/fr/translation.json
+++ b/src/locales/fr/translation.json
@@ -1197,6 +1197,7 @@
"tab": {
"general": "Général",
"members": "Membres",
+ "teams": "Équipes",
"billing": "Facturation",
"developer": "Développeur"
},
@@ -1248,6 +1249,18 @@
"description": "{{name}} devient propriétaire de {{workspace}}. Votre rôle passe à administrateur et seul le nouveau propriétaire pourra la retransférer."
}
},
+ "teams": {
+ "title": "Équipes",
+ "description": "Groupez les membres pour un partage ciblé.",
+ "new": "Nouvelle équipe",
+ "empty": "Aucune équipe.",
+ "createFirst": "Créez votre première équipe",
+ "createTitle": "Créer une équipe",
+ "nameLabel": "Nom de l'équipe",
+ "descriptionLabel": "Description",
+ "memberCount": "{{count}} membres",
+ "loadError": "Impossible de charger les équipes."
+ },
"invites": {
"title": "Invitations en attente",
"expiresIn_one": "Expire dans {{count}} jour",
@@ -2155,10 +2168,6 @@
"liquidai_lfm2_2_6b_q4_k_m": "LFM2 équilibré pour un nettoyage de meilleure qualité",
"liquidai_lfm2_5_350m_q8_0": "Modèle ultraléger pour un nettoyage rapide de la dictée",
"liquidai_lfm2_5_230m_q8_0": "Modèle minuscule, nettoyage instantané sur du matériel modeste"
- },
- "diarization": {
- "segmentation": "Détection des limites de parole pour l'identification des intervenants",
- "embedding_en": "Empreinte vocale pour l'identification des intervenants"
}
}
},
diff --git a/src/locales/it/translation.json b/src/locales/it/translation.json
index e68a2d677..b5abea66a 100644
--- a/src/locales/it/translation.json
+++ b/src/locales/it/translation.json
@@ -1802,6 +1802,7 @@
"tab": {
"general": "Generale",
"members": "Membri",
+ "teams": "Team",
"billing": "Fatturazione",
"developer": "Sviluppatore"
},
@@ -1853,6 +1854,18 @@
"description": "{{name}} diventa il proprietario di {{workspace}}. Il tuo ruolo passa ad amministratore e solo il nuovo proprietario potrà ritrasferirla."
}
},
+ "teams": {
+ "title": "Team",
+ "description": "Raggruppa i membri per una condivisione mirata.",
+ "new": "Nuovo team",
+ "empty": "Ancora nessun team.",
+ "createFirst": "Crea il tuo primo team",
+ "createTitle": "Crea team",
+ "nameLabel": "Nome del team",
+ "descriptionLabel": "Descrizione",
+ "memberCount": "{{count}} membri",
+ "loadError": "Impossibile caricare i team."
+ },
"invites": {
"title": "Inviti in sospeso",
"expiresIn_one": "Scade tra {{count}} giorno",
diff --git a/src/locales/ja/translation.json b/src/locales/ja/translation.json
index 585b85224..90dce91a9 100644
--- a/src/locales/ja/translation.json
+++ b/src/locales/ja/translation.json
@@ -1802,6 +1802,7 @@
"tab": {
"general": "一般",
"members": "メンバー",
+ "teams": "チーム",
"billing": "請求",
"developer": "開発者"
},
@@ -1853,6 +1854,18 @@
"description": "{{name}} が {{workspace}} のオーナーになります。あなたの役割は管理者に変わり、元に戻せるのは新しいオーナーのみです。"
}
},
+ "teams": {
+ "title": "チーム",
+ "description": "メンバーをグループ化して共有範囲を絞ります。",
+ "new": "新しいチーム",
+ "empty": "チームはまだありません。",
+ "createFirst": "最初のチームを作成",
+ "createTitle": "チームを作成",
+ "nameLabel": "チーム名",
+ "descriptionLabel": "説明",
+ "memberCount": "{{count}}人のメンバー",
+ "loadError": "チームを読み込めませんでした。"
+ },
"invites": {
"title": "保留中の招待",
"expiresIn_one": "有効期限まであと{{count}}日",
diff --git a/src/locales/pt/translation.json b/src/locales/pt/translation.json
index 52fcf4afa..4c6244f02 100644
--- a/src/locales/pt/translation.json
+++ b/src/locales/pt/translation.json
@@ -1781,6 +1781,7 @@
"tab": {
"general": "Geral",
"members": "Membros",
+ "teams": "Equipes",
"billing": "Cobrança",
"developer": "Desenvolvedor"
},
@@ -1832,6 +1833,18 @@
"description": "{{name}} se torna o proprietário de {{workspace}}. Sua função muda para administrador e apenas o novo proprietário pode transferi-la de volta."
}
},
+ "teams": {
+ "title": "Equipes",
+ "description": "Agrupe membros para compartilhamento direcionado.",
+ "new": "Nova equipe",
+ "empty": "Ainda não há equipes.",
+ "createFirst": "Crie sua primeira equipe",
+ "createTitle": "Criar equipe",
+ "nameLabel": "Nome da equipe",
+ "descriptionLabel": "Descrição",
+ "memberCount": "{{count}} membros",
+ "loadError": "Não foi possível carregar as equipes."
+ },
"invites": {
"title": "Convites pendentes",
"expiresIn_one": "Expira em {{count}} dia",
diff --git a/src/locales/ru/translation.json b/src/locales/ru/translation.json
index 9bddc7b95..6f8c8b737 100644
--- a/src/locales/ru/translation.json
+++ b/src/locales/ru/translation.json
@@ -1802,6 +1802,7 @@
"tab": {
"general": "Общие",
"members": "Участники",
+ "teams": "Команды",
"billing": "Оплата",
"developer": "Разработчик"
},
@@ -1853,6 +1854,18 @@
"description": "{{name}} станет владельцем {{workspace}}. Ваша роль изменится на администратора, и вернуть владение сможет только новый владелец."
}
},
+ "teams": {
+ "title": "Команды",
+ "description": "Группируйте участников для адресного доступа.",
+ "new": "Новая команда",
+ "empty": "Команд пока нет.",
+ "createFirst": "Создайте первую команду",
+ "createTitle": "Создать команду",
+ "nameLabel": "Название команды",
+ "descriptionLabel": "Описание",
+ "memberCount": "{{count}} участников",
+ "loadError": "Не удалось загрузить команды."
+ },
"invites": {
"title": "Ожидающие приглашения",
"expiresIn_one": "Истекает через {{count}} день",
diff --git a/src/locales/zh-CN/translation.json b/src/locales/zh-CN/translation.json
index 5630c4965..549593dad 100644
--- a/src/locales/zh-CN/translation.json
+++ b/src/locales/zh-CN/translation.json
@@ -1209,7 +1209,12 @@
"annualEquivalent": "$16.67",
"includesPrefix": "所有 Pro 功能 +",
"badge": "最受欢迎",
- "features": ["无限会议录制", "代理模式", "与您的数据对话", "优先支持"],
+ "features": [
+ "无限会议录制",
+ "代理模式",
+ "与您的数据对话",
+ "优先支持"
+ ],
"cta": "开始使用",
"switchToAnnual": "切换为年付"
},
@@ -1797,6 +1802,7 @@
"tab": {
"general": "常规",
"members": "成员",
+ "teams": "团队",
"billing": "账单",
"developer": "开发者"
},
@@ -1848,6 +1854,18 @@
"description": "{{name}} 将成为 {{workspace}} 的所有者。你的角色将变为管理员,只有新所有者才能转回所有权。"
}
},
+ "teams": {
+ "title": "团队",
+ "description": "将成员分组以进行有针对性的共享。",
+ "new": "新建团队",
+ "empty": "暂无团队。",
+ "createFirst": "创建您的第一个团队",
+ "createTitle": "创建团队",
+ "nameLabel": "团队名称",
+ "descriptionLabel": "描述",
+ "memberCount": "{{count}} 名成员",
+ "loadError": "无法加载团队。"
+ },
"invites": {
"title": "待处理的邀请",
"expiresIn_one": "{{count}} 天后过期",
diff --git a/src/locales/zh-TW/translation.json b/src/locales/zh-TW/translation.json
index e9787a672..4ce9a3c85 100644
--- a/src/locales/zh-TW/translation.json
+++ b/src/locales/zh-TW/translation.json
@@ -1209,7 +1209,12 @@
"annualEquivalent": "$16.67",
"includesPrefix": "所有 Pro 功能 +",
"badge": "最熱門",
- "features": ["無限會議錄製", "代理模式", "與您的資料對話", "優先支援"],
+ "features": [
+ "無限會議錄製",
+ "代理模式",
+ "與您的資料對話",
+ "優先支援"
+ ],
"cta": "開始使用",
"switchToAnnual": "切換為年付"
},
@@ -1797,6 +1802,7 @@
"tab": {
"general": "一般",
"members": "成員",
+ "teams": "團隊",
"billing": "帳單",
"developer": "開發者"
},
@@ -1848,6 +1854,18 @@
"description": "{{name}} 將成為 {{workspace}} 的擁有者。你的角色會變更為管理員,且只有新擁有者能將擁有權轉回。"
}
},
+ "teams": {
+ "title": "團隊",
+ "description": "將成員分組以進行有針對性的共享。",
+ "new": "新增團隊",
+ "empty": "尚無團隊。",
+ "createFirst": "建立您的第一個團隊",
+ "createTitle": "建立團隊",
+ "nameLabel": "團隊名稱",
+ "descriptionLabel": "描述",
+ "memberCount": "{{count}} 位成員",
+ "loadError": "無法載入團隊。"
+ },
"invites": {
"title": "待處理的邀請",
"expiresIn_one": "{{count}} 天後到期",
diff --git a/src/services/TeamsService.ts b/src/services/TeamsService.ts
new file mode 100644
index 000000000..db0f3ef5f
--- /dev/null
+++ b/src/services/TeamsService.ts
@@ -0,0 +1,58 @@
+import { cloudGet, cloudPost, cloudPatch, cloudDelete } from "./cloudApi.js";
+import type { Team, TeamMember } from "../types/electron";
+
+interface DataWrap<T> {
+ data: T;
+}
+
+async function list(workspaceId: string): Promise<Team[]> {
+ const res = await cloudGet<DataWrap<Team[]>>(`/api/workspaces/${workspaceId}/teams`);
+ return res.data;
+}
+
+async function create(
+ workspaceId: string,
+ input: { name: string; description?: string }
+): Promise<Team> {
+ const res = await cloudPost<DataWrap<Team>>(`/api/workspaces/${workspaceId}/teams`, input);
+ return res.data;
+}
+
+async function update(
+ teamId: string,
+ patch: { name?: string; description?: string }
+): Promise<Team> {
+ const res = await cloudPatch<DataWrap<Team>>(`/api/teams/${teamId}`, patch);
+ return res.data;
+}
+
+async function remove(teamId: string): Promise<void> {
+ await cloudDelete(`/api/teams/${teamId}`);
+}
+
+async function listMembers(teamId: string): Promise<TeamMember[]> {
+ const res = await cloudGet<DataWrap<TeamMember[]>>(`/api/teams/${teamId}/members`);
+ return res.data;
+}
+
+async function addMember(
+ teamId: string,
+ userId: string,
+ role: "admin" | "member" = "member"
+): Promise<void> {
+ await cloudPost(`/api/teams/${teamId}/members`, { user_id: userId, role });
+}
+
+async function removeMember(teamId: string, userId: string): Promise<void> {
+ await cloudDelete(`/api/teams/${teamId}/members/${userId}`);
+}
+
+export const TeamsService = {
+ list,
+ create,
+ update,
+ remove,
+ listMembers,
+ addMember,
+ removeMember,
+};
diff --git a/src/stores/workspaceStore.ts b/src/stores/workspaceStore.ts
index f3390a25b..58b62e846 100644
--- a/src/stores/workspaceStore.ts
+++ b/src/stores/workspaceStore.ts
@@ -1,6 +1,7 @@
import { create } from "zustand";
-import type { Workspace, WorkspaceMember } from "../types/electron";
+import type { Workspace, WorkspaceMember, Team } from "../types/electron";
import { WorkspacesService } from "../services/WorkspacesService";
+import { TeamsService } from "../services/TeamsService";
import logger from "../utils/logger";
interface WorkspaceState {
@@ -10,11 +11,13 @@ interface WorkspaceState {
error: boolean;
activeWorkspaceId: string | null;
members: WorkspaceMember[];
+ teams: Team[];
setActiveWorkspaceId: (id: string | null) => void;
refresh: () => Promise<void>;
createWorkspace: (name: string) => Promise<Workspace>;
refreshMembers: (workspaceId: string) => Promise<void>;
+ refreshTeams: (workspaceId: string) => Promise<void>;
}
const ACTIVE_WORKSPACE_KEY = "activeWorkspaceId";
@@ -32,6 +35,7 @@ function writeActiveWorkspaceId(id: string | null): void {
let refreshPromise: Promise<void> | null = null;
let membersRequestSeq = 0;
+let teamsRequestSeq = 0;
export const useWorkspaceStore = create<WorkspaceState>((set, get) => ({
workspaces: [],
@@ -40,13 +44,15 @@ export const useWorkspaceStore = create<WorkspaceState>((set, get) => ({
error: false,
activeWorkspaceId: readActiveWorkspaceId(),
members: [],
+ teams: [],
setActiveWorkspaceId: (id) => {
writeActiveWorkspaceId(id);
// Invalidate in-flight member fetches so the old workspace's roster can't
// land under the new one.
membersRequestSeq++;
- set({ activeWorkspaceId: id, members: [] });
+ teamsRequestSeq++;
+ set({ activeWorkspaceId: id, members: [], teams: [] });
},
refresh: () => {
@@ -101,4 +107,20 @@ export const useWorkspaceStore = create<WorkspaceState>((set, get) => ({
throw error;
}
},
+
+ refreshTeams: async (workspaceId) => {
+ const seq = ++teamsRequestSeq;
+ try {
+ const teams = await TeamsService.list(workspaceId);
+ if (seq !== teamsRequestSeq) return;
+ set({ teams });
+ } catch (error) {
+ logger.error(
+ "Failed to load workspace teams",
+ { error: (error as Error).message },
+ "workspaces"
+ );
+ throw error;
+ }
+ },
}));
diff --git a/src/types/electron.ts b/src/types/electron.ts
index 571fd6ac9..4b214a3c6 100644
--- a/src/types/electron.ts
+++ b/src/types/electron.ts
@@ -157,6 +157,28 @@ export interface WorkspaceMember {
image: string | null;
}
+export type TeamRole = "admin" | "member";
+
+export interface Team {
+ id: string;
+ workspace_id: string;
+ name: string;
+ slug: string;
+ description: string | null;
+ created_at: string;
+ updated_at: string;
+ member_count?: number;
+}
+
+export interface TeamMember {
+ user_id: string;
+ role: TeamRole;
+ joined_at: string;
+ email: string;
+ name: string | null;
+ image: string | null;
+}
+
export interface WorkspaceInvitation {
id: string;
email: string;