all repos — caroster @ 3179dea72ab9887db77a2d5cbda9051cbc74b0c9

[Octree] Group carpool to your event https://caroster.io

app/src/pages/Home.js (view raw)

 1import React from 'react';
 2import Layout from '../layouts/Centered';
 3import Paper from '../components/Paper';
 4import Logo from '../components/Logo';
 5import CreateEvent from '../containers/CreateEvent';
 6import {useAuth} from 'strapi-react-context';
 7import {useHistory} from 'react-router-dom';
 8import {useTranslation} from 'react-i18next';
 9
10const Home = () => {
11  const history = useHistory();
12  const {t} = useTranslation();
13  const {token, authState} = useAuth();
14
15  const noUserMenuActions = [
16    {
17      label: t('menu.login'),
18      onClick: () => history.push('/login'),
19      id: 'LoginTabs',
20    },
21    {
22      label: t('menu.register'),
23      onClick: () => history.push('/register'),
24      id: 'RegisterTabs',
25    },
26  ];
27
28  const loggedMenuActions = [
29    {
30      label: t('menu.dashboard'),
31      onClick: () => history.push('/dashboard'),
32      id: 'SeeDashboardTabs',
33    },
34    {
35      label: t('menu.profile'),
36      onClick: () => history.push('/profile'),
37      id: 'ProfileTabs',
38    },
39  ];
40
41  const menuActions = token ? loggedMenuActions : noUserMenuActions;
42
43  return (
44    <Layout
45      menuTitle={t('event.creation.title')}
46      menuActions={menuActions}
47      displayMenu={!!authState && !!authState.user}
48    >
49      <Paper>
50        <Logo />
51        <CreateEvent />
52      </Paper>
53    </Layout>
54  );
55};
56
57export default Home;