all repos — caroster @ 2a6cef8fdcb99be287c564a17ba00403a151d327

[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 LanguagesIcon from '../containers/Languages/Icon';
 7import Paper from '../components/Paper';
 8import Logo from '../components/Logo';
 9
10const Home = () => {
11  const {t} = useTranslation();
12  const router = useRouter();
13  const {isReady, profile} = useProfile();
14
15  const noUserMenuActions = [
16    {
17      label: t('menu.login'),
18      onClick: () => router.push('/auth/login'),
19      id: 'LoginTabs',
20    },
21    {
22      label: t('menu.register'),
23      onClick: () => router.push('/auth/register'),
24      id: 'RegisterTabs',
25    },
26  ];
27
28  const loggedMenuActions = [
29    {
30      label: t('menu.dashboard'),
31      onClick: () => router.push('/dashboard'),
32      id: 'SeeDashboardTabs',
33    },
34    {
35      label: t('menu.profile'),
36      onClick: () => router.push('/profile'),
37      id: 'ProfileTabs',
38    },
39  ];
40
41  const menuActions = !!profile ? loggedMenuActions : noUserMenuActions;
42
43  if (!isReady) return null;
44
45  return (
46    <Layout
47      menuTitle={t('event.creation.title')}
48      menuActions={menuActions}
49      displayMenu={!!profile}
50    >
51      <Paper className={null}>
52        <Logo />
53        <CreateEvent />
54      </Paper>
55      <LanguagesIcon displayMenu={!!profile}/>
56    </Layout>
57  );
58};
59
60export default Home;