Skip to content

Commit f3f01a7

Browse files
committed
Validering i psb
1 parent dea60c9 commit f3f01a7

File tree

3 files changed

+7
-15
lines changed

3 files changed

+7
-15
lines changed

apps/pleiepenger-sykt-barn/src/app/søknad/legeerklæring-step/LegeerklæringStep.tsx

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useAppIntl } from '@i18n/index';
22
import { useAmplitudeInstance } from '@navikt/sif-common-amplitude';
3-
import { FormikAttachmentForm, useAttachmentsHelper } from '@navikt/sif-common-core-ds';
3+
import { FormikAttachmentForm, getAttachmentsValidator, useAttachmentsHelper } from '@navikt/sif-common-core-ds';
44
import Block from '@navikt/sif-common-core-ds/src/atoms/block/Block';
55
import SifGuidePanel from '@navikt/sif-common-core-ds/src/components/sif-guide-panel/SifGuidePanel';
66
import { Attachment } from '@navikt/sif-common-core-ds/src/types/Attachment';
@@ -28,11 +28,7 @@ const LegeerklæringStep = ({ onValidSubmit }: StepCommonProps) => {
2828
persist({ formValues: valuesToPersist, lastStepID: StepID.LEGEERKLÆRING });
2929
};
3030

31-
const { hasPendingUploads, maxTotalSizeExceeded } = useAttachmentsHelper(
32-
attachments,
33-
andreVedlegg,
34-
onAttachmentsChange,
35-
);
31+
const { hasPendingUploads } = useAttachmentsHelper(attachments, andreVedlegg, onAttachmentsChange);
3632

3733
usePersistOnChange(attachments, true, StepID.LEGEERKLÆRING);
3834

@@ -51,7 +47,7 @@ const LegeerklæringStep = ({ onValidSubmit }: StepCommonProps) => {
5147
}}
5248
useValidationErrorSummary={false}
5349
skipValidation={true}
54-
buttonDisabled={hasPendingUploads || maxTotalSizeExceeded}>
50+
buttonDisabled={hasPendingUploads}>
5551
<Block padBottom="xl">
5652
<SifGuidePanel compact={true}>
5753
<p>
@@ -69,6 +65,7 @@ const LegeerklæringStep = ({ onValidSubmit }: StepCommonProps) => {
6965
addLabel: text('steg.lege.vedlegg'),
7066
noAttachmentsText: text('vedleggsliste.ingenLegeerklæringLastetOpp'),
7167
}}
68+
validate={getAttachmentsValidator({ useDefaultMessages: true }, andreVedlegg)}
7269
uploadLaterURL={getLenker(intl.locale).ettersend}
7370
onUnauthorizedOrForbiddenUpload={userNotLoggedIn}
7471
otherAttachments={andreVedlegg}

apps/pleiepenger-sykt-barn/src/app/søknad/opplysninger-om-barnet-step/FødselsattestPart.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Heading } from '@navikt/ds-react';
22
import React from 'react';
33
import { useAppIntl } from '@i18n/index';
44
import { useAmplitudeInstance } from '@navikt/sif-common-amplitude';
5-
import { useAttachmentsHelper } from '@navikt/sif-common-core-ds';
5+
import { getAttachmentsValidator, useAttachmentsHelper } from '@navikt/sif-common-core-ds';
66
import { FormikAttachmentForm } from '@navikt/sif-common-core-ds/src';
77
import Block from '@navikt/sif-common-core-ds/src/atoms/block/Block';
88
import { Attachment } from '@navikt/sif-common-core-ds/src/types/Attachment';
@@ -53,6 +53,7 @@ const FødselsattestPart: React.FC<Props> = ({ fødselsattester }) => {
5353
addLabel: text('steg.omBarnet.fødselsattest.vedlegg'),
5454
noAttachmentsText: text('step.oppsummering.omBarn.ingenFødselsattest'),
5555
}}
56+
validate={getAttachmentsValidator({ useDefaultMessages: true }, andreVedlegg)}
5657
uploadLaterURL={getLenker(intl.locale).ettersend}
5758
onUnauthorizedOrForbiddenUpload={userNotLoggedIn}
5859
otherAttachments={andreVedlegg}

apps/pleiepenger-sykt-barn/src/app/søknad/opplysninger-om-barnet-step/OpplysningerOmBarnetStep.tsx

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import React from 'react';
22
import { Attachment } from '@navikt/sif-common-core-ds/src/types/Attachment';
3-
import {
4-
getTotalSizeOfAttachments,
5-
MAX_TOTAL_ATTACHMENT_SIZE_BYTES,
6-
} from '@navikt/sif-common-core-ds/src/utils/attachmentUtils';
73
import { useFormikContext } from 'formik';
84
import { SøkerdataContext } from '../../context/SøkerdataContext';
95
import { StepCommonProps } from '../../types/StepCommonProps';
@@ -28,14 +24,12 @@ const OpplysningerOmBarnetStep = ({ onValidSubmit }: StepCommonProps) => {
2824
return values && values.fødselsattest ? values[SøknadFormField.fødselsattest] : [];
2925
}, [values]);
3026
const hasPendingUploads: boolean = attachments.find((a) => a.pending === true) !== undefined;
31-
const totalSize = getTotalSizeOfAttachments([...attachments, ...values.legeerklæring]);
32-
const attachmentsSizeOver24Mb = totalSize > MAX_TOTAL_ATTACHMENT_SIZE_BYTES;
3327

3428
return (
3529
<SøknadFormStep
3630
stepId={StepID.OPPLYSNINGER_OM_BARNET}
3731
onValidFormSubmit={onValidSubmit}
38-
buttonDisabled={hasPendingUploads || attachmentsSizeOver24Mb}>
32+
buttonDisabled={hasPendingUploads}>
3933
{søkerdata && (
4034
<div data-testid="opplysninger-om-barnet">
4135
{harRegistrerteBarn(søkerdata) && <RegistrertBarnPart søkersBarn={søkerdata.barn} />}

0 commit comments

Comments
 (0)