src/pages/index.tsx   A
last analyzed

Complexity

Total Complexity 1
Complexity/F 0

Size

Lines of Code 42
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 35
mnd 1
bc 1
fnc 0
dl 0
loc 42
rs 10
bpm 0
cpm 0
noi 0
c 0
b 0
f 0
1
import Head from "next/head"
2
3
import type { NextPage } from "next"
4
5
import JobListings from "@/components/JobListings/JobListings"
6
import Navbar from "@/components/Navbar/Navbar"
7
import { dehydrate, QueryClient } from "@tanstack/react-query"
8
import useJobs, { getJobs } from "@/state/useJobs"
9
import { Loader } from "@navikt/ds-react"
10
11
const Home: NextPage = () => {
12
  const { data, isLoading } = useJobs()
13
14
  return (
15
    <div id="root">
16
      <Head>
17
        <title>NAV Jobb Utforsker</title>
18
      </Head>
19
      <Navbar />
20
      {isLoading ? <Loader /> : <JobListings jobItems={data} />}
21
    </div>
22
  )
23
}
24
25
export default Home
26
27
export const getStaticProps = async () => {
28
  const queryClient = new QueryClient()
29
30
  await queryClient.prefetchQuery({
31
    queryKey: ["jobs"],
32
    queryFn: getJobs
33
  })
34
35
  return {
36
    props: {
37
      dehydratedState: dehydrate(queryClient),
38
    },
39
    revalidate: 60, // In seconds
40
  }
41
}
42