diff --git a/api/application.js b/api/application.js index bd30d50..ab168ea 100644 --- a/api/application.js +++ b/api/application.js @@ -4,7 +4,7 @@ const { Pool } = require('pg'); const nodemailer = require('nodemailer'); const { syncApplication } = require('./google-sheets'); -const { createPayment } = require('./mollie'); +const { createPayment, TICKET_LABELS, calculateAmount } = require('./mollie'); // Initialize PostgreSQL connection pool const pool = new Pool({ @@ -24,10 +24,23 @@ const smtp = nodemailer.createTransport({ tls: { rejectUnauthorized: false }, }); +// Week labels for email display +const WEEK_LABELS = { + week1: 'Week 1: Return to the Commons (Aug 24-30)', + week2: 'Week 2: Post-Capitalist Production (Aug 31-Sep 6)', + week3: 'Week 3: Future Living (Sep 7-13)', + week4: 'Week 4: Governance & Funding Models (Sep 14-20)', +}; + // Email templates -const confirmationEmail = (application) => ({ - subject: 'Application Received - Valley of the Commons', - html: ` +const confirmationEmail = (application) => { + const ticketLabel = TICKET_LABELS[application.contribution_amount] || application.contribution_amount || 'Not selected'; + const amount = application.contribution_amount ? calculateAmount(application.contribution_amount, (application.weeks || []).length) : null; + const weeksHtml = (application.weeks || []).map(w => `
We've received your application to join Valley of the Commons (August 24 - September 20, 2026).
+| Ticket: | +${ticketLabel} | +
| Amount: | +€${amount} | +
| Attendance: | +${application.attendance_type === 'full' ? 'Full 4 weeks' : 'Partial'} | +
Weeks selected: