11'use client'
22
3+ import { getUser } from '@/api/auth/authService'
34import type { AnchorHTMLAttributes , HTMLAttributes , PropsWithChildren } from 'react'
45import { useEffect , useState } from 'react'
56import 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 */
7677export 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 */
206217export 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 >
0 commit comments