Skip to content

Commit

Permalink
Correção e implementação de novas tags
Browse files Browse the repository at this point in the history
  • Loading branch information
rtenorioh committed Aug 18, 2022
1 parent 901bce0 commit a64c08e
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions backend/src/helpers/Mustache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ 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;
};
Expand All @@ -26,6 +26,17 @@ export const control = (): string => {
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 yy: string = Hr.getFullYear().toString();

const dates = dd + "-" + mm + "-" + yy;
return dates;
};

export const hour = (): string => {
const Hr = new Date();

Expand All @@ -42,8 +53,14 @@ export default (body: string, ticket?: Ticket): string => {
name: ticket ? ticket.contact.name : "",
ticket_id: ticket ? ticket.id : "",
ms: msgsd(),
protocol: control(),
hour: hour(),
date: date(),
queue: ticket ? ticket?.queue?.name : "",
connection: ticket ? ticket.whatsapp.name : "",
protocol: new Array(
control(),
ticket ? ticket.id.toString() : ""
).join(""),
};

return Mustache.render(body, view);
Expand Down

0 comments on commit a64c08e

Please sign in to comment.