-
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.
Merge pull request #3583 from navikt/feature/skattekort-frontend-ny
Feature/skattekort frontend ny
- Loading branch information
Showing
29 changed files
with
814 additions
and
13 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
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
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
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
70 changes: 70 additions & 0 deletions
70
...olly-frontend/src/main/js/src/components/fagsystem/skattekort/form/ArbeidsgiverToggle.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 @@ | ||
import React, { useState } from 'react' | ||
import { ToggleGroup } from '@navikt/ds-react' | ||
import { OrgnummerToggle } from '@/components/fagsystem/inntektstub/form/partials/orgnummerToggle' | ||
import { FormTextInput } from '@/components/ui/form/inputs/textInput/TextInput' | ||
import { Kategori } from '@/components/ui/form/kategori/Kategori' | ||
import { UseFormReturn } from 'react-hook-form/dist/types' | ||
|
||
enum ToggleValg { | ||
ORGANISASJON = 'ORGANISASJON', | ||
PRIVAT = 'PRIVAT', | ||
} | ||
|
||
type ArbeidsgiverToggleProps = { | ||
formMethods: UseFormReturn | ||
path: string | ||
} | ||
|
||
export const ArbeidsgiverToggle = ({ formMethods, path }: ArbeidsgiverToggleProps) => { | ||
const organisasjonPath = `${path}.organisasjonsnummer` | ||
const personPath = `${path}.personidentifikator` | ||
|
||
const [inputType, setInputType] = useState( | ||
formMethods.watch(`${path}.personidentifikator`)?.length === 11 | ||
? ToggleValg.PRIVAT | ||
: ToggleValg.ORGANISASJON, | ||
) | ||
|
||
const handleToggleChange = (value: ToggleValg) => { | ||
setInputType(value) | ||
if (value === ToggleValg.ORGANISASJON) { | ||
formMethods.setValue(organisasjonPath, '') | ||
formMethods.setValue(personPath, undefined) | ||
} else if (value === ToggleValg.PRIVAT) { | ||
formMethods.setValue(personPath, '') | ||
formMethods.setValue(organisasjonPath, undefined) | ||
} | ||
} | ||
|
||
return ( | ||
<Kategori title="Arbeidsgiver"> | ||
<div className="toggle--wrapper"> | ||
<ToggleGroup | ||
size={'small'} | ||
onChange={handleToggleChange} | ||
defaultValue={inputType} | ||
style={{ backgroundColor: '#ffffff' }} | ||
> | ||
<ToggleGroup.Item key={ToggleValg.ORGANISASJON} value={ToggleValg.ORGANISASJON}> | ||
Organisasjon | ||
</ToggleGroup.Item> | ||
<ToggleGroup.Item key={ToggleValg.PRIVAT} value={ToggleValg.PRIVAT}> | ||
Privat | ||
</ToggleGroup.Item> | ||
</ToggleGroup> | ||
|
||
{inputType === ToggleValg.ORGANISASJON ? ( | ||
<OrgnummerToggle | ||
formMethods={formMethods} | ||
path={organisasjonPath} | ||
opplysningspliktigPath={null} | ||
/> | ||
) : ( | ||
<div className="flexbox--flex-wrap" style={{ marginTop: '5px' }}> | ||
<FormTextInput name={personPath} label="Personidentifikator" size="xlarge" /> | ||
</div> | ||
)} | ||
</div> | ||
</Kategori> | ||
) | ||
} |
Oops, something went wrong.