all repos — caroster @ e9c732f6628feb42d5ba39eabc8c48a4bb716530

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

frontend/pages/index.tsx (view raw)

 1import {useRouter} from 'next/router';
 2import {useTranslation} from 'react-i18next';
 3import useProfile from '../hooks/useProfile';
 4import Layout from '../layouts/Centered';
 5import CreateEvent from '../containers/CreateEvent';
 6import Paper from '../components/Paper';
 7import Logo from '../components/Logo';
 8
 9const Home = () => {
10  const {t} = useTranslation();
11  const router = useRouter();
12  const {isReady, profile} = useProfile();
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 = !!profile ? loggedMenuActions : noUserMenuActions;
41
42  if (!isReady) return null;
43
44  return (
45    <Layout
46      menuTitle={t('event.creation.title')}
47      menuActions={menuActions}
48      displayMenu={!!profile}
49    >
50      <Paper className={null}>
51        <Logo />
52        <CreateEvent />
53      </Paper>
54    </Layout>
55  );
56};
57
58export default Home;