style: run prettier on entire codebase

This commit is contained in:
BOHA
2026-03-24 19:59:14 +01:00
parent 872be42107
commit 3c167cf5c4
148 changed files with 26740 additions and 13990 deletions

View File

@@ -1,23 +1,27 @@
import { sendMail } from './mailer';
import { config } from '../config/env';
import { sendMail } from "./mailer";
import { config } from "../config/env";
const LEAVE_TYPE_LABELS: Record<string, string> = {
vacation: 'Dovolená',
sick: 'Nemocenská',
unpaid: 'Neplacené volno',
vacation: "Dovolená",
sick: "Nemocenská",
unpaid: "Neplacené volno",
};
function formatDate(dateStr: string): string {
try {
const d = new Date(dateStr);
return `${String(d.getDate()).padStart(2, '0')}.${String(d.getMonth() + 1).padStart(2, '0')}.${d.getFullYear()}`;
return `${String(d.getDate()).padStart(2, "0")}.${String(d.getMonth() + 1).padStart(2, "0")}.${d.getFullYear()}`;
} catch {
return dateStr;
}
}
function escapeHtml(str: string): string {
return str.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
return str
.replace(/&/g, "&amp;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/"/g, "&quot;");
}
interface LeaveRequestData {
@@ -29,18 +33,21 @@ interface LeaveRequestData {
notes?: string | null;
}
export async function notifyNewLeaveRequest(request: LeaveRequestData, employeeName: string): Promise<void> {
export async function notifyNewLeaveRequest(
request: LeaveRequestData,
employeeName: string,
): Promise<void> {
const notifyEmail = config.email.leaveNotify;
if (!notifyEmail) return;
const leaveType = LEAVE_TYPE_LABELS[request.leave_type] || request.leave_type;
const dateFrom = formatDate(request.date_from);
const dateTo = formatDate(request.date_to);
const notes = request.notes || '';
const notes = request.notes || "";
const subject = `Nová žádost o nepřítomnost - ${employeeName} (${leaveType})`;
const appUrl = config.appUrl || '';
const appUrl = config.appUrl || "";
const approvalLink = appUrl
? `<p style="margin-top: 20px;">
<a href="${escapeHtml(appUrl)}/leave-approval"
@@ -49,10 +56,10 @@ export async function notifyNewLeaveRequest(request: LeaveRequestData, employeeN
Přejít ke schvalování
</a>
</p>`
: '';
: "";
const now = new Date();
const timestamp = `${String(now.getDate()).padStart(2, '0')}.${String(now.getMonth() + 1).padStart(2, '0')}.${now.getFullYear()} ${String(now.getHours()).padStart(2, '0')}:${String(now.getMinutes()).padStart(2, '0')}:${String(now.getSeconds()).padStart(2, '0')}`;
const timestamp = `${String(now.getDate()).padStart(2, "0")}.${String(now.getMonth() + 1).padStart(2, "0")}.${now.getFullYear()} ${String(now.getHours()).padStart(2, "0")}:${String(now.getMinutes()).padStart(2, "0")}:${String(now.getSeconds()).padStart(2, "0")}`;
const html = `
<html>
@@ -75,10 +82,14 @@ export async function notifyNewLeaveRequest(request: LeaveRequestData, employeeN
<td style="padding: 10px; background: #f5f5f5; font-weight: bold;">Pracovní dny:</td>
<td style="padding: 10px; border-bottom: 1px solid #ddd;">${request.total_days} dní (${request.total_hours} hodin)</td>
</tr>
${notes ? `<tr>
${
notes
? `<tr>
<td style="padding: 10px; background: #f5f5f5; font-weight: bold;">Poznámka:</td>
<td style="padding: 10px; border-bottom: 1px solid #ddd;">${escapeHtml(notes)}</td>
</tr>` : ''}
</tr>`
: ""
}
</table>
${approvalLink}
<hr style="margin: 30px 0; border: none; border-top: 1px solid #ddd;">
@@ -91,6 +102,8 @@ export async function notifyNewLeaveRequest(request: LeaveRequestData, employeeN
const sent = await sendMail(notifyEmail, subject, html);
if (!sent) {
console.error(`LeaveNotification: Failed to send notification to ${notifyEmail}`);
console.error(
`LeaveNotification: Failed to send notification to ${notifyEmail}`,
);
}
}