Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kontakt info tweaks #1883

Merged
merged 3 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/GeneriskeElementer/LenkeMedLogging.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ import {BodyShort, Link as DsLink, LinkProps } from '@navikt/ds-react';
import {loggNavigasjon} from '../utils/funksjonerForAmplitudeLogging';
import { useLocation, Link as ReactLink } from 'react-router-dom';

interface Props {
interface Props extends LinkProps {
href: string;
loggLenketekst: string;
onClick?: LinkProps["onClick"];
children: ReactNode;
}

Expand Down
10 changes: 10 additions & 0 deletions src/Pages/OmVirksomheten/Kontaktinfo.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
.kontaktinfo{
background: var(--a-gray-100);
padding: 16px;
border-radius: 8px;
gap: 8px;
display: grid;
flex-grow: 1;
}

.kontaktinfo li {
padding: 8px 8px 0 0;
margin: 0;
list-style: none;
}
Expand Down
9 changes: 4 additions & 5 deletions src/Pages/OmVirksomheten/Kontaktinfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import './Kontaktinfo.css';
import { OrganisasjonsDetaljerContext } from '../OrganisasjonDetaljerProvider';
import NyFaneIkon from './NyFaneIkon';
import { erDriftsforstyrrelse } from '../../utils/util';
import Tekstboks from './Tekstboks';
import { Hovedenhet } from '../../api/enhetsregisteretApi';

const KontaktinfoDetaljer = z.object({
Expand Down Expand Up @@ -118,11 +117,11 @@ export const KontaktinfoUnderenhet = () => {
if (kontaktinfo === null) return null;
if (kontaktinfo.eposter.length === 0 && kontaktinfo.telefonnumre.length === 0) return null;
return (
<Tekstboks className="kontaktinfo">
<div className="kontaktinfo">
<TittelMedHjelpetekst>Varslingsadresser for underenhet</TittelMedHjelpetekst>
<KontaktinfoListe kontaktinfo={kontaktinfo} />
<AltinnLenke />
</Tekstboks>
</div>
);
};

Expand All @@ -136,7 +135,7 @@ export const KontaktinfoOverordnetEnhet = ({
const orgType =
overordnetEnhet.organisasjonsform?.kode === 'ORGL' ? 'organisasjonsledd' : 'hovedenhet';
return (
<Tekstboks className="kontaktinfo">
<div className="kontaktinfo">
<TittelMedHjelpetekst>Varslingsadresser for {orgType}</TittelMedHjelpetekst>
{kontaktinfo.eposter.length === 0 && kontaktinfo.telefonnumre.length === 0 ? (
<Alert variant="warning">
Expand All @@ -148,6 +147,6 @@ export const KontaktinfoOverordnetEnhet = ({
<KontaktinfoListe kontaktinfo={kontaktinfo} />
)}
<AltinnLenke />
</Tekstboks>
</div>
);
};
9 changes: 6 additions & 3 deletions src/Pages/OmVirksomheten/OverordnetEnhet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import { enhetsregisteretOverordnetenhetLink } from '../../lenker';
import { Office2 as JuridiskEnhetIkon } from '@navikt/ds-icons';
import './OverordnetEnhet.css';
import { LenkeMedLogging } from '../../GeneriskeElementer/LenkeMedLogging';
import { BodyShort, Heading, Label } from '@navikt/ds-react';
import { BodyShort, Heading, HStack, Label } from '@navikt/ds-react';
import { KontaktinfoOverordnetEnhet } from './Kontaktinfo';
import { Hovedenhet } from '../../api/enhetsregisteretApi';
import { formatOrgNr } from '../../utils/util';

interface Props {
overordnetenhet: Hovedenhet;
Expand All @@ -30,7 +31,7 @@ const OverordnetEnhet = ({ overordnetenhet }: Props) => {
<div className="overordnet-enhet-info__container">
<Tekstboks className="overordnetenhet-orgnr">
<Label>Organisasjonsnummer</Label>
<BodyShort> {overordnetenhet.organisasjonsnummer}</BodyShort>
<BodyShort> {formatOrgNr(overordnetenhet.organisasjonsnummer)}</BodyShort>
</Tekstboks>

<Tekstboks className="overordnetenhet-orgform">
Expand Down Expand Up @@ -87,7 +88,9 @@ const OverordnetEnhet = ({ overordnetenhet }: Props) => {
<NyFaneIkon />
</LenkeMedLogging>
</Tekstboks>
<KontaktinfoOverordnetEnhet overordnetEnhet={overordnetenhet} />
<HStack gap="6">
<KontaktinfoOverordnetEnhet overordnetEnhet={overordnetenhet} />
</HStack>
</div>
);
};
Expand Down
9 changes: 6 additions & 3 deletions src/Pages/OmVirksomheten/Underenhet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import { enhetsregisteretUnderenhetLink } from '../../lenker';
import './Underenhet.css';
import { LenkeMedLogging } from '../../GeneriskeElementer/LenkeMedLogging';
import { Underenhet as UnderenhetType } from '../../api/enhetsregisteretApi';
import { BodyShort, Heading, Label } from '@navikt/ds-react';
import { BodyShort, Heading, HStack, Label } from '@navikt/ds-react';
import { KontaktinfoUnderenhet } from './Kontaktinfo';
import { formatOrgNr } from '../../utils/util';

interface Props {
underenhet: UnderenhetType;
Expand All @@ -27,7 +28,7 @@ const Underenhet = ({ underenhet }: Props) => {

<Tekstboks>
<Label>Organisasjonsnummer</Label>
<BodyShort>{underenhet.organisasjonsnummer}</BodyShort>
<BodyShort>{formatOrgNr(underenhet.organisasjonsnummer)}</BodyShort>
</Tekstboks>

<Tekstboks className="underenhet-adresse">
Expand Down Expand Up @@ -65,7 +66,9 @@ const Underenhet = ({ underenhet }: Props) => {
<NyFaneIkon />
</LenkeMedLogging>
</Tekstboks>
<KontaktinfoUnderenhet />
<HStack gap="6">
<KontaktinfoUnderenhet />
</HStack>
</>
);
};
Expand Down
3 changes: 3 additions & 0 deletions src/utils/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ export const capitalize = (s: string): string => {
const [forbokstav, ...resten] = s;
return [forbokstav.toUpperCase(), ...resten].join('');
};

export const formatOrgNr = (orgNr: string): string =>
orgNr.replace(/(\d{3})(\d{3})(\d{3})/, '$1 $2 $3');
Loading