import React, { useState, useEffect } from 'react' import ReactDOM from 'react-dom' import Link from 'next/link' import dynamic from 'next/dynamic' const Snowfall = dynamic(() => import('react-snowfall'), { ssr: false }) import LogoutIcon from './logoutIcon.js' import Modal from './modal.js' import constants from '../constants.json' import BB from './b.js' import styles from './layout.module.css' import tabs from '../data/tabs.json' import topBarLinks from '../data/topBarLinks.json' const shouldRenderSnow = () => { const date = new Date() // if its december, and date is more than 5 return date.getMonth() === 11 && date.getDate() > 5 } function Snow() { const [windowSize, setWindowSize] = useState([100, 200]) useEffect(() => { setWindowSize([window.innerWidth, window.innerHeight]) window.addEventListener('resize', () => { setWindowSize([window.innerWidth, window.innerHeight]) }) }, []) const snowflakeCount = (windowSize[0] + windowSize[1]) / 26 if (typeof window !== 'object') return null return ReactDOM.createPortal(
, document.body ) } function TopBar({ setSidebarOpen, sidebarOpen, closeSideBar, href, unreads, userId, }) { return ( <> FryLabs
{Object.keys(topBarLinks).map((key) => { const item = topBarLinks[key] return ( {item.text} ) })}
) } function SideBar({ sidebarOpen, closeSideBar, href, setDonateShowing }) { return sidebarOpen ? ( <> ) : null } function Donate() { return (
Donate
Paypalon és Patreonon látszódik a neved, de Patreonon könnyen meg lehet változtatni. Ha név nélkül szeretnél adakozni, akkor írd át egy nickname-re. De akárhova adakozol, a neved sehova se lesz kiadva, és nem látja 3. személy.

A kapott összegekből van fizetve a szerver fenntartása (áram, domain név, ...), ezen túl pedig a sok programozással eltelt idő kipihenése közben használt különböző élvezeti cikkek

) } function UserStatus({ userId, unreads, onClick }) { const unreadCount = unreads ? unreads.length : 0 return (
UID: {userId || '...'}
💬 {unreadCount ?
{unreadCount}
: null}
{ const res = window.confirm('Kijelentkezel?') if (!res) return fetch(constants.apiUrl + 'logout', { method: 'GET', credentials: 'include', headers: { Accept: 'application/json', 'Content-Type': 'application/json', }, }).then(() => { location.reload() }) }} >
) } function MenuIcon({ setSidebarOpen, sidebarOpen }) { return (
{ setSidebarOpen(!sidebarOpen) }} className={styles.menuicon} >
) } export default function Layout({ children, router, globalData }) { const [sidebarOpen, setSidebarOpen] = useState(true) const [donateShowing, setDonateShowing] = useState(false) const userId = globalData.userId const unreads = globalData.unreads useEffect(() => { setDonateShowing(!!router.query.donate) }, [router.query.donate]) let href = router.route if (href === '/' || href === '') { href = 'index' } const closeSideBar = () => { if (typeof window !== 'undefined') { if (window.innerWidth < constants.mobileWindowWidth) { setSidebarOpen(false) } } } useEffect(() => { closeSideBar() window.addEventListener('resize', () => { setSidebarOpen(window.innerWidth >= 700) }) }, []) return ( <>
{donateShowing ? ( { setDonateShowing(false) }} > ) : null}
{children}
{shouldRenderSnow() && } ) }