From 6f212182771ef490ab71a9c38eafe29220b551ec Mon Sep 17 00:00:00 2001 From: Robson Tenorio Date: Sun, 29 Jan 2023 22:54:35 -0300 Subject: [PATCH] =?UTF-8?q?Corre=C3=A7=C3=A3o=20e=20implementa=C3=A7=C3=A3?= =?UTF-8?q?o=20de=20novas=20tags?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit > Pode ser utilizado na saudação e despedida de conexão e setor, respostas rápidas e enviado por mensagem. > > {{name}} 》 Nome do usuário. > > {{user}} 》 Nome do atendente. > > {{ms}} 》 Mensagem de saudação de acordo com o horário (Bom dia, Boa Tarde, Boa noite e Boa madrugada). > > {{protocol}} 》 N° de protocolo gerado a partir da junção de data, no formato ano-mes-dia-T-ticket. > > {{ticket_id}} 》 Número do ticket. > > {{hour}} 》 Hora atual no formato de hora-min-seg (ex: 11:08:32). > > {{date}} 》 Data atual no formato dd-mm-yyyy (ex: 31-08-2022). > > {{date_hour}} 》 Data e hora atual (ex: 29-01-2023 as 22:51:29). > > {{queue}} 》Nome do Setor. > > {{connection}} 》Nome da Conexão. --- backend/src/helpers/Mustache.ts | 44 +++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/backend/src/helpers/Mustache.ts b/backend/src/helpers/Mustache.ts index 6c0f05be..bfe7bcaa 100644 --- a/backend/src/helpers/Mustache.ts +++ b/backend/src/helpers/Mustache.ts @@ -2,15 +2,22 @@ import Mustache from "mustache"; import Ticket from "../models/Ticket"; export const msgsd = (): string => { - let ms = ""; const hh = new Date().getHours(); - if (hh >= 6) { ms = "Bom dia"; } - if (hh > 11) { ms = "Boa tarde"; } - if (hh > 17) { ms = "Boa noite"; } - if (hh > 23 || hh < 6) { ms = "Boa madrugada"; } + if (hh >= 6) { + ms = "Bom Dia"; + } + if (hh > 11) { + ms = "Boa Tarde"; + } + if (hh > 17) { + ms = "Boa Noite"; + } + if (hh > 23 || hh < 6) { + ms = "Boa Madrugada"; + } return ms; }; @@ -18,22 +25,22 @@ export const msgsd = (): string => { export const control = (): string => { const Hr = new Date(); - const dd: string = ("0" + Hr.getDate()).slice(-2); - const mm: string = ("0" + (Hr.getMonth() + 1)).slice(-2); + const dd: string = `0${Hr.getDate()}`.slice(-2); + const mm: string = `0${Hr.getMonth() + 1}`.slice(-2); const yy: string = Hr.getFullYear().toString(); - const ctrl = yy + mm + dd + "T"; + const ctrl = `${yy + mm + dd}T`; return ctrl; }; export const date = (): string => { const Hr = new Date(); - const dd: string = ("0" + Hr.getDate()).slice(-2); - const mm: string = ("0" + (Hr.getMonth() + 1)).slice(-2); + const dd: string = `0${Hr.getDate()}`.slice(-2); + const mm: string = `0${Hr.getMonth() + 1}`.slice(-2); const yy: string = Hr.getFullYear().toString(); - const dates = dd + "-" + mm + "-" + yy; + const dates = `${dd}-${mm}-${yy}`; return dates; }; @@ -41,10 +48,10 @@ export const hour = (): string => { const Hr = new Date(); const hh: number = Hr.getHours(); - const min: string = ("0" + Hr.getMinutes()).slice(-2); - const ss: string = ("0" + Hr.getSeconds()).slice(-2); + const min: string = `0${Hr.getMinutes()}`.slice(-2); + const ss: string = `0${Hr.getSeconds()}`.slice(-2); - const hours = hh + ":" + min + ":" + ss; + const hours = `${hh}:${min}:${ss}`; return hours; }; @@ -57,11 +64,10 @@ export default (body: string, ticket?: Ticket): string => { date: date(), queue: ticket ? ticket?.queue?.name : "", connection: ticket ? ticket.whatsapp.name : "", - protocol: new Array( - control(), - ticket ? ticket.id.toString() : "" - ).join(""), + user: ticket ? ticket?.user.name : "", + date_hour: [date(), hour()].join(" as "), + protocol: [control(), ticket ? ticket.id.toString() : ""].join("") }; return Mustache.render(body, view); -}; \ No newline at end of file +};