// app/(main)/layout.jsx
import Header from '../components/organisms/Header';
import Footer from '../components/organisms/Footer';
import FacebookPixel from '../components/FacebookPixel';

import { getMenuItems } from '../../lib/directQueries/allqueries';

// Separate component for all 4 schemas
function LocalBusinessSchemas() {
  const localBusinessSchemas = [
    // Lahore Office
    {
      "@context": "https://schema.org",
      "@type": "LocalBusiness",
      "name": "Universities Page - Lahore Office",
      "description": "Study abroad consultants in Lahore helping students apply to international universities for free.",
      "url": "https://universitiespage.com/",
      "telephone": "+92-324-3640038",
      "email": "info@universitiespage.com",
      "address": {
        "@type": "PostalAddress",
        "streetAddress": "2nd Floor faisal bank, Raja Market, Garden town",
        "addressLocality": "Lahore",
        "addressRegion": "Punjab",
        "postalCode": "54000",
        "addressCountry": "PK"
      },
      "geo": {
        "@type": "GeoCoordinates",
        "latitude": "31.51087",
        "longitude": "74.3230701"
      },
      "openingHoursSpecification": [{
        "@type": "OpeningHoursSpecification",
        "dayOfWeek": ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
        "opens": "09:30",
        "closes": "18:30"
      }],
      "priceRange": "$$",
      "image": "https://universitiespage.com/logo.png"
    },
    // Karachi Office
    {
      "@context": "https://schema.org",
      "@type": "LocalBusiness",
      "name": "Universities Page - Karachi Office",
      "description": "Study abroad consultants in Karachi providing free university application services.",
      "url": "https://universitiespage.com/",
      "telephone": "+92-310-6225430",
      "email": "info@universitiespage.com",
      "address": {
        "@type": "PostalAddress",
        "streetAddress": "1st floor, Amber Estate, Shahrah-e-Faisal Rd, Bangalore Town Block A Shah",
        "addressLocality": "Karachi",
        "addressRegion": "Sindh",
        "postalCode": "75500",
        "addressCountry": "PK"
      },
      "geo": {
        "@type": "GeoCoordinates",
        "latitude": "24.86832662744072",
        "longitude": "67.08340854233023"
      },
      "openingHoursSpecification": [{
        "@type": "OpeningHoursSpecification",
        "dayOfWeek": ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
        "opens": "09:30",
        "closes": "18:30"
      }],
      "priceRange": "$$",
      "image": "https://universitiespage.com/logo.png"
    },
    // Islamabad Office
    {
      "@context": "https://schema.org",
      "@type": "LocalBusiness",
      "name": "Universities Page - Islamabad Office",
      "description": "Study abroad consultants in Islamabad offering free guidance for international university applications.",
      "url": "https://universitiespage.com/",
      "telephone": "+92-334-9990308",
      "email": "info@universitiespage.com",
      "address": {
        "@type": "PostalAddress",
        "streetAddress": "Punjab Market, Venus Plaza, 1st Floor, Office No. 1, Sector G13/4",
        "addressLocality": "Islamabad",
        "addressRegion": "Islamabad Capital Territory",
        "postalCode": "44000",
        "addressCountry": "PK"
      },
      "geo": {
        "@type": "GeoCoordinates",
        "latitude": "33.65058196555808",
        "longitude": "72.97245639145082"
      },
      "openingHoursSpecification": [{
        "@type": "OpeningHoursSpecification",
        "dayOfWeek": ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
        "opens": "09:30",
        "closes": "18:30"
      }],
      "priceRange": "$$",
      "image": "https://universitiespage.com/logo.png"
    },
    // Faisalabad Office
    {
      "@context": "https://schema.org",
      "@type": "LocalBusiness",
      "name": "Universities Page - Faisalabad Office",
      "description": "Study abroad consultants in Faisalabad helping students apply to overseas universities free of cost.",
      "url": "https://universitiespage.com/",
      "telephone": "+92-310-6225411",
      "email": "info@universitiespage.com",
      "address": {
        "@type": "PostalAddress",
        "streetAddress": "Block, 1st Floor,of Segal Motors, C, Block C People Colony No 1",
        "addressLocality": "Faisalabad",
        "addressRegion": "Punjab",
        "postalCode": "38000",
        "addressCountry": "PK"
      },
      "openingHoursSpecification": [{
        "@type": "OpeningHoursSpecification",
        "dayOfWeek": ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
        "opens": "09:30",
        "closes": "18:30"
      }],
      "priceRange": "$$",
      "image": "https://universitiespage.com/logo.png"
    }
  ];

  return (
    <>
      {localBusinessSchemas.map((schema, index) => (
        <script
          key={`local-business-${index}`}
          type="application/ld+json"
          dangerouslySetInnerHTML={{
            __html: JSON.stringify(schema)
          }}
        />
      ))}
    </>
  );
}

export default async function MainLayout({ children }) {

  const gMenuItems = await getMenuItems();

  return (

    <>
      <Header menuItems={gMenuItems.data} />
      
      {/* Add all 4 schemas */}
      <LocalBusinessSchemas />
      
      <main className="min-h-screen">
        {children}
      </main>
      
      <FacebookPixel />
      <Footer />
    </>
  );
}