'use client';

import { Alert, Typography } from 'antd';
import ContentCard from '@/components/layouts/ContentCard';
import { SOFT_BOOK_FATOR_DEFAULT, SOFT_BOOK_UI_READY } from '../softBookContract';

const { Text } = Typography;

export type SoftBookShellCardProps = {
    projetoId: string | number;
    /** Força render mesmo com flag off (só testes). */
    forceShow?: boolean;
};

/**
 * Shell Fase 10 — Soft-book **por projeto**.
 * Mantém-se oculto: a API só publica o agregado CRM
 * (`GET /v1/crm/negocios/soft-book/agregado`), não `/projetos/{id}/soft-book`.
 */
export function SoftBookShellCard({ projetoId, forceShow = false }: SoftBookShellCardProps) {
    if (!SOFT_BOOK_UI_READY && !forceShow) {
        return null;
    }

    const pct = Math.round(SOFT_BOOK_FATOR_DEFAULT * 100);

    return (
        <ContentCard title="Soft-book de capacidade" data-testid="crm-soft-book-shell">
            <Alert
                type="info"
                showIcon
                message="Indisponível neste ambiente"
                description={
                    <Text type="secondary" style={{ fontSize: 13 }}>
                        Soft-book por projeto #{projetoId} ainda não tem rota na API. Use o
                        agregado em CRM (~{pct}% de compromisso). Não confundir com baseline
                        pós-kickoff.
                    </Text>
                }
            />
        </ContentCard>
    );
}
