all repos — caroster @ 27332dc9778a133a03349f1ebc56af222fff16f0

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

frontend/layouts/EventCreation.tsx (view raw)

 1import {Paper} from '@mui/material';
 2import Layout from './Centered';
 3import Logo from '../components/Logo';
 4import LanguagesIcon from '../containers/Languages/Icon';
 5import {useTranslation} from 'react-i18next';
 6import {useSession} from 'next-auth/react';
 7import {useRouter} from 'next/router';
 8import {ReactNode} from 'react';
 9
10interface Props {
11  announcement?: string;
12  children: ReactNode;
13}
14
15const EventCreationLayout = (props: Props) => {
16  const {t} = useTranslation();
17  const router = useRouter();
18  const session = useSession();
19  const isAuthenticated = session.status === 'authenticated';
20
21  const menuActions = isAuthenticated
22    ? [
23        {
24          label: t('menu.profile'),
25          onClick: () => router.push('/profile'),
26          id: 'ProfileTabs',
27        },
28        {divider: true},
29        {
30          label: t('menu.dashboard'),
31          onClick: () => router.push('/dashboard'),
32          id: 'SeeDashboardTabs',
33        },
34      ]
35    : [
36        {
37          label: t('menu.login'),
38          onClick: () => router.push('/auth/login'),
39          id: 'LoginTabs',
40        },
41      ];
42
43  return (
44    <Layout
45      menuTitle={t('event.creation.title')}
46      displayMenu={isAuthenticated}
47      menuActions={menuActions}
48      {...props}
49    >
50      {props.children}
51      {!isAuthenticated && <LanguagesIcon displayMenu={false} />}
52    </Layout>
53  );
54};
55
56export default EventCreationLayout;