import { serverClient } from "@/lib/trpc/server"

import FooterDetails from "./Details"
import FooterNavigation from "./Navigation"

export default async function Footer() {
  const footerData = await serverClient().contentstack.base.footer()
  const languages = await serverClient().contentstack.languageSwitcher.get()

  if (!footerData || !languages) {
    return <FooterDetails />
  }
  return (
    <footer>
      <FooterNavigation
        mainLinks={footerData.mainLinks}
        secondaryLinks={footerData.secondaryLinks}
        appDownloads={footerData.appDownloads}
      />
      <FooterDetails
        socialMedia={footerData.socialMedia}
        tertiaryLinks={footerData.tertiaryLinks}
        languageUrls={languages.urls}
      />
    </footer>
  )
}
