diff --git a/frontend/src/lib/components/Sidebar.svelte b/frontend/src/lib/components/Sidebar.svelte index a4eabb2..b2fe99a 100644 --- a/frontend/src/lib/components/Sidebar.svelte +++ b/frontend/src/lib/components/Sidebar.svelte @@ -3,7 +3,8 @@ import { onMount } from 'svelte'; import { Popover } from 'bits-ui'; import { auth } from '$lib/auth.svelte'; - import { listTeams, createTeam, switchTeam, type TeamWithRole } from '$lib/api/team'; + import { teams as teamsStore } from '$lib/teams.svelte'; + import { createTeam, switchTeam } from '$lib/api/team'; import { IconMonitor, IconBox, @@ -25,9 +26,7 @@ let teamPopoverOpen = $state(false); - // Real teams from API - let teams = $state([]); - let currentTeamName = $derived(teams.find((t) => t.id === auth.teamId)?.name ?? ''); + let currentTeamName = $derived(teamsStore.list.find((t) => t.id === auth.teamId)?.name ?? ''); let userName = $derived(auth.email ?? ''); // Create team dialog @@ -69,10 +68,7 @@ } async function fetchTeams() { - const result = await listTeams(); - if (result.ok) { - teams = result.data; - } + await teamsStore.fetch(); } async function handleSwitchTeam(teamId: string) { @@ -180,7 +176,7 @@ > Teams - {#each teams as team (team.id)} + {#each teamsStore.list as team (team.id)}