-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementação da tag {{ticket}} e correções
- Loading branch information
Showing
8 changed files
with
67 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,50 @@ | ||
import Mustache from "mustache"; | ||
import Contact from "../models/Contact"; | ||
import Ticket from "../models/Ticket"; | ||
|
||
export default (body: string, contact: Contact): string => { | ||
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";} | ||
|
||
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 yy: string = Hr.getFullYear().toString(); | ||
|
||
const ctrl = yy + mm + dd + "T"; | ||
return ctrl; | ||
}; | ||
|
||
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); | ||
|
||
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 hours = hh + ":" + min + ":" + ss; | ||
return hours; | ||
}; | ||
|
||
export default (body: string, ticket?: Ticket): string => { | ||
const view = { | ||
name: contact ? contact.name : "", | ||
ms: ms, | ||
protocol: protocol, | ||
hora: hora, | ||
name: ticket ? ticket.contact.name : "", | ||
ticket_id: ticket ? ticket.id : "", | ||
ms: msgsd(), | ||
protocol: control(), | ||
hour: hour(), | ||
}; | ||
|
||
return Mustache.render(body, view); | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters