From ecdbe7376cb5263691e87069ba28a6063ce4da9f Mon Sep 17 00:00:00 2001 From: aXenDeveloper Date: Mon, 23 Dec 2024 13:55:38 +0100 Subject: [PATCH 1/2] perf(frontend)!: Update to next-intl v4 --- apps/frontend/global.d.ts | 6 +- apps/frontend/package.json | 2 +- .../helpers/create-packages-json.ts | 2 +- .../templates/basic/apps/frontend/global.d.ts | 6 +- packages/frontend/global.d.ts | 6 +- packages/frontend/package.json | 4 +- .../src/components/translations-provider.tsx | 12 ++-- packages/frontend/src/i18n.ts | 4 +- packages/frontend/src/navigation/index.tsx | 3 +- pnpm-lock.yaml | 63 ++++++++----------- 10 files changed, 51 insertions(+), 57 deletions(-) diff --git a/apps/frontend/global.d.ts b/apps/frontend/global.d.ts index d857f1272..99f6cc429 100644 --- a/apps/frontend/global.d.ts +++ b/apps/frontend/global.d.ts @@ -4,6 +4,8 @@ import type welcome from '@/plugins/welcome/langs/en.json'; type Messages = typeof core & typeof admin & typeof welcome; -declare global { - interface IntlMessages extends Messages {} +declare module 'next-intl' { + interface AppConfig { + Messages: Messages; + } } diff --git a/apps/frontend/package.json b/apps/frontend/package.json index b229ec2a2..10601a11c 100644 --- a/apps/frontend/package.json +++ b/apps/frontend/package.json @@ -18,7 +18,7 @@ "geist": "^1.3.1", "lucide-react": "^0.468.0", "next": "^15.1.2", - "next-intl": "^3.26.2", + "next-intl": "4.0.0-beta-ddd5ae5", "react": "^19.0.0", "react-dom": "^19.0.0", "react-hook-form": "^7.54.1", diff --git a/packages/create-vitnode-app/helpers/create-packages-json.ts b/packages/create-vitnode-app/helpers/create-packages-json.ts index 2f99d41e3..668cad10a 100644 --- a/packages/create-vitnode-app/helpers/create-packages-json.ts +++ b/packages/create-vitnode-app/helpers/create-packages-json.ts @@ -85,7 +85,7 @@ export const createPackagesJSON = async ({ geist: '^1.3.1', 'lucide-react': '^0.469.0', next: '^15.1.2', - 'next-intl': '^3.26.2', + 'next-intl': '4.0.0-beta-ddd5ae5', react: '^19.0.0', 'react-dom': '^19.0.0', 'react-hook-form': '^7.54.1', diff --git a/packages/create-vitnode-app/templates/basic/apps/frontend/global.d.ts b/packages/create-vitnode-app/templates/basic/apps/frontend/global.d.ts index d857f1272..99f6cc429 100644 --- a/packages/create-vitnode-app/templates/basic/apps/frontend/global.d.ts +++ b/packages/create-vitnode-app/templates/basic/apps/frontend/global.d.ts @@ -4,6 +4,8 @@ import type welcome from '@/plugins/welcome/langs/en.json'; type Messages = typeof core & typeof admin & typeof welcome; -declare global { - interface IntlMessages extends Messages {} +declare module 'next-intl' { + interface AppConfig { + Messages: Messages; + } } diff --git a/packages/frontend/global.d.ts b/packages/frontend/global.d.ts index 4125d1b3b..b284f35ab 100644 --- a/packages/frontend/global.d.ts +++ b/packages/frontend/global.d.ts @@ -4,6 +4,8 @@ import type welcome from '../../apps/frontend/src/plugins/welcome/langs/en.json' type Messages = typeof core & typeof admin & typeof welcome; -declare global { - interface IntlMessages extends Messages {} +declare module 'next-intl' { + interface AppConfig { + Messages: Messages; + } } diff --git a/packages/frontend/package.json b/packages/frontend/package.json index 0cdd4b179..d29a66b39 100644 --- a/packages/frontend/package.json +++ b/packages/frontend/package.json @@ -95,7 +95,7 @@ "@hookform/resolvers": "^3.9.1", "lucide-react": "*", "next": "^15.1.2", - "next-intl": "^3.26.2", + "next-intl": "4.0.0-beta-ddd5ae5", "react": "^19.0.0", "react-dom": "^19.0.0", "react-hook-form": "^7.54.1", @@ -119,7 +119,7 @@ "eslint-config-typescript-vitnode": "workspace:*", "lucide-react": "^0.469.0", "next": "^15.1.2", - "next-intl": "^3.26.3", + "next-intl": "4.0.0-beta-ddd5ae5", "react": "^19.0.0", "react-dom": "^19.0.0", "react-hook-form": "^7.54.2", diff --git a/packages/frontend/src/components/translations-provider.tsx b/packages/frontend/src/components/translations-provider.tsx index eebd6d0b3..0f3e1abd9 100644 --- a/packages/frontend/src/components/translations-provider.tsx +++ b/packages/frontend/src/components/translations-provider.tsx @@ -1,4 +1,9 @@ -import { NamespaceKeys, NestedKeyOf, NextIntlClientProvider } from 'next-intl'; +import { + Messages, + NamespaceKeys, + NestedKeyOf, + NextIntlClientProvider, +} from 'next-intl'; import { getLocale, getMessages } from 'next-intl/server'; import 'server-only'; @@ -30,10 +35,7 @@ const pick = (obj: object, paths: string[]) => { }; export async function TranslationsProvider< - NestedKey extends NamespaceKeys< - IntlMessages, - NestedKeyOf - > = never, + NestedKey extends NamespaceKeys> = never, >({ children, namespaces, diff --git a/packages/frontend/src/i18n.ts b/packages/frontend/src/i18n.ts index 4009cf7a9..5324ae2cc 100644 --- a/packages/frontend/src/i18n.ts +++ b/packages/frontend/src/i18n.ts @@ -13,8 +13,8 @@ export const i18nConfigVitNode = async ({ }) => Promise<{ default: object }>; requestLocale: Promise; }) => { - let locale = await requestLocale; let defaultLocale = 'en'; + let locale = (await requestLocale) ?? 'en'; if (!locale) { locale = 'en'; @@ -28,7 +28,7 @@ export const i18nConfigVitNode = async ({ const defaultLanguage = data.languages.find(lang => lang.default); defaultLocale = defaultLanguage?.code ?? 'en'; if (!data.languages.find(lang => lang.code === locale)) { - locale = defaultLanguage?.code; + locale = defaultLanguage?.code ?? defaultLocale; } } catch (_) { // If the request fails, we will use the default plugins diff --git a/packages/frontend/src/navigation/index.tsx b/packages/frontend/src/navigation/index.tsx index 8b0f3b9e1..5367173db 100644 --- a/packages/frontend/src/navigation/index.tsx +++ b/packages/frontend/src/navigation/index.tsx @@ -1,7 +1,6 @@ -import { createNavigation } from 'next-intl/navigation'; +import { createNavigation, QueryParams } from 'next-intl/navigation'; import { getLocale } from 'next-intl/server'; import { RedirectType } from 'next/navigation'; -import { QueryParams } from 'node_modules/next-intl/dist/types/src/navigation/shared/utils'; import React from 'react'; import { usePathname, useRouter } from './router'; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index cb9f2e0d8..76ea25ed1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -130,8 +130,8 @@ importers: specifier: ^15.1.2 version: 15.1.2(@opentelemetry/api@1.9.0)(babel-plugin-react-compiler@19.0.0-beta-df7b47d-20241124)(react-dom@19.0.0(react@19.0.0))(react@19.0.0) next-intl: - specifier: ^3.26.2 - version: 3.26.2(next@15.1.2(@opentelemetry/api@1.9.0)(react-dom@19.0.0(react@19.0.0))(react@19.0.0))(react@19.0.0) + specifier: 4.0.0-beta-ddd5ae5 + version: 4.0.0-beta-ddd5ae5(next@15.1.2(@opentelemetry/api@1.9.0)(babel-plugin-react-compiler@19.0.0-beta-df7b47d-20241124)(react-dom@19.0.0(react@19.0.0))(react@19.0.0))(react@19.0.0)(typescript@5.7.2) react: specifier: ^19.0.0 version: 19.0.0 @@ -743,8 +743,8 @@ importers: specifier: ^15.1.2 version: 15.1.2(@opentelemetry/api@1.9.0)(babel-plugin-react-compiler@19.0.0-beta-df7b47d-20241124)(react-dom@19.0.0(react@19.0.0))(react@19.0.0) next-intl: - specifier: ^3.26.3 - version: 3.26.3(next@15.1.2(@opentelemetry/api@1.9.0)(babel-plugin-react-compiler@19.0.0-beta-df7b47d-20241124)(react-dom@19.0.0(react@19.0.0))(react@19.0.0))(react@19.0.0) + specifier: 4.0.0-beta-ddd5ae5 + version: 4.0.0-beta-ddd5ae5(next@15.1.2(@opentelemetry/api@1.9.0)(babel-plugin-react-compiler@19.0.0-beta-df7b47d-20241124)(react-dom@19.0.0(react@19.0.0))(react@19.0.0))(react@19.0.0)(typescript@5.7.2) react: specifier: ^19.0.0 version: 19.0.0 @@ -2568,6 +2568,9 @@ packages: '@scena/matrix@1.1.1': resolution: {integrity: sha512-JVKBhN0tm2Srl+Yt+Ywqu0oLgLcdemDQlD1OxmN9jaCTwaFPZ7tY8n6dhVgMEaR9qcR7r+kAlMXnSfNyYdE+Vg==} + '@schummar/icu-type-parser@1.21.5': + resolution: {integrity: sha512-bXHSaW5jRTmke9Vd0h5P7BtWZG9Znqb8gSDxZnxaGSJnGwPLDPfS+3g0BKzeWqzgZPsIVZkM7m2tbo18cm5HBw==} + '@sec-ant/readable-stream@0.4.1': resolution: {integrity: sha512-831qok9r2t8AlxLko40y2ebgSDhenenCatLVeW/uBtnHPyhHOvG0C7TvfgecV+wHzIm5KUICgzmVpWS+IMEAeg==} @@ -5174,17 +5177,15 @@ packages: neo-async@2.6.2: resolution: {integrity: sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==} - next-intl@3.26.2: - resolution: {integrity: sha512-fPsL5/9Y/aYNHoOf904b+PhYkm1RfZKrNMAxUvURMqFuQTA0TQAIGnY0s03yPH7oRv9qCFcutaxr6DsHq0aCzQ==} - peerDependencies: - next: ^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0 - react: ^16.8.0 || ^17.0.0 || ^18.0.0 || >=19.0.0-rc <19.0.0 || ^19.0.0 - - next-intl@3.26.3: - resolution: {integrity: sha512-6Y97ODrDsEE1J8cXKMHwg1laLdtkN66QMIqG8BzH4zennJRUNTtM8UMtBDyhfmF6uiZ+xsbWLXmHUgmUymUsfQ==} + next-intl@4.0.0-beta-ddd5ae5: + resolution: {integrity: sha512-AS+aZVXXqlSgM3MYbX9dmBHj+X8sFrYGPbpq09R9dqsiRGE5LeLxZKS4TDGkg4oZzEU52JlUSZNnCTonqFB+lg==} peerDependencies: - next: ^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0 + next: ^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0 react: ^16.8.0 || ^17.0.0 || ^18.0.0 || >=19.0.0-rc <19.0.0 || ^19.0.0 + typescript: ^5.0.0 + peerDependenciesMeta: + typescript: + optional: true next-themes@0.4.4: resolution: {integrity: sha512-LDQ2qIOJF0VnuVrrMSMLrWGjRMkq+0mpgl6e0juCLqdJ+oo8Q84JRWT6Wh11VDQKkMMe+dVzDKLWs5n87T+PkQ==} @@ -6590,15 +6591,10 @@ packages: peerDependencies: react: '>=16.13' - use-intl@3.26.2: - resolution: {integrity: sha512-H0BpBXLNFTkw6RvntLXSXr2+la4T/xilKSG5l8ND9Br9+i1hqHensWouNS288QZdiDTrfYUVswDtUIR6L39JHQ==} + use-intl@4.0.0-beta-ddd5ae5: + resolution: {integrity: sha512-dpudMwXrHizH0iYL3oaCEv/jVe3Gq6RDnloza3AjS0Jp63/l/fNoTkPHGkToxk8F04dy0zxZfUEXB2V8dlphFA==} peerDependencies: - react: ^16.8.0 || ^17.0.0 || ^18.0.0 || >=19.0.0-rc <19.0.0 || ^19.0.0 - - use-intl@3.26.3: - resolution: {integrity: sha512-yY0a2YseO17cKwHA9M6fcpiEJ2Uo81DEU0NOUxNTp6lJVNOuI6nULANPVVht6IFdrYFtlsMmMoc97+Eq9/Tnng==} - peerDependencies: - react: ^16.8.0 || ^17.0.0 || ^18.0.0 || >=19.0.0-rc <19.0.0 || ^19.0.0 + react: ^17.0.0 || ^18.0.0 || >=19.0.0-rc <19.0.0 || ^19.0.0 use-sidecar@1.1.3: resolution: {integrity: sha512-Fedw0aZvkhynoPYlA5WXrMCAMm+nSWdZt6lzJQ7Ok8S6Q+VsHmHpRWndVRJ8Be0ZbkfPc5LRYH+5XrzXcEeLRQ==} @@ -8524,6 +8520,8 @@ snapshots: dependencies: '@daybrush/utils': 1.13.0 + '@schummar/icu-type-parser@1.21.5': {} + '@sec-ant/readable-stream@0.4.1': {} '@selderee/plugin-htmlparser2@0.11.0': @@ -11280,21 +11278,15 @@ snapshots: neo-async@2.6.2: {} - next-intl@3.26.2(next@15.1.2(@opentelemetry/api@1.9.0)(react-dom@19.0.0(react@19.0.0))(react@19.0.0))(react@19.0.0): + next-intl@4.0.0-beta-ddd5ae5(next@15.1.2(@opentelemetry/api@1.9.0)(babel-plugin-react-compiler@19.0.0-beta-df7b47d-20241124)(react-dom@19.0.0(react@19.0.0))(react@19.0.0))(react@19.0.0)(typescript@5.7.2): dependencies: '@formatjs/intl-localematcher': 0.5.9 negotiator: 1.0.0 next: 15.1.2(@opentelemetry/api@1.9.0)(babel-plugin-react-compiler@19.0.0-beta-df7b47d-20241124)(react-dom@19.0.0(react@19.0.0))(react@19.0.0) react: 19.0.0 - use-intl: 3.26.2(react@19.0.0) - - next-intl@3.26.3(next@15.1.2(@opentelemetry/api@1.9.0)(babel-plugin-react-compiler@19.0.0-beta-df7b47d-20241124)(react-dom@19.0.0(react@19.0.0))(react@19.0.0))(react@19.0.0): - dependencies: - '@formatjs/intl-localematcher': 0.5.9 - negotiator: 1.0.0 - next: 15.1.2(@opentelemetry/api@1.9.0)(babel-plugin-react-compiler@19.0.0-beta-df7b47d-20241124)(react-dom@19.0.0(react@19.0.0))(react@19.0.0) - react: 19.0.0 - use-intl: 3.26.3(react@19.0.0) + use-intl: 4.0.0-beta-ddd5ae5(react@19.0.0) + optionalDependencies: + typescript: 5.7.2 next-themes@0.4.4(react-dom@19.0.0(react@19.0.0))(react@19.0.0): dependencies: @@ -12801,15 +12793,10 @@ snapshots: dequal: 2.0.3 react: 19.0.0 - use-intl@3.26.2(react@19.0.0): - dependencies: - '@formatjs/fast-memoize': 2.2.5 - intl-messageformat: 10.7.10 - react: 19.0.0 - - use-intl@3.26.3(react@19.0.0): + use-intl@4.0.0-beta-ddd5ae5(react@19.0.0): dependencies: '@formatjs/fast-memoize': 2.2.5 + '@schummar/icu-type-parser': 1.21.5 intl-messageformat: 10.7.10 react: 19.0.0 From 432e409788d8fef6c39436fa5eee47dfe5e010a6 Mon Sep 17 00:00:00 2001 From: aXenDeveloper Date: Mon, 23 Dec 2024 14:26:29 +0100 Subject: [PATCH 2/2] fix(frontend): Open sub menu on click --- .../views/admin/layout/sidebar/item-nav.tsx | 46 +++++++++++-------- .../core/settings/main/components/desc.tsx | 2 +- .../views/core/settings/main/content.tsx | 4 +- 3 files changed, 30 insertions(+), 22 deletions(-) diff --git a/packages/frontend/src/views/admin/layout/sidebar/item-nav.tsx b/packages/frontend/src/views/admin/layout/sidebar/item-nav.tsx index b8177d5b7..11372ae8e 100644 --- a/packages/frontend/src/views/admin/layout/sidebar/item-nav.tsx +++ b/packages/frontend/src/views/admin/layout/sidebar/item-nav.tsx @@ -40,31 +40,39 @@ export const ItemNavSidebarAdmin = ({ ); if (!textAndIcon) return null; - const button = ( - { - setOpenMobile(false); - }} - > - - {textAndIcon.icon} - {textAndIcon.text} - - - ); - if (!item.children?.length) { - return {button}; + return ( + + { + setOpenMobile(false); + }} + > + + {textAndIcon.icon} + {textAndIcon.text} + + + + ); } return ( - {button} + + + {textAndIcon.icon} + {textAndIcon.text} + + + <> diff --git a/packages/frontend/src/views/admin/views/core/settings/main/components/desc.tsx b/packages/frontend/src/views/admin/views/core/settings/main/components/desc.tsx index bc594c16f..2b057ddbe 100644 --- a/packages/frontend/src/views/admin/views/core/settings/main/components/desc.tsx +++ b/packages/frontend/src/views/admin/views/core/settings/main/components/desc.tsx @@ -31,7 +31,7 @@ export const DescFieldContentMainSettingsCoreAdmin = ({ onLanguageChange={setSelectedLanguage} /> -
+
{ component: props => ( <> -
+
{ component: props => ( <> -
+