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>
This commit is contained in:
@@ -494,37 +494,30 @@ export function NotifikasiTab() {
|
||||
|
||||
setTestingTemplate(template.id);
|
||||
try {
|
||||
// Fetch email settings from notification_settings
|
||||
const { data: emailData } = await supabase
|
||||
.from('notification_settings')
|
||||
.select('*')
|
||||
// Fetch platform settings to get brand name
|
||||
const { data: platformData } = await supabase
|
||||
.from('platform_settings')
|
||||
.select('brand_name')
|
||||
.single();
|
||||
|
||||
if (!emailData || !emailData.api_token || !emailData.from_email) {
|
||||
throw new Error('Konfigurasi email provider belum lengkap');
|
||||
}
|
||||
const brandName = platformData?.brand_name || 'ACCESS HUB';
|
||||
|
||||
// Import EmailTemplateRenderer and ShortcodeProcessor
|
||||
const { EmailTemplateRenderer, ShortcodeProcessor } = await import('@/lib/email-templates/master-template');
|
||||
// Import ShortcodeProcessor to get dummy data
|
||||
const { ShortcodeProcessor } = await import('@/lib/email-templates/master-template');
|
||||
|
||||
// Process shortcodes and render with master template
|
||||
const processedSubject = ShortcodeProcessor.process(template.email_subject || '');
|
||||
const processedContent = ShortcodeProcessor.process(template.email_body_html || '');
|
||||
const fullHtml = EmailTemplateRenderer.render({
|
||||
subject: processedSubject,
|
||||
content: processedContent,
|
||||
brandName: 'ACCESS HUB'
|
||||
});
|
||||
// Get default dummy data for all template variables
|
||||
const dummyData = ShortcodeProcessor.getDummyData();
|
||||
|
||||
// Send test email using send-email-v2
|
||||
const { data, error } = await supabase.functions.invoke('send-email-v2', {
|
||||
// Send test email using send-notification (same as IntegrasiTab)
|
||||
const { data, error } = await supabase.functions.invoke('send-notification', {
|
||||
body: {
|
||||
recipient: template.test_email,
|
||||
api_token: emailData.api_token,
|
||||
from_name: emailData.from_name,
|
||||
from_email: emailData.from_email,
|
||||
subject: processedSubject,
|
||||
content: fullHtml,
|
||||
template_key: template.key,
|
||||
recipient_email: template.test_email,
|
||||
recipient_name: dummyData.nama,
|
||||
variables: {
|
||||
...dummyData,
|
||||
platform_name: brandName,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user