import Layout from '../components/Layout';
import Instructions from '../components/Instructions';
import Result from '../components/Result';
import ResultDescription from '../components/ResultDescription';

const domainStatusEnum = ['FREE', 'OCCUPIED', 'NOT_VALID'];

export async function getEdgeProps({ params }) {
  const { domain } = params;

  const fakeRandomStatus =
    domainStatusEnum[Math.floor(Math.random() * domainStatusEnum.length)];

  return {
    props: {
      domain,
      domainTld: `${domain}.se`,
      status: fakeRandomStatus,
    },
    revalidate: 60, // Revalidate these props once every 60 seconds
  };
}

const DomainDotSePage = ({ domain, domainTld, status }) => (
  <Layout pageTitleSuffix={`Är domänen ${domainTld} ledig?`}>
    <header>
      <h1 className="title">
        <Result domainTld={domainTld} status={status} />
      </h1>
      <h2 className="result-page__description">
        <ResultDescription status={status} />
      </h2>
    </header>
    <footer className="result-page__usage">
      <h3 className="usage__title">Hur använder jag isfree.se?</h3>
      <Instructions />
    </footer>
  </Layout>
);

export default DomainDotSePage;

@@ -1,12 +1,43 @@
+import seFree from 'se-free';%0A%0A
 import Layou
@@ -235,69 +235,8 @@
 ';%0A%0A
-const domainStatusEnum = %5B'FREE', 'OCCUPIED', 'NOT_VALID'%5D;%0A%0A
 expo
@@ -309,25 +309,24 @@
 params;%0A
-%0A
   const 
 fakeRand
@@ -321,100 +321,76 @@
 nst 
-fakeRandomStatus =%0A    domainStatusEnum%5BMath.floor(Math.random() * domainStatusEnum.length)%5D
+domainTld = %60$%7Bdomain%7D.se%60;%0A  const status = await seFree(domainTld)
 ;%0A%0A 
@@ -445,51 +445,17 @@
 nTld
-: %60$%7Bdomain%7D.se%60,%0A      status: fakeRandomS
+,%0A      s
 tatu

Use real result using seFree