-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into fjern_login_context
- Loading branch information
Showing
14 changed files
with
412 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,8 @@ | ||
const sessions = {}; | ||
export const mock = function (app) { | ||
app.get('/min-side-arbeidsgiver/api/innlogget', (req, res) => { | ||
const token = sessions[req.ip]; | ||
if (token) { | ||
console.log('innlogget? ja (session eksisterer)'); | ||
res.status(200).send(); | ||
} else { | ||
console.log('innlogget? nei (session mangler)'); | ||
res.status(401).send(); | ||
} | ||
res.status(200).send(); | ||
}); | ||
app.get('/min-side-arbeidsgiver/redirect-til-login', async (req, res) => { | ||
const response = await fetch('https://fakedings.intern.dev.nav.no/fake/custom', { | ||
method: 'POST', | ||
headers: { | ||
'Content-type': 'application/x-www-form-urlencoded', | ||
}, | ||
body: `sub=00112233445&aud=${encodeURIComponent('bruker-api')}&acr=Level4`, | ||
}); | ||
const token = await response.text(); | ||
sessions[req.ip] = token; | ||
console.log(`login: setter session til ${token}`); | ||
res.redirect(req.get('referer')); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
const response = [ | ||
{ | ||
hovedenhet: null, | ||
underenhet: null, | ||
}, | ||
{ | ||
hovedenhet: { | ||
eposter: [], | ||
telefonnumre: [], | ||
}, | ||
underenhet: { | ||
eposter: [], | ||
telefonnumre: [], | ||
}, | ||
}, | ||
{ | ||
hovedenhet: { | ||
eposter: ['[email protected]'], | ||
telefonnumre: [], | ||
}, | ||
underenhet: { | ||
eposter: [], | ||
telefonnumre: ['+4700000'], | ||
}, | ||
}, | ||
{ | ||
hovedenhet: { | ||
eposter: ['[email protected]', '[email protected]'], | ||
telefonnumre: [], | ||
}, | ||
underenhet: { | ||
eposter: ['[email protected]'], | ||
telefonnumre: ['+4700000'], | ||
}, | ||
}, | ||
{ | ||
hovedenhet: { | ||
eposter: ['[email protected]', '[email protected]'], | ||
telefonnumre: ['+4700000'], | ||
}, | ||
underenhet: { | ||
eposter: [], | ||
telefonnumre: ['+4700000'], | ||
}, | ||
}, | ||
]; | ||
|
||
export const mock = (app) => { | ||
app.post('/min-side-arbeidsgiver/api/kontaktinfo/v1', (req, res) => { | ||
const randomRespons = response[Math.floor(Math.random() * 5)]; | ||
return res.send(randomRespons); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
.informasjon-om-bedrift { | ||
margin: 2rem auto; | ||
padding: 2rem; | ||
max-width: 60rem; | ||
width: 100%; | ||
margin: 24px auto; | ||
padding: 2rem; | ||
max-width: 60rem; | ||
width: 100%; | ||
} | ||
|
||
.informasjon-om-bedrift .ny-fane-ikon { | ||
margin-top: 3px; | ||
margin-top: 3px; | ||
} | ||
|
||
.informasjon-om-bedrift hr { | ||
width: 100%; | ||
} | ||
width: 100%; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,72 @@ | ||
import React, {FunctionComponent, useContext, useEffect, useState} from 'react'; | ||
import {OrganisasjonsDetaljerContext} from '../OrganisasjonDetaljerProvider'; | ||
import {Enhet, hentOverordnetEnhet, hentUnderenhet} from '../../api/enhetsregisteretApi'; | ||
import React, { FunctionComponent, useContext, useEffect, useState } from 'react'; | ||
import { OrganisasjonsDetaljerContext } from '../OrganisasjonDetaljerProvider'; | ||
import { Enhet, hentOverordnetEnhet, hentUnderenhet } from '../../api/enhetsregisteretApi'; | ||
import Underenhet from './Underenhet/Underenhet'; | ||
import OverordnetEnhet from './OverordnetEnhet/OverordnetEnhet'; | ||
import Brodsmulesti from '../Brodsmulesti/Brodsmulesti'; | ||
import './InformasjonOmBedrift.css'; | ||
import {Panel} from "@navikt/ds-react"; | ||
import { Panel } from '@navikt/ds-react'; | ||
|
||
interface Enheter { | ||
export interface Enheter { | ||
underenhet: Enhet; | ||
hovedenhet: Enhet; | ||
} | ||
|
||
const hentEnheter = async (orgnr: string): Promise<Enheter | undefined> => { | ||
const underenhet = await hentUnderenhet(orgnr) | ||
const underenhet = await hentUnderenhet(orgnr); | ||
if (underenhet === undefined) { | ||
return undefined | ||
return undefined; | ||
} | ||
if (underenhet.overordnetEnhet === undefined) { | ||
return undefined | ||
return undefined; | ||
} | ||
const hovedenhet = await hentOverordnetEnhet(underenhet.overordnetEnhet) | ||
const hovedenhet = await hentOverordnetEnhet(underenhet.overordnetEnhet); | ||
if (hovedenhet === undefined) { | ||
return undefined | ||
return undefined; | ||
} | ||
return {underenhet, hovedenhet} | ||
} | ||
return { underenhet, hovedenhet }; | ||
}; | ||
|
||
const Kontaktpanel = ({ children }: { children: React.ReactNode }) => ( | ||
<Panel className="informasjon-om-bedrift">{children}</Panel> | ||
); | ||
|
||
const InformasjonOmBedrift: FunctionComponent = () => { | ||
const {valgtOrganisasjon} = useContext(OrganisasjonsDetaljerContext); | ||
const { valgtOrganisasjon } = useContext(OrganisasjonsDetaljerContext); | ||
const [enheter, setEnheter] = useState<Enheter | undefined>(undefined); | ||
const orgnr = valgtOrganisasjon?.organisasjon.OrganizationNumber ?? ''; | ||
const orgnr = valgtOrganisasjon?.organisasjon.OrganizationNumber; | ||
|
||
useEffect(() => { | ||
if (orgnr !== '') { | ||
hentEnheter(orgnr).then(setEnheter) | ||
if (orgnr !== undefined) { | ||
hentEnheter(orgnr).then(setEnheter); | ||
} else { | ||
setEnheter(undefined) | ||
setEnheter(undefined); | ||
} | ||
}, [orgnr]); | ||
|
||
return ( | ||
<> | ||
<Brodsmulesti brodsmuler={[{url: '/bedriftsinformasjon', title: 'Bedriftsprofil', handleInApp: true}]}/> | ||
<Panel className='informasjon-om-bedrift'> | ||
{enheter !== undefined ? ( | ||
<> | ||
<Underenhet underenhet={enheter.underenhet}/> | ||
<OverordnetEnhet overordnetenhet={enheter.hovedenhet}/> | ||
</> | ||
) : ( | ||
<Brodsmulesti | ||
brodsmuler={[ | ||
{ url: '/bedriftsinformasjon', title: 'Bedriftsprofil', handleInApp: true }, | ||
]} | ||
/> | ||
{enheter !== undefined ? ( | ||
<> | ||
<Kontaktpanel> | ||
<Underenhet underenhet={enheter.underenhet} /> | ||
</Kontaktpanel> | ||
<Kontaktpanel> | ||
<OverordnetEnhet overordnetenhet={enheter.hovedenhet} /> | ||
</Kontaktpanel> | ||
</> | ||
) : ( | ||
<Kontaktpanel> | ||
<div>Kunne ikke hente informasjon</div> | ||
)} | ||
</Panel> | ||
</Kontaktpanel> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export default InformasjonOmBedrift; | ||
export default InformasjonOmBedrift; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
.kontaktinfo { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 16px; | ||
max-width: 32rem; | ||
margin-top: 16px; | ||
} | ||
|
||
.kontaktinfo li { | ||
margin: 0; | ||
list-style: none; | ||
} | ||
|
||
.kontaktinfo ul { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
.kontaktinfo-tittel { | ||
display: flex; | ||
align-items: center; | ||
gap: 8px; | ||
} |
Oops, something went wrong.