import React from 'react';
import { getTier, getNextTier } from './CpasBadge';

/**
 * Shows a warning banner if adding `addingPoints` to `currentPoints`
 * would cross into a new CPAS tier.
 */
export default function TierWarning({ currentPoints, addingPoints }) {
    if (!currentPoints && currentPoints !== 0) return null;

    const current   = getTier(currentPoints);
    const projected = getTier(currentPoints + addingPoints);

    if (current.label === projected.label) return null;

    const tierUp = getNextTier(currentPoints);

    return (
        <div style={{
            background: '#fff3cd',
            border: '2px solid #ffc107',
            borderRadius: '6px',
            padding: '12px 16px',
            margin: '12px 0',
            fontSize: '13px',
        }}>
            <strong>⚠ Tier Escalation Warning</strong><br />
            Adding <strong>{addingPoints} point{addingPoints !== 1 ? 's' : ''}</strong> will move this employee
            from <strong>{current.label}</strong> to <strong>{projected.label}</strong>.
            {tierUp && (
                <span> Tier threshold crossed at <strong>{tierUp.min} points</strong>.</span>
            )}
        </div>
    );
}
