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