Skip to content

Commit aa365c4

Browse files
committed
update username display
1 parent 673edd3 commit aa365c4

File tree

3 files changed

+27
-17
lines changed

3 files changed

+27
-17
lines changed

web/components/layout/Page.tsx

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use client'
22

3+
import { getUser } from '@/api/auth/authService'
34
import type { AnchorHTMLAttributes, HTMLAttributes, PropsWithChildren } from 'react'
45
import { useEffect, useState } from 'react'
56
import Head from 'next/head'
@@ -46,7 +47,7 @@ export const StagingDisclaimerDialog = () => {
4647
isModal={false}
4748
isOpen={isStagingDisclaimerOpen}
4849
titleElement={translation('developmentAndPreviewInstance')}
49-
description={(<MarkdownInterpreter text={translation('stagingModalDisclaimerMarkdown')}/>)}
50+
description={(<MarkdownInterpreter text={translation('stagingModalDisclaimerMarkdown')} />)}
5051
className={clsx('z-20 w-200')}
5152
backgroundClassName="z-10"
5253
>
@@ -75,6 +76,16 @@ type HeaderProps = HTMLAttributes<HTMLHeadElement>
7576
*/
7677
export const Header = ({ ...props }: HeaderProps) => {
7778
const translation = useTasksTranslation()
79+
const [username, setUsername] = useState<string | undefined>();
80+
81+
useEffect(() => {
82+
const fetchUser = async () => {
83+
const user = await getUser();
84+
setUsername(user?.profile.name);
85+
}
86+
87+
fetchUser();
88+
}, []);
7889

7990
return (
8091
<header
@@ -85,7 +96,7 @@ export const Header = ({ ...props }: HeaderProps) => {
8596
)}
8697
>
8798
<div className="flex-col-0">
88-
<Input placeholder={translation('search')}/>
99+
<Input placeholder={translation('search')} />
89100
</div>
90101
<div className="flex-row-4 justify-end">
91102
<IconButton color="neutral">
@@ -95,8 +106,8 @@ export const Header = ({ ...props }: HeaderProps) => {
95106
<SettingsIcon />
96107
</IconButton>
97108
<SolidButton color="neutral">
98-
{'User Name'}
99-
<ExpansionIcon isExpanded={false}/>
109+
{username}
110+
<ExpansionIcon isExpanded={false} />
100111
</SolidButton>
101112
</div>
102113
</header>
@@ -169,21 +180,21 @@ export const Sidebar = ({ ...props }: SidebarProps) => {
169180
>
170181
<nav className="flex-col-2 overflow-auto">
171182
<Link href="/" className="flex-row-2 text-primary items-center rounded-lg p-2 mb-8">
172-
<HelpwaveLogo className="min-h-7 min-w-7 p-0.5 bg-header-background rounded-md"/>
183+
<HelpwaveLogo className="min-h-7 min-w-7 p-0.5 bg-header-background rounded-md" />
173184
<span className="typography-title-md whitespace-nowrap">{'helpwave tasks'}</span>
174185
</Link>
175186
{/* TODO add station swticher here */}
176187
<SidebarLink href="/" route={route}>
177-
<Grid2X2PlusIcon className="-rotate-90"/>
188+
<Grid2X2PlusIcon className="-rotate-90" />
178189
<span className="flex grow">{translation('dashboard')}</span>
179190
</SidebarLink>
180191
<SidebarLink href="/tasks" route={route}>
181-
<CircleCheck/>
192+
<CircleCheck />
182193
<span className="flex grow">{translation('myTasks')}</span>
183194
{data?.myTasksCount !== undefined && (<span className="text-description">{data.myTasksCount}</span>)}
184195
</SidebarLink>
185196
<SidebarLink href="/patients" route={route}>
186-
<User/>
197+
<User />
187198
<span className="flex grow">{translation('patients')}</span>
188199
{data?.patientsCount !== undefined && (<span className="text-description">{data.patientsCount}</span>)}
189200
</SidebarLink>
@@ -204,21 +215,21 @@ type PageWithHeaderProps = PropsWithChildren<{
204215
* The page content will be passed as the children
205216
*/
206217
export const Page = ({
207-
children,
208-
pageTitle,
209-
}: PageWithHeaderProps) => {
218+
children,
219+
pageTitle,
220+
}: PageWithHeaderProps) => {
210221
return (
211222
<div className="flex-row-8 h-screen w-screen overflow-hidden">
212223
<Head>
213224
<title>{titleWrapper(pageTitle)}</title>
214225
</Head>
215-
<StagingDisclaimerDialog/>
216-
<Sidebar className="my-4 ml-4"/>
226+
<StagingDisclaimerDialog />
227+
<Sidebar className="my-4 ml-4" />
217228
<div className="flex-col-4 grow overflow-hidden">
218-
<Header className="mr-4 mt-4 bg-background text-on-background"/>
229+
<Header className="mr-4 mt-4 bg-background text-on-background" />
219230
<main className="flex-col-2 grow overflow-auto">
220231
{children}
221-
<div className="min-h-16"/>
232+
<div className="min-h-16" />
222233
</main>
223234
</div>
224235
</div>

web/next-env.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/// <reference types="next" />
22
/// <reference types="next/image-types/global" />
3-
import "./build/dev/types/routes.d.ts";
43

54
// NOTE: This file should not be edited
65
// see https://nextjs.org/docs/pages/api-reference/config/typescript for more information.

web/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"moduleResolution": "bundler",
1616
"resolveJsonModule": true,
1717
"isolatedModules": true,
18-
"jsx": "react-jsx",
18+
"jsx": "preserve",
1919
"incremental": true,
2020
"forceConsistentCasingInFileNames": true,
2121
"allowSyntheticDefaultImports": true,

0 commit comments

Comments
 (0)