// Seed structured pagedata for FAQ, Returns, Shipping, Privacy pages
const { query } = require("./src/database");

async function seedFaqData() {
  const faqData = {
    header: {
      title: "Frequently Asked Questions",
      subtitle: "Quick answers to common questions",
    },
    items: [
      {
        question: "How do I place an order?",
        answer:
          "Simply browse our shop, add items to your cart, and proceed to checkout. You can pay securely with credit card, debit card, or PayPal.",
      },
      {
        question: "Do you offer custom artwork?",
        answer:
          "Yes! We offer custom commissions for paintings and artwork. Contact us with your vision and we'll provide a quote and timeline.",
      },
      {
        question: "How long does shipping take?",
        answer:
          "Standard shipping takes 5-7 business days. Express shipping (2-3 days) and overnight options are available. Processing time is 1-2 business days.",
      },
      {
        question: "What payment methods do you accept?",
        answer:
          "We accept all major credit cards (Visa, Mastercard, American Express, Discover), debit cards, and PayPal.",
      },
      {
        question: "Can I cancel or modify my order?",
        answer:
          "You can cancel or modify your order within 24 hours of placing it. Contact us immediately at contact@skyartshop.com.",
      },
      {
        question: "Do you ship internationally?",
        answer:
          "Yes, we ship to Canada, UK, and Australia. International shipping costs vary by location and are calculated at checkout.",
      },
      {
        question: "What is your return policy?",
        answer:
          "We offer a 30-day return policy on most items. Items must be unused and in original packaging. See our Returns page for full details.",
      },
      {
        question: "How can I track my order?",
        answer:
          "Once your order ships, you'll receive an email with tracking information. You can also check your order status in your account.",
      },
    ],
  };

  await query(`UPDATE pages SET pagedata = $1 WHERE slug = 'faq'`, [
    JSON.stringify(faqData),
  ]);
  console.log("FAQ pagedata seeded");
}

async function seedReturnsData() {
  const returnsData = {
    header: {
      title: "Returns & Refunds",
      subtitle: "Our hassle-free return policy",
    },
    highlight:
      "We want you to love your purchase! If you're not completely satisfied, we offer a 30-day return policy on most items.",
    sections: [
      {
        title: "Return Eligibility",
        content:
          "To be eligible for a return, your item must meet the following conditions:",
        listItems: [
          "Returned within 30 days of delivery",
          "Unused and in the same condition that you received it",
          "In the original packaging with all tags attached",
          "Accompanied by the original receipt or proof of purchase",
        ],
      },
      {
        title: "Non-Returnable Items",
        content: "The following items cannot be returned:",
        listItems: [
          "Personalized or custom-made items",
          "Sale items marked as 'final sale'",
          "Gift cards or digital downloads",
          "Items marked as non-returnable at checkout",
          "Opened consumable items (inks, glues, adhesives)",
        ],
      },
      {
        title: "How to Start a Return",
        content: "To initiate a return, follow these simple steps:",
        listItems: [
          "Contact Us: Email support@skyartshop.com with your order number",
          "Get Authorization: Receive your return authorization number",
          "Pack & Ship: Securely package and ship your return",
          "Get Refund: Receive your refund within 5-7 business days",
        ],
      },
      {
        title: "Return Shipping",
        content:
          "For domestic returns, you'll receive a prepaid return shipping label via email. International customers are responsible for return shipping costs. We recommend using a trackable shipping service.",
        listItems: [],
      },
      {
        title: "Refund Process",
        content:
          "Once we receive your return, we will inspect the item and notify you of the approval or rejection of your refund. If approved, your refund will be processed within 2-3 business days and applied to your original payment method.",
        listItems: [],
      },
    ],
  };

  await query(`UPDATE pages SET pagedata = $1 WHERE slug = 'returns-refunds'`, [
    JSON.stringify(returnsData),
  ]);
  console.log("Returns pagedata seeded");
}

async function seedShippingData() {
  const shippingData = {
    header: {
      title: "Shipping Information",
      subtitle: "Fast, reliable delivery to your door",
    },
    sections: [
      {
        title: "Shipping Methods",
        content: "We offer several shipping options to meet your needs:",
        listItems: [
          "Standard Shipping: 5-7 business days - FREE on orders over $50",
          "Express Shipping: 2-3 business days - $12.99",
          "Overnight Shipping: Next business day - $24.99",
        ],
      },
      {
        title: "Processing Time",
        content:
          "Orders are processed within 1-2 business days. Orders placed after 2:00 PM EST will be processed the next business day. Custom or personalized items may require additional processing time.",
        listItems: [],
      },
      {
        title: "Delivery Areas",
        content: "We currently ship to the following locations:",
        listItems: [
          "United States (all 50 states)",
          "Canada",
          "United Kingdom",
          "Australia",
        ],
      },
      {
        title: "Order Tracking",
        content:
          "Once your order ships, you'll receive an email with your tracking number. You can track your package directly through the carrier's website or in your account dashboard.",
        listItems: [],
      },
      {
        title: "Shipping Restrictions",
        content:
          "Some items may have shipping restrictions due to size, weight, or destination regulations. These will be noted on the product page.",
        listItems: [],
      },
    ],
  };

  await query(`UPDATE pages SET pagedata = $1 WHERE slug = 'shipping-info'`, [
    JSON.stringify(shippingData),
  ]);
  console.log("Shipping pagedata seeded");
}

async function seedPrivacyData() {
  const privacyData = {
    header: {
      title: "Privacy Policy",
    },
    lastUpdated: "January 2025",
    sections: [
      {
        title: "Information We Collect",
        content:
          "We collect information you provide directly to us, such as when you create an account, make a purchase, subscribe to our newsletter, or contact us for support. This may include your name, email address, postal address, phone number, and payment information.",
      },
      {
        title: "How We Use Your Information",
        content:
          "We use the information we collect to process transactions, send order confirmations and shipping updates, respond to your comments and questions, send marketing communications (with your consent), improve our website and customer service, and comply with legal obligations.",
      },
      {
        title: "Information Sharing",
        content:
          "We do not sell, trade, or rent your personal information to third parties. We may share your information with service providers who assist us in operating our website, conducting our business, or servicing you, as long as they agree to keep this information confidential.",
      },
      {
        title: "Cookies and Tracking",
        content:
          "We use cookies and similar tracking technologies to track activity on our website and hold certain information. Cookies are files with small amounts of data which may include an anonymous unique identifier. You can instruct your browser to refuse all cookies or to indicate when a cookie is being sent.",
      },
      {
        title: "Data Security",
        content:
          "We implement a variety of security measures to maintain the safety of your personal information. All payment transactions are processed through secure, encrypted gateways and are not stored on our servers.",
      },
      {
        title: "Your Rights",
        content:
          "You have the right to access, update, or delete your personal information at any time. You can update your account information through your account settings or contact us directly for assistance.",
      },
      {
        title: "Contact Us",
        content:
          "If you have any questions about this Privacy Policy, please contact us at privacy@skyartshop.com.",
      },
    ],
  };

  await query(`UPDATE pages SET pagedata = $1 WHERE slug = 'privacy'`, [
    JSON.stringify(privacyData),
  ]);
  console.log("Privacy pagedata seeded");
}

async function seedContactData() {
  const contactData = {
    header: {
      title: "Get in Touch",
      subtitle:
        "Have a question, suggestion, or just want to say hello? We'd love to hear from you!",
    },
    phone: "(555) 123-4567",
    email: "hello@skyartshop.com",
    address: "123 Creative Lane, Artville, CA 90210",
    businessHours: [
      { day: "Monday - Friday", hours: "9:00 AM - 5:00 PM EST" },
      { day: "Saturday - Sunday", hours: "Closed" },
    ],
  };

  await query(`UPDATE pages SET pagedata = $1 WHERE slug = 'contact'`, [
    JSON.stringify(contactData),
  ]);
  console.log("Contact pagedata seeded");
}

async function main() {
  try {
    console.log("Seeding page structured data...");
    await seedFaqData();
    await seedReturnsData();
    await seedShippingData();
    await seedPrivacyData();
    await seedContactData();
    console.log("\nAll pagedata seeded successfully!");
    process.exit(0);
  } catch (error) {
    console.error("Error seeding data:", error);
    process.exit(1);
  }
}

main();
