import React from "react";
import { NextPage, GetStaticProps } from "next";
import Head from "next/head";
import JobAd from "@models/JobAd";
import JobAdApi from "@api/jobAdApi";
import useFetchJobAds from "@hooks/useFetchJobAds";
import CorporatePageView from "@views/CorporatePage/CorporatePageView";
import PageWrapper from "@views/common/PageWrapper";

interface InitialProps {
  initialJobAds: JobAd[];
}

const CorporatePage: NextPage<InitialProps> = ({ initialJobAds }) => {
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
  const { data, error } = useFetchJobAds({ initialData: initialJobAds });
  return (
    <>
      <Head>
        <link rel="canonical" href={`${process.env.NEXT_PUBLIC_SITE_URL}/yritysyhteistyo`} />
      </Head>
      <PageWrapper>
        <CorporatePageView jobAds={data as JobAd[]} />
      </PageWrapper>
    </>
  );
};

export const getStaticProps: GetStaticProps<InitialProps> = async () => {
  const initialJobAds = await JobAdApi.getJobAds();
  return {
    props: {
      initialJobAds,
    },
    revalidate: 10,
  };
};

export default CorporatePage;
