'use client';

import { FileText } from 'lucide-react';
import { ICON_SIZE_MD } from '@/components/icons';
import React from 'react';
import {
    Card,
    Tag,
} from 'antd';
import { formatDate } from '@/lib/utils/export';
import type { AtaType } from './ModalOpcoesAta';

export interface CardAtaProps {
    item: AtaType;
    onOpenOpcoes?: (item: AtaType) => void;
    onView?: (item: AtaType) => void;
}

export function CardAta({ item, onOpenOpcoes, onView }: CardAtaProps) {
    const handleClick = () => (onOpenOpcoes ? onOpenOpcoes(item) : onView?.(item));
    return (
        <Card
            hoverable
            className="module-card bordered-left"
            style={{ borderLeft: '6px solid #fa8c16', marginBottom: 16, cursor: 'pointer' }}
            styles={{ body: { padding: '16px 20px' } }}
            onClick={handleClick}
        >
            <div style={{ display: 'flex', flexDirection: 'column', gap: 10 }}>
                <div style={{ fontWeight: 700, color: '#2c3e50' }}>
                    <FileText size={ICON_SIZE_MD} style={{ marginRight: 8, color: '#fa8c16' }} aria-hidden />
                    {item.titulo}
                </div>
                <Tag color={item.aprovada ? 'success' : 'default'}>{item.aprovada ? 'Aprovada' : 'Pendente'}</Tag>
                {item.projeto?.nome && <div style={{ fontSize: 12, color: '#7f8c8d' }}>{item.projeto.nome}</div>}
                {item.data && <div style={{ fontSize: 12, color: '#95a5a6' }}>{formatDate(item.data)}</div>}
            </div>
        </Card>
    );
}
