import React, { useState } from 'react'; import NavItem from "./NavItem"; import NavReset from "./NavReset"; import NavResult from "./NavResult"; import LanguageSelector from "./LanguageSelector"; import { ToggleButton, Title, Grid } from "../primitives"; type Props = { heading?: string, page?: string, setPage: (page: string, property?: string) => void, tableOfContents: any[] showIntro: () => void, translations: Record } export default function Nav({ heading = "Missing page heading", page: currentPage, setPage, tableOfContents, showIntro, translations }: Props) { const [tocExpanded, setTocExpanded] = useState(true); const toggleToc = () => setTocExpanded(!tocExpanded); const currentIndex = tableOfContents.findIndex(page => page.id === currentPage); return (
{tocExpanded ? `${currentIndex + 1} av ${tableOfContents.length} steg` : "Skjul all steg"} {heading} {tableOfContents.filter(page => page.type !== "Result").map((page, index) =>
  • )}
    {tableOfContents.filter(page => page.type === "Result").map((page) => )}
    ) }