import { usePage } from '@inertiajs/react';
import { useEffect } from 'react';
import type { User } from '@/types/auth';

export function applyJabesWomenTheme(enabled: boolean): void {
    if (typeof document === 'undefined') {
        return;
    }

    document.documentElement.classList.toggle('jabes-women', enabled);
}

export function useJabesWomenTheme(): boolean {
    const user = usePage().props.auth?.user as User | undefined;
    const enabled = user?.jabes_women_enabled === true;

    useEffect(() => {
        applyJabesWomenTheme(enabled);
    }, [enabled]);

    return enabled;
}
