novas atualizacoes do sistema de fechamento

This commit is contained in:
Vitex Tecnologia
2026-04-27 16:50:27 -03:00
parent 6da067c641
commit 4c28862c5c
27 changed files with 3388 additions and 300 deletions
+27 -1
View File
@@ -5,15 +5,19 @@ import { buildCommanderHeaders, resolveCommanderBaseUrl } from "./commanderHttp"
export type FechamentoTarefaItem = {
id: string;
fechamentoId: string;
asanaTaskGid?: string | null;
tipo: string;
numeroTicket: string | null;
descricao: string;
cliente: string | null;
linkAsana: string | null;
etiquetas: { gid: string; name: string }[] | null;
tempoMinutos: number | null;
pontuacao: number;
pontuacaoOriginal: number;
estaRevisada: boolean;
dataInicio: string | null;
dataVencimento: string | null;
dataConclusao: string | null;
editadoEm: string | null;
editadoPorId: string | null;
@@ -96,6 +100,24 @@ type ApiErrorShape = {
};
class FechamentoFechamentosService {
private normalizeEtiquetas(
value: FechamentoTarefaItem["etiquetas"] | undefined,
tarefaId: string,
): { gid: string; name: string }[] | null {
if (!Array.isArray(value) || value.length === 0) {
return null;
}
const out: { gid: string; name: string }[] = [];
for (let i = 0; i < value.length; i += 1) {
const item = value[i];
const name = typeof item?.name === "string" ? item.name.trim() : "";
if (!name) continue;
const gidRaw = typeof item?.gid === "string" ? item.gid.trim() : "";
out.push({ gid: gidRaw || `${tarefaId}-etiqueta-${i}`, name });
}
return out.length > 0 ? out : null;
}
private extractFilenameFromContentDisposition(value: string | undefined): string | null {
if (!value) return null;
const utf8Match = value.match(/filename\*=UTF-8''([^;]+)/i);
@@ -132,7 +154,11 @@ class FechamentoFechamentosService {
const response = await axios.get<ListarTarefasResponse>(`${baseUrl}/fechamentos/${fechamentoId}/tarefas`, {
headers,
});
return response.data.data ?? [];
const tarefas = response.data.data ?? [];
return tarefas.map((tarefa) => ({
...tarefa,
etiquetas: this.normalizeEtiquetas(tarefa.etiquetas, tarefa.id),
}));
} catch (error) {
this.handleAxiosError(error, "Erro ao listar tarefas do fechamento.");
}