Add n8n test mode toggle and edge function improvements

- Add test/production toggle for n8n webhook URLs in IntegrasiTab
- Update create-meet-link function to use database test_mode setting
- Add send-email-v2 edge function for Mailketing API integration
- Update daily-reminders and send-consultation-reminder to use send-email-v2
- Remove deprecated branding field from BrandingTab
- Update domain references from hub.dwindi.com to with.dwindi.com
- Add environment variables for Coolify deployment
- Add comprehensive edge function test script
- Update payment flow redirect to order detail page

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
dwindown
2025-12-23 00:24:40 +07:00
parent f1cc2ba3f7
commit dfda71053c
11 changed files with 385 additions and 49 deletions

View File

@@ -69,7 +69,63 @@ serve(async (req: Request): Promise<Response> => {
if (!profile?.email) continue;
// Call send-notification function
const { error: notifyError } = await supabase.functions.invoke("send-notification", {
// Get notification template and settings to send via send-email-v2
const { data: template } = await supabase
.from("notification_templates")
.select("*")
.eq("key", "consulting_reminder")
.eq("is_active", true)
.single();
const { data: emailSettings } = await supabase
.from("notification_settings")
.select("*")
.single();
let notifyError = null;
if (template && emailSettings?.api_token) {
// Build payload with proper shortcode mapping
const payload = {
nama: profile.full_name,
email: profile.email,
tanggal_konsultasi: new Date(slot.date).toLocaleDateString('id-ID', {
weekday: 'long',
year: 'numeric',
month: 'long',
day: 'numeric'
}),
jam_konsultasi: `${slot.start_time.substring(0, 5)} - ${slot.end_time.substring(0, 5)} WIB`,
link_meet: slot.meet_link || "Akan diinformasikan",
jenis_konsultasi: slot.topic_category,
};
// Process shortcodes in template
let emailBody = template.email_body_html || "";
let emailSubject = template.email_subject || "Reminder Konsultasi";
Object.entries(payload).forEach(([key, value]) => {
const regex = new RegExp(`\\{${key}\\}`, "g");
emailBody = emailBody.replace(regex, String(value));
emailSubject = emailSubject.replace(regex, String(value));
});
// Send via send-email-v2 (Mailketing API)
const { error: emailError } = await supabase.functions.invoke("send-email-v2", {
body: {
to: profile.email,
api_token: emailSettings.api_token,
from_name: emailSettings.from_name || "Access Hub",
from_email: emailSettings.from_email || "noreply@with.dwindi.com",
subject: emailSubject,
html_body: emailBody,
},
});
notifyError = emailError;
} else {
notifyError = { message: "Template not active or email not configured" };
}
body: {
template_key: "consultation_reminder",
recipient_email: profile.email,