import { useEffect, useState } from 'react';

export const useSidebarCollapse = () => {
    const [collapsed, setCollapsed] = useState(
        () => localStorage.getItem('sidebar:collapsed') === '1',
    );

    useEffect(() => {
        localStorage.setItem('sidebar:collapsed', collapsed ? '1' : '0');
    }, [collapsed]);

    return { collapsed, setCollapsed };
};
