import { Button, Hr, Section, Text } from "@react-email/components"; import { BaseLayout } from "./BaseLayout"; interface OrderItem { id: string; name: string; quantity: number; price: string; } interface OrderConfirmationProps { language: string; orderId: string; orderNumber: string; customerEmail: string; customerName: string; items: OrderItem[]; total: string; shippingAddress?: string; billingAddress?: string; phone?: string; siteUrl: string; dashboardUrl?: string; isAdmin?: boolean; } const translations: Record< string, { title: string; preview: string; greeting: string; orderReceived: string; orderNumber: string; items: string; quantity: string; total: string; shippingTo: string; questions: string; thankYou: string; adminTitle: string; adminPreview: string; adminGreeting: string; adminMessage: string; customerLabel: string; customerEmailLabel: string; billingAddressLabel: string; phoneLabel: string; viewDashboard: string; } > = { sr: { title: "Potvrda narudžbine", preview: "Vaša narudžbina je potvrđena", greeting: "Poštovani {name},", orderReceived: "Zahvaljujemo se na Vašoj narudžbini! Primili smo je i sada je u pripremi.", orderNumber: "Broj narudžbine", items: "Artikli", quantity: "Količina", total: "Ukupno", shippingTo: "Adresa za dostavu", questions: "Imate pitanja? Pišite nam na support@manoonoils.com", thankYou: "Hvala Vam što kupujete kod nas!", adminTitle: "Nova narudžbina!", adminPreview: "Nova narudžbina je primljena", adminGreeting: "Čestitamo na prodaji!", adminMessage: "Nova narudžbina je upravo primljena. Detalji su ispod:", customerLabel: "Kupac", customerEmailLabel: "Email kupca", billingAddressLabel: "Adresa za naplatu", phoneLabel: "Telefon", viewDashboard: "Pogledaj u Dashboardu", }, en: { title: "Order Confirmation", preview: "Your order has been confirmed", greeting: "Dear {name},", orderReceived: "Thank you for your order! We have received it and it is now being processed.", orderNumber: "Order number", items: "Items", quantity: "Quantity", total: "Total", shippingTo: "Shipping address", questions: "Questions? Email us at support@manoonoils.com", thankYou: "Thank you for shopping with us!", adminTitle: "New Order! 🎉", adminPreview: "A new order has been received", adminGreeting: "Congratulations on the sale!", adminMessage: "A new order has just been placed. Details below:", customerLabel: "Customer", customerEmailLabel: "Customer Email", billingAddressLabel: "Billing Address", phoneLabel: "Phone", viewDashboard: "View in Dashboard", }, de: { title: "Bestellungsbestätigung", preview: "Ihre Bestellung wurde bestätigt", greeting: "Sehr geehrte/r {name},", orderReceived: "Vielen Dank für Ihre Bestellung! Wir haben sie erhalten und sie wird nun bearbeitet.", orderNumber: "Bestellnummer", items: "Artikel", quantity: "Menge", total: "Gesamt", shippingTo: "Lieferadresse", questions: "Fragen? Schreiben Sie uns an support@manoonoils.com", thankYou: "Vielen Dank für Ihren Einkauf!", adminTitle: "Neue Bestellung! 🎉", adminPreview: "Eine neue Bestellung wurde erhalten", adminGreeting: "Glückwunsch zum Verkauf!", adminMessage: "Eine neue Bestellung wurde soeben aufgegeben. Details unten:", customerLabel: "Kunde", customerEmailLabel: "Kunden-E-Mail", billingAddressLabel: "Rechnungsadresse", phoneLabel: "Telefon", viewDashboard: "Im Dashboard anzeigen", }, fr: { title: "Confirmation de commande", preview: "Votre commande a été confirmée", greeting: "Cher(e) {name},", orderReceived: "Merci pour votre commande! Nous l'avons reçue et elle est en cours de traitement.", orderNumber: "Numéro de commande", items: "Articles", quantity: "Quantité", total: "Total", shippingTo: "Adresse de livraison", questions: "Questions? Écrivez-nous à support@manoonoils.com", thankYou: "Merci d'avoir Magasiné avec nous!", adminTitle: "Nouvelle commande! 🎉", adminPreview: "Une nouvelle commande a été reçue", adminGreeting: "Félicitations pour la vente!", adminMessage: "Une nouvelle commande vient d'être passée. Détails ci-dessous:", customerLabel: "Client", customerEmailLabel: "Email du client", billingAddressLabel: "Adresse de facturation", phoneLabel: "Téléphone", viewDashboard: "Voir dans le Dashboard", }, }; export function OrderConfirmation({ language = "en", orderId, orderNumber, customerEmail, customerName, items, total, shippingAddress, billingAddress, phone, siteUrl, dashboardUrl, isAdmin = false, }: OrderConfirmationProps) { const t = translations[language] || translations.en; // For admin emails, always use English const adminT = translations["en"]; if (isAdmin) { return ( {adminT.adminTitle} {adminT.adminGreeting} {adminT.adminMessage}
{adminT.orderNumber}: {orderNumber} {adminT.customerLabel}: {customerName} {adminT.customerEmailLabel}: {customerEmail} {phone && ( {adminT.phoneLabel}: {phone} )}
{adminT.items}
{items.map((item) => (
{item.quantity}x {item.name} {item.price}
))}
{adminT.total}: {total}
{shippingAddress && (
{adminT.shippingTo} {shippingAddress}
)} {billingAddress && (
{adminT.billingAddressLabel} {billingAddress}
)}
); } return ( {t.title} {t.greeting.replace("{name}", customerName)} {t.orderReceived}
{t.orderNumber}: {orderNumber}
{t.items}
{items.map((item) => (
{item.quantity}x {item.name} {item.price}
))}
{t.total}: {total}
{shippingAddress && (
{t.shippingTo} {shippingAddress}
)}
{t.questions} {t.thankYou}
); } const styles = { title: { fontSize: "24px", fontWeight: "bold" as const, color: "#1a1a1a", marginBottom: "20px", }, greeting: { fontSize: "16px", color: "#333333", marginBottom: "10px", }, text: { fontSize: "14px", color: "#666666", marginBottom: "20px", }, orderInfo: { backgroundColor: "#f9f9f9", padding: "15px", borderRadius: "8px", marginBottom: "20px", }, orderNumber: { fontSize: "14px", color: "#333333", margin: "0 0 8px 0", }, customerInfo: { fontSize: "14px", color: "#333333", margin: "0 0 4px 0", }, itemsSection: { marginBottom: "20px", }, sectionTitle: { fontSize: "16px", fontWeight: "bold" as const, color: "#1a1a1a", marginBottom: "10px", }, hr: { borderColor: "#e0e0e0", margin: "10px 0", }, itemRow: { display: "flex" as const, justifyContent: "space-between" as const, padding: "8px 0", }, itemName: { fontSize: "14px", color: "#333333", margin: "0", }, itemPrice: { fontSize: "14px", color: "#333333", margin: "0", }, totalRow: { display: "flex" as const, justifyContent: "space-between" as const, padding: "8px 0", }, totalLabel: { fontSize: "16px", fontWeight: "bold" as const, color: "#1a1a1a", margin: "0", }, totalValue: { fontSize: "16px", fontWeight: "bold" as const, color: "#1a1a1a", margin: "0", }, shippingSection: { marginBottom: "20px", }, shippingAddress: { fontSize: "14px", color: "#666666", margin: "0", }, buttonSection: { textAlign: "center" as const, marginBottom: "20px", }, button: { backgroundColor: "#000000", color: "#ffffff", padding: "12px 30px", borderRadius: "4px", fontSize: "14px", fontWeight: "bold" as const, textDecoration: "none", }, questions: { fontSize: "14px", color: "#666666", marginBottom: "10px", }, thankYou: { fontSize: "14px", fontWeight: "bold" as const, color: "#1a1a1a", }, };