-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathTestFaktaside.tsx
48 lines (42 loc) · 1.66 KB
/
TestFaktaside.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import * as React from "react";
import { Block } from "../utils/richTextUtils/richTextTypes";
import { faktaSideMockQueryData } from "./faktaSideMockQueryData";
import FaktaSide from "../components/faktaside/Faktaside";
import { FaktasideQueryData, IFaktaside } from "../sanity/groq/faktaside/faktasideQuery";
import { translated } from "./createSanityBlock";
import { mockMenuData } from "../sanity/groq/menu/mockMenuData";
import { MenuQueryData, MenyLenkeRaw } from "../sanity/groq/menu/menuQuery";
type Props = {
partialFaktaside?: Partial<IFaktaside>;
partialOppsett?: Partial<FaktasideQueryData["oppsett"]>;
innhold?: Block[];
partialMeny?: Partial<MenuQueryData>;
};
function TestFaktaside(props: Props) {
const faktaSide: IFaktaside = { ...faktaSideMockQueryData.faktaside, ...props.partialFaktaside };
const oppsett = { ...faktaSideMockQueryData.oppsett, ...props.partialOppsett };
const faktasideData: FaktasideQueryData = {
...faktaSideMockQueryData,
faktaside: {
...faktaSide,
innhold: props.innhold ? translated(props.innhold) : faktaSide.innhold,
},
oppsett,
};
const menuData: MenuQueryData = {
sider: props.partialMeny?.sider || [
{
title: faktaSide.title,
slug: faktaSide.slug,
beskrivelse: faktaSide.beskrivelse,
id: faktaSide.id,
nokkelordBeskrivelse: translated("Noen nøkkelord"),
visSprakversjon: faktaSide.visSprakversjon,
},
...mockMenuData.sider,
],
lenker: (props.partialMeny?.lenker || mockMenuData.lenker) as MenyLenkeRaw[],
};
return <FaktaSide menuQueryData={menuData} faktasideQueryData={faktasideData} />;
}
export default TestFaktaside;