import Link from "next/link";
import React, {FC} from "react";
import useRoutes from "@/hooks/useRoutes";
import classNames from "classnames";

interface Props {
    isOpen: boolean;
    setIsOpen: (isOpen: boolean) => void;
    handleLogout: (e: React.MouseEvent) => void;
}

const divStyles = classNames(
    'absolute', 'text-xxl', 'rounded-b', 'top-full mt-1', 'left-0', 'right-0', '', 'py-2',
    'bg-gray-600', 'border-secondary', 'shadow-md', 'flex', 'flex-col', 'space-y-3',
    'md:hidden'
)

const linkStyles = classNames(
    'border-b-2', 'border-secondary', 'uppercase',
    'text-primary', 'hover:bg-secondary', 'pb-2', 'pl-5',
    'space-grotesk', 'text-xl'
)

const MobileDropdownMenu: FC<Props> = ({ isOpen, setIsOpen, handleLogout }) => {
    const routes = useRoutes();

    if (!isOpen) return null;

    return (
        <div className={divStyles}>
            <Link
                href={routes.home()}
                className={linkStyles}
                onClick={() => setIsOpen(false)}
            >
                Home
            </Link>
            <Link
                href={routes.dish.index()}
                className={linkStyles}
                onClick={() => setIsOpen(false)}
            >
                Dishes
            </Link>
            <Link
                href={routes.user.index()}
                className={linkStyles}
                onClick={() => setIsOpen(false)}
            >
                Users
            </Link>
            <Link
                href={routes.schedule.history()}
                className={linkStyles}
                onClick={() => setIsOpen(false)}
            >
                History
            </Link>
            <Link
                href={routes.auth.login()}
                onClick={handleLogout}
                className={linkStyles}>
                Logout
            </Link>
        </div>
    )
}

export default MobileDropdownMenu