Skip to content

Commit

Permalink
Correção e implementação de novas tags
Browse files Browse the repository at this point in the history
> 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.
  • Loading branch information
rtenorioh committed Jan 30, 2023
1 parent 836cd56 commit 6f21218
Showing 1 changed file with 25 additions and 19 deletions.
44 changes: 25 additions & 19 deletions backend/src/helpers/Mustache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,56 @@ 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;
};

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;
};

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;
};

Expand All @@ -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);
};
};

0 comments on commit 6f21218

Please sign in to comment.