const { Pool } = require("pg");

const pool = new Pool({
  host: "localhost",
  port: 5432,
  database: "skyartshop",
  user: "skyartapp",
  password: "SkyArt2025Pass",
});

const defaultPrivacyContent = `<p>At Sky Art Shop, we take your privacy seriously. This Privacy Policy explains how we collect, use, disclose, and safeguard your information when you visit our website and make purchases from our store.</p>

<h2><strong>Information We Collect</strong></h2>
<p>We collect information you provide directly to us when you:</p>
<ul>
<li>Create an account or make a purchase</li>
<li>Subscribe to our newsletter</li>
<li>Contact our customer service</li>
<li>Participate in surveys or promotions</li>
<li>Post reviews or comments</li>
</ul>
<p>This information may include your name, email address, shipping address, phone number, and payment information.</p>

<h2><strong>How We Use Your Information</strong></h2>
<p>We use the information we collect to:</p>
<ul>
<li>Process and fulfill your orders</li>
<li>Send you order confirmations and shipping updates</li>
<li>Respond to your questions and provide customer support</li>
<li>Send you promotional emails (with your consent)</li>
<li>Improve our website and services</li>
<li>Prevent fraud and enhance security</li>
<li>Comply with legal obligations</li>
</ul>

<h2><strong>Information Sharing</strong></h2>
<p>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 and conducting our business.</p>

<h2><strong>Cookies and Tracking</strong></h2>
<p>We use cookies and similar tracking technologies to track activity on our website. You can instruct your browser to refuse all cookies or to indicate when a cookie is being sent.</p>

<h2><strong>Data Security</strong></h2>
<p>We implement security measures to maintain the safety of your personal information. All payment transactions are processed through secure, encrypted gateways.</p>

<h2><strong>Your Rights</strong></h2>
<p>You have the right to access, update, or delete your personal information at any time. Contact us for assistance.</p>

<h2><strong>Contact Us</strong></h2>
<p>If you have questions about this Privacy Policy, please contact us at privacy@skyartshop.com.</p>`;

const pageData = {
  header: {
    title: "Privacy Policy",
    subtitle: "How we protect and use your information",
  },
  lastUpdated: "January 18, 2026",
  mainContent: defaultPrivacyContent,
  contactBox: {
    title: "Privacy Questions?",
    message:
      "If you have any questions about this Privacy Policy, please contact us:",
    email: "privacy@skyartshop.com",
    phone: "(555) 123-4567",
    address: "Sky Art Shop, 123 Creative Lane, City, ST 12345",
  },
};

async function restorePrivacyContent() {
  try {
    const result = await pool.query(
      `UPDATE pages 
       SET pagedata = $1 
       WHERE slug = 'privacy'
       RETURNING id, slug`,
      [JSON.stringify(pageData)],
    );

    if (result.rowCount > 0) {
      console.log("✓ Privacy policy content restored successfully");
      console.log("  Page ID:", result.rows[0].id);
    } else {
      console.log("✗ Privacy page not found in database");
    }
  } catch (error) {
    console.error("Error restoring privacy content:", error);
  } finally {
    await pool.end();
  }
}

restorePrivacyContent();
