import { type FC } from "react"
import { GetServerSidePropsContext } from "next/types"
import { ReduxWrapperConfig } from "@frontend/next-rtk-wrapper"
import { serverSideDataResolverWrapper } from "@/app/api/wrapper"
import LandingView from "@/destinations/LandingView"

const config = {
  local: [],
} as ReduxWrapperConfig<GetServerSidePropsContext>

interface LandingPageProps {
  serviceKey: string
  landingKey: string
}

const LandingPage: FC<LandingPageProps> = ({ serviceKey, landingKey }) => {
  return <LandingView serviceKey={serviceKey} landingKey={landingKey} />
}

export const getServerSideProps = serverSideDataResolverWrapper({
  config,
  wrapped(ctx, results, userState) {
    return {
      props: {
        serviceKey: ctx!.params!.serviceId,
        landingKey: ctx!.params!.landingId,
      },
    }
  },
})

export default LandingPage
