Skip to content

Commit

Permalink
Tar bort fakta-felles som bare ble brukt ca et sted (#6870)
Browse files Browse the repository at this point in the history
* Tar bort fakta-felles som bare ble brukt ca et sted

* Fikser test
  • Loading branch information
hallvardastark authored Nov 27, 2024
1 parent 471daa7 commit 5344d1f
Show file tree
Hide file tree
Showing 16 changed files with 32 additions and 142 deletions.
17 changes: 12 additions & 5 deletions packages/fakta-arbeidsforhold/src/ArbeidsforholdFaktaIndex.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import React from 'react';
import { createIntl, createIntlCache, RawIntlProvider } from 'react-intl';
import { Aksjonspunkt, ArbeidsgiverOpplysningerPerId, Behandling, KodeverkMedNavn } from '@k9-sak-web/types';
import ArbeidsforholdV2 from '@k9-sak-web/types/src/arbeidsforholdV2TsType';
import { ArbeidsgiverOpplysningerPerId, Behandling, KodeverkMedNavn } from '@k9-sak-web/types';
import StandardFaktaProps from '@k9-sak-web/fakta-felles/standardFaktaPropsTsType';
import ArbeidsforholdInfoPanel from './components/ArbeidsforholdInfoPanel';
import { createIntl, createIntlCache, RawIntlProvider } from 'react-intl';
import messages from '../i18n/nb_NO.json';
import ArbeidsforholdInfoPanel from './components/ArbeidsforholdInfoPanel';

type StandardFaktaProps = Readonly<{
aksjonspunkter: Aksjonspunkt[];
readOnly: boolean;
submittable: boolean;
harApneAksjonspunkter: boolean;
alleMerknaderFraBeslutter: { [key: string]: { notAccepted?: boolean } };
submitCallback?: (aksjonspunktData: any) => Promise<any>;
}>;

const cache = createIntlCache();

Expand Down
5 changes: 0 additions & 5 deletions packages/fakta-felles/i18n/nb_NO.json

This file was deleted.

5 changes: 0 additions & 5 deletions packages/fakta-felles/index.ts

This file was deleted.

20 changes: 0 additions & 20 deletions packages/fakta-felles/package.json

This file was deleted.

12 changes: 0 additions & 12 deletions packages/fakta-felles/src/standardFaktaPropsTsType.ts

This file was deleted.

12 changes: 0 additions & 12 deletions packages/fakta-felles/standardFaktaPropsTsType.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/fakta-medlemskap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"@fpsak-frontend/prop-types": "1.0.0",
"@fpsak-frontend/shared-components": "1.0.0",
"@fpsak-frontend/utils": "1.0.0",
"@k9-sak-web/fakta-felles": "1.0.0",
"@navikt/ft-form-hooks": "5.2.7",
"@navikt/ft-plattform-komponenter": "5.1.3",
"i18n-iso-countries": "7.13.0",
Expand Down
1 change: 0 additions & 1 deletion packages/fakta-verge/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"@fpsak-frontend/prop-types": "1.0.0",
"@fpsak-frontend/shared-components": "1.0.0",
"@fpsak-frontend/utils": "1.0.0",
"@k9-sak-web/fakta-felles": "1.0.0",
"prop-types": "15.8.1",
"react": "18.3.1",
"react-intl": "7.0.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
import { renderWithIntlAndReduxForm } from '@fpsak-frontend/utils-test/test-utils';
import { screen } from '@testing-library/react';
import React from 'react';
import messages from '../../i18n/nb_NO.json';
import FaktaBegrunnelseTextField from './FaktaBegrunnelseTextField';

describe('<FaktaBegrunnelseTextField>', () => {
it('skal ikke vise tekstfelt når en ikke har lov til å løse aksjonspunkt', () => {
renderWithIntlAndReduxForm(
<FaktaBegrunnelseTextField isReadOnly={false} isSubmittable={false} hasBegrunnelse={false} />,
{ messages },
);

expect(screen.queryByRole('textbox')).not.toBeInTheDocument();
});

it('skal vise tekstfelt når en har lov til å løse aksjonspunkt og en har gjort endringer', () => {
renderWithIntlAndReduxForm(<FaktaBegrunnelseTextField isReadOnly={false} isSubmittable hasBegrunnelse={false} />, {
messages,
});
renderWithIntlAndReduxForm(<FaktaBegrunnelseTextField isReadOnly={false} isSubmittable hasBegrunnelse={false} />);

expect(screen.getByRole('textbox', { name: 'Begrunn endringene' })).toBeInTheDocument();
});
Expand All @@ -29,17 +24,14 @@ describe('<FaktaBegrunnelseTextField>', () => {
});

it('skal vise standard-label når en ikke har valgt å vise vurderingstekst eller sende med tekstkode', () => {
renderWithIntlAndReduxForm(<FaktaBegrunnelseTextField isReadOnly={false} isSubmittable hasBegrunnelse={false} />, {
messages,
});
renderWithIntlAndReduxForm(<FaktaBegrunnelseTextField isReadOnly={false} isSubmittable hasBegrunnelse={false} />);

expect(screen.getByRole('textbox', { name: 'Begrunn endringene' })).toBeInTheDocument();
});

it('skal vise label for vurdering når dette er markert av prop', () => {
renderWithIntlAndReduxForm(
<FaktaBegrunnelseTextField isReadOnly={false} isSubmittable hasBegrunnelse={false} hasVurderingText />,
{ messages },
);

expect(screen.getByRole('textbox', { name: 'Vurdering' })).toBeInTheDocument();
Expand All @@ -48,7 +40,6 @@ describe('<FaktaBegrunnelseTextField>', () => {
it('skal vise medsendt label', () => {
renderWithIntlAndReduxForm(
<FaktaBegrunnelseTextField isReadOnly={false} isSubmittable hasBegrunnelse={false} label="Test" />,
{ messages },
);

expect(screen.getByRole('textbox', { name: 'Test' })).toBeInTheDocument();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,9 @@
import { TextAreaField } from '@fpsak-frontend/form';
import { decodeHtmlEntity, hasValidText, maxLength, minLength, required } from '@fpsak-frontend/utils';
import React from 'react';
import { RawIntlProvider, createIntl, createIntlCache } from 'react-intl';

import { Aksjonspunkt } from '@k9-sak-web/types';
import messages from '../../i18n/nb_NO.json';
import styles from './faktaBegrunnelseTextField.module.css';

const cache = createIntlCache();

const intl = createIntl(
{
locale: 'nb-NO',
messages,
},
cache,
);

const minLength3 = minLength(3);
const maxLength1500 = maxLength(1500);

Expand Down Expand Up @@ -48,10 +35,10 @@ const FaktaBegrunnelseTextField = ({
hasVurderingText = false,
name = 'begrunnelse',
}: OwnProps) => {
const code = hasVurderingText ? 'FaktaBegrunnelseTextField.Vurdering' : 'FaktaBegrunnelseTextField.BegrunnEndringene';
const textAreaLabel = label || { id: code };
const defaultLabel = hasVurderingText ? 'Vurdering' : 'Begrunn endringene';
const textAreaLabel = label || defaultLabel;
return (
<RawIntlProvider value={intl}>
<>
{(isSubmittable || hasBegrunnelse) && (
<div className={styles.begrunnelseTextField}>
<TextAreaField
Expand All @@ -63,7 +50,7 @@ const FaktaBegrunnelseTextField = ({
/>
</div>
)}
</RawIntlProvider>
</>
);
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import { renderWithIntlAndReduxForm } from '@fpsak-frontend/utils-test/test-utils';
import { screen } from '@testing-library/react';
import React from 'react';
import messages from '../../i18n/nb_NO.json';
import { render, screen } from '@testing-library/react';
import { FaktaSubmitButton } from './FaktaSubmitButton';

describe('<FaktaSubmitButton>', () => {
it('skal ikke vise knapp når readonly', () => {
renderWithIntlAndReduxForm(
render(
<FaktaSubmitButton
isReadOnly
isSubmittable
Expand All @@ -17,14 +14,13 @@ describe('<FaktaSubmitButton>', () => {
behandlingId={1}
behandlingVersjon={2}
/>,
{ messages },
);

expect(screen.queryByRole('button')).not.toBeInTheDocument();
});

it('skal vise knapp som trykkbar når en kan avklare aksjonspunkt og en har gjort endringer', () => {
renderWithIntlAndReduxForm(
render(
<FaktaSubmitButton
isReadOnly={false}
isSubmittable
Expand All @@ -35,14 +31,13 @@ describe('<FaktaSubmitButton>', () => {
behandlingId={1}
behandlingVersjon={2}
/>,
{ messages },
);

expect(screen.getByRole('button', { name: 'Bekreft og fortsett' })).not.toBeDisabled();
});

it('skal vise knapp som utgrået når en ikke kan avklare aksjonspunkt', () => {
renderWithIntlAndReduxForm(
render(
<FaktaSubmitButton
isReadOnly={false}
isSubmittable={false}
Expand All @@ -53,14 +48,13 @@ describe('<FaktaSubmitButton>', () => {
behandlingId={1}
behandlingVersjon={2}
/>,
{ messages },
);

expect(screen.getByRole('button', { name: 'Bekreft og fortsett' })).toBeDisabled();
});

it('skal vise knapp som utgrået når en har trykket på knapp', () => {
renderWithIntlAndReduxForm(
render(
<FaktaSubmitButton
isReadOnly={false}
isSubmittable
Expand All @@ -71,14 +65,13 @@ describe('<FaktaSubmitButton>', () => {
behandlingId={1}
behandlingVersjon={2}
/>,
{ messages },
);

expect(screen.getByRole('button', { name: 'Bekreft og fortsett' })).toBeDisabled();
});

it('skal vise knapp som utgrået når en ikke har gjort endringer og det er tomme obligatoriske felter', () => {
renderWithIntlAndReduxForm(
render(
<FaktaSubmitButton
isReadOnly={false}
isSubmittable
Expand All @@ -89,14 +82,13 @@ describe('<FaktaSubmitButton>', () => {
behandlingId={1}
behandlingVersjon={2}
/>,
{ messages },
);

expect(screen.getByRole('button', { name: 'Bekreft og fortsett' })).toBeDisabled();
});

it('skal vise knapp som trykkbar når en ikke har gjort endringer men alle obligatoriske felter er utfylte', () => {
renderWithIntlAndReduxForm(
render(
<FaktaSubmitButton
isReadOnly={false}
isSubmittable
Expand All @@ -107,14 +99,13 @@ describe('<FaktaSubmitButton>', () => {
behandlingId={1}
behandlingVersjon={2}
/>,
{ messages },
);

expect(screen.getByRole('button', { name: 'Bekreft og fortsett' })).not.toBeDisabled();
});

it('skal vise knapp som utgrået når en ikke har gjort endringer og aksjonspunktet er løst tidligere', () => {
renderWithIntlAndReduxForm(
render(
<FaktaSubmitButton
isReadOnly={false}
isSubmittable
Expand All @@ -125,7 +116,6 @@ describe('<FaktaSubmitButton>', () => {
behandlingId={1}
behandlingVersjon={2}
/>,
{ messages },
);

expect(screen.getByRole('button', { name: 'Bekreft og fortsett' })).toBeDisabled();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
import React from 'react';
import { FormattedMessage, RawIntlProvider, createIntl, createIntlCache } from 'react-intl';
import { connect } from 'react-redux';

import { hasBehandlingFormErrorsOfType, isBehandlingFormDirty, isBehandlingFormSubmitting } from '@fpsak-frontend/form';
import { ariaCheck, isRequiredMessage } from '@fpsak-frontend/utils';

import { Button } from '@navikt/ds-react';
import messages from '../../i18n/nb_NO.json';

const cache = createIntlCache();

const intl = createIntl(
{
locale: 'nb-NO',
messages,
},
cache,
);

const isDisabled = (
isDirty: boolean,
Expand Down Expand Up @@ -69,7 +57,7 @@ export const FaktaSubmitButton = ({
onClick,
dataId,
}: Partial<PureOwnProps> & MappedOwnProps) => (
<RawIntlProvider value={intl}>
<div>
{!isReadOnly && (
<Button
variant="primary"
Expand All @@ -81,10 +69,10 @@ export const FaktaSubmitButton = ({
data-id={dataId}
>
{!!buttonText && buttonText}
{!buttonText && <FormattedMessage id="SubmitButton.ConfirmInformation" />}
{!buttonText && 'Bekreft og fortsett'}
</Button>
)}
</RawIntlProvider>
</div>
);

const mapStateToProps = (state: any, ownProps: PureOwnProps): MappedOwnProps => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { behandlingForm } from '@fpsak-frontend/form';
import aksjonspunktCodes from '@fpsak-frontend/kodeverk/src/aksjonspunktCodes';
import { AksjonspunktHelpText, VerticalSpacer } from '@fpsak-frontend/shared-components';
import { FaktaBegrunnelseTextField, FaktaSubmitButton } from '@k9-sak-web/fakta-felles';
import { BodyShort } from '@navikt/ds-react';
import PropTypes from 'prop-types';
import React from 'react';
import { injectIntl } from 'react-intl';
import { connect } from 'react-redux';
import { createSelector } from 'reselect';

import { decodeHtmlEntity } from '@fpsak-frontend/utils';
import vergeAksjonspunkterPropType from '../propTypes/vergeAksjonspunkterPropType';
import FaktaBegrunnelseTextField from './FaktaBegrunnelseTextField';
import FaktaSubmitButton from './FaktaSubmitButton';

/**
* RegistrereVergeInfoPanel
Expand Down
2 changes: 1 addition & 1 deletion public/mockServiceWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ async function handleRequest(event, requestId) {
// Ensure MSW is active and ready to handle the message, otherwise
// this message will pend indefinitely.
if (client && activeClientIds.has(client.id)) {
; (async function () {
;(async function () {
const responseClone = response.clone()

sendToClient(
Expand Down
Loading

0 comments on commit 5344d1f

Please sign in to comment.