import { gql } from 'graphql-request'
import fetchAPI from '@/lib/api/fetchAPI'

/**
 * Query the work with us page
 */
export async function getWorkWithUsPage() {
  const data = await fetchAPI(
    gql`
      query WorkingWithUsPage {
        page(id: "working-with-us", idType: URI) {
          title
          content
          seo {
            fullHead
          }
          featuredImage {
            node {
              alt: altText
              imageUrl: sourceUrl
              placeholder: sourceUrl(size: THUMBNAIL)
            }
          }
          workWithUsPageContent {
            heroSection {
              heroTitle
              mainDescription
            }
            contentSections {
              title
              description
              productionSpecsSection {
                specTitle
                specDescription
              }
              bodySection {
                ... on Page_Workwithuspagecontent_contentSections_BodySection_3ColPhotosLayout {
                  fieldGroupName
                  photoGrid {
                    image {
                      alt: altText
                      imageUrl: sourceUrl
                      placeholder: sourceUrl(size: THUMBNAIL)
                    }
                  }
                }
                ... on Page_Workwithuspagecontent_contentSections_BodySection_AsymmetricalPhotoLayout {
                  fieldGroupName
                  largeImagePlacement
                  photoGrid {
                    image {
                      alt: altText
                      imageUrl: sourceUrl
                      placeholder: sourceUrl(size: THUMBNAIL)
                    }
                  }
                }
                ... on Page_Workwithuspagecontent_contentSections_BodySection_FullWidthPhotoLayout {
                  fieldGroupName
                  image {
                    alt: altText
                    imageUrl: sourceUrl
                    placeholder: sourceUrl(size: THUMBNAIL)
                  }
                }
              }
            }
          }
          customCtaSection {
            enableCta
            ctaText
            ctaLink {
              title
              url
            }
          }
        }
      }
    `
  )

  return data
}
