// Fix reminder templates const { PrismaClient } = require('@prisma/client'); const prisma = new PrismaClient(); const DEFAULT_TEMPLATES = [ { trigger: "booking_confirmed", offsetMinutes: 0, sortOrder: 1, isActive: true, message: `Hi {{name}}! ✅ Your {{treatment}} appointment at {{clinic}} is confirmed: 📅 {{date}} 🕐 {{time}} ✅ *Tap here to confirm:* {{confirmLink}} Or simply reply *YES* to confirm. If you need to reschedule, reply *RESCHEDULE* and we'll find a new time for you. We're looking forward to seeing you! 😊`, }, { trigger: "1_day_before", offsetMinutes: -1440, sortOrder: 2, isActive: true, message: `Hi {{name}}! Your appointment is *tomorrow*: 📅 {{date}} at {{time}} 📍 {{clinic}} Please arrive 10 minutes early. ✅ *Tap here to confirm:* {{confirmLink}} Or reply *CONFIRM* if you're all set ✅ Reply *RESCHEDULE* if you need to change 📅 We're looking forward to seeing you!`, }, { trigger: "2_hours_before", offsetMinutes: -120, sortOrder: 3, isActive: true, message: `See you in 2 hours, {{name}}! 🙌 Your {{treatment}} appointment: 🕐 {{time}} at {{clinic}} Safe travels! 😊`, }, ]; async function main() { console.log('🔧 Fixing reminder templates...'); // Get the clinic const clinic = await prisma.clinic.findFirst(); if (!clinic) { console.log('❌ No clinic found!'); return; } console.log(`🏥 Using clinic: ${clinic.name}`); // Clear old templates and add new ones await prisma.reminderTemplate.deleteMany({ where: { clinicId: clinic.id } }); for (const template of DEFAULT_TEMPLATES) { await prisma.reminderTemplate.create({ data: { ...template, clinicId: clinic.id, }, }); } console.log(`✅ Added ${DEFAULT_TEMPLATES.length} active reminder templates`); // Verify const count = await prisma.reminderTemplate.count({ where: { clinicId: clinic.id, isActive: true } }); console.log(`📊 Total active templates: ${count}`); await prisma.$disconnect(); } main().catch(console.error);