feat(alerts): format hours in admin alert emails using minutes when <1h; minor null-safe for contracted/month
This commit is contained in:
parent
0a3e1a0130
commit
dbb8d7fa63
1 changed files with 7 additions and 2 deletions
|
|
@ -11,7 +11,12 @@ import { sendSmtpMail } from "@/server/email-smtp"
|
||||||
export const runtime = "nodejs"
|
export const runtime = "nodejs"
|
||||||
|
|
||||||
function fmtHours(ms: number) {
|
function fmtHours(ms: number) {
|
||||||
return (ms / 3600000).toFixed(2)
|
const hours = ms / 3600000
|
||||||
|
if (hours > 0 && hours < 1) {
|
||||||
|
const mins = Math.round(hours * 60)
|
||||||
|
return `${mins} min`
|
||||||
|
}
|
||||||
|
return `${hours.toFixed(2)} h`
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function POST(request: Request) {
|
export async function POST(request: Request) {
|
||||||
|
|
@ -85,7 +90,7 @@ export async function POST(request: Request) {
|
||||||
<li>Horas internas: <strong>${fmtHours(item.internalMs)}</strong></li>
|
<li>Horas internas: <strong>${fmtHours(item.internalMs)}</strong></li>
|
||||||
<li>Horas externas: <strong>${fmtHours(item.externalMs)}</strong></li>
|
<li>Horas externas: <strong>${fmtHours(item.externalMs)}</strong></li>
|
||||||
<li>Total: <strong>${fmtHours(item.totalMs)}</strong></li>
|
<li>Total: <strong>${fmtHours(item.totalMs)}</strong></li>
|
||||||
<li>Contratadas/mês: <strong>${item.contractedHoursPerMonth}</strong></li>
|
<li>Contratadas/mês: <strong>${item.contractedHoursPerMonth ?? "—"}</strong></li>
|
||||||
</ul>
|
</ul>
|
||||||
<p>Reveja a alocação da equipe e, se necessário, ajuste o atendimento.</p>
|
<p>Reveja a alocação da equipe e, se necessário, ajuste o atendimento.</p>
|
||||||
`
|
`
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue