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