Skip to content

Commit

Permalink
feat: add logged in user to header (#220)
Browse files Browse the repository at this point in the history
## This PR

- adds the logged-in user to the header

### Related Issues

Fixes #219

### Notes


![image](https://github.com/open-feature/playground/assets/682996/4caa0878-f6fd-46b0-9100-2789321925b3)

---------

Signed-off-by: Michael Beemer <beeme1mr@users.noreply.github.com>
  • Loading branch information
beeme1mr authored Jun 16, 2023
1 parent 690cf0f commit 1fbffcf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/ui/src/app/demos/fib3r/fib3r-demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class Fib3rDemo extends Component<
: 'Welcome to FaaS: Fibonacci as a Service!'
}
hexColor={this.state.hexColor}
loggedIn={!!this.state.email}
loggedInUser={this.state.email}
onLogoutClick={this.onLogoutClick.bind(this)}
onLoginClick={this.onLoginClick.bind(this)}
></Header>
Expand Down
10 changes: 7 additions & 3 deletions packages/ui/src/app/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React from 'react';
export class Header extends React.Component<{
title: string;
hexColor: string;
loggedIn: boolean;
loggedInUser?: string | null;
titleClassName: string;
loginClassName: string;
onLoginClick: () => void;
Expand All @@ -19,8 +19,12 @@ export class Header extends React.Component<{
<Typography className={this.props.titleClassName} variant="h6" component="div" style={{ flexGrow: 1 }}>
{this.props.title}
</Typography>
<Button className='step-click-login' onClick={this.props.loggedIn ? this.props.onLogoutClick : this.props.onLoginClick} color="inherit">
{this.props.loggedIn ? 'Logout' : 'Login'}
<Button
className="step-click-login"
onClick={this.props.loggedInUser ? this.props.onLogoutClick : this.props.onLoginClick}
color="inherit"
>
{this.props.loggedInUser ? this.props.loggedInUser : 'Login'}
</Button>
</Toolbar>
</AppBar>
Expand Down

0 comments on commit 1fbffcf

Please sign in to comment.