import React from 'react';
import { __ } from '@wordpress/i18n';
import { Tag } from 'primereact/tag';

/**
 * Badge per lo status AR1. Stati possibili:
 * MISSING, DRAFT, AWAITING_SIGNATURE, SIGNED, VERIFIED, VALID, APPROACHING, EXPIRED, SUPERSEDED
 */
const STATUS_CONFIG = {
    MISSING:            { severity: 'danger',    label: 'Da compilare',     icon: 'pi pi-exclamation-circle' },
    DRAFT:              { severity: 'warning',   label: 'Bozza in corso',   icon: 'pi pi-pencil' },
    AWAITING_SIGNATURE: { severity: 'info',      label: 'Attesa firma',     icon: 'pi pi-hourglass' },
    SIGNED:             { severity: 'info',      label: 'Firmato',          icon: 'pi pi-verified' },
    VERIFIED:           { severity: 'success',   label: 'Verificato',       icon: 'pi pi-check-circle' },
    VALID:              { severity: 'success',   label: 'Valido',           icon: 'pi pi-check-circle' },
    APPROACHING:        { severity: 'warning',   label: 'In scadenza',      icon: 'pi pi-clock' },
    EXPIRED:            { severity: 'danger',    label: 'Scaduto',          icon: 'pi pi-times-circle' },
    SUPERSEDED:         { severity: 'secondary', label: 'Sostituito',       icon: 'pi pi-history' },
};

const Ar1StatusTag = ({ status }) => {
    const cfg = STATUS_CONFIG[status] || { severity: 'secondary', label: status || '—', icon: 'pi pi-circle' };
    return <Tag severity={cfg.severity} icon={cfg.icon} value={__(cfg.label, 'gepafin')} />;
};

export default Ar1StatusTag;
