From 2afad11cb621dde43de3270c2b14853ef55c1d2f Mon Sep 17 00:00:00 2001 From: ZhenYi <434836402@qq.com> Date: Wed, 15 Apr 2026 22:55:01 +0800 Subject: [PATCH] fix(frontend): use workspaceInfo API to get full workspace data for sidebar --- src/app/homepage/layout.tsx | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/app/homepage/layout.tsx b/src/app/homepage/layout.tsx index 352199a..f6b1fd8 100644 --- a/src/app/homepage/layout.tsx +++ b/src/app/homepage/layout.tsx @@ -1,7 +1,8 @@ import {Outlet} from 'react-router-dom'; -import {WorkspaceSidebar} from '@/components/layout/workspace-sidebar'; import {useQuery} from '@tanstack/react-query'; -import {workspaceList, type WorkspaceInfoResponse} from '@/client'; +import {workspaceList, workspaceInfo} from '@/client'; +import type {WorkspaceInfoResponse} from '@/client'; +import {WorkspaceSidebar} from '@/components/layout/workspace-sidebar'; import {Spinner} from '@/components/ui/spinner'; export default function HomePageLayout() { @@ -13,7 +14,20 @@ export default function HomePageLayout() { }, }); - if (isLoading) { + const first = data?.workspaces?.[0]; + const slug = first?.slug; + + const {data: workspaceInfoData, isLoading: infoLoading} = useQuery({ + queryKey: ['workspaceInfo', slug], + queryFn: async (): Promise => { + if (!slug) throw new Error('no slug'); + const resp = await workspaceInfo({path: {slug}}); + return resp.data!.data!; + }, + enabled: !!slug, + }); + + if (isLoading || infoLoading) { return (
@@ -21,8 +35,7 @@ export default function HomePageLayout() { ); } - const first = data?.workspaces?.[0]; - if (!first) { + if (!workspaceInfoData) { return (
Loading workspace...
@@ -30,21 +43,9 @@ export default function HomePageLayout() { ); } - const workspace: WorkspaceInfoResponse = { - slug: first.slug, - name: first.name, - description: first.description ?? null, - my_role: first.my_role, - avatar_url: first.avatar_url ?? null, - member_count: data?.member_count ?? 0, - project_count: data?.project_count ?? 0, - created_at: first.created_at, - updated_at: first.updated_at ?? first.created_at, - }; - return (
- +