|
1 | 1 | import React from 'react';
|
2 |
| -import { Alert, Heading, Loader } from '@navikt/ds-react'; |
3 |
| -import { useContentTree } from '../hooks/useContentTree'; |
4 |
| -import { NavigationItem } from './contentTreeEntry/NavigationItem'; |
5 |
| -import { SimpleTreeView } from '@mui/x-tree-view'; |
| 2 | +import { Alert, Heading, Tabs } from '@navikt/ds-react'; |
| 3 | +import { LayerPanel } from './layerPanel/LayerPanel'; |
| 4 | +import { useAppState } from 'client/context/appState/useAppState'; |
| 5 | + |
| 6 | +const locales = ['no', 'en', 'nn', 'se'] as const; |
| 7 | +export type Locale = (typeof locales)[number]; |
| 8 | + |
| 9 | +const getLabel = (locale: Locale) => { |
| 10 | + const translations: Record<Locale, string> = { |
| 11 | + no: 'Norsk', |
| 12 | + en: 'Engelsk', |
| 13 | + nn: 'Nynorsk', |
| 14 | + se: 'Samisk', |
| 15 | + }; |
| 16 | + return translations[locale]; |
| 17 | +}; |
6 | 18 |
|
7 | 19 | export const NavigationBar = () => {
|
8 |
| - const { data, isLoading } = useContentTree('/', 'no'); |
| 20 | + const { setSelectedLocale } = useAppState(); |
9 | 21 |
|
10 | 22 | return (
|
11 | 23 | <div>
|
12 | 24 | <Heading size={'small'}>{'Innhold'}</Heading>
|
13 |
| - {isLoading ? ( |
14 |
| - <Loader /> |
15 |
| - ) : ( |
16 |
| - <SimpleTreeView> |
17 |
| - {data?.children.map((entry) => <NavigationItem entry={entry} key={entry.id} />)} |
18 |
| - </SimpleTreeView> |
19 |
| - )} |
| 25 | + <Tabs defaultValue="no" onChange={(locale) => setSelectedLocale(locale as Locale)}> |
| 26 | + <Tabs.List> |
| 27 | + {locales.map((locale) => ( |
| 28 | + <Tabs.Tab key={locale} value={locale} label={getLabel(locale)} /> |
| 29 | + ))} |
| 30 | + </Tabs.List> |
| 31 | + {locales.map((locale) => ( |
| 32 | + <Tabs.Panel key={locale} value={locale}> |
| 33 | + <LayerPanel locale={locale} /> |
| 34 | + </Tabs.Panel> |
| 35 | + ))} |
| 36 | + </Tabs> |
20 | 37 | <Alert variant={'warning'} size={'small'} inline={true} style={{ marginTop: '1.5rem' }}>
|
21 | 38 | {'Obs: dette arkivet er under utvikling og er ikke klart til bruk!'}
|
22 | 39 | </Alert>
|
|
0 commit comments