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

skal kunne sende inn egendefinert visning dersom søk på person ikke r… #1580

Merged
merged 1 commit into from
Sep 25, 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
5 changes: 4 additions & 1 deletion packages/familie-header/src/søk/Søk.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { ReactNode } from 'react';
import styled from 'styled-components';
import '@navikt/ds-css';
import { Ressurs, RessursStatus } from '@navikt/familie-typer/dist';
Expand All @@ -20,6 +20,7 @@ export interface SøkProps {
søkeresultatOnClick: (søkResultat: ISøkeresultat) => void;
placeholder?: string;
size?: 'small' | 'medium';
ingenFagsakKomponent?: ReactNode;
}

const SøkContainer = styled.div`
Expand All @@ -43,6 +44,7 @@ export const Søk = ({
placeholder,
label,
size = 'small',
ingenFagsakKomponent,
}: SøkProps) => {
const {
ankerRef,
Expand Down Expand Up @@ -106,6 +108,7 @@ export const Søk = ({
søkeresultatOnClick={søkeresultatOnClick}
søkeresultater={søkeresultater}
valgtSøkeresultat={valgtSøkeresultat}
ingenFagsakKomponent={ingenFagsakKomponent}
/>
</Popover.Content>
</Popover>
Expand Down
25 changes: 17 additions & 8 deletions packages/familie-header/src/søk/Søkeresultat.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { ReactNode } from 'react';

import styled from 'styled-components';
import { adressebeskyttelsestyper } from '@navikt/familie-typer';
Expand All @@ -18,6 +18,7 @@ interface Props {
søkeresultater: ISøkeresultat[];
valgtSøkeresultat: number;
settValgtSøkeresultat: (søkeresultatIndex: number) => void;
ingenFagsakKomponent?: ReactNode;
}

const ResultatListe = styled.ul`
Expand All @@ -31,6 +32,7 @@ const ResultatListeElement = styled.li<{ $fokus: boolean }>`
padding: 0.5rem;
outline: ${({ $fokus }) => ($fokus ? `3px solid var(--a-orange-300)` : '')};
border-radius: 8px;

&:hover {
background-color: var(--a-gray-100);
cursor: pointer;
Expand Down Expand Up @@ -61,6 +63,7 @@ const Søkeresultat: React.FC<Props> = ({
søkeresultatOnClick,
søkeresultater,
valgtSøkeresultat,
ingenFagsakKomponent,
}) => {
return søkeresultater.length > 0 ? (
<ResultatListe aria-labelledby={inputId}>
Expand Down Expand Up @@ -103,13 +106,9 @@ const Søkeresultat: React.FC<Props> = ({
</BodyShort>

{!søkeresultat.fagsakId && søkeresultat.harTilgang && (
<BodyShort size={'small'}>
{`Ingen fagsak. ${
!søkeresultat.fagsakId
? 'Trykk for å opprette >'
: ''
}`}
</BodyShort>
<ResultatVisningUtenFagsak
ingenFagsakKomponent={ingenFagsakKomponent}
/>
)}
</div>
</ResultatListeElementKnapp>
Expand All @@ -123,4 +122,14 @@ const Søkeresultat: React.FC<Props> = ({
);
};

const ResultatVisningUtenFagsak: React.FC<{ ingenFagsakKomponent?: ReactNode }> = ({
ingenFagsakKomponent,
}) => {
if (ingenFagsakKomponent) {
return ingenFagsakKomponent;
}

return <BodyShort size={'small'}>{`Ingen fagsak. Trykk for å opprette.`}</BodyShort>;
};

export default Søkeresultat;
5 changes: 4 additions & 1 deletion packages/familie-header/src/søk/Søkeresultater.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { ReactNode } from 'react';
import styled from 'styled-components';
import { Ressurs, RessursStatus } from '@navikt/familie-typer';
import { inputId } from '.';
Expand All @@ -15,6 +15,7 @@ interface Props {
søkeresultater: Ressurs<ISøkeresultat[]>;
valgtSøkeresultat: number;
settValgtSøkeresultat: (søkeresultatIndex: number) => void;
ingenFagsakKomponent?: ReactNode;
}

export const StyledAlertStripe = styled(Alert)`
Expand All @@ -27,6 +28,7 @@ const Søkeresultater: React.FC<Props> = ({
søkeresultatOnClick,
søkeresultater,
valgtSøkeresultat,
ingenFagsakKomponent,
}) => {
switch (søkeresultater.status) {
case RessursStatus.SUKSESS:
Expand All @@ -37,6 +39,7 @@ const Søkeresultater: React.FC<Props> = ({
settValgtSøkeresultat={settValgtSøkeresultat}
formaterResultat={formaterResultat}
søkeresultatOnClick={søkeresultatOnClick}
ingenFagsakKomponent={ingenFagsakKomponent}
/>
);
case RessursStatus.FEILET:
Expand Down