import {useState} from "react";
import {Grid} from "antd";
import {useLocation, useNavigate} from "react-router-dom";
import useAuthUtils from "../../Hooks/useAuthUtils.js";


const {useBreakpoint} = Grid;


const useMainLayoutUI = () => {
    const screens = useBreakpoint();

    const [collapsed, setCollapsed] = useState(true);
    const navigate = useNavigate();
    const location = useLocation();
    const {logoutAndRedirect} = useAuthUtils();

    const handleMenuClick = ({key}) => {
        if (key === "logout") {
            logoutAndRedirect();
            return;
        }
        navigate(key);
    };
    const getItem = (label, key, icon, children) => ({key, icon, children, label});

    return {screens, collapsed, setCollapsed, location, handleMenuClick, getItem};
};

export default useMainLayoutUI;