B2B-31: refactor profile menu, header

This commit is contained in:
devmc-ee
2025-06-29 19:25:50 +03:00
parent a8dbc98b62
commit fbbc2f8760
14 changed files with 132 additions and 69 deletions

View File

@@ -28,12 +28,8 @@ export const loadTeamWorkspace = cache(workspaceLoader);
async function workspaceLoader(accountSlug: string) {
const client = getSupabaseServerClient();
const api = createTeamAccountsApi(client);
const [workspace, user] = await Promise.all([
api.getAccountWorkspace(accountSlug),
requireUserInServerComponent(),
]);
const user = await requireUserInServerComponent();
const workspace = await api.getAccountWorkspace(accountSlug, user.id);
// we cannot find any record for the selected account
// so we redirect the user to the home page
if (!workspace.data?.account) {
@@ -42,6 +38,7 @@ async function workspaceLoader(accountSlug: string) {
return {
...workspace.data,
accounts: workspace.data.accounts.map(({ user_accounts }) => ({...user_accounts})),
user,
};
}