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';
9import GenericMenu from '../containers/GenericMenu';
10const Menu = () => {
11 const history = useHistory();
12 const {t} = useTranslation();
13 const {token} = useAuth();
14 const goProfile = history.push.bind(undefined, '/profile');
15 const goDashboard = history.push.bind(undefined, '/dashboard');
16 const goLogin = history.push.bind(undefined, '/login');
17 const goRegister = history.push.bind(undefined, '/register');
18 const goAbout = () => (window.location.href = t('meta.about_href'));
19
20 return (
21 <GenericMenu
22 title={t('event.creation.title')}
23 actions={[
24 !!token && {
25 label: t('menu.dashboard'),
26 onClick: goDashboard,
27 id: 'SeeDashboardTabs',
28 },
29 !!token && {
30 label: t('menu.profile'),
31 onClick: goProfile,
32 id: 'ProfileTabs',
33 },
34 !token && {
35 label: t('menu.login'),
36 onClick: goLogin,
37 id: 'LoginTabs',
38 },
39 !token && {
40 label: t('menu.register'),
41 onClick: goRegister,
42 id: 'RegisterTabs',
43 },
44 {
45 label: t('menu.about'),
46 onClick: goAbout,
47 id: 'AboutTabs',
48 },
49 ]}
50 />
51 );
52};
53
54const Home = () => {
55 return (
56 <>
57 <Menu />
58 <Layout>
59 <Paper>
60 <Logo />
61 <CreateEvent />
62 </Paper>
63 </Layout>
64 </>
65 );
66};
67
68export default Home;