From c0da47a5510e6d132e12852cd820e91e2a696876 Mon Sep 17 00:00:00 2001 From: Igor Weber Date: Mon, 20 Nov 2023 17:04:22 +0100 Subject: [PATCH] Intl 2 > 3 --- package-lock.json | 225 +++++------------- package.json | 6 +- .../navKnapp.snapshot.test.tsx.snap | 4 +- .../periodeBanner.snapshot.test.tsx.snap | 4 +- .../utils/sporsmalsobjekterUtil.test.tsx | 6 +- src/app/app.tsx | 4 +- src/app/reducers/localesReducer.tsx | 12 +- .../begrunnelse/begrunnelseVelger.tsx | 2 +- src/app/store/configureStore.tsx | 6 +- src/app/utils/intlUtil.tsx | 11 +- src/index.tsx | 9 +- 11 files changed, 79 insertions(+), 210 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6cc3a8af..d7d6b3a7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,6 @@ "@types/react-aria-menubutton": "^6.2.12", "@types/react-collapse": "^5.0.4", "@types/react-dom": "^17.0.23", - "@types/react-intl": "^2.3.18", "@types/react-intl-redux": "^0.1.19", "@types/react-redux": "^7.1.30", "@types/react-router": "^5.1.20", @@ -85,7 +84,7 @@ "react-burger-menu": "^3.0.9", "react-collapse": "^5.1.1", "react-dom": "^17.0.2", - "react-intl": "^2.9.0", + "react-intl": "^3.12.1", "react-intl-redux": "^2.3.0", "react-modal": "^3.16.1", "react-motion": "^0.5.2", @@ -4641,11 +4640,6 @@ "@types/react": "^17" } }, - "node_modules/@types/react-intl": { - "version": "2.3.18", - "resolved": "https://registry.npmjs.org/@types/react-intl/-/react-intl-2.3.18.tgz", - "integrity": "sha512-DVNJs49zUxKRZng8VuILE886Yihdsf3yLr5vHk9zJrmF8SyRSK3sxNSvikAKxNkv9hX55XBTJShz6CkJnbNjgg==" - }, "node_modules/@types/react-intl-redux": { "version": "0.1.19", "resolved": "https://registry.npmjs.org/@types/react-intl-redux/-/react-intl-redux-0.1.19.tgz", @@ -4656,51 +4650,6 @@ "redux": "^4.0.0" } }, - "node_modules/@types/react-intl-redux/node_modules/intl-format-cache": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/intl-format-cache/-/intl-format-cache-4.3.1.tgz", - "integrity": "sha512-OEUYNA7D06agqPOYhbTkl0T8HA3QKSuwWh1HiClEnpd9vw7N+3XsQt5iZ0GUEchp5CW1fQk/tary+NsbF3yQ1Q==" - }, - "node_modules/@types/react-intl-redux/node_modules/intl-messageformat": { - "version": "7.8.4", - "resolved": "https://registry.npmjs.org/intl-messageformat/-/intl-messageformat-7.8.4.tgz", - "integrity": "sha512-yS0cLESCKCYjseCOGXuV4pxJm/buTfyCJ1nzQjryHmSehlptbZbn9fnlk1I9peLopZGGbjj46yHHiTAEZ1qOTA==", - "dependencies": { - "intl-format-cache": "^4.2.21", - "intl-messageformat-parser": "^3.6.4" - } - }, - "node_modules/@types/react-intl-redux/node_modules/intl-messageformat-parser": { - "version": "3.6.4", - "resolved": "https://registry.npmjs.org/intl-messageformat-parser/-/intl-messageformat-parser-3.6.4.tgz", - "integrity": "sha512-RgPGwue0mJtoX2Ax8EmMzJzttxjnva7gx0Q7mKJ4oALrTZvtmCeAw5Msz2PcjW4dtCh/h7vN/8GJCxZO1uv+OA==", - "deprecated": "We've written a new parser that's 6x faster and is backwards compatible. Please use @formatjs/icu-messageformat-parser", - "dependencies": { - "@formatjs/intl-unified-numberformat": "^3.2.0" - } - }, - "node_modules/@types/react-intl-redux/node_modules/react-intl": { - "version": "3.12.1", - "resolved": "https://registry.npmjs.org/react-intl/-/react-intl-3.12.1.tgz", - "integrity": "sha512-cgumW29mwROIqyp8NXStYsoIm27+8FqnxykiLSawWjOxGIBeLuN/+p2srei5SRIumcJefOkOIHP+NDck05RgHg==", - "dependencies": { - "@formatjs/intl-displaynames": "^1.2.0", - "@formatjs/intl-listformat": "^1.4.1", - "@formatjs/intl-relativetimeformat": "^4.5.9", - "@formatjs/intl-unified-numberformat": "^3.2.0", - "@formatjs/intl-utils": "^2.2.0", - "@types/hoist-non-react-statics": "^3.3.1", - "@types/invariant": "^2.2.31", - "hoist-non-react-statics": "^3.3.2", - "intl-format-cache": "^4.2.21", - "intl-messageformat": "^7.8.4", - "intl-messageformat-parser": "^3.6.4", - "shallow-equal": "^1.2.1" - }, - "peerDependencies": { - "react": "^16.3.0" - } - }, "node_modules/@types/react-redux": { "version": "7.1.30", "resolved": "https://registry.npmjs.org/@types/react-redux/-/react-redux-7.1.30.tgz", @@ -11701,39 +11650,26 @@ } }, "node_modules/intl-format-cache": { - "version": "2.2.9", - "resolved": "https://registry.npmjs.org/intl-format-cache/-/intl-format-cache-2.2.9.tgz", - "integrity": "sha512-Zv/u8wRpekckv0cLkwpVdABYST4hZNTDaX7reFetrYTJwxExR2VyTqQm+l0WmL0Qo8Mjb9Tf33qnfj0T7pjxdQ==" + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/intl-format-cache/-/intl-format-cache-4.3.1.tgz", + "integrity": "sha512-OEUYNA7D06agqPOYhbTkl0T8HA3QKSuwWh1HiClEnpd9vw7N+3XsQt5iZ0GUEchp5CW1fQk/tary+NsbF3yQ1Q==" }, "node_modules/intl-messageformat": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/intl-messageformat/-/intl-messageformat-2.2.0.tgz", - "integrity": "sha512-I+tSvHnXqJYjDfNmY95tpFMj30yoakC6OXAo+wu/wTMy6tA/4Fd4mvV7Uzs4cqK/Ap29sHhwjcY+78a8eifcXw==", + "version": "7.8.4", + "resolved": "https://registry.npmjs.org/intl-messageformat/-/intl-messageformat-7.8.4.tgz", + "integrity": "sha512-yS0cLESCKCYjseCOGXuV4pxJm/buTfyCJ1nzQjryHmSehlptbZbn9fnlk1I9peLopZGGbjj46yHHiTAEZ1qOTA==", "dependencies": { - "intl-messageformat-parser": "1.4.0" + "intl-format-cache": "^4.2.21", + "intl-messageformat-parser": "^3.6.4" } }, "node_modules/intl-messageformat-parser": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/intl-messageformat-parser/-/intl-messageformat-parser-1.4.0.tgz", - "integrity": "sha512-/XkqFHKezO6UcF4Av2/Lzfrez18R0jyw7kRFhSeB/YRakdrgSc9QfFZUwNJI9swMwMoNPygK1ArC5wdFSjPw+A==", - "deprecated": "We've written a new parser that's 6x faster and is backwards compatible. Please use @formatjs/icu-messageformat-parser" - }, - "node_modules/intl-relativeformat": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/intl-relativeformat/-/intl-relativeformat-2.2.0.tgz", - "integrity": "sha512-4bV/7kSKaPEmu6ArxXf9xjv1ny74Zkwuey8Pm01NH4zggPP7JHwg2STk8Y3JdspCKRDriwIyLRfEXnj2ZLr4Bw==", - "deprecated": "This package has been deprecated, please see migration guide at 'https://github.com/formatjs/formatjs/tree/master/packages/intl-relativeformat#migration-guide'", - "dependencies": { - "intl-messageformat": "^2.0.0" - } - }, - "node_modules/invariant": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/invariant/-/invariant-2.2.4.tgz", - "integrity": "sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==", + "version": "3.6.4", + "resolved": "https://registry.npmjs.org/intl-messageformat-parser/-/intl-messageformat-parser-3.6.4.tgz", + "integrity": "sha512-RgPGwue0mJtoX2Ax8EmMzJzttxjnva7gx0Q7mKJ4oALrTZvtmCeAw5Msz2PcjW4dtCh/h7vN/8GJCxZO1uv+OA==", + "deprecated": "We've written a new parser that's 6x faster and is backwards compatible. Please use @formatjs/icu-messageformat-parser", "dependencies": { - "loose-envify": "^1.0.0" + "@formatjs/intl-unified-numberformat": "^3.2.0" } }, "node_modules/ipaddr.js": { @@ -18997,19 +18933,25 @@ "integrity": "sha512-/6UZ2qgEyH2aqzYZgQPxEnz33NJ2gNsnHA2o5+o4wW9bLM/JYQitNP9xPhsXwC08hMMovfGe/8retsdDsczPRg==" }, "node_modules/react-intl": { - "version": "2.9.0", - "resolved": "https://registry.npmjs.org/react-intl/-/react-intl-2.9.0.tgz", - "integrity": "sha512-27jnDlb/d2A7mSJwrbOBnUgD+rPep+abmoJE511Tf8BnoONIAUehy/U1zZCHGO17mnOwMWxqN4qC0nW11cD6rA==", + "version": "3.12.1", + "resolved": "https://registry.npmjs.org/react-intl/-/react-intl-3.12.1.tgz", + "integrity": "sha512-cgumW29mwROIqyp8NXStYsoIm27+8FqnxykiLSawWjOxGIBeLuN/+p2srei5SRIumcJefOkOIHP+NDck05RgHg==", "dependencies": { - "hoist-non-react-statics": "^3.3.0", - "intl-format-cache": "^2.0.5", - "intl-messageformat": "^2.1.0", - "intl-relativeformat": "^2.1.0", - "invariant": "^2.1.1" + "@formatjs/intl-displaynames": "^1.2.0", + "@formatjs/intl-listformat": "^1.4.1", + "@formatjs/intl-relativetimeformat": "^4.5.9", + "@formatjs/intl-unified-numberformat": "^3.2.0", + "@formatjs/intl-utils": "^2.2.0", + "@types/hoist-non-react-statics": "^3.3.1", + "@types/invariant": "^2.2.31", + "hoist-non-react-statics": "^3.3.2", + "intl-format-cache": "^4.2.21", + "intl-messageformat": "^7.8.4", + "intl-messageformat-parser": "^3.6.4", + "shallow-equal": "^1.2.1" }, "peerDependencies": { - "prop-types": "^15.5.4", - "react": "^0.14.9 || ^15.0.0 || ^16.0.0" + "react": "^16.3.0" } }, "node_modules/react-intl-redux": { @@ -26626,11 +26568,6 @@ "@types/react": "^17" } }, - "@types/react-intl": { - "version": "2.3.18", - "resolved": "https://registry.npmjs.org/@types/react-intl/-/react-intl-2.3.18.tgz", - "integrity": "sha512-DVNJs49zUxKRZng8VuILE886Yihdsf3yLr5vHk9zJrmF8SyRSK3sxNSvikAKxNkv9hX55XBTJShz6CkJnbNjgg==" - }, "@types/react-intl-redux": { "version": "0.1.19", "resolved": "https://registry.npmjs.org/@types/react-intl-redux/-/react-intl-redux-0.1.19.tgz", @@ -26639,49 +26576,6 @@ "@types/react-redux": "*", "react-intl": "^3", "redux": "^4.0.0" - }, - "dependencies": { - "intl-format-cache": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/intl-format-cache/-/intl-format-cache-4.3.1.tgz", - "integrity": "sha512-OEUYNA7D06agqPOYhbTkl0T8HA3QKSuwWh1HiClEnpd9vw7N+3XsQt5iZ0GUEchp5CW1fQk/tary+NsbF3yQ1Q==" - }, - "intl-messageformat": { - "version": "7.8.4", - "resolved": "https://registry.npmjs.org/intl-messageformat/-/intl-messageformat-7.8.4.tgz", - "integrity": "sha512-yS0cLESCKCYjseCOGXuV4pxJm/buTfyCJ1nzQjryHmSehlptbZbn9fnlk1I9peLopZGGbjj46yHHiTAEZ1qOTA==", - "requires": { - "intl-format-cache": "^4.2.21", - "intl-messageformat-parser": "^3.6.4" - } - }, - "intl-messageformat-parser": { - "version": "3.6.4", - "resolved": "https://registry.npmjs.org/intl-messageformat-parser/-/intl-messageformat-parser-3.6.4.tgz", - "integrity": "sha512-RgPGwue0mJtoX2Ax8EmMzJzttxjnva7gx0Q7mKJ4oALrTZvtmCeAw5Msz2PcjW4dtCh/h7vN/8GJCxZO1uv+OA==", - "requires": { - "@formatjs/intl-unified-numberformat": "^3.2.0" - } - }, - "react-intl": { - "version": "3.12.1", - "resolved": "https://registry.npmjs.org/react-intl/-/react-intl-3.12.1.tgz", - "integrity": "sha512-cgumW29mwROIqyp8NXStYsoIm27+8FqnxykiLSawWjOxGIBeLuN/+p2srei5SRIumcJefOkOIHP+NDck05RgHg==", - "requires": { - "@formatjs/intl-displaynames": "^1.2.0", - "@formatjs/intl-listformat": "^1.4.1", - "@formatjs/intl-relativetimeformat": "^4.5.9", - "@formatjs/intl-unified-numberformat": "^3.2.0", - "@formatjs/intl-utils": "^2.2.0", - "@types/hoist-non-react-statics": "^3.3.1", - "@types/invariant": "^2.2.31", - "hoist-non-react-statics": "^3.3.2", - "intl-format-cache": "^4.2.21", - "intl-messageformat": "^7.8.4", - "intl-messageformat-parser": "^3.6.4", - "shallow-equal": "^1.2.1" - } - } } }, "@types/react-redux": { @@ -31766,37 +31660,25 @@ } }, "intl-format-cache": { - "version": "2.2.9", - "resolved": "https://registry.npmjs.org/intl-format-cache/-/intl-format-cache-2.2.9.tgz", - "integrity": "sha512-Zv/u8wRpekckv0cLkwpVdABYST4hZNTDaX7reFetrYTJwxExR2VyTqQm+l0WmL0Qo8Mjb9Tf33qnfj0T7pjxdQ==" + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/intl-format-cache/-/intl-format-cache-4.3.1.tgz", + "integrity": "sha512-OEUYNA7D06agqPOYhbTkl0T8HA3QKSuwWh1HiClEnpd9vw7N+3XsQt5iZ0GUEchp5CW1fQk/tary+NsbF3yQ1Q==" }, "intl-messageformat": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/intl-messageformat/-/intl-messageformat-2.2.0.tgz", - "integrity": "sha512-I+tSvHnXqJYjDfNmY95tpFMj30yoakC6OXAo+wu/wTMy6tA/4Fd4mvV7Uzs4cqK/Ap29sHhwjcY+78a8eifcXw==", + "version": "7.8.4", + "resolved": "https://registry.npmjs.org/intl-messageformat/-/intl-messageformat-7.8.4.tgz", + "integrity": "sha512-yS0cLESCKCYjseCOGXuV4pxJm/buTfyCJ1nzQjryHmSehlptbZbn9fnlk1I9peLopZGGbjj46yHHiTAEZ1qOTA==", "requires": { - "intl-messageformat-parser": "1.4.0" + "intl-format-cache": "^4.2.21", + "intl-messageformat-parser": "^3.6.4" } }, "intl-messageformat-parser": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/intl-messageformat-parser/-/intl-messageformat-parser-1.4.0.tgz", - "integrity": "sha512-/XkqFHKezO6UcF4Av2/Lzfrez18R0jyw7kRFhSeB/YRakdrgSc9QfFZUwNJI9swMwMoNPygK1ArC5wdFSjPw+A==" - }, - "intl-relativeformat": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/intl-relativeformat/-/intl-relativeformat-2.2.0.tgz", - "integrity": "sha512-4bV/7kSKaPEmu6ArxXf9xjv1ny74Zkwuey8Pm01NH4zggPP7JHwg2STk8Y3JdspCKRDriwIyLRfEXnj2ZLr4Bw==", - "requires": { - "intl-messageformat": "^2.0.0" - } - }, - "invariant": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/invariant/-/invariant-2.2.4.tgz", - "integrity": "sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==", + "version": "3.6.4", + "resolved": "https://registry.npmjs.org/intl-messageformat-parser/-/intl-messageformat-parser-3.6.4.tgz", + "integrity": "sha512-RgPGwue0mJtoX2Ax8EmMzJzttxjnva7gx0Q7mKJ4oALrTZvtmCeAw5Msz2PcjW4dtCh/h7vN/8GJCxZO1uv+OA==", "requires": { - "loose-envify": "^1.0.0" + "@formatjs/intl-unified-numberformat": "^3.2.0" } }, "ipaddr.js": { @@ -36768,15 +36650,22 @@ "integrity": "sha512-/6UZ2qgEyH2aqzYZgQPxEnz33NJ2gNsnHA2o5+o4wW9bLM/JYQitNP9xPhsXwC08hMMovfGe/8retsdDsczPRg==" }, "react-intl": { - "version": "2.9.0", - "resolved": "https://registry.npmjs.org/react-intl/-/react-intl-2.9.0.tgz", - "integrity": "sha512-27jnDlb/d2A7mSJwrbOBnUgD+rPep+abmoJE511Tf8BnoONIAUehy/U1zZCHGO17mnOwMWxqN4qC0nW11cD6rA==", + "version": "3.12.1", + "resolved": "https://registry.npmjs.org/react-intl/-/react-intl-3.12.1.tgz", + "integrity": "sha512-cgumW29mwROIqyp8NXStYsoIm27+8FqnxykiLSawWjOxGIBeLuN/+p2srei5SRIumcJefOkOIHP+NDck05RgHg==", "requires": { - "hoist-non-react-statics": "^3.3.0", - "intl-format-cache": "^2.0.5", - "intl-messageformat": "^2.1.0", - "intl-relativeformat": "^2.1.0", - "invariant": "^2.1.1" + "@formatjs/intl-displaynames": "^1.2.0", + "@formatjs/intl-listformat": "^1.4.1", + "@formatjs/intl-relativetimeformat": "^4.5.9", + "@formatjs/intl-unified-numberformat": "^3.2.0", + "@formatjs/intl-utils": "^2.2.0", + "@types/hoist-non-react-statics": "^3.3.1", + "@types/invariant": "^2.2.31", + "hoist-non-react-statics": "^3.3.2", + "intl-format-cache": "^4.2.21", + "intl-messageformat": "^7.8.4", + "intl-messageformat-parser": "^3.6.4", + "shallow-equal": "^1.2.1" } }, "react-intl-redux": { diff --git a/package.json b/package.json index a0b91be4..4af2843a 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,6 @@ "@types/react-aria-menubutton": "^6.2.12", "@types/react-collapse": "^5.0.4", "@types/react-dom": "^17.0.23", - "@types/react-intl": "^2.3.18", "@types/react-intl-redux": "^0.1.19", "@types/react-redux": "^7.1.30", "@types/react-router": "^5.1.20", @@ -81,7 +80,7 @@ "react-burger-menu": "^3.0.9", "react-collapse": "^5.1.1", "react-dom": "^17.0.2", - "react-intl": "^2.9.0", + "react-intl": "^3.12.1", "react-intl-redux": "^2.3.0", "react-modal": "^3.16.1", "react-motion": "^0.5.2", @@ -162,6 +161,9 @@ ], "snapshotSerializers": [ "enzyme-to-json/serializer" + ], + "transformIgnorePatterns": [ + "/node_modules/(?!intl-messageformat|intl-messageformat-parser).+\\.js$" ] }, "husky": { diff --git a/src/__test__/components/__snapshots__/navKnapp.snapshot.test.tsx.snap b/src/__test__/components/__snapshots__/navKnapp.snapshot.test.tsx.snap index 49afd439..64984464 100644 --- a/src/__test__/components/__snapshots__/navKnapp.snapshot.test.tsx.snap +++ b/src/__test__/components/__snapshots__/navKnapp.snapshot.test.tsx.snap @@ -7,8 +7,6 @@ exports[`NavKnapp 1`] = ` onClick={[Function]} type="submit" > - - Neste - + Neste `; diff --git a/src/__test__/components/__snapshots__/periodeBanner.snapshot.test.tsx.snap b/src/__test__/components/__snapshots__/periodeBanner.snapshot.test.tsx.snap index ba6ff64d..64b61949 100644 --- a/src/__test__/components/__snapshots__/periodeBanner.snapshot.test.tsx.snap +++ b/src/__test__/components/__snapshots__/periodeBanner.snapshot.test.tsx.snap @@ -8,9 +8,7 @@ exports[`PeriodeBanner 1`] = `

- - Meldekort for perioden - + Meldekort for perioden

, - localeData: localeDataNB, } -const locales: Locales = [locale] +const locales: Locale[] = [locale] const intl: IntlState = { locale: 'nb', diff --git a/src/app/app.tsx b/src/app/app.tsx index c45fe49b..12ef6928 100644 --- a/src/app/app.tsx +++ b/src/app/app.tsx @@ -34,7 +34,7 @@ import { isOldIE, isOldSafari, } from './utils/browsers'; -import { InjectedIntlProps, injectIntl } from 'react-intl'; +import { WrappedComponentProps, injectIntl } from 'react-intl'; if (erMock()) { setupMock(); @@ -56,7 +56,7 @@ interface MapDispatchToProps { toggleMeny: (erApen: boolean) => void; } -type Props = MapStateToProps & MapDispatchToProps & InjectedIntlProps; +type Props = MapStateToProps & MapDispatchToProps & WrappedComponentProps; interface AppState { henterPersonInfo: boolean; diff --git a/src/app/reducers/localesReducer.tsx b/src/app/reducers/localesReducer.tsx index 1b182424..5800c4d8 100644 --- a/src/app/reducers/localesReducer.tsx +++ b/src/app/reducers/localesReducer.tsx @@ -1,42 +1,34 @@ import * as React from 'react'; import NorskFlaggSVG from '../components/sprakvelger/NorskFlaggSVG'; import EngelskFlaggSVG from '../components/sprakvelger/EngelskFlaggSVG'; -import localeDataNB from 'react-intl/locale-data/nb'; -import localeDataEN from 'react-intl/locale-data/en'; export interface Locale { label: string; tittel: string; ikon: JSX.Element; - localeData: ReactIntl.LocaleData; } -export interface Locales extends Array {} - -const locales: Locales = [ +const locales = [ { label: 'nb', tittel: 'Norsk', ikon: , - localeData: localeDataNB, }, /* { label: 'nn', tittel: 'Nynorsk', ikon: , - localeData: localeDataNN, }, */ { label: 'en', tittel: 'English', ikon: , - localeData: localeDataEN, }, ]; -const localesReducer = (state: Locales = locales): Locales => { // (state: Locales = locales, action: any) +const localesReducer = (state: Locale[] = locales): Locale[] => { // (state: Locale[] = locales, action: any) return state; }; diff --git a/src/app/sider/innsending/1-sporsmalsside/begrunnelse/begrunnelseVelger.tsx b/src/app/sider/innsending/1-sporsmalsside/begrunnelse/begrunnelseVelger.tsx index 50e5536d..cb82284c 100644 --- a/src/app/sider/innsending/1-sporsmalsside/begrunnelse/begrunnelseVelger.tsx +++ b/src/app/sider/innsending/1-sporsmalsside/begrunnelse/begrunnelseVelger.tsx @@ -25,7 +25,7 @@ interface BegrunnselseProps { type Props = MapDispatchToProps & MapStateToProps & BegrunnselseProps; const BegrunnelseVelger: React.FunctionComponent = props => { - const optionsString = hentIntl().messages['korriger.begrunnelse.valg']; + const optionsString = hentIntl().messages['korriger.begrunnelse.valg'] as string; const options = JSON.parse(optionsString ? optionsString : '{}'); const handleOnChange = (event: React.ChangeEvent) => { diff --git a/src/app/store/configureStore.tsx b/src/app/store/configureStore.tsx index dea3678e..0b9866f7 100644 --- a/src/app/store/configureStore.tsx +++ b/src/app/store/configureStore.tsx @@ -28,7 +28,7 @@ import personReducer from '../reducers/personReducer'; import personStatusReducer, { PersonStatusState, } from '../reducers/personStatusReducer'; -import { default as localesReducer, Locales } from '../reducers/localesReducer'; +import { default as localesReducer, Locale } from '../reducers/localesReducer'; import { intlReducer, IntlState } from 'react-intl-redux'; import { combineEpics, createEpicMiddleware, Epic } from 'redux-observable'; @@ -65,7 +65,7 @@ export const history = createBrowserHistory({ const initialState = {}; export interface RootState { - locales: Locales; + locales: Locale[]; intl: IntlState; router: RouterState; person: Person; @@ -109,8 +109,6 @@ const rootReducer = (state: RootState, action: any ) => { action.payload.response.status !== undefined && action.payload.response.status === 401 ) { - // const { intl } = state; - // state = { intl }; storage.removeItem('persist:meldekort:undefined'); } } diff --git a/src/app/utils/intlUtil.tsx b/src/app/utils/intlUtil.tsx index 02e756b4..ba6f3c4c 100644 --- a/src/app/utils/intlUtil.tsx +++ b/src/app/utils/intlUtil.tsx @@ -1,4 +1,4 @@ -import { IntlProvider } from 'react-intl'; +import { createIntl } from 'react-intl'; import { store } from '../store/configureStore'; import { Konstanter } from './consts'; import { fetchGet } from '../api/api'; @@ -111,12 +111,11 @@ export const downloadMessages = async (sprak: string, fraDato: Date) => { export const hentIntl = () => { const intlState = store.getState().intl; - const intlProvider = new IntlProvider({ + + return createIntl({ locale: intlState.locale, - messages: intlState.messages, - }); - const { intl } = intlProvider.getChildContext(); - return intl; + messages: intlState.messages + }) }; export const hentLocale = () => { diff --git a/src/index.tsx b/src/index.tsx index c5d455df..f7d3a74a 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,6 +1,6 @@ import 'babel-polyfill'; import * as React from 'react'; -import { FunctionComponentElement, ReactElement } from 'react'; +import { ExoticComponent, FunctionComponentElement, ReactElement } from 'react'; import * as ReactDOM from 'react-dom'; import App from './app/app'; import * as serviceWorker from './registerServiceWorker'; @@ -8,9 +8,7 @@ import { IntlProvider, updateIntl } from 'react-intl-redux'; import { Provider, ProviderProps } from 'react-redux'; import { persistor, store } from './app/store/configureStore'; import { PersistGate } from 'redux-persist/integration/react'; -import { Locales } from './app/reducers/localesReducer'; import { Konstanter } from './app/utils/consts'; -import { addLocaleData } from 'react-intl'; import NavFrontendSpinner from 'nav-frontend-spinner'; import { downloadMessages } from './app/utils/intlUtil'; @@ -33,16 +31,13 @@ import 'nav-frontend-veilederpanel-style/dist/main.css'; import './index.css'; import { erViggo } from './app/utils/viggoUtils'; -const locales: Locales = store.getState().locales; -locales.forEach(locale => addLocaleData(locale.localeData)); - const rootElement = document.getElementById('meldekort__root'); const render = (element: FunctionComponentElement) => { ReactDOM.render(element, rootElement); }; -const renderApp = (Component: React.ComponentType, locale: string) => { +const renderApp = (Component: ExoticComponent, locale: string) => { render( }>