import Link from 'next/link'; import {useEffect, useState} from "react"; import {useRouter} from "next/router"; import {signOut, useSession} from 'next-auth/client'; import {MenuIcon, XIcon} from '@heroicons/react/outline'; import {collectPageParameters, telemetryEventTypes, useTelemetry} from "../lib/telemetry"; export default function Shell(props) { const router = useRouter(); const [ session, loading ] = useSession(); const [ profileDropdownExpanded, setProfileDropdownExpanded ] = useState(false); const [ mobileMenuExpanded, setMobileMenuExpanded ] = useState(false); let telemetry = useTelemetry(); useEffect(() => { telemetry.withJitsu((jitsu) => { return jitsu.track(telemetryEventTypes.pageView, collectPageParameters(router.pathname)) }); }, [telemetry]) const toggleProfileDropdown = () => { setProfileDropdownExpanded(!profileDropdownExpanded); } const toggleMobileMenu = () => { setMobileMenuExpanded(!mobileMenuExpanded); } const logoutHandler = () => { signOut({ redirect: false }).then( () => router.push('/auth/logout') ); } if ( ! loading && ! session ) { router.replace('/auth/login'); } return session && (

{props.heading}

{props.children}
); }