"use strict";

module.exports = {
  up: async (queryInterface, Sequelize) => {
    const templates = [
      {
        id: Sequelize.fn("UUID"),
        name: "KYB Application Submitted",
        slug: "kyb_submitted",
        subject: "Airpero — KYB Application Received",
        bodyHtml: `
<p style="font-size: 22px; font-weight: 800; color: #1a1a2e;">KYB Application Submitted 🚀</p>
<p>Hi <strong>{{merchantName}}</strong>,</p>
<p>We have successfully received your Know Your Business (KYB) application.</p>
<p>Our compliance team will review your submitted details and documents shortly. We will notify you of any updates or if additional information is required.</p>
`,
        availableVariables: "{{merchantName}}",
        createdAt: new Date(),
        updatedAt: new Date(),
      },
      {
        id: Sequelize.fn("UUID"),
        name: "KYB Application Under Review",
        slug: "kyb_under_review",
        subject: "Airpero — KYB Application Under Review",
        bodyHtml: `
<p style="font-size: 22px; font-weight: 800; color: #2563eb;">Application Under Review 🔎</p>
<p>Hi <strong>{{merchantName}}</strong>,</p>
<p>Our compliance team is currently reviewing your KYB application.</p>
<p>We will notify you as soon as a decision is made or if we need any more details from you.</p>
`,
        availableVariables: "{{merchantName}}",
        createdAt: new Date(),
        updatedAt: new Date(),
      },
      {
        id: Sequelize.fn("UUID"),
        name: "KYB Additional Documents Required",
        slug: "kyb_additional_docs",
        subject: "Airpero — KYB Update: Additional Information Required",
        bodyHtml: `
<p style="font-size: 22px; font-weight: 800; color: #d97706;">Action Required ⚠️</p>
<p>Hi <strong>{{merchantName}}</strong>,</p>
<p>We need some additional information to proceed with your KYB application:</p>
<div style="background: #fffbeb; border-left: 4px solid #f59e0b; padding: 10px; margin-top: 10px;">
  <strong>{{reason}}</strong>
</div>
<p>Please log in to your dashboard to upload the requested documents or update your details.</p>
`,
        availableVariables: "{{merchantName}}, {{reason}}",
        createdAt: new Date(),
        updatedAt: new Date(),
      },
      {
        id: Sequelize.fn("UUID"),
        name: "KYB Application Approved",
        slug: "kyb_approved",
        subject: "Airpero — KYB Application Approved",
        bodyHtml: `
<p style="font-size: 22px; font-weight: 800; color: #16a34a;">KYB Approved ✅</p>
<p>Hi <strong>{{merchantName}}</strong>,</p>
<p>Congratulations! Your KYB application has been fully approved.</p>
<p>Your account limits have been lifted, and you now have full access to all Merchant features.</p>
`,
        availableVariables: "{{merchantName}}",
        createdAt: new Date(),
        updatedAt: new Date(),
      },
      {
        id: Sequelize.fn("UUID"),
        name: "KYB Application Rejected",
        slug: "kyb_rejected",
        subject: "Airpero — KYB Application Declined",
        bodyHtml: `
<p style="font-size: 22px; font-weight: 800; color: #dc2626;">KYB Application Declined ❌</p>
<p>Hi <strong>{{merchantName}}</strong>,</p>
<p>Unfortunately, your KYB application has been declined for the following reason:</p>
<div style="background: #fef2f2; border-left: 4px solid #ef4444; padding: 10px; margin-top: 10px;">
  <strong>{{reason}}</strong>
</div>
<p>Please contact support if you believe this is an error.</p>
`,
        availableVariables: "{{merchantName}}, {{reason}}",
        createdAt: new Date(),
        updatedAt: new Date(),
      }
    ];

    await queryInterface.bulkInsert("EmailTemplates", templates, {});
  },

  down: async (queryInterface, Sequelize) => {
    const slugs = [
      "kyb_submitted",
      "kyb_under_review",
      "kyb_additional_docs",
      "kyb_approved",
      "kyb_rejected"
    ];
    await queryInterface.bulkDelete("EmailTemplates", { slug: slugs }, {});
  },
};
