Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/components/flags/FlagsApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,11 +320,11 @@ class FlagsApi extends React.Component {

</Container>
<div style={{'display' : 'flex', 'margin-top' : '25px', 'justify-content' : 'center'}}>
<Button variant="outline-secondary" onClick={() => this.exitGame()}>
QUIT
</Button>&nbsp;
<Button variant="outline-secondary" onClick={() => this.restartGame()}>
RESTART
</Button>&nbsp;
<Button variant="outline-secondary" onClick={() => this.redirectToProfile()}>
PROFILE
</Button>
</div>
</div>
Expand All @@ -333,12 +333,13 @@ class FlagsApi extends React.Component {
redirect = () => {
this.gameOver();
this.props.dispatch({type : 'reset'});
this.props.history.push('/main');
this.props.history.push('/');
}

redirectToProfile = () => {
exitGame = () => {
this.gameOver();
this.props.history.push('/profile');
this.props.dispatch({type : 'reset'});
this.props.history.push('/');
}
}

Expand Down
24 changes: 23 additions & 1 deletion src/components/flags/Profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import ListGroupItem from "react-bootstrap/ListGroupItem";
import Tab from "react-bootstrap/Tab";
import Tabs from "react-bootstrap/Tabs";
import Alert from "react-bootstrap/Alert";
import { useHistory } from 'react-router-dom';

const Profile = () => {
const history = useHistory();
const [key, setKey] = useState('learn');
const [user, setUser] = useState(null);
const [statsData, setStatsData] = useState([]);
Expand Down Expand Up @@ -90,10 +92,30 @@ const Profile = () => {
</Table>
);

const handleClose = () => {
history.push('/');
};

return (
<div style={{ minHeight: '100vh', margin: '0px', padding: '0px' }}>
<Card>
<div style={{ display: 'flex', alignItems: 'center', padding: '1rem' }}>
<div style={{ display: 'flex', alignItems: 'center', padding: '1rem', position: 'relative' }}>
<button
onClick={handleClose}
style={{
position: 'absolute',
top: '10px',
right: '10px',
background: 'none',
border: 'none',
fontSize: '1.5rem',
cursor: 'pointer',
opacity: 0.5
}}
aria-label="Close"
>
&times;
</button>
<Card.Img
variant="left"
src={user.telegramPhotoUrl}
Expand Down
29 changes: 21 additions & 8 deletions src/components/home/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,32 @@ const Home = () => {
<h1><span role="img" aria-label="checkered flag">🏁</span> Flags Quiz</h1>
<p>Test your geography knowledge and compete for the top spot!</p>
{isLoggedIn ? (
<Button
variant="success"
size="lg"
onClick={handlePlay}
>
Play
</Button>
<>
<Button
variant="outline-secondary"
size="lg"
onClick={handlePlay}
style={{ textTransform: 'uppercase' }}
>
Play
</Button>
{' '}
<Button
variant="outline-secondary"
size="lg"
onClick={() => history.push('/profile')}
style={{ textTransform: 'uppercase' }}
>
Profile
</Button>
</>
) : (
<Button
variant="success"
variant="outline-secondary"
size="lg"
onClick={oauthLogin}
disabled={isLoading}
style={{ textTransform: 'uppercase' }}
>
{isLoading ? 'Logging in...' : 'Login to Play'}
</Button>
Expand Down