@@ -199,11 +192,8 @@ const SoknadsfristVilkarProsessIndex = ({
erOverstyrt={erOverstyrt}
submitCallback={submitCallback}
overrideReadOnly={overrideReadOnly}
- kanOverstyreAccess={kanOverstyreAccess}
toggleOverstyring={toggleOverstyring}
status={activePeriode.vilkarStatus.kode}
- panelTittelKode={panelTittelKode}
- lovReferanse={activeVilkår.lovReferanse ?? lovReferanse}
alleDokumenter={dokumenterSomSkalVurderes}
dokumenterIAktivPeriode={dokumenterIAktivPeriode}
periode={activePeriode}
diff --git a/packages/prosess-vilkar-soknadsfrist/src/components/FormState.ts b/packages/prosess-vilkar-soknadsfrist/src/components/FormState.ts
new file mode 100644
index 0000000000..777e6b0f23
--- /dev/null
+++ b/packages/prosess-vilkar-soknadsfrist/src/components/FormState.ts
@@ -0,0 +1,11 @@
+interface AvklarteKrav {
+ erVilkarOk: string | boolean;
+ begrunnelse: string;
+ journalpostId: string;
+ fraDato: string;
+}
+
+export interface FormState {
+ isOverstyrt: boolean;
+ avklarteKrav: AvklarteKrav[];
+}
diff --git a/packages/prosess-vilkar-soknadsfrist/src/components/OverstyrBekreftKnappPanel.spec.tsx b/packages/prosess-vilkar-soknadsfrist/src/components/OverstyrBekreftKnappPanel.spec.tsx
index 3af8dd39da..7c1c06be9f 100644
--- a/packages/prosess-vilkar-soknadsfrist/src/components/OverstyrBekreftKnappPanel.spec.tsx
+++ b/packages/prosess-vilkar-soknadsfrist/src/components/OverstyrBekreftKnappPanel.spec.tsx
@@ -1,21 +1,17 @@
-import { renderWithIntl } from '@fpsak-frontend/utils-test/test-utils';
-import { screen } from '@testing-library/react';
+import { render, screen } from '@testing-library/react';
import React from 'react';
-import messages from '../../i18n/nb_NO.json';
import OverstyrBekreftKnappPanel from './OverstyrBekreftKnappPanel';
describe('
', () => {
it('skal rendre submit-knapp når en ikke er i readonly-modus', () => {
- renderWithIntl(, {
- messages,
- });
+ render();
expect(screen.getByRole('button', { name: 'Bekreft overstyring' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: 'Bekreft overstyring' })).not.toBeDisabled();
});
it('skal ikke vise submit-knapp når en er i readonly-modus', () => {
- renderWithIntl(, { messages });
+ render();
expect(screen.queryByRole('button', { name: 'Bekreft overstyring' })).not.toBeInTheDocument();
});
diff --git a/packages/prosess-vilkar-soknadsfrist/src/components/OverstyrBekreftKnappPanel.tsx b/packages/prosess-vilkar-soknadsfrist/src/components/OverstyrBekreftKnappPanel.tsx
index 46a9ead264..9abdf3bc09 100644
--- a/packages/prosess-vilkar-soknadsfrist/src/components/OverstyrBekreftKnappPanel.tsx
+++ b/packages/prosess-vilkar-soknadsfrist/src/components/OverstyrBekreftKnappPanel.tsx
@@ -1,6 +1,5 @@
import { Button } from '@navikt/ds-react';
import React from 'react';
-import { FormattedMessage } from 'react-intl';
interface OwnProps {
disabled?: boolean;
@@ -15,7 +14,7 @@ const OverstyrBekreftKnappPanel = ({ disabled = false, submitting, pristine, ove
}
return (
);
};
diff --git a/packages/prosess-vilkar-soknadsfrist/src/components/SoknadsfristVilkarDokument.module.css b/packages/prosess-vilkar-soknadsfrist/src/components/SoknadsfristVilkarDokument.module.css
index ea0d1198a9..c3c57d1029 100644
--- a/packages/prosess-vilkar-soknadsfrist/src/components/SoknadsfristVilkarDokument.module.css
+++ b/packages/prosess-vilkar-soknadsfrist/src/components/SoknadsfristVilkarDokument.module.css
@@ -11,3 +11,10 @@
.fullBreddeIE {
width: 100%;
}
+
+.editButton {
+ :global(.navds-label) {
+ font-size: 0.875rem;
+ text-decoration: underline;
+ }
+}
diff --git a/packages/prosess-vilkar-soknadsfrist/src/components/SoknadsfristVilkarDokument.tsx b/packages/prosess-vilkar-soknadsfrist/src/components/SoknadsfristVilkarDokument.tsx
index f38a003e49..40eb2e664f 100644
--- a/packages/prosess-vilkar-soknadsfrist/src/components/SoknadsfristVilkarDokument.tsx
+++ b/packages/prosess-vilkar-soknadsfrist/src/components/SoknadsfristVilkarDokument.tsx
@@ -1,6 +1,6 @@
import avslattImage from '@fpsak-frontend/assets/images/avslaatt.svg';
import innvilgetImage from '@fpsak-frontend/assets/images/check.svg';
-import { DatepickerField, RadioGroupField, TextAreaField } from '@fpsak-frontend/form';
+import { RadioGroupPanelRHF } from '@fpsak-frontend/form';
import {
FlexColumn,
FlexContainer,
@@ -9,6 +9,10 @@ import {
VerticalSpacer,
useSaksbehandlerOppslag,
} from '@fpsak-frontend/shared-components';
+import { initializeDate } from '@fpsak-frontend/utils';
+import { DokumentStatus, Vilkarperiode } from '@k9-sak-web/types';
+import { BodyShort, Button } from '@navikt/ds-react';
+import { Datepicker, TextAreaField } from '@navikt/ft-form-hooks';
import {
dateAfterOrEqual,
dateBeforeOrEqual,
@@ -17,28 +21,27 @@ import {
maxLength,
minLength,
required,
- requiredIfNotPristine,
-} from '@fpsak-frontend/utils';
-import { DokumentStatus } from '@k9-sak-web/types';
-import { BodyShort } from '@navikt/ds-react';
+} from '@navikt/ft-form-validators';
import { AssessedBy } from '@navikt/ft-plattform-komponenter';
-import moment from 'moment';
import React, { useCallback, useMemo } from 'react';
-import { FormattedMessage, useIntl } from 'react-intl';
-
+import { useFormContext } from 'react-hook-form';
import { formatDate } from '../utils';
-
+import { FormState } from './FormState';
import styles from './SoknadsfristVilkarDokument.module.css';
const minLength3 = minLength(3);
const maxLength1500 = maxLength(1500);
interface SoknadsfristVilkarDokumentProps {
- erVilkarOk?: boolean | string;
readOnly: boolean;
skalViseBegrunnelse?: boolean;
dokument: DokumentStatus;
dokumentIndex: number;
erAktivtDokument: boolean;
+ toggleEditForm: React.Dispatch>;
+ erOverstyrt?: boolean;
+ redigerVurdering?: boolean;
+ dokumentErVurdert: boolean;
+ periode?: Vilkarperiode;
}
export const DELVIS_OPPFYLT = 'DELVIS_OPPFYLT';
@@ -50,21 +53,27 @@ export const DELVIS_OPPFYLT = 'DELVIS_OPPFYLT';
* Resultatet kan overstyres av Nav-ansatt med overstyr-rettighet.
*/
export const SoknadsfristVilkarDokument = ({
- erVilkarOk,
readOnly,
skalViseBegrunnelse = true,
dokument,
erAktivtDokument,
dokumentIndex,
+ toggleEditForm,
+ erOverstyrt,
+ redigerVurdering,
+ dokumentErVurdert,
+ periode,
}: SoknadsfristVilkarDokumentProps) => {
- const intl = useIntl();
+ const { getValues } = useFormContext();
+ const harBegrunnelse = !!getValues('avklarteKrav')[dokumentIndex]?.begrunnelse;
+ const erVilkarOk = readOnly && dokumentErVurdert && periode.vilkarStatus.kode === 'OPPFYLT';
const { hentSaksbehandlerNavn } = useSaksbehandlerOppslag();
const opprettetAv = hentSaksbehandlerNavn(dokument?.avklarteOpplysninger?.opprettetAv);
const opprettetTidspunkt = dokument?.avklarteOpplysninger?.opprettetTidspunkt;
const minDate = useMemo(
() =>
dokument.status.reduce(
- (acc, curr) => (!acc || moment(curr.periode.fom) < moment(acc) ? curr.periode.fom : acc),
+ (acc, curr) => (!acc || initializeDate(curr.periode.fom) < initializeDate(acc) ? curr.periode.fom : acc),
'',
),
[dokument.journalpostId],
@@ -72,7 +81,7 @@ export const SoknadsfristVilkarDokument = ({
const maxDate = useMemo(
() =>
dokument.status.reduce(
- (acc, curr) => (!acc || moment(curr.periode.tom) > moment(acc) ? curr.periode.tom : acc),
+ (acc, curr) => (!acc || initializeDate(curr.periode.tom) > initializeDate(acc) ? curr.periode.tom : acc),
'',
),
[dokument.innsendingstidspunkt, dokument.journalpostId],
@@ -88,16 +97,20 @@ export const SoknadsfristVilkarDokument = ({
{skalViseBegrunnelse && (
<>
-
-
-
+
>
)}
@@ -108,17 +121,10 @@ export const SoknadsfristVilkarDokument = ({
- {erVilkarOk && (
-
- {chunks} }} />
-
- )}
+ {erVilkarOk && Vilkåret er oppfylt for hele perioden}
{!erVilkarOk && (
- {chunks} }}
- />
+ Vilkåret er ikke oppfylt for denne perioden
)}
@@ -127,54 +133,60 @@ export const SoknadsfristVilkarDokument = ({
)}
{(!readOnly || erVilkarOk === undefined) && (
- {chunks} }} />
- ),
+ value: 'true',
+ label: 'Vilkåret er oppfylt for hele perioden',
},
{
value: DELVIS_OPPFYLT,
- label: (
- {chunks} }}
- />
- ),
+ label: 'Vilkåret er oppfylt for deler av perioden',
element: (
-
),
},
{
- value: false,
+ value: 'false',
label: (
- {chunks} }}
- />
+ <>
+ Vilkåret er ikke oppfylt for denne perioden
+ >
),
},
]}
/>
)}
+ {!erOverstyrt && dokumentErVurdert && harBegrunnelse && !redigerVurdering && (
+
+
+
+
+ )}
);
diff --git a/packages/prosess-vilkar-soknadsfrist/src/components/SoknadsfristVilkarForm.spec.tsx b/packages/prosess-vilkar-soknadsfrist/src/components/SoknadsfristVilkarForm.spec.tsx
index 4921a7266b..95c9c04948 100644
--- a/packages/prosess-vilkar-soknadsfrist/src/components/SoknadsfristVilkarForm.spec.tsx
+++ b/packages/prosess-vilkar-soknadsfrist/src/components/SoknadsfristVilkarForm.spec.tsx
@@ -1,13 +1,9 @@
-import React from 'react';
// import behandlingType from '@fpsak-frontend/kodeverk/src/behandlingType';
import vilkarUtfallType from '@fpsak-frontend/kodeverk/src/vilkarUtfallType';
-import { renderWithIntlAndReduxForm } from '@fpsak-frontend/utils-test/test-utils';
-import { reduxFormPropsMock } from '@fpsak-frontend/utils-test/redux-form-test-helper';
import { K9sakApiKeys, requestApi } from '@k9-sak-web/sak-app/src/data/k9sakApi';
import { DokumentStatus } from '@k9-sak-web/types';
import Vilkarperiode from '@k9-sak-web/types/src/vilkarperiode';
-import { screen } from '@testing-library/react';
-import messages from '../../i18n/nb_NO.json';
+import { render, screen } from '@testing-library/react';
import { SoknadsfristVilkarForm } from './SoknadsfristVilkarForm';
const periode = {
@@ -51,15 +47,11 @@ const dokumenter = [
describe('