feat(MED-122): update analysis packages page, pageheader
This commit is contained in:
@@ -1,15 +1,14 @@
|
||||
import { use } from 'react';
|
||||
import { redirect } from 'next/navigation';
|
||||
|
||||
import { PageBody } from '@kit/ui/page';
|
||||
import { Trans } from '@kit/ui/trans';
|
||||
|
||||
import { createI18nServerInstance } from '~/lib/i18n/i18n.server';
|
||||
import { withI18n } from '~/lib/i18n/with-i18n';
|
||||
import { PageBody, PageHeader } from '@kit/ui/page';
|
||||
import { Trans } from '@kit/ui/trans';
|
||||
import { getSupabaseServerClient } from '@/packages/supabase/src/clients/server-client';
|
||||
import { toTitleCase } from '@/lib/utils';
|
||||
|
||||
import Dashboard from '../_components/dashboard';
|
||||
// local imports
|
||||
import { HomeLayoutPageHeader } from '../_components/home-page-header';
|
||||
import { loadUserWorkspace } from '../_lib/server/load-user-workspace';
|
||||
|
||||
export const generateMetadata = async () => {
|
||||
const i18n = await createI18nServerInstance();
|
||||
@@ -20,15 +19,24 @@ export const generateMetadata = async () => {
|
||||
};
|
||||
};
|
||||
|
||||
function UserHomePage() {
|
||||
const { tempVisibleAccounts } = use(loadUserWorkspace());
|
||||
async function UserHomePage() {
|
||||
const account = await getAccount();
|
||||
if (!account) {
|
||||
redirect('/');
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<HomeLayoutPageHeader
|
||||
title={<Trans i18nKey={'common:routes.home'} />}
|
||||
description={<></>}
|
||||
<PageHeader title={
|
||||
<>
|
||||
<Trans i18nKey={'common:welcome'} />
|
||||
{account.name ? `, ${toTitleCase(account.name)}` : ''}
|
||||
</>
|
||||
}
|
||||
description={
|
||||
<Trans i18nKey={'dashboard:recentlyCheckedDescription'} />
|
||||
}
|
||||
/>
|
||||
|
||||
<PageBody>
|
||||
<Dashboard />
|
||||
</PageBody>
|
||||
@@ -36,4 +44,21 @@ function UserHomePage() {
|
||||
);
|
||||
}
|
||||
|
||||
async function getAccount() {
|
||||
const client = getSupabaseServerClient();
|
||||
|
||||
const {
|
||||
data: { user },
|
||||
} = await client.auth.getUser();
|
||||
|
||||
const accountResponse = await client
|
||||
.schema('medreport')
|
||||
.from('accounts')
|
||||
.select('name')
|
||||
.eq('primary_owner_user_id', user!.id)
|
||||
.single();
|
||||
|
||||
return accountResponse.data;
|
||||
}
|
||||
|
||||
export default withI18n(UserHomePage);
|
||||
|
||||
Reference in New Issue
Block a user