Skip to content

Commit

Permalink
UPDATE: Fjerne referanse til lang.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulMartinKokseter committed May 27, 2024
1 parent b0043ef commit c92a639
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 77 deletions.
74 changes: 2 additions & 72 deletions apps/frontend/src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@ import { ALIGN, HeaderNavigation, StyledNavigationItem as NavigationItem, Styled
import { Button } from 'baseui/button'
import { Block, BlockProps } from 'baseui/block'
import { useLocation, useNavigate } from 'react-router-dom'
import { intl, theme } from '../util'
import { theme } from '../util'
import { user } from '../service/User'
import { StyledLink } from 'baseui/link'
import { StatefulPopover } from 'baseui/popover'
import { LabelMedium } from 'baseui/typography'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faUser } from '@fortawesome/free-solid-svg-icons'
import { OptionProfile, StatefulMenu } from 'baseui/menu'
import { Lang, langs, langsArray } from '../util/intl/intl'
import { StatefulMenu } from 'baseui/menu'
import { TriangleDown } from 'baseui/icon'
import { FlagIcon } from './common/Flag'
import { paddingAll } from './common/Style'
import MainSearch from './search/MainSearch'

Expand Down Expand Up @@ -59,70 +57,6 @@ const LoginButton = () => {
)
}

const Flag = (props: { langCode: string }) => (
<span role="img" aria-label={langs[props.langCode].name}>
<FlagIcon country={langs[props.langCode].flag} />
</span>
)

const FlagWithName = (props: { langCode: string }) => (
<span>
<Flag langCode={props.langCode} /> {langs[props.langCode].name}
</span>
)

const LangDropdown = (props: { setLang: (lang: string) => void }) => {
return (
<StatefulPopover
content={({ close }) => (
<StatefulMenu
items={langsArray.filter((l) => l.langCode !== intl.getLanguage())}
onItemSelect={({ item }) => {
close()
props.setLang(item.langCode)
}}
overrides={{
Option: {
component: OptionProfile,
props: {
getProfileItemLabels: (lang: Lang) => ({
title: lang.name,
subtitle: lang.langCode,
}),
getProfileItemImg: (lang: Lang) => () => <Flag langCode={lang.langCode} />,
overrides: {
ListItemProfile: {
props: {
style: {
paddingTop: theme.sizing.scale100,
paddingBottom: theme.sizing.scale100,
paddingLeft: theme.sizing.scale600,
paddingRight: theme.sizing.scale800,
},
},
},
ProfileImgContainer: {
props: {
style: {
height: theme.sizing.scale900,
width: theme.sizing.scale900,
},
},
},
},
},
},
}}
/>
)}
>
<Button endEnhancer={() => <TriangleDown size={24} />} kind="tertiary">
<FlagWithName langCode={intl.getLanguage()} />
</Button>
</StatefulPopover>
)
}

const AdminOptions = () => {
const navigate = useNavigate()
const pages = [
Expand Down Expand Up @@ -174,10 +108,6 @@ const Header = (props: HeaderProps) => {
</NavigationItem>
)}

<NavigationItem $style={{ paddingLeft: 0 }}>
<LangDropdown setLang={props.setLang} />
</NavigationItem>

{!user.isLoggedIn() && (
<NavigationItem $style={{ paddingLeft: 0 }}>
<LoginButton />
Expand Down
11 changes: 6 additions & 5 deletions apps/frontend/src/pages/AlertEventPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,15 @@ export const AlertEventPage = () => {
<Block width="100%" display="flex" marginBottom={theme.sizing.scale200}>
<Block width="50%" display="flex" justifyContent="flex-start" alignItems="center">
<LabelMedium marginRight={theme.sizing.scale600}>Type: </LabelMedium>
<StatefulSelect options={Object.values(AlertEventType).map((t) => ({ id: t, label: intl[t] }))} onChange={(params) => setType(params?.option?.id as AlertEventType)} />
<StatefulSelect options={Object.values(AlertEventType).map((t) => ({ id: t, label: intl[t] + t }))} onChange={(params) => setType(params?.option?.id as AlertEventType)} />
</Block>

<Block width="50%" display="flex" justifyContent="flex-end" alignItems="center">
<LabelMedium marginRight={theme.sizing.scale600}>Nivå: </LabelMedium>
{levelButton(intl.all)}
{levelButton(intl.INFO, AlertEventLevel.INFO)}
{levelButton(intl.WARNING, AlertEventLevel.WARNING)}
{levelButton(intl.ERROR, AlertEventLevel.ERROR)}
{levelButton('Alle')}
{levelButton('Info', AlertEventLevel.INFO)}
{levelButton('Advarsel', AlertEventLevel.WARNING)}
{levelButton('Feil', AlertEventLevel.ERROR)}
</Block>
</Block>
<Table
Expand Down Expand Up @@ -198,6 +198,7 @@ export const AlertEventPage = () => {

<Cell>
{intl[event.level]} - {intl[event.type]}
{event.level} - {event.type}
</Cell>
<Cell>{moment(event.changeStamp.lastModifiedDate).format('lll')}</Cell>
<Cell>{event.changeStamp.lastModifiedBy}</Cell>
Expand Down

0 comments on commit c92a639

Please sign in to comment.