import styles from '/styles/ReadyOrNot.module.css' import Link from 'next/link' import { useRouter } from 'next/router' import useSWR from 'swr'; import ReadyOrNotMap from '../interfaces/ReadyOrNot'; import React, { useState } from 'react'; import Image from 'next/image'; import useWindowSize from '../components/windowsize'; const fetcher = (url: string) => fetch(url).then((res) => res.json()) function stopPropagation(e: any) { e.stopPropagation(); } const Sidebar = () => { const isMobile = useWindowSize(); const router = useRouter(); const [active, setActive] = useState(isMobile); const { maps, isLoading, isError }: { maps: ReadyOrNotMap[], isLoading: boolean, isError: boolean } = useNavbar(); if (typeof (isMobile) === "boolean" && typeof (active) === "undefined") { setActive(!isMobile); } if (isError) { return ( <>
) } else if (isLoading) { return ( <>
) } else { return ( <>
setActive(!active)}>
{active" : "<"} />
); } } function useNavbar() { const { data, error } = useSWR(`/api/navbar`, fetcher) return { maps: data, isLoading: !error && !data, isError: error } } export default Sidebar;