refactor(email): abstract email system with proper architecture

- Create service layer for email generation (PaymentMethodService, OrderTransformerService, EmailBuilderService)
- Extract all hardcoded values to configuration files
- Add proper TypeScript types for all email data structures
- Update GraphQL subscription to include transactions and events
- Refactor order-created, order-cancelled templates to use new architecture
- Payment method now dynamically detected from order transactions

This makes the email system:
- Testable: Each service can be unit tested independently
- Configurable: All values in config.ts, no hardcoding
- Extensible: Easy to add new languages or payment methods
- Maintainable: Clear separation of concerns
This commit is contained in:
Unchained
2026-03-29 17:33:15 +02:00
parent 28b864ecdb
commit 6492619cbc
12 changed files with 894 additions and 375 deletions
+1 -1
View File
@@ -4,7 +4,7 @@ import {
OrderCancelledWebhookPayloadFragment,
} from "@/generated/graphql";
import { saleorApp } from "@/saleor-app";
import { getOrderCancelledEmails } from "@/lib/email-templates";
import { getOrderCancelledEmails } from "@/lib/email-templates/order-cancelled";
import { Resend } from "resend";
const resend = new Resend(process.env.RESEND_API_KEY);