Skip to content

Commit

Permalink
feat: add Dashboard button from showcase page
Browse files Browse the repository at this point in the history
  • Loading branch information
aldbr committed Sep 26, 2023
1 parent 3cadce3 commit 7a4969f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
22 changes: 22 additions & 0 deletions src/app/components/DashboardButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { useOidcAccessToken } from "@axa-fr/react-oidc";
import { Button } from "@mui/material";
import { deepOrange, lightGreen } from "@mui/material/colors";
import Link from "next/link";

/**
* Dashboard button, should only appear if user is connected
* @returns a Button
*/
export function DashboardButton() {
const { accessToken, accessTokenPayload } = useOidcAccessToken();

if (!accessToken) {
return null;
}

return (
<Button variant="outlined" component={Link} href="/dashboard">
Dashboard
</Button>
);
}
12 changes: 10 additions & 2 deletions src/app/components/LoginButton.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useOidcAccessToken } from "@axa-fr/react-oidc";
import { Avatar, Button } from "@mui/material";
import { deepOrange } from "@mui/material/colors";
import { deepOrange, lightGreen } from "@mui/material/colors";
import NextLink from "next/link";

/**
Expand All @@ -12,7 +12,15 @@ export function LoginButton() {

if (!accessToken) {
return (
<Button component={NextLink} href="/dashboard">
<Button
sx={{
bgcolor: lightGreen[700],
"&:hover": { bgcolor: deepOrange[500] },
}}
variant="contained"
component={NextLink}
href="/dashboard"
>
Login
</Button>
);
Expand Down
6 changes: 5 additions & 1 deletion src/app/components/ShowcaseAppBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { styled } from "@mui/material/styles";
import { DiracLogo } from "./DiracLogo";
import { LoginButton } from "./LoginButton";
import { Stack } from "@mui/material";
import { DashboardButton } from "./DashboardButton";

/**
* Controls the response due to a scrolling
Expand Down Expand Up @@ -58,7 +59,10 @@ export default function ShowcaseAppBar(props: Props) {
}}
>
<div />
<LoginButton />
<Stack direction="row">
<DashboardButton />
<LoginButton />
</Stack>
</Toolbar>
</Stack>
</AppBar>
Expand Down

0 comments on commit 7a4969f

Please sign in to comment.