import React, { useEffect } from "react";
import {AuthComponent} from "@components";

type MetadataProps = {
    children: JSX.Element | JSX.Element[],
    title: string,
    bodyClass: string,
    needsAuth? : boolean
}

export default function MetadataSetter({children, title, bodyClass, needsAuth = false}: MetadataProps){
    useEffect(() => {
        document.title= title;
        document.body.classList.add(bodyClass);
    }, [title])

    return needsAuth ? <AuthComponent>{children}</AuthComponent> : <>{children}</>;
}