-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Endrer 'Steg X av X', 'Vis alle steg' og 'Skjul alle steg' slik at de fungerer på NN og EN i tillegg til NB * Legger til steg tittel tekster * Flytter formProgressSteps ut av StegContext * Legger til tittel til formProgressSteps * Fikser visning av tittel * Legger til tittelBlock og tittelFlettefeltVerider * Bytter til bruk av useEffect for reaktiv og riktig oppdaterting av formProgressSteps * Legger til console.log for testing * Fjerner bruk av useEffect * Bytter til bruk av barnForSteg istedenfor barnInkludertISøknaden ettersom barnForSteg og steg alltid er i sync mtp hvor mange barn som eksisterer * Legger til tittel uten flettefelt for Om Barnet * Flytter formProgressSteps ut i egen hook for bedre separasjon av kode * Endrer navn på formProgressSteps til norsk: formProgressSteg
- Loading branch information
1 parent
57f210a
commit e3323c0
Showing
16 changed files
with
133 additions
and
25 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
88 changes: 88 additions & 0 deletions
88
src/frontend/components/Felleskomponenter/Steg/useFormProgressSteg.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,88 @@ | ||
import { useApp } from '../../../context/AppContext'; | ||
import { useSteg } from '../../../context/StegContext'; | ||
import { ISteg, RouteEnum } from '../../../typer/routes'; | ||
import { FlettefeltVerdier, LocaleRecordBlock } from '../../../typer/sanity/sanity'; | ||
|
||
interface IStegMedTittel extends ISteg { | ||
tittel: string; | ||
} | ||
|
||
export const useFormProgressSteg = (): IStegMedTittel[] => { | ||
const { tekster, plainTekst } = useApp(); | ||
const { steg, barnForSteg } = useSteg(); | ||
|
||
const { | ||
FORSIDE, | ||
OM_DEG, | ||
DIN_LIVSSITUASJON, | ||
VELG_BARN, | ||
OM_BARNA, | ||
OM_BARNET, | ||
OPPSUMMERING, | ||
DOKUMENTASJON, | ||
EØS_FOR_BARN, | ||
EØS_FOR_SØKER, | ||
KVITTERING, | ||
} = tekster(); | ||
|
||
let antallBarnCounter = 0; | ||
return steg | ||
.map(steg => { | ||
let tittelBlock: LocaleRecordBlock; | ||
let tittelFlettefeltVerider: FlettefeltVerdier | undefined = undefined; | ||
|
||
switch (steg.route) { | ||
case RouteEnum.Forside: | ||
tittelBlock = FORSIDE.soeknadstittelBarnetrygd; | ||
break; | ||
case RouteEnum.OmDeg: | ||
tittelBlock = OM_DEG.omDegTittel; | ||
break; | ||
case RouteEnum.DinLivssituasjon: | ||
tittelBlock = DIN_LIVSSITUASJON.dinLivssituasjonTittel; | ||
break; | ||
case RouteEnum.VelgBarn: | ||
tittelBlock = VELG_BARN.velgBarnTittel; | ||
break; | ||
case RouteEnum.OmBarna: | ||
tittelBlock = OM_BARNA.omBarnaTittel; | ||
break; | ||
case RouteEnum.OmBarnet: | ||
if (barnForSteg.length === 0) { | ||
tittelBlock = OM_BARNET.omBarnetTittelUtenFlettefelt; | ||
} else { | ||
tittelBlock = OM_BARNET.omBarnetTittel; | ||
tittelFlettefeltVerider = { | ||
barnetsNavn: barnForSteg[antallBarnCounter].navn, | ||
}; | ||
antallBarnCounter++; | ||
} | ||
break; | ||
case RouteEnum.EøsForSøker: | ||
tittelBlock = EØS_FOR_SØKER.eoesForSokerTittel; | ||
break; | ||
case RouteEnum.EøsForBarn: | ||
tittelBlock = EØS_FOR_BARN.eoesForBarnTittel; | ||
break; | ||
case RouteEnum.Oppsummering: | ||
tittelBlock = OPPSUMMERING.oppsummeringTittel; | ||
break; | ||
case RouteEnum.Dokumentasjon: | ||
tittelBlock = DOKUMENTASJON.dokumentasjonTittel; | ||
break; | ||
case RouteEnum.Kvittering: | ||
tittelBlock = KVITTERING.kvitteringTittel; | ||
break; | ||
default: | ||
// Alle routes i RouteEnum må gjennomgås i switch(), ellers feiler _exhaustiveCheck | ||
const _exhaustiveCheck: never = steg.route; | ||
return _exhaustiveCheck; | ||
} | ||
|
||
return { | ||
...steg, | ||
tittel: plainTekst(tittelBlock, tittelFlettefeltVerider), | ||
}; | ||
}) | ||
.filter(steg => steg.route !== RouteEnum.Forside && steg.route !== RouteEnum.Kvittering); | ||
}; |
1 change: 1 addition & 0 deletions
1
src/frontend/components/SøknadsSteg/DinLivssituasjon/innholdTyper.ts
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,6 @@ | ||
import { LocaleRecordBlock } from '../../../typer/sanity/sanity'; | ||
|
||
export interface IDinLivssituasjonTekstinnhold { | ||
dinLivssituasjonTittel: LocaleRecordBlock; | ||
dinLivssituasjonGuide: LocaleRecordBlock; | ||
} |
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
1 change: 1 addition & 0 deletions
1
src/frontend/components/SøknadsSteg/EøsSteg/Barn/innholdTyper.ts
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,6 @@ | ||
import { LocaleRecordBlock } from '../../../../typer/sanity/sanity'; | ||
|
||
export interface IEøsForBarnTekstinnhold { | ||
eoesForBarnTittel: LocaleRecordBlock; | ||
eosForBarnGuide: LocaleRecordBlock; | ||
} |
1 change: 1 addition & 0 deletions
1
src/frontend/components/SøknadsSteg/EøsSteg/Søker/innholdTyper.ts
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,6 @@ | ||
import { LocaleRecordBlock } from '../../../../typer/sanity/sanity'; | ||
|
||
export interface IEøsForSøkerTekstinnhold { | ||
eoesForSokerTittel: LocaleRecordBlock; | ||
eosForSokerGuide: LocaleRecordBlock; | ||
} |
5 changes: 5 additions & 0 deletions
5
src/frontend/components/SøknadsSteg/Kvittering/innholdTyper.ts
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,5 @@ | ||
import { LocaleRecordBlock } from '../../../typer/sanity/sanity'; | ||
|
||
export type IKvitteringTekstinnhold = { | ||
kvitteringTittel: LocaleRecordBlock; | ||
}; |
1 change: 1 addition & 0 deletions
1
src/frontend/components/SøknadsSteg/OmBarnaDine/innholdTyper.ts
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,6 @@ | ||
import { LocaleRecordBlock } from '../../../typer/sanity/sanity'; | ||
|
||
export interface IOmBarnaTekstinnhold { | ||
omBarnaTittel: LocaleRecordBlock; | ||
omBarnaGuide: LocaleRecordBlock; | ||
} |
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 @@ | ||
import { LocaleRecordBlock } from '../../../typer/sanity/sanity'; | ||
|
||
export interface IOmBarnetTekstinnhold { | ||
omBarnetTittel: LocaleRecordBlock; | ||
omBarnetTittelUtenFlettefelt: LocaleRecordBlock; | ||
omBarnetGuide: LocaleRecordBlock; | ||
} |
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,6 @@ | ||
import { LocaleRecordBlock } from '../../../typer/sanity/sanity'; | ||
|
||
export interface IOmDegTekstinnhold { | ||
omDegTittel: LocaleRecordBlock; | ||
omDegGuide: LocaleRecordBlock; | ||
} |
1 change: 1 addition & 0 deletions
1
src/frontend/components/SøknadsSteg/Oppsummering/innholdTyper.ts
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,6 @@ | ||
import { LocaleRecordBlock } from '../../../typer/sanity/sanity'; | ||
|
||
export interface IOppsummeringTekstinnhold { | ||
oppsummeringTittel: LocaleRecordBlock; | ||
oppsummeringGuide: LocaleRecordBlock; | ||
} |
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,6 @@ | ||
import { LocaleRecordBlock } from '../../../typer/sanity/sanity'; | ||
|
||
export interface IVelgBarnTekstinnhold { | ||
velgBarnTittel: LocaleRecordBlock; | ||
velgBarnGuide: LocaleRecordBlock; | ||
} |
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