diff --git a/src/modules/intelligence-score/pages/FechamentoDetalhes.tsx b/src/modules/intelligence-score/pages/FechamentoDetalhes.tsx index db4fcf8..9a2b432 100644 --- a/src/modules/intelligence-score/pages/FechamentoDetalhes.tsx +++ b/src/modules/intelligence-score/pages/FechamentoDetalhes.tsx @@ -165,11 +165,17 @@ function toPontuacaoInput(value: number): string { return String(rounded); } +/** Datas Asana/competência são civis (YYYY-MM-DD); evita exibir dia anterior por fuso (ex.: 01/04 UTC → 31/03 BRT). */ function formatDateOnly(value: string | null): string { if (!value) return "—"; + const isoMatch = value.match(/^(\d{4})-(\d{2})-(\d{2})/); + if (isoMatch) { + const [, year, month, day] = isoMatch; + return `${day}/${month}/${year}`; + } const parsed = new Date(value); if (Number.isNaN(parsed.getTime())) return "—"; - return parsed.toLocaleDateString("pt-BR"); + return parsed.toLocaleDateString("pt-BR", { timeZone: "UTC" }); } function normalizeTextFilter(value: string): string { @@ -1143,7 +1149,18 @@ export default function FechamentoDetalhes() { `Reprocessamento concluído: ${data.tarefasImportadas} tarefa(s) atualizada(s), ${data.tarefasRemovidasForaCompetencia} removida(s) fora da competência.`, ); setIsReprocessAsanaOpen(false); - await loadTarefas(); + if (data.fechamentoId !== fechamentoId) { + navigate(`/intelligence-score/fechamentos/${data.fechamentoId}`, { + replace: true, + state: { + competenciaId, + status: "em_aberto" as const, + readonlyView: initialState?.readonlyView, + }, + }); + } else { + await loadTarefas(); + } } catch (error) { const message = error instanceof Error ? error.message : "Erro ao reprocessar Asana."; toast.error(message); diff --git a/src/modules/intelligence-score/pages/MeuFechamento.tsx b/src/modules/intelligence-score/pages/MeuFechamento.tsx index 47d9411..caddd42 100644 --- a/src/modules/intelligence-score/pages/MeuFechamento.tsx +++ b/src/modules/intelligence-score/pages/MeuFechamento.tsx @@ -37,9 +37,6 @@ function formatPontos(valor: number): string { export default function MeuFechamento() { const navigate = useNavigate(); const { me } = useAuthAccess(); - const caps = me?.capabilities; - const podeExportarPlanilha = caps?.fechamentos.exportarPlanilha ?? false; - const podeExportarPdf = caps?.fechamentos.exportarPdf ?? false; const currentYear = new Date().getFullYear(); const [loading, setLoading] = useState(true); const [exportacao, setExportacao] = useState<{ fechamentoId: string; tipo: "planilha" | "pdf" } | null>(null); @@ -287,7 +284,6 @@ export default function MeuFechamento() { disabled={ !item.fechamento || item.fechamento.status !== "fechado" || - !podeExportarPlanilha || (exportacao?.fechamentoId === item.fechamento?.id && exportacao?.tipo === "planilha") || (exportacao?.fechamentoId === item.fechamento?.id && exportacao?.tipo === "pdf") } @@ -304,7 +300,6 @@ export default function MeuFechamento() { disabled={ !item.fechamento || item.fechamento.status !== "fechado" || - !podeExportarPdf || (exportacao?.fechamentoId === item.fechamento?.id && exportacao?.tipo === "planilha") || (exportacao?.fechamentoId === item.fechamento?.id && exportacao?.tipo === "pdf") } @@ -318,7 +313,7 @@ export default function MeuFechamento() {