Replace session with user in team accounts

This commit replaces the session object with the user object in the team accounts feature. This change is reflected in the team-account-danger-zone, layout, team-account-workspace, and billing components. The usage of the user object provides more specificity and accuracy in handling user information compared to the more generic session object.
This commit is contained in:
giancarlo
2024-04-16 22:41:06 +08:00
parent d7cf271e8a
commit c238e08fa7
4 changed files with 8 additions and 7 deletions

View File

@@ -30,12 +30,12 @@ export const loadTeamWorkspace = cache(async (accountSlug: string) => {
accountResult,
accountsResult,
{
data: { session },
data: { user },
},
] = await Promise.all([
accountPromise,
accountsPromise,
client.auth.getSession(),
client.auth.getUser(),
]);
if (accountResult.error) {
@@ -63,6 +63,6 @@ export const loadTeamWorkspace = cache(async (accountSlug: string) => {
return {
account: accountData,
accounts: accountsResult.data,
session,
user,
};
});

View File

@@ -37,6 +37,7 @@ export const generateMetadata = async () => {
async function TeamAccountBillingPage({ params }: Params) {
const workspace = await loadTeamWorkspace(params.account);
const accountId = workspace.account.id;
const [subscription, customerId] =
await loadTeamAccountBillingPage(accountId);

View File

@@ -32,7 +32,7 @@ function TeamWorkspaceLayout({
collapsed={false}
account={params.account}
accounts={accounts}
user={data.session?.user ?? null}
user={data?.user ?? null}
/>
}
>