all repos — caroster @ v8.2

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

frontend/layouts/EventCreation.tsx (view raw)

 1import Layout from './Centered';
 2import LanguagesIcon from '../containers/Languages/Icon';
 3import {useTranslation} from 'next-i18next';
 4import {useSession} from 'next-auth/react';
 5import {useRouter} from 'next/router';
 6import {ReactNode} from 'react';
 7import {Breakpoint} from '@mui/material';
 8
 9interface Props {
10  announcement?: string;
11  children: ReactNode;
12  maxWidth?: Breakpoint;
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          icon: 'account_circle',
28        },
29        {divider: true},
30        {
31          label: t('menu.dashboard'),
32          onClick: () => router.push('/dashboard'),
33          id: 'SeeDashboardTabs',
34          icon: 'dashboard',
35        },
36      ]
37    : [
38        {
39          label: t('menu.login'),
40          onClick: () => router.push('/auth/login'),
41          id: 'LoginTabs',
42          icon: 'login',
43        },
44      ];
45
46  return (
47    <Layout
48      menuTitle={t('event.creation.title')}
49      displayMenu={isAuthenticated}
50      menuActions={menuActions}
51      {...props}
52    >
53      {props.children}
54      {!isAuthenticated && <LanguagesIcon displayMenu={false} />}
55    </Layout>
56  );
57};
58
59export default EventCreationLayout;