import type { Core } from '@strapi/strapi';

export default {
  /**
   * An asynchronous register function that runs before
   * your application is initialized.
   *
   * This gives you an opportunity to extend code.
   */
  register(/* { strapi }: { strapi: Core.Strapi } */) {},

  /**
   * An asynchronous bootstrap function that runs before
   * your application gets started.
   *
   * This gives you an opportunity to set up your data model,
   * run jobs, or perform some special logic.
   */
  async bootstrap({ strapi }: { strapi: Core.Strapi }) {
    try {
      // Use the Document Service API for Strapi 5
      const pageContent = await strapi.documents('api::page-content.page-content').findFirst();
      if (pageContent && !pageContent.heroTitle) {
        await strapi.documents('api::page-content.page-content').update({
          documentId: pageContent.documentId,
          data: {
            heroTitle: 'Shaping the Future <br/>Through <span className="text-gradient">Excellence</span>',
            heroSubtitle: 'We deliver premium end-to-end solutions for our Completed Projects, On Progress Projects, and Interior Design. Elevating environments from concept to realization.',
            heroButtonText: 'View Portfolio',
            aboutTitle: 'A Legacy of <br/>Craftsmanship',
            aboutSubtitle: 'Who We Are',
            aboutParagraph1: 'Incorporated on 14 February 2012, <strong>Win Modern Design</strong> is a premier Interior Design firm specialising in both Residential and Commercial projects, with a distinct focus on contemporary architecture and bespoke detailing.',
            aboutButtonText: 'Read More',
            expertiseSubtitle: 'Our Expertise',
            expertiseTitle: 'End-to-End <span className="text-gradient">Solutions</span>',
            expertiseDescription: 'We deliver holistic services that transform spaces from concept to completion. Our multidisciplinary team ensures every detail is meticulously crafted to exceed expectations.',
            contactTitle: 'WIN HQ',
            contactAddress: '<strong>Win Modern Design Sdn. Bhd.</strong> (201201004534 (978059-M))<br/>Unit 6-01, Level 6, Plaza DNP,<br/>No. 59, Jalan Dato Abdullah Tahir,<br/>80300 Johor Bahru, Johor,<br/>Malaysia.',
            contactPhone: '+60 7 330 5981',
            contactEmail: 'info@wingroup.com.my',
            footerAboutText: '&copy; 2026 - Win Modern Design Sdn. Bhd. (201201004534 (978059-M)) All Rights Reserved.'
          }
        });
        console.log("Successfully seeded default text into Page Content!");
      }
    } catch (err) {
      console.log("Failed to seed Page Content:", err);
    }
  },
};
