Skip to content

Commit

Permalink
Implementação das tags {{ms}}, {{procol}} e {{hora}}
Browse files Browse the repository at this point in the history
  • Loading branch information
rtenorioh authored May 19, 2022
1 parent a3fa83b commit 05dbcb2
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions backend/src/helpers/Mustache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,34 @@ import Mustache from "mustache";
import Contact from "../models/Contact";

export default (body: string, contact: Contact): string => {

let ms = "";

const Hr = new Date();

const dd: string = ("0" + Hr.getDate()).slice(-2);
const mm: string = ("0" + (Hr.getMonth() + 1)).slice(-2);
const yy: string = Hr.getFullYear().toString();
const hh: number = Hr.getHours();
const min: string = ("0" + Hr.getMinutes()).slice(-2);
const ss: string = ("0" + Hr.getSeconds()).slice(-2);

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

let protocol = yy+mm+dd+String(hh)+min+ss;

let hora = hh+":"+min+":"+ss;

const view = {
name: contact ? contact.name : ""
name: contact ? contact.name : "",
ms: ms,
protocol: protocol,
hora: hora,
};

return Mustache.render(body, view);
};

};

2 comments on commit 05dbcb2

@rtenorioh
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{{ms}} 》 Mensagem de saudação (Bom dia, Boa Tarde, Boa noite e Boa madrugada).

{{protocol}} 》 N° de protocolo gerado a partir da junção de data e hora atual, no formato ano-mes-dia-hora-min-seg.

{{hora}} 》 Hora atual no formato de hora-min-seg.

@patronotech
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amigo ótimo trabalho, parabéns você consegue orientar como incluir o número do ticket no protocolo?
Agradeço desde já.
Abraços

Please sign in to comment.