-
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.
* Setter default epost for krrstub ved reservert true * Lagt til defaultverdi for epost dersom krrstub reservert er valgt og en infomelding om dette * Endret litt på toast oppsett i dolly-frontend
- Loading branch information
Showing
6 changed files
with
50 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,8 @@ import { useKodeverk } from '@/utils/hooks/useKodeverk' | |
import { AdresseKodeverk } from '@/config/kodeverk' | ||
import { useFormContext } from 'react-hook-form' | ||
import { KrrValidation } from '@/components/fagsystem/krrstub/form/KrrValidation' | ||
import { useBoolean } from 'react-use' | ||
import StyledAlert from '@/components/ui/alert/StyledAlert' | ||
|
||
type Change = { | ||
value: boolean | ||
|
@@ -26,6 +28,7 @@ export const KrrstubForm = () => { | |
const { kodeverk: landkoder, loading } = useKodeverk(AdresseKodeverk.ArbeidOgInntektLand) | ||
const [land, setLand] = useState(formMethods.watch('krrstub.land')) | ||
const [mobilnummer, setMobilnummer] = useState(formMethods.watch('values.krrstub.mobil') || '') | ||
const [showInfoStripe, setShowInfoStripe] = useBoolean(false) | ||
const leverandoerer = SelectOptionsOppslag.hentKrrLeverandoerer() | ||
|
||
const mergedeLandkoder = landkoder?.map((landkode: Option) => { | ||
|
@@ -62,6 +65,16 @@ export const KrrstubForm = () => { | |
} | ||
formMethods.trigger('krrstub') | ||
} | ||
|
||
const handleReservertChange = (option: Option) => { | ||
setShowInfoStripe(option?.value === true) | ||
formMethods.setValue('krrstub.reservert', option?.value) | ||
if (option?.value === true && !formMethods.watch('krrstub.epost')) { | ||
formMethods.setValue('krrstub.epost', '[email protected]') | ||
} | ||
formMethods.trigger('krrstub') | ||
} | ||
|
||
return ( | ||
//@ts-ignore | ||
<Vis attributt={krrAttributt}> | ||
|
@@ -71,6 +84,12 @@ export const KrrstubForm = () => { | |
iconType="krr" | ||
startOpen={erForsteEllerTest(formMethods.getValues(), [krrAttributt])} | ||
> | ||
{showInfoStripe && ( | ||
<StyledAlert variant={'info'} size={'small'}> | ||
E-post blir automatisk lagt til dersom identen er reservert slik at den får digital | ||
kontaktinformasjon i KRR. | ||
</StyledAlert> | ||
)} | ||
<div className="flexbox--flex-wrap"> | ||
<DollySelect | ||
name="krrstub.registrert" | ||
|
@@ -82,7 +101,12 @@ export const KrrstubForm = () => { | |
/> | ||
{registrert && ( | ||
<> | ||
<FormSelect name="krrstub.reservert" label="Reservert" options={Options('boolean')} /> | ||
<FormSelect | ||
name="krrstub.reservert" | ||
label="Reservert" | ||
onChange={handleReservertChange} | ||
options={Options('boolean')} | ||
/> | ||
<FormTextInput name="krrstub.epost" label="E-post" /> | ||
<div | ||
style={{ | ||
|
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
21 changes: 21 additions & 0 deletions
21
apps/dolly-frontend/src/main/js/src/components/ui/toast/InfoToast.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,21 @@ | ||
import { toast, ToastContainer } from 'react-toastify' | ||
import 'react-toastify/dist/ReactToastify.css' | ||
|
||
type Props = { | ||
infoTekst: string | ||
onClose: () => void | ||
} | ||
|
||
export const InfoToast = ({ infoTekst, onClose }: Props) => { | ||
toast.info(infoTekst, { | ||
position: 'bottom-right', | ||
toastId: 'info-toast', | ||
autoClose: 10000, | ||
closeOnClick: true, | ||
pauseOnHover: true, | ||
draggable: true, | ||
onClose: () => onClose(), | ||
}) | ||
|
||
return <ToastContainer theme={'light'} /> | ||
} |
8 changes: 0 additions & 8 deletions
8
apps/dolly-frontend/src/main/js/src/components/ui/toast/Toast.cy.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
2 changes: 1 addition & 1 deletion
2
apps/dolly-frontend/src/main/js/src/components/ui/toast/__tests__/Toast.test.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