Skip to content

Commit 189f2b6

Browse files
committed
Refactor icon usage in settings and custom date formatting
- Replaced Lucide icon usage with Preact icons - Removed LucideInit component and associated script from _app.tsx. - Modified settings page to include a date format selection. - Cleaned up unused imports and files related to Lucide.
1 parent 06b02c9 commit 189f2b6

File tree

32 files changed

+321
-193
lines changed

32 files changed

+321
-193
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.4.0
1+
1.5.0

backend/src/routes/admin.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,7 @@ adminRoutes.get("/invoices/:id/html", async (c) => {
674674
businessSettings,
675675
selectedTemplateId,
676676
highlight,
677+
settingsMap.dateFormat,
677678
);
678679
return new Response(html, {
679680
headers: {
@@ -737,7 +738,7 @@ adminRoutes.get("/invoices/:id/pdf", async (c) => {
737738
businessSettings,
738739
selectedTemplateId,
739740
highlight,
740-
{ embedXml, embedXmlProfileId: xmlProfileId },
741+
{ embedXml, embedXmlProfileId: xmlProfileId, dateFormat: settingsMap.dateFormat },
741742
);
742743
// Detect embedded attachments for diagnostics
743744
let hasAttachment = false;

backend/src/routes/public.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ publicRoutes.get("/public/invoices/:share_token/pdf", async (c) => {
9797
businessSettings,
9898
selectedTemplateId,
9999
highlight,
100-
{ embedXml, embedXmlProfileId: xmlProfileId },
100+
{ embedXml, embedXmlProfileId: xmlProfileId, dateFormat: settingsMap.dateFormat },
101101
);
102102
// Detect embedded attachments for diagnostics
103103
let hasAttachment = false;
@@ -180,6 +180,7 @@ publicRoutes.get("/public/invoices/:share_token/html", async (c) => {
180180
businessSettings,
181181
selectedTemplateId,
182182
highlight,
183+
settingsMap.dateFormat,
183184
);
184185
return new Response(html, {
185186
headers: {

backend/src/utils/pdf.ts

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,18 @@ function lighten(hex: string, amount = 0.85): string {
4343
return `#${rr}${gg}${bb}`;
4444
}
4545

46-
function formatDate(d?: Date) {
47-
return d ? new Date(d).toLocaleDateString() : undefined;
46+
function formatDate(d?: Date, format: string = "YYYY-MM-DD") {
47+
if (!d) return undefined;
48+
const date = new Date(d);
49+
const year = date.getFullYear();
50+
const month = String(date.getMonth() + 1).padStart(2, '0');
51+
const day = String(date.getDate()).padStart(2, '0');
52+
53+
if (format === "DD.MM.YYYY") {
54+
return `${day}.${month}.${year}`;
55+
}
56+
// Default to YYYY-MM-DD
57+
return `${year}-${month}-${day}`;
4858
}
4959

5060
function toMoney(n: number): string {
@@ -232,6 +242,7 @@ function buildContext(
232242
invoice: InvoiceWithDetails,
233243
settings?: BusinessSettings & { logoUrl?: string; brandLayout?: string },
234244
_highlight?: string,
245+
dateFormat?: string,
235246
): TemplateContext & { logoUrl?: string; brandLogoLeft?: boolean } {
236247
const currency = invoice.currency || settings?.currency || "USD";
237248
// Build tax summary from normalized taxes if present
@@ -267,8 +278,8 @@ function buildContext(
267278

268279
// Invoice
269280
invoiceNumber: invoice.invoiceNumber,
270-
issueDate: formatDate(invoice.issueDate)!,
271-
dueDate: formatDate(invoice.dueDate),
281+
issueDate: formatDate(invoice.issueDate, dateFormat)!,
282+
dueDate: formatDate(invoice.dueDate, dateFormat),
272283
currency,
273284
status: invoice.status,
274285

@@ -330,7 +341,7 @@ export async function generateInvoicePDF(
330341
businessSettings?: BusinessSettings,
331342
templateId?: string,
332343
customHighlightColor?: string,
333-
opts?: { embedXmlProfileId?: string; embedXml?: boolean; xmlOptions?: Record<string, unknown> },
344+
opts?: { embedXmlProfileId?: string; embedXml?: boolean; xmlOptions?: Record<string, unknown>; dateFormat?: string },
334345
): Promise<Uint8Array> {
335346
// Inline remote logo when possible for robust HTML rendering
336347
const inlined = await inlineLogoIfPossible(businessSettings);
@@ -339,6 +350,7 @@ export async function generateInvoicePDF(
339350
inlined,
340351
templateId,
341352
customHighlightColor,
353+
opts?.dateFormat,
342354
);
343355
// First, attempt Puppeteer-based rendering
344356
let pdfBytes = await tryPuppeteerPdf(html);
@@ -349,6 +361,7 @@ export async function generateInvoicePDF(
349361
inlined,
350362
customHighlightColor,
351363
templateId,
364+
opts?.dateFormat || "YYYY-MM-DD",
352365
);
353366
}
354367

@@ -448,8 +461,9 @@ export function buildInvoiceHTML(
448461
settings?: BusinessSettings,
449462
templateId?: string,
450463
highlight?: string,
464+
dateFormat?: string,
451465
): string {
452-
const ctx = buildContext(invoice, settings, highlight);
466+
const ctx = buildContext(invoice, settings, highlight, dateFormat);
453467
const hl = normalizeHex(highlight) || "#2563eb";
454468
const hlLight = lighten(hl, 0.86);
455469

@@ -661,6 +675,7 @@ async function generateStyledPDF(
661675
businessSettings?: BusinessSettings,
662676
customHighlightColor?: string,
663677
templateId?: string,
678+
dateFormat: string = "YYYY-MM-DD",
664679
): Promise<Uint8Array> {
665680
const highlight = customHighlightColor
666681
? hexToRgb(customHighlightColor)
@@ -671,12 +686,14 @@ async function generateStyledPDF(
671686
invoiceData,
672687
businessSettings,
673688
highlight,
689+
dateFormat,
674690
);
675691
}
676692
return await generateProfessionalPDF(
677693
invoiceData,
678694
businessSettings,
679695
highlight,
696+
dateFormat,
680697
);
681698
}
682699

@@ -704,6 +721,7 @@ async function generateProfessionalPDF(
704721
invoiceData: InvoiceWithDetails,
705722
businessSettings?: BusinessSettings,
706723
highlightRgb?: ReturnType<typeof rgb>,
724+
dateFormat: string = "YYYY-MM-DD",
707725
): Promise<Uint8Array> {
708726
const highlight = highlightRgb || rgb(0.15, 0.39, 0.92);
709727

@@ -774,7 +792,7 @@ async function generateProfessionalPDF(
774792
color: rgb(0.1, 0.1, 0.1),
775793
});
776794
ctx.page.drawText(
777-
`Date: ${new Date(invoiceData.issueDate).toLocaleDateString()}`,
795+
`Date: ${formatDate(invoiceData.issueDate, dateFormat)}`,
778796
{
779797
x: boxX + 10,
780798
y: boxY + boxH - 34,
@@ -785,7 +803,7 @@ async function generateProfessionalPDF(
785803
);
786804
if (invoiceData.dueDate) {
787805
ctx.page.drawText(
788-
`Due: ${new Date(invoiceData.dueDate).toLocaleDateString()}`,
806+
`Due: ${formatDate(invoiceData.dueDate, dateFormat)}`,
789807
{
790808
x: boxX + 10,
791809
y: boxY + boxH - 50,
@@ -1022,6 +1040,7 @@ async function generateMinimalistPDF(
10221040
invoiceData: InvoiceWithDetails,
10231041
businessSettings?: BusinessSettings,
10241042
highlightRgb?: ReturnType<typeof rgb>,
1043+
dateFormat: string = "YYYY-MM-DD",
10251044
): Promise<Uint8Array> {
10261045
const highlight = highlightRgb || rgb(0.05, 0.59, 0.41);
10271046

@@ -1075,7 +1094,7 @@ async function generateMinimalistPDF(
10751094
drawLabelValue(
10761095
ctx,
10771096
"Issue Date:",
1078-
new Date(invoiceData.issueDate).toLocaleDateString(),
1097+
formatDate(invoiceData.issueDate, dateFormat) || "",
10791098
margins.left,
10801099
9,
10811100
70,
@@ -1085,7 +1104,7 @@ async function generateMinimalistPDF(
10851104
drawLabelValue(
10861105
ctx,
10871106
"Due Date:",
1088-
new Date(invoiceData.dueDate).toLocaleDateString(),
1107+
formatDate(invoiceData.dueDate, dateFormat) || "",
10891108
margins.left,
10901109
9,
10911110
70,

frontend/VERSION

Whitespace-only changes.

frontend/_fresh/chunk-EX6SY4DB.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

frontend/_fresh/island-breadcrumbs.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)