From 5344d1f556438ca181f6b7746a6e50fe2681aa85 Mon Sep 17 00:00:00 2001 From: Hallvard Andreas Stark <57254397+hallvardastark@users.noreply.github.com> Date: Wed, 27 Nov 2024 13:01:06 +0100 Subject: [PATCH] Tar bort fakta-felles som bare ble brukt ca et sted (#6870) * Tar bort fakta-felles som bare ble brukt ca et sted * Fikser test --- .../src/ArbeidsforholdFaktaIndex.tsx | 17 ++++++++---- packages/fakta-felles/i18n/nb_NO.json | 5 ---- packages/fakta-felles/index.ts | 5 ---- packages/fakta-felles/package.json | 20 -------------- .../src/standardFaktaPropsTsType.ts | 12 --------- .../fakta-felles/standardFaktaPropsTsType.ts | 12 --------- packages/fakta-medlemskap/package.json | 1 - packages/fakta-verge/package.json | 1 - .../FaktaBegrunnelseTextField.spec.tsx | 13 ++-------- .../components/FaktaBegrunnelseTextField.tsx | 21 +++------------ .../src/components/FaktaSubmitButton.spec.tsx | 26 ++++++------------- .../src/components/FaktaSubmitButton.tsx | 18 +++---------- .../components/RegistrereVergeInfoPanel.jsx | 4 +-- .../faktaBegrunnelseTextField.module.css | 0 public/mockServiceWorker.js | 2 +- yarn.lock | 17 ------------ 16 files changed, 32 insertions(+), 142 deletions(-) delete mode 100644 packages/fakta-felles/i18n/nb_NO.json delete mode 100644 packages/fakta-felles/index.ts delete mode 100644 packages/fakta-felles/package.json delete mode 100644 packages/fakta-felles/src/standardFaktaPropsTsType.ts delete mode 100644 packages/fakta-felles/standardFaktaPropsTsType.ts rename packages/{fakta-felles => fakta-verge}/src/components/FaktaBegrunnelseTextField.spec.tsx (86%) rename packages/{fakta-felles => fakta-verge}/src/components/FaktaBegrunnelseTextField.tsx (79%) rename packages/{fakta-felles => fakta-verge}/src/components/FaktaSubmitButton.spec.tsx (85%) rename packages/{fakta-felles => fakta-verge}/src/components/FaktaSubmitButton.tsx (87%) rename packages/{fakta-felles => fakta-verge}/src/components/faktaBegrunnelseTextField.module.css (100%) diff --git a/packages/fakta-arbeidsforhold/src/ArbeidsforholdFaktaIndex.tsx b/packages/fakta-arbeidsforhold/src/ArbeidsforholdFaktaIndex.tsx index 40584bdb25..916ebb3729 100644 --- a/packages/fakta-arbeidsforhold/src/ArbeidsforholdFaktaIndex.tsx +++ b/packages/fakta-arbeidsforhold/src/ArbeidsforholdFaktaIndex.tsx @@ -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; +}>; const cache = createIntlCache(); diff --git a/packages/fakta-felles/i18n/nb_NO.json b/packages/fakta-felles/i18n/nb_NO.json deleted file mode 100644 index e27b036d26..0000000000 --- a/packages/fakta-felles/i18n/nb_NO.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "SubmitButton.ConfirmInformation": "Bekreft og fortsett", - "FaktaBegrunnelseTextField.BegrunnEndringene": "Begrunn endringene", - "FaktaBegrunnelseTextField.Vurdering": "Vurdering" -} diff --git a/packages/fakta-felles/index.ts b/packages/fakta-felles/index.ts deleted file mode 100644 index b54f94a820..0000000000 --- a/packages/fakta-felles/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export { default as FaktaSubmitButton } from './src/components/FaktaSubmitButton'; -export { default as FaktaBegrunnelseTextField } from './src/components/FaktaBegrunnelseTextField'; -export type { FormValues as FaktaBegrunnelseFormValues } from './src/components/FaktaBegrunnelseTextField'; - -export type { default as StandardFaktaProps } from './src/standardFaktaPropsTsType'; diff --git a/packages/fakta-felles/package.json b/packages/fakta-felles/package.json deleted file mode 100644 index 77699d1bc7..0000000000 --- a/packages/fakta-felles/package.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "@k9-sak-web/fakta-felles", - "version": "1.0.0", - "main": "index.ts", - "module": "index.ts", - "license": "MIT", - "private": true, - "dependencies": { - "@fpsak-frontend/form": "1.0.0", - "@fpsak-frontend/utils": "1.0.0", - "@k9-sak-web/types": "1.0.0", - "react": "18.3.1", - "react-intl": "7.0.1", - "react-redux": "9.1.2", - "redux": "5.0.1" - }, - "devDependencies": { - "@fpsak-frontend/utils-test": "1.0.0" - } -} diff --git a/packages/fakta-felles/src/standardFaktaPropsTsType.ts b/packages/fakta-felles/src/standardFaktaPropsTsType.ts deleted file mode 100644 index aaa187c972..0000000000 --- a/packages/fakta-felles/src/standardFaktaPropsTsType.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { Aksjonspunkt } from '@k9-sak-web/types'; - -type StandardFaktaProps = Readonly<{ - aksjonspunkter: Aksjonspunkt[]; - readOnly: boolean; - submittable: boolean; - harApneAksjonspunkter: boolean; - alleMerknaderFraBeslutter: { [key: string]: { notAccepted?: boolean } }; - submitCallback?: (aksjonspunktData: any) => Promise; -}>; - -export default StandardFaktaProps; diff --git a/packages/fakta-felles/standardFaktaPropsTsType.ts b/packages/fakta-felles/standardFaktaPropsTsType.ts deleted file mode 100644 index aaa187c972..0000000000 --- a/packages/fakta-felles/standardFaktaPropsTsType.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { Aksjonspunkt } from '@k9-sak-web/types'; - -type StandardFaktaProps = Readonly<{ - aksjonspunkter: Aksjonspunkt[]; - readOnly: boolean; - submittable: boolean; - harApneAksjonspunkter: boolean; - alleMerknaderFraBeslutter: { [key: string]: { notAccepted?: boolean } }; - submitCallback?: (aksjonspunktData: any) => Promise; -}>; - -export default StandardFaktaProps; diff --git a/packages/fakta-medlemskap/package.json b/packages/fakta-medlemskap/package.json index 73f7283eef..08a4e1da1f 100644 --- a/packages/fakta-medlemskap/package.json +++ b/packages/fakta-medlemskap/package.json @@ -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", diff --git a/packages/fakta-verge/package.json b/packages/fakta-verge/package.json index c3f7322b33..406b7e83f2 100644 --- a/packages/fakta-verge/package.json +++ b/packages/fakta-verge/package.json @@ -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", diff --git a/packages/fakta-felles/src/components/FaktaBegrunnelseTextField.spec.tsx b/packages/fakta-verge/src/components/FaktaBegrunnelseTextField.spec.tsx similarity index 86% rename from packages/fakta-felles/src/components/FaktaBegrunnelseTextField.spec.tsx rename to packages/fakta-verge/src/components/FaktaBegrunnelseTextField.spec.tsx index 74866055b7..c6da32fb75 100644 --- a/packages/fakta-felles/src/components/FaktaBegrunnelseTextField.spec.tsx +++ b/packages/fakta-verge/src/components/FaktaBegrunnelseTextField.spec.tsx @@ -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('', () => { it('skal ikke vise tekstfelt når en ikke har lov til å løse aksjonspunkt', () => { renderWithIntlAndReduxForm( , - { 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(, { - messages, - }); + renderWithIntlAndReduxForm(); expect(screen.getByRole('textbox', { name: 'Begrunn endringene' })).toBeInTheDocument(); }); @@ -29,9 +24,7 @@ describe('', () => { }); it('skal vise standard-label når en ikke har valgt å vise vurderingstekst eller sende med tekstkode', () => { - renderWithIntlAndReduxForm(, { - messages, - }); + renderWithIntlAndReduxForm(); expect(screen.getByRole('textbox', { name: 'Begrunn endringene' })).toBeInTheDocument(); }); @@ -39,7 +32,6 @@ describe('', () => { it('skal vise label for vurdering når dette er markert av prop', () => { renderWithIntlAndReduxForm( , - { messages }, ); expect(screen.getByRole('textbox', { name: 'Vurdering' })).toBeInTheDocument(); @@ -48,7 +40,6 @@ describe('', () => { it('skal vise medsendt label', () => { renderWithIntlAndReduxForm( , - { messages }, ); expect(screen.getByRole('textbox', { name: 'Test' })).toBeInTheDocument(); diff --git a/packages/fakta-felles/src/components/FaktaBegrunnelseTextField.tsx b/packages/fakta-verge/src/components/FaktaBegrunnelseTextField.tsx similarity index 79% rename from packages/fakta-felles/src/components/FaktaBegrunnelseTextField.tsx rename to packages/fakta-verge/src/components/FaktaBegrunnelseTextField.tsx index 299fdd7fb0..b28a05c97c 100644 --- a/packages/fakta-felles/src/components/FaktaBegrunnelseTextField.tsx +++ b/packages/fakta-verge/src/components/FaktaBegrunnelseTextField.tsx @@ -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); @@ -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 ( - + <> {(isSubmittable || hasBegrunnelse) && (
)} -
+ ); }; diff --git a/packages/fakta-felles/src/components/FaktaSubmitButton.spec.tsx b/packages/fakta-verge/src/components/FaktaSubmitButton.spec.tsx similarity index 85% rename from packages/fakta-felles/src/components/FaktaSubmitButton.spec.tsx rename to packages/fakta-verge/src/components/FaktaSubmitButton.spec.tsx index ca82460cb9..ca75fcb560 100644 --- a/packages/fakta-felles/src/components/FaktaSubmitButton.spec.tsx +++ b/packages/fakta-verge/src/components/FaktaSubmitButton.spec.tsx @@ -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('', () => { it('skal ikke vise knapp når readonly', () => { - renderWithIntlAndReduxForm( + render( ', () => { 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( ', () => { 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( ', () => { 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( ', () => { 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( ', () => { 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( ', () => { 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( ', () => { behandlingId={1} behandlingVersjon={2} />, - { messages }, ); expect(screen.getByRole('button', { name: 'Bekreft og fortsett' })).toBeDisabled(); diff --git a/packages/fakta-felles/src/components/FaktaSubmitButton.tsx b/packages/fakta-verge/src/components/FaktaSubmitButton.tsx similarity index 87% rename from packages/fakta-felles/src/components/FaktaSubmitButton.tsx rename to packages/fakta-verge/src/components/FaktaSubmitButton.tsx index 6f371c9103..6eef43c799 100644 --- a/packages/fakta-felles/src/components/FaktaSubmitButton.tsx +++ b/packages/fakta-verge/src/components/FaktaSubmitButton.tsx @@ -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, @@ -69,7 +57,7 @@ export const FaktaSubmitButton = ({ onClick, dataId, }: Partial & MappedOwnProps) => ( - +
{!isReadOnly && ( )} - +
); const mapStateToProps = (state: any, ownProps: PureOwnProps): MappedOwnProps => { diff --git a/packages/fakta-verge/src/components/RegistrereVergeInfoPanel.jsx b/packages/fakta-verge/src/components/RegistrereVergeInfoPanel.jsx index c301e723bb..d7b8b894b3 100644 --- a/packages/fakta-verge/src/components/RegistrereVergeInfoPanel.jsx +++ b/packages/fakta-verge/src/components/RegistrereVergeInfoPanel.jsx @@ -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 diff --git a/packages/fakta-felles/src/components/faktaBegrunnelseTextField.module.css b/packages/fakta-verge/src/components/faktaBegrunnelseTextField.module.css similarity index 100% rename from packages/fakta-felles/src/components/faktaBegrunnelseTextField.module.css rename to packages/fakta-verge/src/components/faktaBegrunnelseTextField.module.css diff --git a/public/mockServiceWorker.js b/public/mockServiceWorker.js index 5f1172f0ff..fead0b3ff9 100644 --- a/public/mockServiceWorker.js +++ b/public/mockServiceWorker.js @@ -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( diff --git a/yarn.lock b/yarn.lock index 2c2af51122..4a2e4fa788 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2650,7 +2650,6 @@ __metadata: "@fpsak-frontend/shared-components": 1.0.0 "@fpsak-frontend/utils": 1.0.0 "@fpsak-frontend/utils-test": 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 @@ -2734,7 +2733,6 @@ __metadata: "@fpsak-frontend/shared-components": 1.0.0 "@fpsak-frontend/utils": 1.0.0 "@fpsak-frontend/utils-test": 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 @@ -4336,21 +4334,6 @@ __metadata: languageName: unknown linkType: soft -"@k9-sak-web/fakta-felles@1.0.0, @k9-sak-web/fakta-felles@workspace:packages/fakta-felles": - version: 0.0.0-use.local - resolution: "@k9-sak-web/fakta-felles@workspace:packages/fakta-felles" - dependencies: - "@fpsak-frontend/form": 1.0.0 - "@fpsak-frontend/utils": 1.0.0 - "@fpsak-frontend/utils-test": 1.0.0 - "@k9-sak-web/types": 1.0.0 - react: 18.3.1 - react-intl: 7.0.1 - react-redux: 9.1.2 - redux: 5.0.1 - languageName: unknown - linkType: soft - "@k9-sak-web/fakta-inntektsmelding@1.0.0, @k9-sak-web/fakta-inntektsmelding@workspace:packages/fakta-inntektsmelding": version: 0.0.0-use.local resolution: "@k9-sak-web/fakta-inntektsmelding@workspace:packages/fakta-inntektsmelding"