'use client';

import { useLayoutEffect } from 'react';
import { usePageShellOptionsSetter, type PageShellOptionsConfig } from './PageShellOptionsContext';

export type PageShellOptionsProps = PageShellOptionsConfig;

/**
 * Opt-in de layout do shell (`AntLayout` main).
 * Monta/desmonta opções ao entrar/sair da página — o padrão global mantém o container central.
 *
 * @example
 * ```tsx
 * export function MinhaTelaKanban() {
 *   return (
 *     <>
 *       <PageShellOptions contentBoardBleed />
 *       <ListPageLayout ... />
 *     </>
 *   );
 * }
 * ```
 */
export function PageShellOptions({
    contentBoardBleed = false,
    hideAppFooter = false,
    hideMobileBottomNav = false,
}: PageShellOptionsProps) {
    const setOptions = usePageShellOptionsSetter();

    useLayoutEffect(() => {
        setOptions({ contentBoardBleed, hideAppFooter, hideMobileBottomNav });
        return () => setOptions(null);
    }, [contentBoardBleed, hideAppFooter, hideMobileBottomNav, setOptions]);

    return null;
}
