/**
 * Email Configuration - All configurable values extracted from hardcoded locations
 * This makes the system configurable without changing code
 */

import type { 
  LanguageCode, 
  EmailTemplateConfig, 
  AdminEmailTemplateConfig, 
  PaymentMethodConfig,
  EmailServiceConfig 
} from "./types";

// Payment method configurations - easily extendable
export const paymentMethodConfigs: Record<string, PaymentMethodConfig> = {
  card: {
    id: "card",
    label: "Card",
  },
  cod: {
    id: "cod",
    label: "Cash on Delivery",
  },
  paypal: {
    id: "paypal",
    label: "PayPal",
  },
  bank_transfer: {
    id: "bank_transfer",
    label: "Bank Transfer",
  },
  unknown: {
    id: "unknown",
    label: "Unknown",
  },
};

// Customer email translations - configuration driven
export const emailTranslations: Record<LanguageCode, EmailTemplateConfig> = {
  en: {
    subject: "Order {{orderNumber}} Confirmed",
    title: "Order Confirmed",
    greeting: "Dear {{customerName}},",
    body: "Thank you for your order! We have received it and it is now being processed.",
    orderLabel: "Order:",
    dateLabel: "Date:",
    statusLabel: "Status:",
    itemsLabel: "Items",
    subtotalLabel: "Subtotal:",
    shippingLabel: "Shipping:",
    taxLabel: "Tax:",
    totalLabel: "Total:",
    shippingAddressLabel: "Shipping Address",
    phoneLabel: "Phone:",
    phoneNotProvided: "Not provided",
    viewOrderButton: "View Order",
    thankYou: "Thank you!",
    companyName: "ManoonOils",
    footerText: "support@manoonoils.com",
  },
  sr: {
    subject: "Porudžbina {{orderNumber}} Potvrđena",
    title: "Porudžbina Potvrđena",
    greeting: "Poštovani {{customerName}},",
    body: "Hvala vam na porudžbini! Primili smo je i sada je obrađujemo.",
    orderLabel: "Porudžbina:",
    dateLabel: "Datum:",
    statusLabel: "Status:",
    itemsLabel: "Artikli",
    subtotalLabel: "Međuzbir:",
    shippingLabel: "Dostava:",
    taxLabel: "Porez:",
    totalLabel: "Ukupno:",
    shippingAddressLabel: "Adresa za Dostavu",
    phoneLabel: "Telefon:",
    phoneNotProvided: "Nije navedeno",
    viewOrderButton: "Pogledaj Porudžbinu",
    thankYou: "Hvala vam!",
    companyName: "ManoonOils",
    footerText: "support@manoonoils.com",
  },
  de: {
    subject: "Bestellung {{orderNumber}} Bestätigt",
    title: "Bestellung Bestätigt",
    greeting: "Sehr geehrte/r {{customerName}},",
    body: "Vielen Dank für Ihre Bestellung! Wir haben sie erhalten und bearbeiten sie jetzt.",
    orderLabel: "Bestellung:",
    dateLabel: "Datum:",
    statusLabel: "Status:",
    itemsLabel: "Artikel",
    subtotalLabel: "Zwischensumme:",
    shippingLabel: "Versand:",
    taxLabel: "Steuer:",
    totalLabel: "Gesamt:",
    shippingAddressLabel: "Lieferadresse",
    phoneLabel: "Telefon:",
    phoneNotProvided: "Nicht angegeben",
    viewOrderButton: "Bestellung Ansehen",
    thankYou: "Vielen Dank!",
    companyName: "ManoonOils",
    footerText: "support@manoonoils.com",
  },
  fr: {
    subject: "Commande {{orderNumber}} Confirmée",
    title: "Commande Confirmée",
    greeting: "Cher/Chère {{customerName}},",
    body: "Merci pour votre commande! Nous l'avons reçue et elle est en cours de traitement.",
    orderLabel: "Commande:",
    dateLabel: "Date:",
    statusLabel: "Statut:",
    itemsLabel: "Articles",
    subtotalLabel: "Sous-total:",
    shippingLabel: "Livraison:",
    taxLabel: "Taxe:",
    totalLabel: "Total:",
    shippingAddressLabel: "Adresse de Livraison",
    phoneLabel: "Téléphone:",
    phoneNotProvided: "Non fourni",
    viewOrderButton: "Voir la Commande",
    thankYou: "Merci!",
    companyName: "ManoonOils",
    footerText: "support@manoonoils.com",
  },
};

// Admin email translations - always in English but configurable
export const adminEmailTranslations: AdminEmailTemplateConfig = {
  adminTitle: "New Order! 🎉",
  adminOrderLabel: "Order",
  customerLabel: "Customer",
  nameLabel: "Name:",
  emailLabel: "Email:",
  dashboardButton: "Dashboard",
};

// Default payment label for admin emails
export const adminPaymentConfig = {
  paymentLabel: "Payment:",
};

// Email service configuration - loaded from environment or defaults
export const emailServiceConfig: EmailServiceConfig = {
  fromEmail: process.env.EMAIL_FROM_ADDRESS || "support@mail.manoonoils.com",
  fromName: process.env.EMAIL_FROM_NAME || "Manoon Oils",
  adminEmails: process.env.ADMIN_EMAILS?.split(",") || [
    "me@hytham.me",
    "tamara@hytham.me",
  ],
  companyName: process.env.COMPANY_NAME || "ManoonOils",
  companyLogoUrl:
    process.env.COMPANY_LOGO_URL ||
    "https://minio-api.nodecrew.me/manoon-media/2024/09/cropped-manoon-logo_256x-1-1.png",
  dashboardUrl: process.env.DASHBOARD_URL || "https://dashboard.manoonoils.com",
  storefrontUrl: process.env.STOREFRONT_URL || "https://manoonoils.com",
  trackingUrl: process.env.TRACKING_URL || "https://track.manoonoils.com",
};

// Locale configurations for date formatting
export const localeConfigs: Record<LanguageCode, string> = {
  en: "en-US",
  sr: "sr-RS",
  de: "de-DE",
  fr: "fr-FR",
};

// Default fallback language
export const DEFAULT_LANGUAGE: LanguageCode = "en";

// Default currency
export const DEFAULT_CURRENCY = "EUR";
