Skip to content

Commit

Permalink
🚚 Flyttet queries og typer
Browse files Browse the repository at this point in the history
  • Loading branch information
KenAJoh committed Jan 5, 2024
1 parent fb709a1 commit ccde897
Show file tree
Hide file tree
Showing 19 changed files with 93 additions and 90 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import dynamic from "next/dynamic";
import { Box, Page, VStack } from "@navikt/ds-react";
import Footer from "@/layout/footer/Footer";
import { GpEntryPageProps } from "@/layout/god-praksis-page/types";
import { GpEntryPageProps } from "@/layout/god-praksis-page/interface";
import useInitialState from "@/layout/god-praksis-page/useInitialState";
import Header from "@/layout/header/Header";
import Hero from "./hero/Hero";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from "@navikt/aksel-icons";
import { BodyLong, Detail, Heading, VStack } from "@navikt/ds-react";
import { useFormatedDate } from "@/hooks/useFormatedDate";
import { GpArticleT } from "@/layout/god-praksis-page/queries";
import { GpArticleT } from "@/layout/god-praksis-page/interface";
import styles from "./articles.module.css";

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import cl from "clsx";
import { Heading } from "@navikt/ds-react";
import { GpArticleT } from "@/layout/god-praksis-page/queries";
import { GpArticleT } from "@/layout/god-praksis-page/interface";
import { ArticleCard } from "./ArticleCard";
import styles from "./articles.module.css";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import useSWRInfinite from "swr/infinite";
import { ChevronDownCircleIcon } from "@navikt/aksel-icons";
import { Button } from "@navikt/ds-react";
import ErrorBoundary from "@/error-boundary";
import { GpArticleT } from "@/layout/god-praksis-page/queries";
import { GP_LAZYLOADED_ARTICLES } from "@/layout/god-praksis-page/types";
import {
GP_LAZYLOADED_ARTICLES,
GpArticleT,
} from "@/layout/god-praksis-page/interface";
import useGpQuery from "@/layout/god-praksis-page/useGpQuery";
import ArticleGrid from "./ArticleGrid";
import styles from "./articles.module.css";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useMemo } from "react";
import { VStack } from "@navikt/ds-react";
import { ChipsData } from "@/layout/god-praksis-page/types";
import { ChipsData } from "@/layout/god-praksis-page/interface";
import useGpQuery from "@/layout/god-praksis-page/useGpQuery";
import ChipNav from "./ChipNav";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { chipsDataAllQueryResponse } from "../queries";
import { ChipsData, ChipsDataGroupedByTema } from "../types";
import {
ChipsData,
ChipsDataGroupedByTema,
chipsDataAllQueryResponse,
} from "../interface";

export const groupByTema = (
chipsData: chipsDataAllQueryResponse["chipsDataAll"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Link from "next/link";
import { useRef } from "react";
import { ChevronDownIcon } from "@navikt/aksel-icons";
import { BodyLong, Box, Heading, Modal, VStack } from "@navikt/ds-react";
import { GpTemaT, HeroNavT } from "@/layout/god-praksis-page/types";
import { GpTemaT, HeroNavT } from "@/layout/god-praksis-page/interface";

/**
* TODO:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BodyLong, Box, Heading } from "@navikt/ds-react";
import Cube from "@/layout/god-praksis-page/hero/Cube";
import HeroSelect from "@/layout/god-praksis-page/hero/HeroSelect";
import { GpTemaT, HeroNavT } from "@/layout/god-praksis-page/types";
import { GpTemaT, HeroNavT } from "@/layout/god-praksis-page/interface";

/**
* TODO:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Link from "next/link";
import { useRef } from "react";
import { ChevronDownIcon } from "@navikt/aksel-icons";
import { BodyShort, Modal } from "@navikt/ds-react";
import { HeroNavT } from "@/layout/god-praksis-page/types";
import { HeroNavT } from "@/layout/god-praksis-page/interface";

function HeroSelect({
heroNav,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GpGroupedArticlesT } from "../types";
import { GpGroupedArticlesT } from "../interface";
import { getArticleList } from "./get-article-list";

const baseArticle = (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
GP_INITIAL_ARTICLES,
GpGroupedArticlesT,
} from "@/layout/god-praksis-page/types";
} from "@/layout/god-praksis-page/interface";

export function getArticleList(
articles: GpGroupedArticlesT,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GpArticleT } from "..//queries";
import { GpArticleT } from "../interface";
import { groupArticles } from "./group-articles";

const baseArticle = (id: string): GpArticleT => ({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { GpArticleT } from "@/layout/god-praksis-page/queries";
import { GpGroupedArticlesInputT, GpGroupedArticlesT } from "../types";
import {
GpArticleT,
GpGroupedArticlesInputT,
GpGroupedArticlesT,
} from "../interface";

/**
* De-duplicates re-occuring articles and maps the to the matching innholdstype and undertema
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,61 @@
import { groq } from "next-sanity";
import { GP_INITIAL_ARTICLES } from "@/layout/god-praksis-page/types";

export const GP_LAZYLOADED_ARTICLES = 3;
export const GP_INITIAL_ARTICLES = 9;

export type GpTemaT = {
title: string;
slug: string;
description?: string;
undertema: { title: string; description: string }[];
};

export type GpInnholdstypeT = {
title: string;
description?: string;
hasRefs: boolean;
};

export type HeroNavT = {
heroNav: {
title: string;
slug: string;
hasRefs: boolean;
}[];
};

export type GpGroupedArticlesT = {
innholdstype: string | null;
undertema: string | null;
article: GpArticleT;
}[];

export type GpGroupedArticlesInputT = {
initialInnholdstype?: {
title: string;
articles: GpArticleT[];
}[];

initialUndertema?: {
title: string;
articles: GpArticleT[];
}[];
};

export type ChipsDataGroupedByTema = {
[temaSlug: string]: ChipsData;
};

export type ChipsData = {
"undertema-title": string;
"innholdstype-title": string;
}[];

export type GpEntryPageProps = HeroNavT & {
tema: GpTemaT | null;
} & {
initialArticles: GpGroupedArticlesT;
} & { chipsData: ChipsData };

export const heroNavQuery = groq`
"heroNav": *[_type == "gp.tema"]{
Expand Down
65 changes: 0 additions & 65 deletions aksel.nav.no/website/components/layout/god-praksis-page/types.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { getArticleList } from "@/layout/god-praksis-page/initial-load/get-article-list";
import { GpArticleT } from "@/layout/god-praksis-page/queries";
import { GpGroupedArticlesT } from "@/layout/god-praksis-page/types";
import {
GpArticleT,
GpGroupedArticlesT,
} from "@/layout/god-praksis-page/interface";
import useGpQuery from "@/layout/god-praksis-page/useGpQuery";

/**
Expand Down
6 changes: 4 additions & 2 deletions aksel.nav.no/website/pages/api/gp-articles.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { NextApiRequest, NextApiResponse } from "next";
import { groq } from "next-sanity";
import { baseGpArticleData } from "@/layout/god-praksis-page/queries";
import { GP_LAZYLOADED_ARTICLES } from "@/layout/god-praksis-page/types";
import {
GP_LAZYLOADED_ARTICLES,
baseGpArticleData,
} from "@/layout/god-praksis-page/interface";
import { getClient } from "@/sanity/client.server";

export default async function gpArticles(
Expand Down
4 changes: 2 additions & 2 deletions aksel.nav.no/website/pages/gp/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import GodPraksisPage from "@/layout/god-praksis-page/GodPraksisPage";
import { groupByTema } from "@/layout/god-praksis-page/chips/dataTransforms";
import { groupArticles } from "@/layout/god-praksis-page/initial-load/group-articles";
import {
GpEntryPageProps,
chipsDataAllQuery,
chipsDataAllQueryResponse,
heroNavQuery,
Expand All @@ -13,8 +14,7 @@ import {
initialTemaPageArticlesResponse,
temaQuery,
temaQueryResponse,
} from "@/layout/god-praksis-page/queries";
import { GpEntryPageProps } from "@/layout/god-praksis-page/types";
} from "@/layout/god-praksis-page/interface";
import { getClient } from "@/sanity/client.server";
import { getGpTema } from "@/sanity/interface";
import { NextPageT } from "@/types";
Expand Down
4 changes: 2 additions & 2 deletions aksel.nav.no/website/pages/gp/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import GodPraksisPage from "@/layout/god-praksis-page/GodPraksisPage";
import { chipsDataForAllTema } from "@/layout/god-praksis-page/chips/dataTransforms";
import { groupArticles } from "@/layout/god-praksis-page/initial-load/group-articles";
import {
GpEntryPageProps,
chipsDataAllQuery,
chipsDataAllQueryResponse,
heroNavQuery,
heroNavQueryResponse,
initialGpMainPageArticles,
initialGpMainPageArticlesResponse,
} from "@/layout/god-praksis-page/queries";
import { GpEntryPageProps } from "@/layout/god-praksis-page/types";
} from "@/layout/god-praksis-page/interface";
import { getClient } from "@/sanity/client.server";
import { NextPageT } from "@/types";
import { SEO } from "@/web/seo/SEO";
Expand Down

0 comments on commit ccde897

Please sign in to comment.