'use client';

import { confirmDialog } from '@/lib/feedback/confirmDialog';

import { message } from '@/lib/feedback/message';

import React, { useState, useMemo, useCallback, useRef } from 'react';
import dynamic from 'next/dynamic';
/**
 * Listagem de entregas (desenvolvimento) — rota aninhada ao projeto.
 * FRONT-S2-02.di — extraído de `app/.../projetos/[id]/desenvolvimento/entregas/page.tsx`.
 */

import { BarChart3, Box, Clock, Filter, Loader2, Menu } from 'lucide-react';
import {
    Alert,
    Badge,
    Button,
    Col,
    Input,
    Modal,
    Row,
    Select,
    Space,
    Tag,
    Tooltip,
} from 'antd';
import { ICON_SIZE_MD } from '@/components/icons';
import { LazyDataTable } from '@/components/lazy';
import { LazyExportButton } from '@/components/lazy';
import type { ColumnsType } from 'antd/es/table';
import { useRouter, useParams } from 'next/navigation';
import { useQueryCache } from '@/hooks/useQueryCache';
import { useMutationCache } from '@/hooks/useMutationCache';
import { useResponsiveModalProps } from '@/hooks/useResponsiveModalProps';
import { useListingMobileChrome } from '@/components/mobile';
import { API_ENDPOINTS } from '@/lib/api/endpoints';
import { createIdempotencyKey, idempotencyKeyHeaders } from '@/lib/api/idempotencyKey';
import { PaginatedResponse } from '@/types';
import { projetosProjetoCanonical } from '@/lib/routes/projetosProjetoCanonical';
import dayjs from 'dayjs';
import ProjetoLayout from '@/components/layouts/ProjetoLayout';
import MetricsGrid from '@/components/layouts/MetricsGrid';
import MetricCard from '@/components/layouts/MetricCard';
import { FormGroup } from '@/components/form';
import { OperativeRouteHint } from '@/components/layouts/OperativeRouteHint/OperativeRouteHint';
import { ButtonHeaderIcon } from '@/components/ui';
import { MobileFiltersDrawer, MobilePageActionBar } from '@/components/filters';
import type { DesenvolvimentoEntregaListItem } from './types';
import {
        getDesenvolvimentoEntregaPrioridadeColor,
        getDesenvolvimentoEntregaStatusColor,
        getDesenvolvimentoEntregaStatusLabel} from './desenvolvimentoEntregasListaDisplay';
import { FiltrosModalFooterPadrao,
    ListPageCreateFloatButton} from '@/components/listings';
import { useProjetoWriteGates } from '@/features/projetos/hooks/useProjetoWriteGates';
import btnHeaderStyles from '@/components/ui/buttons/ButtonHeaderIcon/ButtonHeaderIcon.module.scss';
import { queryKeys } from '@/lib/cache/queryKeys';

const ModalOpcoesEntrega = dynamic(
    () => import('./ModalOpcoesEntrega').then((m) => m.ModalOpcoesEntrega),
    { ssr: false },
);

const STATUS_FILTRO_LABELS: Record<string, string> = {
    planejada: 'Planejada',
    em_preparacao: 'Em Preparação',
    entregue: 'Entregue',
    aceita: 'Aceita',
    rejeitada: 'Rejeitada'};

const TIPO_FILTRO_LABELS: Record<string, string> = {
    feature: 'Feature',
    bugfix: 'Bugfix',
    hotfix: 'Hotfix',
    refactor: 'Refactor'};

export function DesenvolvimentoEntregasListaScreen() {
    const router = useRouter();
    const params = useParams();
    const { isMobile } = useListingMobileChrome();
    const { canEditar, permsLoading } = useProjetoWriteGates();
    const projetoId =
        typeof params?.id === 'string' ? params.id : Array.isArray(params?.id) ? params?.id[0] : '';
    const projetoIdNum = projetoId && !Number.isNaN(Number(projetoId)) ? Number(projetoId) : undefined;
    const [currentPage, setCurrentPage] = useState(1);
    const [pageSize, setPageSize] = useState(10);
    const [searchValue, setSearchValue] = useState('');
    const [searchInput, setSearchInput] = useState('');
    const [statusFilter, setStatusFilter] = useState<string>('');
    const [tipoFilter, setTipoFilter] = useState<string>('');
    const [filtrosModalOpen, setFiltrosModalOpen] = useState(false);
    const [draftStatusFilter, setDraftStatusFilter] = useState('');
    const [draftTipoFilter, setDraftTipoFilter] = useState('');
    const [draftSearchInput, setDraftSearchInput] = useState('');
    const [opcoesItem, setOpcoesItem] = useState<DesenvolvimentoEntregaListItem | null>(null);
    const filtrosModalLayout = useResponsiveModalProps();

    const {
        data: entregas,
        isLoading,
        refetch} = useQueryCache<PaginatedResponse<DesenvolvimentoEntregaListItem>>({
        queryKey: queryKeys.entregas.listaPosicional(projetoIdNum ?? 0, currentPage, pageSize, searchValue, statusFilter, tipoFilter),
        endpoint: API_ENDPOINTS.entregas.index,
        params: {
            page: currentPage,
            per_page: pageSize,
            ...(projetoIdNum && { projeto_id: projetoIdNum }),
            ...(searchValue && { search: searchValue }),
            ...(statusFilter && { status: statusFilter }),
            ...(tipoFilter && { tipo: tipoFilter })},
        enabled: projetoIdNum != null,
        staleTime: 1 * 60 * 1000,
        gcTime: 5 * 60 * 1000});

    const entregarMutation = useMutationCache<unknown, number>({
        endpoint: (id) => API_ENDPOINTS.entregas.entregar(id),
        method: 'POST',
        invalidateQueries: [['entregas']],
        onSuccess: () => {
            message.success('Entrega marcada como entregue!');
            refetch();
        },
        onError: (err: unknown) => {
            const error = err as { response?: { data?: { message?: string } } };
            message.error(error?.response?.data?.message || 'Erro ao marcar entrega');
        }});

    const aceitarIdempotencyKeyRef = useRef(createIdempotencyKey());

    const aceitarMutation = useMutationCache<unknown, number>({
        endpoint: (id) => API_ENDPOINTS.entregas.aceitar(id),
        method: 'POST',
        config: () => ({ headers: idempotencyKeyHeaders(aceitarIdempotencyKeyRef.current) }),
        invalidateQueries: [['entregas']],
        onSuccess: () => {
            message.success('Entrega aceita com sucesso!');
            aceitarIdempotencyKeyRef.current = createIdempotencyKey();
            refetch();
        },
        onError: (err: unknown) => {
            const error = err as { response?: { data?: { message?: string } } };
            message.error(error?.response?.data?.message || 'Erro ao aceitar entrega');
        }});

    const rejeitarMutation = useMutationCache<unknown, number>({
        endpoint: (id) => API_ENDPOINTS.entregas.rejeitar(id),
        method: 'POST',
        invalidateQueries: [['entregas']],
        onSuccess: () => {
            message.success('Entrega rejeitada');
            refetch();
        },
        onError: (err: unknown) => {
            const error = err as { response?: { data?: { message?: string } } };
            message.error(error?.response?.data?.message || 'Erro ao rejeitar entrega');
        }});

    const limparTodosFiltros = useCallback(() => {
        setStatusFilter('');
        setTipoFilter('');
        setSearchValue('');
        setSearchInput('');
        setDraftStatusFilter('');
        setDraftTipoFilter('');
        setDraftSearchInput('');
        setCurrentPage(1);
    }, []);

    const handlePageChange = (page: number, size?: number) => {
        setCurrentPage(page);
        if (size) setPageSize(size);
    };

    const handleEntregar = async (id: number) => {
        confirmDialog({
            title: 'Marcar como Entregue',
            content: 'Deseja marcar esta entrega como entregue?',
            okText: 'Entregar',
            okType: 'primary',
            cancelText: 'Cancelar',
            onOk: () => entregarMutation.mutate(id)});
    };

    const handleAceitar = async (id: number) => {
        confirmDialog({
            title: 'Aceitar Entrega',
            content: 'Deseja aceitar esta entrega?',
            okText: 'Aceitar',
            okType: 'primary',
            cancelText: 'Cancelar',
            onOk: () => aceitarMutation.mutate(id)});
    };

    const handleRejeitar = async (id: number) => {
        confirmDialog({
            title: 'Rejeitar Entrega',
            content: 'Deseja rejeitar esta entrega?',
            okText: 'Rejeitar',
            okType: 'danger',
            cancelText: 'Cancelar',
            onOk: () => rejeitarMutation.mutate(id)});
    };

    const columns: ColumnsType<DesenvolvimentoEntregaListItem> = useMemo(
        () => [
            {
                title: 'Código',
                dataIndex: 'codigo',
                key: 'codigo',
                width: 120,
                sorter: (a, b) =>
                    String(a.codigo ?? '').localeCompare(String(b.codigo ?? ''), 'pt'),
                render: (codigo: string) => (codigo ? <Tag>{codigo}</Tag> : '-')},
            {
                title: 'Título',
                dataIndex: 'titulo',
                key: 'titulo',
                sorter: (a, b) =>
                    String(a.titulo ?? '').localeCompare(String(b.titulo ?? ''), 'pt'),
                render: (text: string) => (
                    <span style={{ fontWeight: 600, color: '#2c3e50' }}>{text}</span>
                )},
            {
                title: 'Projeto',
                dataIndex: ['projeto', 'nome'],
                key: 'projeto',
                sorter: (a, b) =>
                    String(a.projeto?.nome ?? '').localeCompare(String(b.projeto?.nome ?? ''), 'pt'),
                render: (text: string, record: DesenvolvimentoEntregaListItem) =>
                    text ? (
                        <a
                            href="#"
                            onClick={(e) => {
                                e.preventDefault();
                                router.push(`/projetos/${record.projeto_id}`);
                            }}
                        >
                            {text}
                        </a>
                    ) : (
                        '-'
                    )},
            {
                title: 'Sprint',
                dataIndex: ['sprint', 'nome'],
                key: 'sprint',
                sorter: (a, b) =>
                    String(a.sprint?.nome ?? '').localeCompare(String(b.sprint?.nome ?? ''), 'pt'),
                render: (text: string) => text || '-'},
            {
                title: 'Status',
                dataIndex: 'status',
                key: 'status',
                sorter: (a, b) =>
                    String(a.status ?? '').localeCompare(String(b.status ?? ''), 'pt'),
                render: (status: string) => (
                    <Tag color={getDesenvolvimentoEntregaStatusColor(status)}>
                        {getDesenvolvimentoEntregaStatusLabel(status)}
                    </Tag>
                )},
            {
                title: 'Prioridade',
                dataIndex: 'prioridade',
                key: 'prioridade',
                sorter: (a, b) =>
                    String(a.prioridade ?? '').localeCompare(String(b.prioridade ?? ''), 'pt'),
                render: (prioridade: string) =>
                    prioridade ? (
                        <Tag color={getDesenvolvimentoEntregaPrioridadeColor(prioridade)}>
                            {prioridade.toUpperCase()}
                        </Tag>
                    ) : (
                        '-'
                    )},
            {
                title: 'Data Planejada',
                dataIndex: 'data_planejada',
                key: 'data_planejada',
                sorter: (a, b) =>
                    dayjs(a.data_planejada).valueOf() - dayjs(b.data_planejada).valueOf(),
                render: (data: string) => (data ? dayjs(data).format('DD/MM/YYYY') : '-')},
            {
                title: 'Responsável',
                dataIndex: ['responsavel', 'nome'],
                key: 'responsavel',
                sorter: (a, b) =>
                    String(a.responsavel?.nome ?? '').localeCompare(
                        String(b.responsavel?.nome ?? ''),
                        'pt'
                    ),
                render: (text: string) => text || '-'},
            {
                title: '',
                key: 'acoes',
                width: 56,
                align: 'center',
                onCell: () => ({ onClick: (e: React.MouseEvent) => e.stopPropagation() }),
                render: (_: unknown, record: DesenvolvimentoEntregaListItem) => (
                    <Button
                        type="text"
                        size="small"
                        icon={<Menu />}
                        onClick={() => setOpcoesItem(record)}
                        aria-label="Opções"
                    />
                )},
        ],
        [router]
    );

    const listaEntregas = useMemo(() => entregas?.data ?? [], [entregas?.data]);

    const planejadas = listaEntregas.filter((e) => e.status === 'planejada').length;
    const emPreparacao = listaEntregas.filter((e) => e.status === 'em_preparacao').length;

    const filtrosAtivosCount = useMemo(() => {
        let n = 0;
        if (statusFilter) n += 1;
        if (tipoFilter) n += 1;
        if (searchValue.trim()) n += 1;
        return n;
    }, [statusFilter, tipoFilter, searchValue]);
    const filtrosComAlgumAtivo = filtrosAtivosCount > 0;

    const resumoFiltrosAplicados = useMemo(() => {
        const partes: string[] = [];
        if (statusFilter) partes.push(`Status: ${STATUS_FILTRO_LABELS[statusFilter] ?? statusFilter}`);
        if (tipoFilter) partes.push(`Tipo: ${TIPO_FILTRO_LABELS[tipoFilter] ?? tipoFilter}`);
        const q = searchValue.trim();
        if (q) partes.push(`Pesquisa: "${q}"`);
        return partes.length ? partes.join(' · ') : '';
    }, [statusFilter, tipoFilter, searchValue]);

    const abrirModalFiltros = useCallback(() => {
        setDraftStatusFilter(statusFilter);
        setDraftTipoFilter(tipoFilter);
        setDraftSearchInput(searchInput);
        setFiltrosModalOpen(true);
    }, [statusFilter, tipoFilter, searchInput]);

    const reporRascunhoFiltros = useCallback(() => {
        setDraftStatusFilter('');
        setDraftTipoFilter('');
        setDraftSearchInput('');
    }, []);

    const aplicarFiltrosModal = useCallback(() => {
        setStatusFilter(draftStatusFilter);
        setTipoFilter(draftTipoFilter);
        const q = draftSearchInput.trim();
        setSearchValue(q);
        setSearchInput(q);
        setCurrentPage(1);
        setFiltrosModalOpen(false);
    }, [draftStatusFilter, draftTipoFilter, draftSearchInput]);

    return (
        <ProjetoLayout
            projetoId={projetoId}
            pageTitle="Entregas"
            showPageTitleIcon={false}
            titleSection="Entregas"
            headerAction={
                    <Space wrap size={8} align="center">
                        {!isMobile ? (
                            <Tooltip
                                title={
                                    filtrosComAlgumAtivo
                                        ? `Filtros ativos (${filtrosAtivosCount}) — abrir para alterar status, tipo ou pesquisa`
                                        : 'Definir status, tipo e texto de pesquisa na listagem'
                                }
                            >
                                <span style={{ display: 'inline-block' }}>
                                <Badge dot={filtrosComAlgumAtivo} color="geekblue">
                                    <ButtonHeaderIcon
                                        data-testid="desenvolvimento-entregas-abrir-filtros"
                                        icon={<Filter size={ICON_SIZE_MD} aria-hidden />}
                                        title={
                                            filtrosAtivosCount > 0
                                                ? `Filtros (${filtrosAtivosCount})`
                                                : 'Filtros'
                                        }
                                        aria-label="Abrir filtros de entregas"
                                        aria-expanded={filtrosModalOpen}
                                        aria-haspopup="dialog"
                                        onClick={abrirModalFiltros}
                                        className={btnHeaderStyles.btnHeaderIcon}
                                    />
                                </Badge>
                                </span>
                            </Tooltip>
                        ) : null}
                        {!isMobile ? (
                            <Tooltip title="Exportar entregas visíveis nesta página (Excel, PDF, CSV ou JSON)">
                                <span style={{ display: 'inline-block' }}>
                                    <LazyExportButton
                                        data={listaEntregas as unknown as Record<string, unknown>[]}
                                        columns={[
                                            { key: 'codigo', label: 'Código' },
                                            { key: 'titulo', label: 'Título' },
                                            { key: 'status', label: 'Status' },
                                            { key: 'prioridade', label: 'Prioridade' },
                                        ]}
                                        filename="entregas"
                                        title="Exportar entregas"
                                        iconOnly
                                        size="large"
                                        exportMenuMode="modal"
                                        className={btnHeaderStyles.btnHeaderIcon}
                                    />
                                </span>
                            </Tooltip>
                        ) : null}
                        <Tooltip title="Ver dashboard de entregas">
                            <span style={{ display: 'inline-block' }}>
                                <Button
                                    icon={<BarChart3 size={ICON_SIZE_MD} aria-hidden />}
                                    onClick={() =>
                                        router.push(
                                            projetoId
                                                ? `/projetos/${projetoId}/desenvolvimento/entregas/dashboard`
                                                : '/entregas/dashboard'
                                        )
                                    }
                                >
                                    {isMobile ? 'Métricas' : 'Dashboard'}
                                </Button>
                            </span>
                        </Tooltip>
                    </Space>
            }
        >
            {projetoId ? (
                <OperativeRouteHint
                    message="Previsibilidade de entrega"
                    description="A lista já está filtrada por este projeto. Use Filtros no cabeçalho para refinar; o dashboard dá visão agregada — volte aqui para ações linha a linha."
                >
                    <Space wrap>
                        <Button type="primary" onClick={() => router.push(`/projetos/${projetoId}/kanban`)}>
                            Ver Kanban
                        </Button>
                        <Button
                            onClick={() =>
                                router.push(`/projetos/${projetoId}/desenvolvimento/entregas/dashboard`)
                            }
                        >
                            Dashboard de entregas
                        </Button>
                    </Space>
                </OperativeRouteHint>
            ) : null}

            {entregas && (
                <MetricsGrid columns={3} style={{ marginBottom: 24 }}>
                    <MetricCard
                        icon={<Box size={ICON_SIZE_MD} aria-hidden />}
                        label="Total de Entregas"
                        value={(entregas.meta?.total || listaEntregas.length).toString()}
                        variant="projetos"
                    />
                    <MetricCard
                        icon={<Clock size={ICON_SIZE_MD} aria-hidden />}
                        label="Planejadas"
                        value={planejadas.toString()}
                        variant="emAndamento"
                    />
                    <MetricCard
                        icon={<Loader2 size={ICON_SIZE_MD} className="animate-spin" aria-hidden />}
                        label="Em Preparação"
                        value={emPreparacao.toString()}
                        variant="emAndamento"
                    />
                </MetricsGrid>
            )}

            {(() => {
                const filtrosFields = (
                    <>
                        <Row gutter={16}>
                            <Col xs={24} sm={8}>
                                <FormGroup label="Status">
                                    <Select
                                        placeholder="Todos"
                                        allowClear
                                        style={{ width: '100%' }}
                                        value={draftStatusFilter || undefined}
                                        onChange={(value) => setDraftStatusFilter(value ?? '')}
                                    >
                                        <Select.Option value="planejada">Planejada</Select.Option>
                                        <Select.Option value="em_preparacao">Em Preparação</Select.Option>
                                        <Select.Option value="entregue">Entregue</Select.Option>
                                        <Select.Option value="aceita">Aceita</Select.Option>
                                        <Select.Option value="rejeitada">Rejeitada</Select.Option>
                                    </Select>
                                </FormGroup>
                            </Col>
                            <Col xs={24} sm={8}>
                                <FormGroup label="Tipo">
                                    <Select
                                        placeholder="Todos"
                                        allowClear
                                        style={{ width: '100%' }}
                                        value={draftTipoFilter || undefined}
                                        onChange={(value) => setDraftTipoFilter(value ?? '')}
                                    >
                                        <Select.Option value="feature">Feature</Select.Option>
                                        <Select.Option value="bugfix">Bugfix</Select.Option>
                                        <Select.Option value="hotfix">Hotfix</Select.Option>
                                        <Select.Option value="refactor">Refactor</Select.Option>
                                    </Select>
                                </FormGroup>
                            </Col>
                        </Row>
                        <Row gutter={16} style={{ marginTop: 16 }}>
                            <Col xs={24}>
                                <FormGroup label="Pesquisa">
                                    <Input.Search
                                        placeholder={'Buscar entregas (código, título…) — confirme com "Filtrar" ou Enter em "Pesquisar"'}
                                        allowClear
                                        value={draftSearchInput}
                                        onChange={(e) => setDraftSearchInput(e.target.value)}
                                        onSearch={() => aplicarFiltrosModal()}
                                        enterButton="Pesquisar"
                                        aria-label="Pesquisar entregas na listagem"
                                    />
                                </FormGroup>
                            </Col>
                        </Row>
                    </>
                );
                if (isMobile) {
                    return (
                        <MobileFiltersDrawer
                            open={filtrosModalOpen}
                            onClose={() => setFiltrosModalOpen(false)}
                            onApply={aplicarFiltrosModal}
                            onReset={reporRascunhoFiltros}
                            title="Filtrar e pesquisar"
                            dataTestId="desenvolvimento-entregas-filtros-modal"
                        >
                            <div style={{ padding: '12px 16px' }}>{filtrosFields}</div>
                        </MobileFiltersDrawer>
                    );
                }
                return (
                    <Modal
                        title="Filtrar e pesquisar"
                        data-testid="desenvolvimento-entregas-filtros-modal"
                        open={filtrosModalOpen}
                        onCancel={() => setFiltrosModalOpen(false)}
                        width={filtrosModalLayout.width ?? 640}
                        centered={filtrosModalLayout.centered}
                        styles={filtrosModalLayout.styles}
                        footer={
                            <FiltrosModalFooterPadrao
                                onLimparTodos={reporRascunhoFiltros}
                                onFechar={() => setFiltrosModalOpen(false)}
                                showFiltrarPrimary
                                onFiltrar={aplicarFiltrosModal}
                                dataTestIdLimparTodos="desenvolvimento-entregas-filtros-modal-limpar-todos"
                            />
                        }
                        destroyOnHidden
                        keyboard
                        focusTriggerAfterClose
                    >
                        {filtrosFields}
                    </Modal>
                );
            })()}

            {filtrosComAlgumAtivo ? (
                <Alert
                    type="info"
                    showIcon
                    style={{ marginBottom: 16 }}
                    message={`Filtros aplicados (${filtrosAtivosCount})`}
                    description={
                        <>
                            {resumoFiltrosAplicados}
                            <Button type="link" onClick={limparTodosFiltros} style={{ paddingLeft: 8 }}>
                                Limpar filtros
                            </Button>
                        </>
                    }
                />
            ) : null}

            <div style={{ marginTop: filtrosComAlgumAtivo ? 0 : undefined }}>
            <LazyDataTable<DesenvolvimentoEntregaListItem>
                columns={columns}
                data={listaEntregas}
                paginatedData={entregas || undefined}
                loading={isLoading}
                onRefresh={refetch}
                onPageChange={handlePageChange}
                onRow={(record: unknown) => ({
                    onClick: () => setOpcoesItem(record as DesenvolvimentoEntregaListItem),
                    style: { cursor: 'pointer' }})}
                autoMobileFromColumns={{
                    testIdPrefix: 'desenvolvimento-entregas',
                    listHeading: 'Lista de entregas',
                    getFallbackTitle: (record: any) =>
                        [record.codigo, record.titulo?.trim()].filter(Boolean).join(' — ') ||
                        `Entrega ${record.id}`,
                    getSubtitle: (record: any) => {
                        const status = getDesenvolvimentoEntregaStatusLabel(record.status);
                        const prio = record.prioridade
                            ? String(record.prioridade)
                            : null;
                        return [status, prio].filter(Boolean).join(' · ') || undefined;
                    },
                    excludeFieldKeys: ['codigo', 'titulo', 'status', 'acoes'],
                    onCardClick: (item) => setOpcoesItem(item),
                    onOpenOptions: (item) => setOpcoesItem(item),
                }}
            />
</div>

            {isMobile ? (
                <MobilePageActionBar
                    onOpenFilters={abrirModalFiltros}
                    activeFiltersCount={filtrosAtivosCount}
                    filterButtonLabel="Filtros"
                    onRefresh={() => void refetch()}
                    refreshLoading={isLoading}
                    hideOpcoes
                />
            ) : null}

            {!permsLoading && canEditar ? (
                <ListPageCreateFloatButton
                    data-testid="desenvolvimento-entregas-fab-nova"
                    tooltip={{
                        title: 'Nova entrega — refine a listagem com Filtros no cabeçalho',
                    }}
                    onClick={() => router.push(projetosProjetoCanonical.planejamentoEntregas(projetoId))}
                />
            ) : null}

            <ModalOpcoesEntrega
                open={opcoesItem !== null}
                onClose={() => setOpcoesItem(null)}
                item={opcoesItem}
                onVer={() => {
                    setOpcoesItem(null);
                    router.push(projetosProjetoCanonical.planejamentoEntregas(projetoId));
                }}
                onEntregar={(item) => {
                    setOpcoesItem(null);
                    handleEntregar(item.id);
                }}
                onAceitar={(item) => {
                    setOpcoesItem(null);
                    handleAceitar(item.id);
                }}
                onRejeitar={(item) => {
                    setOpcoesItem(null);
                    handleRejeitar(item.id);
                }}
            />
        </ProjetoLayout>
    );
}
