Files
meet-hub/supabase/migrations/20250103000002_add_test_email_template.sql
dwindown 053465afa3 Fix email system and implement OTP confirmation flow
Email System Fixes:
- Fix email sending after payment: handle-order-paid now calls send-notification
  instead of send-email-v2 directly, properly processing template variables
- Fix order_created email timing: sent immediately after order creation,
  before payment QR code generation
- Update email templates to use short order ID (8 chars) instead of full UUID
- Add working "Akses Sekarang" buttons to payment_success and access_granted emails
- Add platform_url column to platform_settings for email links

OTP Verification Flow:
- Create dedicated /confirm-otp page for users who close registration modal
- Add link in checkout modal and email to dedicated OTP page
- Update OTP email template with better copywriting and dedicated page link
- Fix send-auth-otp to fetch platform settings for dynamic brand_name and platform_url
- Auto-login users after OTP verification in checkout flow

Admin Features:
- Add delete user functionality with cascade deletion of all related data
- Update IntegrasiTab to read/write email settings from platform_settings only
- Add test email template for email configuration testing

Cleanup:
- Remove obsolete send-consultation-reminder and send-test-email functions
- Update send-email-v2 to read email config from platform_settings
- Remove footer links (Ubah Preferensi/Unsubscribe) from email templates

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-03 18:02:25 +07:00

49 lines
1.3 KiB
SQL

-- Add test_email template for "Uji Coba Email" button in Integrasi tab
INSERT INTO notification_templates (key, name, email_subject, email_body_html, is_active, created_at, updated_at)
VALUES (
'test_email',
'Test Email',
'Email Test - {platform_name}',
'
<div style="font-family: Arial, sans-serif; max-width: 600px; margin: 0 auto; padding: 20px;">
<h2 style="color: #333;">Email Test - {platform_name}</h2>
<p>Halo,</p>
<p>Ini adalah email tes dari sistem <strong>{platform_name}</strong>.</p>
<div style="margin: 20px 0; padding: 15px; background-color: #f0f0f0; border-left: 4px solid #000;">
<p style="margin: 0; font-size: 14px;">
<strong>✓ Konfigurasi email berhasil!</strong><br>
Email Anda telah terkirim dengan benar menggunakan provider: <strong>Mailketing</strong>
</p>
</div>
<p style="font-size: 14px; color: #666;">
Jika Anda menerima email ini, berarti konfigurasi email sudah benar.
</p>
<p style="font-size: 14px;">
Terima kasih,<br>
Tim {platform_name}
</p>
</div>
',
true,
NOW(),
NOW()
)
ON CONFLICT (key) DO UPDATE SET
email_subject = EXCLUDED.email_subject,
email_body_html = EXCLUDED.email_body_html,
updated_at = NOW();
-- Verify the template
SELECT
key,
name,
email_subject,
is_active
FROM notification_templates
WHERE key = 'test_email';