-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
189 additions
and
107 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,5 +1,11 @@ | ||
# Change Log | ||
|
||
## 4.2.5 | ||
|
||
### Patch Changes | ||
|
||
- kelvinsok | ||
|
||
## 4.2.4 | ||
|
||
## 4.2.3 | ||
|
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,5 +1,7 @@ | ||
# Change Log | ||
|
||
## 4.2.5 | ||
|
||
## 4.2.4 | ||
|
||
## 4.2.3 | ||
|
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,5 +1,11 @@ | ||
# Change Log | ||
|
||
## 4.2.5 | ||
|
||
### Patch Changes | ||
|
||
- kelvinsok | ||
|
||
## 4.2.4 | ||
|
||
### Patch Changes | ||
|
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
70 changes: 70 additions & 0 deletions
70
packages/aap-felles-react/src/KelvinAppHeader/Kelvinsøk.tsx
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,70 @@ | ||
'use client' | ||
|
||
import {Dispatch, SetStateAction} from "react"; | ||
import { Search} from "@navikt/ds-react"; | ||
import React from "react"; | ||
import {Søkeresultat} from "./Kelvinsøkeresultat"; | ||
interface OppgavesøkeResultat { | ||
label: string; | ||
href: string; | ||
} | ||
interface SaksøkeResultat { | ||
saksnummer: string; | ||
periode: { | ||
fom: string; | ||
tom: string; | ||
}; | ||
} | ||
interface Props { | ||
setSøkeresultat: Dispatch<SetStateAction<Søkeresultat | undefined>>; | ||
} | ||
export const Kelvinsøk = ({ setSøkeresultat }: Props) => { | ||
|
||
async function utførSøk(søketekst: string) { | ||
const isFnr = søketekst.length === 11; | ||
let oppgaveData: OppgavesøkeResultat[] = []; | ||
try { | ||
oppgaveData = await fetch(`${process.env.NEXT_PUBLIC_OPPGAVESTYRING_URL}/api/oppgave/sok`, { | ||
method: 'POST', | ||
body: JSON.stringify({ søketekst }), | ||
}).then((res) => res.json()); | ||
} catch (error) { | ||
console.error(error) | ||
} | ||
let sakData: SaksøkeResultat[] = []; | ||
if(isFnr){ | ||
try { | ||
sakData = await fetch(`${process.env.NEXT_PUBLIC_SAKSBEHANDLING_URL}/api/sak/finn`, { | ||
method: 'POST', | ||
body: JSON.stringify({ ident: søketekst }), | ||
}).then((res) => res.json()); | ||
} catch (error) { | ||
console.error(error) | ||
} | ||
} | ||
const resData: Søkeresultat = { | ||
oppgaver: oppgaveData, | ||
saker: sakData.map(sak => ({ | ||
href: `${process.env.NEXT_PUBLIC_SAKSBEHANDLING_URL}/sak/${sak.saksnummer}`, | ||
label: `${sak.periode.fom} - ${sak.periode.tom} (${sak.saksnummer})` | ||
})) | ||
} | ||
setSøkeresultat(resData); | ||
} | ||
return ( | ||
<form | ||
data-theme={'dark'} | ||
className={'kelvin-oppgavesok-form'} | ||
role={'search'} | ||
onSubmit={(e) => { | ||
const input = e.currentTarget.elements?.[0] as HTMLInputElement; | ||
if (input.value) { | ||
utførSøk(input.value); | ||
} | ||
e.preventDefault(); | ||
}} | ||
> | ||
<Search label={'Søk etter person eller sak'} variant="secondary" hideLabel={true} size={'small'} /> | ||
</form> | ||
); | ||
}; |
43 changes: 43 additions & 0 deletions
43
packages/aap-felles-react/src/KelvinAppHeader/Kelvinsøkeresultat.tsx
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,43 @@ | ||
'use client' | ||
|
||
import {HStack, Label} from "@navikt/ds-react"; | ||
import React from "react"; | ||
export interface Søkeresultat { | ||
saker: {href: string; label: string}[]; | ||
oppgaver: {href: string; label: string}[]; | ||
} | ||
interface Props { | ||
søkeresultat: Søkeresultat | ||
} | ||
export const Kelvinsøkeresultat = ({søkeresultat}: Props) => { | ||
return ( | ||
<section> | ||
<HStack gap={'4'}> | ||
{søkeresultat.saker.length > 0 && (<div> | ||
<Label>Saker</Label> | ||
<ul className={'kelvin-oppgavesok-resultat'}> | ||
{søkeresultat.saker.map((søk, index) => ( | ||
<li key={`saker-resultat-${index}`}> | ||
<a | ||
href={søk.href} | ||
>{søk.label}</a> | ||
</li> | ||
))} | ||
</ul> | ||
</div>)} | ||
{søkeresultat.oppgaver.length > 0 && (<div> | ||
<Label>Oppgaver</Label> | ||
<ul className={'kelvin-oppgavesok-resultat'}> | ||
{søkeresultat.oppgaver.map((søk, index) => ( | ||
<li key={`oppgaver-resultat-${index}`}> | ||
<a | ||
href={søk.href} | ||
>{søk.label}</a> | ||
</li> | ||
))} | ||
</ul> | ||
</div>)} | ||
</HStack> | ||
</section> | ||
) | ||
} |
80 changes: 0 additions & 80 deletions
80
packages/aap-felles-react/src/KelvinAppHeader/Oppgavesøk.tsx
This file was deleted.
Oops, something went wrong.
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,5 +1,7 @@ | ||
# Change Log | ||
|
||
## 4.2.5 | ||
|
||
## 4.2.4 | ||
|
||
## 4.2.3 | ||
|
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,5 +1,7 @@ | ||
# Change Log | ||
|
||
## 4.2.5 | ||
|
||
## 4.2.4 | ||
|
||
## 4.2.3 | ||
|
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,5 +1,7 @@ | ||
# Change Log | ||
|
||
## 4.2.5 | ||
|
||
## 4.2.4 | ||
|
||
## 4.2.3 | ||
|
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