From f3eff4b8059fafb3729214cbb8977b078201b169 Mon Sep 17 00:00:00 2001 From: admbrainsteel Date: Tue, 20 Oct 2026 13:34:22 -0300 Subject: [PATCH] =?UTF-8?q?feat:=20adicionar=20exibi=C3=A7=C3=A3o=20da=20f?= =?UTF-8?q?ase=20da=20OF=20no=20hist=C3=B3rico=20de=20apontamentos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../apontamento/ApontamentosList.tsx | 28 +++++++++++++++++-- .../historico/ApontamentosFilters.tsx | 4 ++- .../historico/ApontamentosListItem.tsx | 26 ++++++++++++++++- .../historico/useApontamentosFilters.tsx | 6 ++-- 4 files changed, 57 insertions(+), 7 deletions(-) diff --git a/src/components/apontamento/ApontamentosList.tsx b/src/components/apontamento/ApontamentosList.tsx index 1c18c06..bcce49a 100644 --- a/src/components/apontamento/ApontamentosList.tsx +++ b/src/components/apontamento/ApontamentosList.tsx @@ -12,12 +12,15 @@ import { ptBR } from 'date-fns/locale'; export const ApontamentosList = () => { const { apontamentos, loading } = useApontamentosProducao(); const [filtroOF, setFiltroOF] = useState(''); + const [filtroFase, setFiltroFase] = useState(''); const [filtroProcesso, setFiltroProcesso] = useState(''); const [filtroData, setFiltroData] = useState(''); const [filtroPecaComponente, setFiltroPecaComponente] = useState(''); const apontamentosFiltrados = apontamentos.filter(apt => { const matchOF = !filtroOF || apt.of_number.toLowerCase().includes(filtroOF.toLowerCase()); + const faseStr = apt.peca?.etapa_fase || (apt.componente as any)?.peca?.etapa_fase || ''; + const matchFase = !filtroFase || faseStr.toLowerCase().includes(filtroFase.toLowerCase()); const matchProcesso = !filtroProcesso || apt.processo?.nome.toLowerCase().includes(filtroProcesso.toLowerCase()); const matchData = !filtroData || apt.data_apontamento.includes(filtroData); @@ -25,7 +28,7 @@ export const ApontamentosList = () => { const matchPecaComponente = !filtroPecaComponente || getMarcaExibida(apt).toLowerCase().includes(filtroPecaComponente.toLowerCase()); - return matchOF && matchProcesso && matchData && matchPecaComponente; + return matchOF && matchFase && matchProcesso && matchData && matchPecaComponente; }); // Função para determinar a marca exibida baseada no tipo de apontamento @@ -90,7 +93,7 @@ export const ApontamentosList = () => { -
+
{ className="h-8" />
+
+ + setFiltroFase(e.target.value)} + className="h-8" + /> +
{ OF + Fase Peça/Componente Tipo Processo @@ -184,6 +197,17 @@ export const ApontamentosList = () => { {apontamento.of_number} + + {apontamento.peca?.etapa_fase ? ( + + {apontamento.peca.etapa_fase.toLowerCase().startsWith('fase') || apontamento.peca.etapa_fase.toLowerCase().startsWith('etapa') + ? apontamento.peca.etapa_fase + : `Fase ${apontamento.peca.etapa_fase}`} + + ) : ( + - + )} +
{getMarcaExibida(apontamento)} diff --git a/src/components/apontamento/historico/ApontamentosFilters.tsx b/src/components/apontamento/historico/ApontamentosFilters.tsx index 9055a56..6eb2818 100644 --- a/src/components/apontamento/historico/ApontamentosFilters.tsx +++ b/src/components/apontamento/historico/ApontamentosFilters.tsx @@ -95,7 +95,9 @@ export const ApontamentosFilters: React.FC = ({ Todas as fases {uniqueFases.map((fase) => ( - {fase} + + {fase.toLowerCase().startsWith('fase') || fase.toLowerCase().startsWith('etapa') ? fase : `Fase ${fase}`} + ))} diff --git a/src/components/apontamento/historico/ApontamentosListItem.tsx b/src/components/apontamento/historico/ApontamentosListItem.tsx index 263ac37..bd92f43 100644 --- a/src/components/apontamento/historico/ApontamentosListItem.tsx +++ b/src/components/apontamento/historico/ApontamentosListItem.tsx @@ -35,6 +35,15 @@ export const ApontamentosListItem: React.FC = ({ } }; + const getFaseItem = (apontamento: ApontamentoProducao) => { + const rawFase = apontamento.peca?.etapa_fase || (apontamento.componente as any)?.peca?.etapa_fase; + if (!rawFase || !String(rawFase).trim()) return null; + const str = String(rawFase).trim(); + return str.toLowerCase().startsWith('fase') || str.toLowerCase().startsWith('etapa') + ? str + : `Fase ${str}`; + }; + return (
@@ -52,6 +61,21 @@ export const ApontamentosListItem: React.FC = ({ {apontamento.of_number || 'N/A'} + {getFaseItem(apontamento) ? ( + + {getFaseItem(apontamento)} + + ) : ( + + Fase - + + )} {apontamento.is_forcado && ( = ({ Tem certeza de que deseja reverter este apontamento? Esta ação não pode ser desfeita e irá remover permanentemente o registro de:
- {getMarcaItem(apontamento)} - {apontamento.quantidade_produzida} unidades + {getMarcaItem(apontamento)} (OF: {apontamento.of_number || 'N/A'}{getFaseItem(apontamento) ? ` • ${getFaseItem(apontamento)}` : ''}) - {apontamento.quantidade_produzida} unidades diff --git a/src/components/apontamento/historico/useApontamentosFilters.tsx b/src/components/apontamento/historico/useApontamentosFilters.tsx index 6373e77..8148cd1 100644 --- a/src/components/apontamento/historico/useApontamentosFilters.tsx +++ b/src/components/apontamento/historico/useApontamentosFilters.tsx @@ -89,12 +89,12 @@ export const useApontamentosFilters = (apontamentos: ApontamentoProducao[]) => { : apontamentos; const fases = apontamentosFiltrados - .map(apt => apt.peca?.etapa_fase) + .map(apt => apt.peca?.etapa_fase || (apt.componente as any)?.peca?.etapa_fase) .filter((fase): fase is string => { return typeof fase === 'string' && fase.trim() !== ''; }) .filter((fase, index, array) => array.indexOf(fase) === index) - .sort(); + .sort((a, b) => a.localeCompare(b, undefined, { numeric: true, sensitivity: 'base' })); console.log(`📋 Fases únicas encontradas para OF "${filterOF}": ${fases.length}`, fases); return fases; @@ -166,7 +166,7 @@ export const useApontamentosFilters = (apontamentos: ApontamentoProducao[]) => { // Aplicar filtro por Fase APENAS se selecionado if (filterFase && filterFase !== '' && filterFase !== 'all') { const beforeFase = resultado.length; - resultado = resultado.filter(apt => apt.peca?.etapa_fase === filterFase); + resultado = resultado.filter(apt => (apt.peca?.etapa_fase || (apt.componente as any)?.peca?.etapa_fase) === filterFase); console.log(`📋 Filtro Fase "${filterFase}": ${beforeFase} → ${resultado.length} registros`); }