-- Recreates the About Us / Contact Us / Portal CMS pages (dim_web_pages) — these existed
-- earlier in the same work but were removed and rebuilt here after a client-charset bug
-- (mysql defaulting to cp850, not utf8mb4) corrupted em-dashes in several other pages;
-- deploy this one with --default-character-set=utf8mb4 same as the others.
-- Idempotent (guarded by slug existence per site), additive only.
-- Deploy: mysql --default-character-set=utf8mb4 -u root -p db_abos_v0.1 < db/larcare_core_pages_seed.sql

USE db_abos_v0.1;

SET @site_id = (SELECT id FROM dim_web_sites WHERE primary_domain = 'larcareservices.com' LIMIT 1);
SET @tenant_id = (SELECT tenant_id FROM dim_web_sites WHERE id = @site_id);
SET @business_id = (SELECT business_id FROM dim_web_sites WHERE id = @site_id);

-- ================= About Us =================
INSERT INTO dim_web_pages (tenant_id, business_id, site_id, slug, title, route, status, layout_json, meta_title)
SELECT @tenant_id, @business_id, @site_id, 'about-us', 'About Us', '/about-us', 'published', JSON_OBJECT(
  'version', 1,
  'blocks', JSON_ARRAY(
    JSON_OBJECT('id', 'about-hero', 'type', 'hero', 'props', JSON_OBJECT(
      'heading', 'Larry Puts the Care in LarCare',
      'imageUrl', '/images/hero/about-hero.jpg'
    ), 'children', JSON_ARRAY()),
    JSON_OBJECT('id', 'about-intro', 'type', 'richText', 'props', JSON_OBJECT('html',
      '<h2 style="text-align:center">Learn More About LarCare</h2><p style="text-align:center">At LarCare, our highly skilled healthcare professionals are dedicated to providing specialized home healthcare services. Our mission is to support our patients'' desire to maintain their independence within the comfort of their own homes. Prioritizing home healthcare, we ensure every aspect of our service reflects our commitment to your health and autonomy.</p>'
    ), 'children', JSON_ARRAY()),
    JSON_OBJECT('id', 'about-letter', 'type', 'richText', 'props', JSON_OBJECT('html',
      '<p>Dear Valued Patient and Family,</p><p>Thank you for selecting LarCare Inc. as your in-home care provider. We are deeply honored to support your journey towards recovery and wellness. At LarCare, our mission is to meet your healthcare needs through a partnership that delivers an unparalleled care experience.</p><p>You are at the heart of everything we do. Our team, fueled by a passion for home health care, offers a comprehensive suite of services including Skilled Nursing, Physical Therapy, Occupational Therapy, Speech Therapy, Medical Social Work, Private Duty Nursing, and Personal Care Assistance.</p><p>Thank you for entrusting us with your care.</p><p>Warm regards,<br>Larry Talford</p>'
    ), 'children', JSON_ARRAY()),
    JSON_OBJECT('id', 'about-mission-columns', 'type', 'columns', 'props', JSON_OBJECT('columnCount', 2, 'gapPx', 32), 'children', JSON_ARRAY(
      JSON_OBJECT('id', 'about-mission-text', 'type', 'richText', 'props', JSON_OBJECT('html',
        '<h2>Our Mission</h2><p>Our mission is to empower our clients by delivering personalized in-home healthcare services, fostering independence, and enhancing quality of life through professional and compassionate care. We strive for greatness as the standard for In-Home Healthcare needs.</p>'
      ), 'children', JSON_ARRAY()),
      JSON_OBJECT('id', 'about-mission-image', 'type', 'image', 'props', JSON_OBJECT('url', '/images/hero/mission.jpg', 'altText', 'Our mission'), 'children', JSON_ARRAY())
    ))
  )
), 'About LarCare | LarCare Services'
WHERE @site_id IS NOT NULL
  AND NOT EXISTS (SELECT 1 FROM dim_web_pages WHERE site_id = @site_id AND slug = 'about-us');

-- ================= Contact Us =================
INSERT INTO dim_web_pages (tenant_id, business_id, site_id, slug, title, route, status, layout_json, meta_title)
SELECT @tenant_id, @business_id, @site_id, 'contact-us', 'Contact Us', '/about-us/contact-us', 'published', JSON_OBJECT(
  'version', 1,
  'blocks', JSON_ARRAY(
    JSON_OBJECT('id', 'contact-hero', 'type', 'hero', 'props', JSON_OBJECT('heading', 'Contact Us', 'imageUrl', '/images/hero/contact-hero.jpg'), 'children', JSON_ARRAY()),
    JSON_OBJECT('id', 'contact-intro', 'type', 'richText', 'props', JSON_OBJECT('html',
      '<h2>Need assistance?</h2><p>Please complete the contact form.</p>'
    ), 'children', JSON_ARRAY()),
    JSON_OBJECT('id', 'contact-form', 'type', 'formEmbed', 'props', JSON_OBJECT('formKey', 'contact'), 'children', JSON_ARRAY()),
    JSON_OBJECT('id', 'contact-image', 'type', 'image', 'props', JSON_OBJECT('url', '/images/hero/contact-team.jpg', 'altText', 'The LarCare team'), 'children', JSON_ARRAY())
  )
), 'Contact Us | LarCare Services'
WHERE @site_id IS NOT NULL
  AND NOT EXISTS (SELECT 1 FROM dim_web_pages WHERE site_id = @site_id AND slug = 'contact-us');

-- ================= Portal =================
INSERT INTO dim_web_pages (tenant_id, business_id, site_id, slug, title, route, status, layout_json, meta_title)
SELECT @tenant_id, @business_id, @site_id, 'portal', 'Portal', '/portal', 'published', JSON_OBJECT(
  'version', 1,
  'blocks', JSON_ARRAY(
    JSON_OBJECT('id', 'portal-hero', 'type', 'hero', 'props', JSON_OBJECT(
      'heading', 'LarCare Portal',
      'subheading', 'Access your patient or employee portal to view schedules, documents, and care plans.',
      'imageUrl', '/images/hero/portal-hero.jpg'
    ), 'children', JSON_ARRAY()),
    JSON_OBJECT('id', 'portal-intro', 'type', 'richText', 'props', JSON_OBJECT('html',
      '<p style="text-align:center">The LarCare Portal is provided through a secure third-party system. Click below to sign in with your existing credentials.</p>'
    ), 'children', JSON_ARRAY()),
    JSON_OBJECT('id', 'portal-cta', 'type', 'button', 'props', JSON_OBJECT('label', 'Go to Portal', 'href', 'https://portal.larcareservices.com', 'variant', 'primary'), 'children', JSON_ARRAY())
  )
), 'Portal | LarCare Services'
WHERE @site_id IS NOT NULL
  AND NOT EXISTS (SELECT 1 FROM dim_web_pages WHERE site_id = @site_id AND slug = 'portal');
