all repos — caroster @ 7cb2fa527ba3985be0656d729ca079ff779fb3a2

[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} = 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 menuTitle={t('event.creation.title')} menuActions={menuActions}>
45      <Paper>
46        <Logo />
47        <CreateEvent />
48      </Paper>
49    </Layout>
50  );
51};
52
53export default Home;