-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
38 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
BACKEND_URI="http://127.0.0.1:8080" | ||
BACKEND_URI="http://localhost:8080" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 8 additions & 11 deletions
19
Website/src/app/components/header.tsx → ...src/app/components/layout/currentUser.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,30 @@ | ||
"use client"; | ||
|
||
import Link from "next/link"; | ||
import { useContext } from "react"; | ||
import { UsernameContext } from "@/app/components/username-provider"; | ||
import Link from "next/link"; | ||
|
||
/** | ||
* The header for the web page | ||
* A component showing the name of the currently logged-in user, with a logout link, | ||
* or a login link if the user is not logged-in. | ||
*/ | ||
export default function Header() { | ||
export function CurrentUser({ className }: { className?: string }) { | ||
const username = useContext(UsernameContext); | ||
|
||
return ( | ||
<header className={"flex flex-row w-full flex-initial justify-items-center p-2"}> | ||
<div> | ||
<Link href={"/"}>RailTrail Admin interface</Link> | ||
</div> | ||
<div className={"grow"} /> | ||
<> | ||
{username ? ( | ||
<div> | ||
<div className={className}> | ||
Hello {username} –{" "} | ||
<Link href={"/logout"} prefetch={false}> | ||
Logout | ||
</Link> | ||
</div> | ||
) : ( | ||
<div> | ||
<div className={className}> | ||
<Link href={"/login"}>Login</Link> | ||
</div> | ||
)} | ||
</header> | ||
</> | ||
); | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import Link from "next/link"; | ||
import { CurrentUser } from "@/app/components/layout/currentUser"; | ||
|
||
/** | ||
* The header for the web page | ||
*/ | ||
export default function Header() { | ||
return ( | ||
<header | ||
className={ | ||
"flex flex-row w-full justify-items-center justify-around p-2 flex-wrap bg-white dark:bg-slate-800" | ||
}> | ||
<div className={"mr-auto"}> | ||
<Link href={"/"}>RailTrail Verwaltung</Link> | ||
</div> | ||
<CurrentUser className={"ml-auto sm:order-last"} /> | ||
{/* Force a line break for small devices */} | ||
<div className={"w-full sm:hidden"} /> | ||
|
||
<div>Foo</div> | ||
<div>Bar</div> | ||
<div>Baz</div> | ||
</header> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters