fix: Preis-/Datumsformat an Kunden-Locale anpassen, Produktgalerie-LCP verbessern
- format.ts: formatPrice/formatDate/formatDateTime/formatMonthYear nehmen jetzt ein optionales Locale-Argument (Default "de" fuer unveraenderte Aufrufer wie Rechnungen/Admin) und formatieren fuer "en" als en-GB statt hart codiert als de-DE -- englischsprachige Kundschaft sah bisher trotz gewaehlter Sprache "9,90 €" und "10. Mai 2026" statt "€9.90"/"10 May 2026". Alle kundenseitigen Aufrufer (Produktseite, Warenkorb, Checkout, Bestell- verfolgung, Konto-Bestellungen, Ernten-/Chargenseiten, Live-Suchvorschlaege, Bestell-/Versand-E-Mails) reichen jetzt die aktive Locale durch. - en.ts: openCart/shippingWithCount/shippingLabel pluralisieren "item(s)" jetzt korrekt (vorher z.B. "Open cart, 1 items"). - product-gallery.tsx: Haupt- und Vorschaubilder nutzen jetzt next/image statt <img> (hochgeladene Produktfotos sind immer same-origin unter /uploads/..., brauchen also keine remotePatterns-Konfiguration wie der entfernte Kommentar behauptete) -- Hauptbild mit priority/responsivem sizes, da es auf der Produktseite das wahrscheinlichste LCP-Element ist. - content-image.tsx: neue optionale priority-Prop; hero.tsx setzt sie fuer das Startseiten-Hero-Bild (ebenfalls LCP-Kandidat). - Sticky-Mobile-CTA-Leiste und useCartStock-Polling gegengeprueft: bereits korrekt (pb-28-Platzreservierung bzw. Fetch nur bei Warenkorb-Aenderung ohne Intervall) -- keine Aenderung noetig. Verifiziert: tsc --noEmit clean, pnpm test (142/142 gruen), pnpm build erfolgreich.
This commit is contained in:
1 parent
ac432e261b
commit
de0f6ee249
20 files changed
+137
-84
No files matched your search
@@ -76,7 +76,7 @@ export async function orderConfirmationEmail(order: OrderConfirmationInput): Pro
|
||||
const rows = order.items
|
||||
.map(
|
||||
(item) =>
|
||||
`<tr><td style="padding:6px 0;">${item.quantity} × ${item.productName} (${item.weightGrams} g)</td><td style="padding:6px 0;text-align:right;">${formatPrice(item.totalCents)}</td></tr>`
|
||||
`<tr><td style="padding:6px 0;">${item.quantity} × ${item.productName} (${item.weightGrams} g)</td><td style="padding:6px 0;text-align:right;">${formatPrice(item.totalCents, "EUR", order.locale)}</td></tr>`
|
||||
)
|
||||
.join("");
|
||||
|
||||
@@ -101,10 +101,10 @@ export async function orderConfirmationEmail(order: OrderConfirmationInput): Pro
|
||||
${rows}
|
||||
</table>
|
||||
<table role="presentation" width="100%" style="font-size:14px;margin-top:12px;">
|
||||
<tr><td>${s.subtotal}</td><td style="text-align:right;">${formatPrice(order.subtotalCents)}</td></tr>
|
||||
<tr><td>${s.shipping}</td><td style="text-align:right;">${order.shippingCents === 0 ? s.freeShipping : formatPrice(order.shippingCents)}</td></tr>
|
||||
${order.discountCents ? `<tr><td>${s.discount}</td><td style="text-align:right;">−${formatPrice(order.discountCents)}</td></tr>` : ""}
|
||||
<tr><td style="font-weight:bold;color:#24352B;padding-top:8px;">${s.total}</td><td style="text-align:right;font-weight:bold;color:#24352B;padding-top:8px;">${formatPrice(order.totalCents)}</td></tr>
|
||||
<tr><td>${s.subtotal}</td><td style="text-align:right;">${formatPrice(order.subtotalCents, "EUR", order.locale)}</td></tr>
|
||||
<tr><td>${s.shipping}</td><td style="text-align:right;">${order.shippingCents === 0 ? s.freeShipping : formatPrice(order.shippingCents, "EUR", order.locale)}</td></tr>
|
||||
${order.discountCents ? `<tr><td>${s.discount}</td><td style="text-align:right;">−${formatPrice(order.discountCents, "EUR", order.locale)}</td></tr>` : ""}
|
||||
<tr><td style="font-weight:bold;color:#24352B;padding-top:8px;">${s.total}</td><td style="text-align:right;font-weight:bold;color:#24352B;padding-top:8px;">${formatPrice(order.totalCents, "EUR", order.locale)}</td></tr>
|
||||
</table>
|
||||
${deliveryHtml}
|
||||
${giftHtml}
|
||||
@@ -113,10 +113,10 @@ export async function orderConfirmationEmail(order: OrderConfirmationInput): Pro
|
||||
);
|
||||
|
||||
const text = `${s.heading(order.firstName)}\n\n${order.orderNumber}\n\n${order.items
|
||||
.map((i) => `${i.quantity} x ${i.productName} (${i.weightGrams} g) — ${formatPrice(i.totalCents)}`)
|
||||
.join("\n")}\n\n${s.subtotal}: ${formatPrice(order.subtotalCents)}\n${s.shipping}: ${
|
||||
order.shippingCents === 0 ? s.freeShipping : formatPrice(order.shippingCents)
|
||||
}${order.discountCents ? `\n${s.discount}: −${formatPrice(order.discountCents)}` : ""}\n${s.total}: ${formatPrice(order.totalCents)}${
|
||||
.map((i) => `${i.quantity} x ${i.productName} (${i.weightGrams} g) — ${formatPrice(i.totalCents, "EUR", order.locale)}`)
|
||||
.join("\n")}\n\n${s.subtotal}: ${formatPrice(order.subtotalCents, "EUR", order.locale)}\n${s.shipping}: ${
|
||||
order.shippingCents === 0 ? s.freeShipping : formatPrice(order.shippingCents, "EUR", order.locale)
|
||||
}${order.discountCents ? `\n${s.discount}: −${formatPrice(order.discountCents, "EUR", order.locale)}` : ""}\n${s.total}: ${formatPrice(order.totalCents, "EUR", order.locale)}${
|
||||
order.giftMessage ? `\n\n${s.giftNote}` : ""
|
||||
}${order.trackingUrl ? `\n\n${s.trackOrder}: ${order.trackingUrl}` : ""}`;
|
||||
|
||||
|
||||
+27
-11
@@ -1,8 +1,24 @@
|
||||
import type { Locale } from "@/i18n/config";
|
||||
|
||||
// BCP-47-Tag je Locale fuer Intl.*Format — "en-GB" statt "en-US" fuer
|
||||
// Englisch, damit die Tagesreihenfolge (10 May 2026) der deutschen
|
||||
// Konvention (10. Mai 2026) naeher bleibt als das umgestellte US-Format
|
||||
// (May 10, 2026). Zahlungs-/Preisformatierung unterscheidet sich zwischen
|
||||
// beiden englischen Varianten fuer EUR ohnehin nicht.
|
||||
const INTL_LOCALE: Record<Locale, string> = {
|
||||
de: "de-DE",
|
||||
en: "en-GB",
|
||||
};
|
||||
|
||||
/**
|
||||
* Formatiert Cent-Betraege als deutsche Euro-Preisangabe, z.B. 990 -> "9,90 €".
|
||||
* Formatiert Cent-Betraege als Euro-Preisangabe in der uebergebenen Sprache,
|
||||
* z.B. 990 -> "9,90 €" (de) oder "€9.90" (en). Ohne "locale" faellt die
|
||||
* Funktion auf Deutsch zurueck — das gilt fuer interne/rechtlich gebundene
|
||||
* Ausgaben wie Rechnungen und den Admin-Bereich, die bewusst nicht der
|
||||
* Kunden-Locale folgen.
|
||||
*/
|
||||
export function formatPrice(cents: number, currency = "EUR"): string {
|
||||
return new Intl.NumberFormat("de-DE", {
|
||||
export function formatPrice(cents: number, currency = "EUR", locale: Locale = "de"): string {
|
||||
return new Intl.NumberFormat(INTL_LOCALE[locale], {
|
||||
style: "currency",
|
||||
currency,
|
||||
}).format(cents / 100);
|
||||
@@ -11,20 +27,20 @@ export function formatPrice(cents: number, currency = "EUR"): string {
|
||||
/**
|
||||
* Formatiert den Grundpreis (Preis pro Kilogramm), z.B. fuer Vergleichbarkeit im Shop.
|
||||
*/
|
||||
export function formatPricePerKg(cents: number, currency = "EUR"): string {
|
||||
return `${formatPrice(cents, currency)} / kg`;
|
||||
export function formatPricePerKg(cents: number, currency = "EUR", locale: Locale = "de"): string {
|
||||
return `${formatPrice(cents, currency, locale)} / kg`;
|
||||
}
|
||||
|
||||
export function formatDate(date: Date): string {
|
||||
return new Intl.DateTimeFormat("de-DE", {
|
||||
export function formatDate(date: Date, locale: Locale = "de"): string {
|
||||
return new Intl.DateTimeFormat(INTL_LOCALE[locale], {
|
||||
day: "2-digit",
|
||||
month: "long",
|
||||
year: "numeric",
|
||||
}).format(date);
|
||||
}
|
||||
|
||||
export function formatDateTime(date: Date): string {
|
||||
return new Intl.DateTimeFormat("de-DE", {
|
||||
export function formatDateTime(date: Date, locale: Locale = "de"): string {
|
||||
return new Intl.DateTimeFormat(INTL_LOCALE[locale], {
|
||||
day: "2-digit",
|
||||
month: "2-digit",
|
||||
year: "numeric",
|
||||
@@ -33,8 +49,8 @@ export function formatDateTime(date: Date): string {
|
||||
}).format(date);
|
||||
}
|
||||
|
||||
export function formatMonthYear(date: Date): string {
|
||||
return new Intl.DateTimeFormat("de-DE", {
|
||||
export function formatMonthYear(date: Date, locale: Locale = "de"): string {
|
||||
return new Intl.DateTimeFormat(INTL_LOCALE[locale], {
|
||||
month: "long",
|
||||
year: "numeric",
|
||||
}).format(date);
|
||||
|
||||
Reference in new issue
Block a user