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