From 4e7a72e41b2a17d78a829f2efb3066de85d5a788 Mon Sep 17 00:00:00 2001 From: Robin MacPherson Date: Thu, 30 May 2024 06:37:49 -0700 Subject: [PATCH 01/34] Upgrade Node --- .nvmrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.nvmrc b/.nvmrc index 53d838af..9de22568 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -lts/gallium +lts/iron From fa9530348ce1fafaca73aa6ef83ee9c00a3b9792 Mon Sep 17 00:00:00 2001 From: Robin MacPherson Date: Thu, 30 May 2024 06:39:13 -0700 Subject: [PATCH 02/34] Add all languages to UILanguage enum + migration --- packages/j-db-client/package.json | 2 +- .../migration.sql | 12 ++++++++++++ packages/j-db-client/prisma/schema.prisma | 4 ++++ packages/web/generated/graphql.tsx | 4 ++++ packages/web/package-lock.json | 17 +++++++---------- packages/web/package.json | 5 +---- 6 files changed, 29 insertions(+), 15 deletions(-) create mode 100644 packages/j-db-client/prisma/migrations/20240523150228_add_missing_uilangs_to_enum/migration.sql diff --git a/packages/j-db-client/package.json b/packages/j-db-client/package.json index 0376bb64..bdf9b692 100644 --- a/packages/j-db-client/package.json +++ b/packages/j-db-client/package.json @@ -1,6 +1,6 @@ { "name": "@journaly/j-db-client", - "version": "13.20.0", + "version": "13.21.0", "description": "Journaly's internal database client.", "main": "dist/index", "scripts": { diff --git a/packages/j-db-client/prisma/migrations/20240523150228_add_missing_uilangs_to_enum/migration.sql b/packages/j-db-client/prisma/migrations/20240523150228_add_missing_uilangs_to_enum/migration.sql new file mode 100644 index 00000000..39f4d216 --- /dev/null +++ b/packages/j-db-client/prisma/migrations/20240523150228_add_missing_uilangs_to_enum/migration.sql @@ -0,0 +1,12 @@ +-- AlterEnum +-- This migration adds more than one value to an enum. +-- With PostgreSQL versions 11 and earlier, this is not possible +-- in a single migration. This can be worked around by creating +-- multiple migrations, each migration adding only one value to +-- the enum. + + +ALTER TYPE "UILanguage" ADD VALUE 'CHINESE_SIMPLIFIED'; +ALTER TYPE "UILanguage" ADD VALUE 'CHINESE_TRADITIONAL'; +ALTER TYPE "UILanguage" ADD VALUE 'ITALIAN'; +ALTER TYPE "UILanguage" ADD VALUE 'PORTUGUESE_BRAZILIAN'; diff --git a/packages/j-db-client/prisma/schema.prisma b/packages/j-db-client/prisma/schema.prisma index aa67a385..2ccd8b47 100644 --- a/packages/j-db-client/prisma/schema.prisma +++ b/packages/j-db-client/prisma/schema.prisma @@ -494,6 +494,10 @@ enum UILanguage { ENGLISH GERMAN SPANISH + CHINESE_SIMPLIFIED + CHINESE_TRADITIONAL + ITALIAN + PORTUGUESE_BRAZILIAN } enum BadgeType { diff --git a/packages/web/generated/graphql.tsx b/packages/web/generated/graphql.tsx index d1df52d1..0ae0c6dc 100644 --- a/packages/web/generated/graphql.tsx +++ b/packages/web/generated/graphql.tsx @@ -730,8 +730,12 @@ export type TopicTranslation = { } export enum UiLanguage { + ChineseSimplified = 'CHINESE_SIMPLIFIED', + ChineseTraditional = 'CHINESE_TRADITIONAL', English = 'ENGLISH', German = 'GERMAN', + Italian = 'ITALIAN', + PortugueseBrazilian = 'PORTUGUESE_BRAZILIAN', Spanish = 'SPANISH', } diff --git a/packages/web/package-lock.json b/packages/web/package-lock.json index 72b543b0..9d436c41 100644 --- a/packages/web/package-lock.json +++ b/packages/web/package-lock.json @@ -11,7 +11,7 @@ "dependencies": { "@apollo/client": "3.7.14", "@github/text-expander-element": "^2.5.0", - "@journaly/j-db-client": "^13.20.0", + "@journaly/j-db-client": "^13.21.0", "@prisma/client": "^3.15.2", "@stripe/react-stripe-js": "^1.2.2", "@stripe/stripe-js": "^1.12.1", @@ -101,9 +101,6 @@ "ts-jest": "^29.1.1", "typescript": "^4.5.2", "yargs": "^16.2.0" - }, - "engines": { - "node": "16.x" } }, "node_modules/@ampproject/remapping": { @@ -2747,9 +2744,9 @@ "integrity": "sha512-CtzORUwWTTOTqfVtHaKRJ0I1kNQd1bpn3sUh8I3nJDVY+5/M/Oe1DnEWzPQvqq/xPIIkzzzIP7mfCoAjFRvDhg==" }, "node_modules/@journaly/j-db-client": { - "version": "13.20.0", - "resolved": "https://registry.npmjs.org/@journaly/j-db-client/-/j-db-client-13.20.0.tgz", - "integrity": "sha512-azX4mKZhicDmomFZqtliVhRaEjlu2Y9gz9u+NkrN1epDewov4SvwAoSn98/90cRr6W2Vh6GbjfxjUddzs7YraQ==", + "version": "13.21.0", + "resolved": "https://registry.npmjs.org/@journaly/j-db-client/-/j-db-client-13.21.0.tgz", + "integrity": "sha512-43vnZ3kcdDWdBJgaJAxcyJEh4mL8rI4fNjE1039/cTdB/pLAx/GMKpojCt/WNk5GBzwbiyWNrDv1sr95apUqsg==", "dependencies": { "@prisma/client": "^3.15.2" } @@ -20715,9 +20712,9 @@ "integrity": "sha512-CtzORUwWTTOTqfVtHaKRJ0I1kNQd1bpn3sUh8I3nJDVY+5/M/Oe1DnEWzPQvqq/xPIIkzzzIP7mfCoAjFRvDhg==" }, "@journaly/j-db-client": { - "version": "13.20.0", - "resolved": "https://registry.npmjs.org/@journaly/j-db-client/-/j-db-client-13.20.0.tgz", - "integrity": "sha512-azX4mKZhicDmomFZqtliVhRaEjlu2Y9gz9u+NkrN1epDewov4SvwAoSn98/90cRr6W2Vh6GbjfxjUddzs7YraQ==", + "version": "13.21.0", + "resolved": "https://registry.npmjs.org/@journaly/j-db-client/-/j-db-client-13.21.0.tgz", + "integrity": "sha512-43vnZ3kcdDWdBJgaJAxcyJEh4mL8rI4fNjE1039/cTdB/pLAx/GMKpojCt/WNk5GBzwbiyWNrDv1sr95apUqsg==", "requires": { "@prisma/client": "^3.15.2" } diff --git a/packages/web/package.json b/packages/web/package.json index d9086453..87bded5d 100644 --- a/packages/web/package.json +++ b/packages/web/package.json @@ -1,9 +1,6 @@ { "name": "journaly", "version": "1.0.0", - "engines": { - "node": "16.x" - }, "description": "A foreign-language journaling application.", "repository": { "type": "git", @@ -43,7 +40,7 @@ "dependencies": { "@apollo/client": "3.7.14", "@github/text-expander-element": "^2.5.0", - "@journaly/j-db-client": "^13.20.0", + "@journaly/j-db-client": "^13.21.0", "@prisma/client": "^3.15.2", "@stripe/react-stripe-js": "^1.2.2", "@stripe/stripe-js": "^1.12.1", From 662cf6675745a2f90cb35d1dd67699a1e6187702 Mon Sep 17 00:00:00 2001 From: Robin MacPherson Date: Thu, 30 May 2024 06:39:53 -0700 Subject: [PATCH 03/34] Use all languages in langCodeToUiLanguage --- packages/web/hooks/useUILanguage.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/web/hooks/useUILanguage.ts b/packages/web/hooks/useUILanguage.ts index d2f7648f..0c94a686 100644 --- a/packages/web/hooks/useUILanguage.ts +++ b/packages/web/hooks/useUILanguage.ts @@ -3,13 +3,16 @@ import { I18nContext } from 'react-i18next' import { UiLanguage as UILanguage } from '@/generated/graphql' -const langCodeToUILangMap: { [key: string]: UILanguage } = { +export const langCodeToUILangMap: { [key: string]: UILanguage } = { en: UILanguage.English, de: UILanguage.German, es: UILanguage.Spanish, + zh_CN: UILanguage.ChineseSimplified, + zh_TW: UILanguage.ChineseTraditional, + it: UILanguage.Italian, + pt_BR: UILanguage.PortugueseBrazilian, } - const useUILanguage = () => { const { i18n: { language } } = React.useContext(I18nContext) From 0b9d0b868cef7c06eb718003e8e47915d7d9db5b Mon Sep 17 00:00:00 2001 From: Robin MacPherson Date: Thu, 30 May 2024 06:40:39 -0700 Subject: [PATCH 04/34] Create journalyMiddleware.ts --- packages/web/lib/journalyMiddleware.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 packages/web/lib/journalyMiddleware.ts diff --git a/packages/web/lib/journalyMiddleware.ts b/packages/web/lib/journalyMiddleware.ts new file mode 100644 index 00000000..7012a69b --- /dev/null +++ b/packages/web/lib/journalyMiddleware.ts @@ -0,0 +1,20 @@ +import { ApolloClient } from '@apollo/client' +import { NextPageContext } from 'next' +import { initApolloClient } from './apollo' + +export const journalyMiddleware = async ( + ctx: NextPageContext, + callback: (apolloClient: ApolloClient) => Promise, +) => { + const headers: any = {} + if (typeof window === 'undefined' && ctx.req) { + // If SSR, copy the request cookies into apollo client so it has the same + // auth context as the request for the page. + headers['cookie'] = ctx.req.headers.cookie + } + const apolloClient = initApolloClient({}, headers) + await callback(apolloClient) + return { + apolloState: apolloClient.cache.extract(), + } +} From 4f0eaabe94b9291349893fe962d3a773adc4f304 Mon Sep 17 00:00:00 2001 From: Robin MacPherson Date: Thu, 30 May 2024 06:41:27 -0700 Subject: [PATCH 05/34] Wrap app root in ApolloProvider --- packages/web/pages/_app.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/web/pages/_app.tsx b/packages/web/pages/_app.tsx index 11c477ab..b4b827d8 100644 --- a/packages/web/pages/_app.tsx +++ b/packages/web/pages/_app.tsx @@ -1,3 +1,4 @@ +import React from 'react' import App from 'next/app' import Head from 'next/head' import Router, { withRouter } from 'next/router' @@ -12,20 +13,22 @@ import '@/styles/globalStyles.css' import 'react-toastify/dist/ReactToastify.css' import 'reactjs-popup/dist/index.css' import '@/styles/react-toastify-overrides.css' +import { ApolloProvider } from '@apollo/client' +import { initApolloClient } from '@/lib/apollo' // Show loading progress on page loads Router.events.on('routeChangeStart', () => NProgress.start()) Router.events.on('routeChangeError', () => NProgress.done()) Router.events.on('routeChangeComplete', () => NProgress.done()) - class JournalyApp extends App { componentDidMount() {} render() { const { Component, pageProps } = this.props + const client = initApolloClient(pageProps.apolloState) return ( - <> + Journaly @@ -34,7 +37,7 @@ class JournalyApp extends App { - + ) } } From 2e5043c7494bc15612af698787c02e303d561500 Mon Sep 17 00:00:00 2001 From: Robin MacPherson Date: Thu, 30 May 2024 06:43:31 -0700 Subject: [PATCH 06/34] First page refactor removing withApollo --- .../pages/dashboard/profile/[id]/index.tsx | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/packages/web/pages/dashboard/profile/[id]/index.tsx b/packages/web/pages/dashboard/profile/[id]/index.tsx index 06e4baea..ccbd8d32 100644 --- a/packages/web/pages/dashboard/profile/[id]/index.tsx +++ b/packages/web/pages/dashboard/profile/[id]/index.tsx @@ -1,9 +1,10 @@ import React from 'react' import { useRouter } from 'next/router' -import { withApollo } from '@/lib/apollo' -import { useUserByIdentifierQuery } from '@/generated/graphql' +import { UserByIdentifierDocument, useUserByIdentifierQuery } from '@/generated/graphql' import theme from '@/theme' +import { journalyMiddleware } from '@/lib/journalyMiddleware' +import { NextPageContext } from 'next' /** * This page is part of the deprecated URL pattern: `/dashboard/*` and should not be used. @@ -60,4 +61,23 @@ const OldProfilePage = () => { return null } -export default withApollo(OldProfilePage) +OldProfilePage.getInitialProps = async (ctx: NextPageContext) => { + const props = await journalyMiddleware(ctx, async (apolloClient) => { + const idStr = ctx.query.id as string + const id = parseInt(idStr, 10) + + await apolloClient.query({ + query: UserByIdentifierDocument, + variables: { + id, + }, + }) + }) + + return { + ...props, + namespacesRequired: ['common'], + } +} + +export default OldProfilePage From 1f969d7e997c4a3c960ffac66430d2da0e9a57af Mon Sep 17 00:00:00 2001 From: Robin MacPherson Date: Thu, 30 May 2024 06:45:27 -0700 Subject: [PATCH 07/34] Write `getUiLanguage` fn + refactor page using it --- packages/web/pages/post/[id]/index.tsx | 62 ++++++++++++++++++++++---- 1 file changed, 54 insertions(+), 8 deletions(-) diff --git a/packages/web/pages/post/[id]/index.tsx b/packages/web/pages/post/[id]/index.tsx index 99243103..a36fa7fb 100644 --- a/packages/web/pages/post/[id]/index.tsx +++ b/packages/web/pages/post/[id]/index.tsx @@ -1,17 +1,18 @@ import React from 'react' -import { NextPage } from 'next' +import { NextPage, NextPageContext } from 'next' import { useRouter } from 'next/router' -import { withApollo } from '@/lib/apollo' import Post from '@/components/Dashboard/Post' import LoadingWrapper from '@/components/LoadingWrapper' import DashboardLayout from '@/components/Layouts/DashboardLayout' -import { PostStatus, usePostPageQuery } from '@/generated/graphql' +import { PostPageDocument, PostStatus, UiLanguage, usePostPageQuery } from '@/generated/graphql' import PostAuthorCard from '@/components/Dashboard/Post/PostAuthorCard' import PostComments from '@/components/Dashboard/Post/PostComments' -import useUILanguage from '@/hooks/useUILanguage' +import useUILanguage, { langCodeToUILangMap } from '@/hooks/useUILanguage' import theme from '@/theme' import PrivateShareLink from '@/components/PrivateShareLink' +import { journalyMiddleware } from '@/lib/journalyMiddleware' +import i18nConfig from '@/config/i18n' const PostPage: NextPage = () => { const idStr = useRouter().query.id as string @@ -72,8 +73,53 @@ const PostPage: NextPage = () => { ) } -PostPage.getInitialProps = async () => ({ - namespacesRequired: ['common', 'post', 'comment', 'post-author-card'], -}) +const getUiLanguage = (ctx: NextPageContext): UiLanguage => { + let langCode + if (ctx.req) { + const i18n = ctx.req.i18n as any + if (!i18n) { + langCode = 'en' + } else { + const { allLanguages, defaultLanguage, fallbackLng } = i18n.options + const fallback = fallbackLng || defaultLanguage -export default withApollo(PostPage) + if (!i18n.languages) { + langCode = typeof fallback === 'string' ? fallback : null + } else { + langCode = i18n.languages.find((lang: string) => allLanguages.includes(lang)) || fallback + } + } + } else { + langCode = i18nConfig.i18n.language + } + + return langCodeToUILangMap[langCode] || UiLanguage.English +} + +PostPage.getInitialProps = async (ctx) => { + const props = await journalyMiddleware(ctx, async (apolloClient) => { + const idStr = ctx.query.id as string + const id = parseInt(idStr, 10) + + // const uiLanguage = useUILanguage() + + // const { i18n: { language } } = React.useContext(I18nContext) + + // return langCodeToUILangMap[language] || UILanguage.English + + await apolloClient.query({ + query: PostPageDocument, + variables: { + id, + uiLanguage: getUiLanguage(ctx), + }, + }) + }) + + return { + ...props, + namespacesRequired: ['common', 'post', 'comment', 'post-author-card'], + } +} + +export default PostPage From a6561fd6a2cc6c38aee56c14a964d86d213601f3 Mon Sep 17 00:00:00 2001 From: Robin MacPherson Date: Thu, 30 May 2024 06:49:57 -0700 Subject: [PATCH 08/34] Factor `getUiLanguage` out --- packages/web/lib/getUiLanguage.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 packages/web/lib/getUiLanguage.ts diff --git a/packages/web/lib/getUiLanguage.ts b/packages/web/lib/getUiLanguage.ts new file mode 100644 index 00000000..ecc9b9e5 --- /dev/null +++ b/packages/web/lib/getUiLanguage.ts @@ -0,0 +1,27 @@ +import { NextPageContext } from 'next' +import { langCodeToUILangMap } from '@/hooks/useUILanguage' +import { UiLanguage } from '@/generated/graphql' +import i18nConfig from '@/config/i18n' + +export const getUiLanguage = (ctx: NextPageContext): UiLanguage => { + let langCode + if (ctx.req) { + const i18n = ctx.req.i18n as any + if (!i18n) { + langCode = 'en' + } else { + const { allLanguages, defaultLanguage, fallbackLng } = i18n.options + const fallback = fallbackLng || defaultLanguage + + if (!i18n.languages) { + langCode = typeof fallback === 'string' ? fallback : null + } else { + langCode = i18n.languages.find((lang: string) => allLanguages.includes(lang)) || fallback + } + } + } else { + langCode = i18nConfig.i18n.language + } + + return langCodeToUILangMap[langCode] || UiLanguage.English +} From 739c275a4c93b7132110b8ba7db97eef43716828 Mon Sep 17 00:00:00 2001 From: Robin MacPherson Date: Thu, 30 May 2024 07:41:43 -0700 Subject: [PATCH 09/34] Refactor About page --- packages/web/pages/about.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/web/pages/about.tsx b/packages/web/pages/about.tsx index a5239f62..137b7001 100644 --- a/packages/web/pages/about.tsx +++ b/packages/web/pages/about.tsx @@ -1,7 +1,6 @@ import { NextPage } from 'next' import LandingPageLayout from '@/components/Layouts/LandingPageLayout' import About from '@/components/Site/About' -import { withApollo } from '@/lib/apollo' const AboutPage: NextPage = () => ( @@ -9,8 +8,11 @@ const AboutPage: NextPage = () => ( ) -AboutPage.getInitialProps = async () => ({ - namespacesRequired: ['common'], -}) +// TODO: Let's get the about page translated? +AboutPage.getInitialProps = async () => { + return { + namespacesRequired: ['common'], + } +} -export default withApollo(AboutPage) +export default AboutPage \ No newline at end of file From b65fcd5ebc9a9f0a0074b9b5a05032d533d05b65 Mon Sep 17 00:00:00 2001 From: Robin MacPherson Date: Thu, 30 May 2024 07:43:20 -0700 Subject: [PATCH 10/34] Refactor Home page --- packages/web/pages/index.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/web/pages/index.tsx b/packages/web/pages/index.tsx index e324188a..85271e8e 100644 --- a/packages/web/pages/index.tsx +++ b/packages/web/pages/index.tsx @@ -1,7 +1,6 @@ import React from 'react' import { NextPage } from 'next' -import { withApollo } from '@/lib/apollo' import LandingPageLayout from '@/components/Layouts/LandingPageLayout' import Home from '@/components/Site/Home' @@ -17,4 +16,4 @@ HomePage.getInitialProps = async () => ({ namespacesRequired: ['common', 'marketing'], }) -export default withApollo(HomePage) +export default HomePage From f2964ec8d19cfbfd87836c320404ca81fc2887bb Mon Sep 17 00:00:00 2001 From: Robin MacPherson Date: Thu, 30 May 2024 07:43:50 -0700 Subject: [PATCH 11/34] Refactor Login page --- packages/web/pages/login.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/web/pages/login.tsx b/packages/web/pages/login.tsx index 473b14f0..c35f90b7 100644 --- a/packages/web/pages/login.tsx +++ b/packages/web/pages/login.tsx @@ -1,5 +1,4 @@ import { NextPage } from 'next' -import { withApollo } from '@/lib/apollo' import LoginForm from '@/components/LoginForm' import LandingPageLayout from '@/components/Layouts/LandingPageLayout' @@ -18,4 +17,4 @@ LoginPage.getInitialProps = async () => ({ namespacesRequired: ['common', 'authentication'], }) -export default withApollo(LoginPage) +export default LoginPage From 3f077171a661a983bb79c642f0cdc59b9129303a Mon Sep 17 00:00:00 2001 From: Robin MacPherson Date: Thu, 6 Jun 2024 06:35:02 -0700 Subject: [PATCH 12/34] Refactor NUM_POSTS_PER_MY_POSTS_PAGE into constant --- .../web/components/Dashboard/MyPosts/MyPosts.tsx | 12 ++++++------ packages/web/constants.ts | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/web/components/Dashboard/MyPosts/MyPosts.tsx b/packages/web/components/Dashboard/MyPosts/MyPosts.tsx index 459f1123..75ea85dd 100644 --- a/packages/web/components/Dashboard/MyPosts/MyPosts.tsx +++ b/packages/web/components/Dashboard/MyPosts/MyPosts.tsx @@ -13,8 +13,7 @@ import PostCard from '../PostCard' import theme from '@/theme' import Filters, { PostQueryVarsType } from '@/components/Dashboard/Filters' import Pagination from '@/components/Pagination' - -const NUM_POSTS_PER_PAGE = 10 +import { NUM_POSTS_PER_MY_POSTS_PAGE } from '@/constants' type Props = { currentUser: UserType @@ -40,18 +39,19 @@ const MyPosts: React.FC = ({ currentUser, status }) => { }) const { loading, data, error } = usePostsQuery({ variables: { - first: NUM_POSTS_PER_PAGE, - skip: (currentPage - 1) * NUM_POSTS_PER_PAGE, + first: NUM_POSTS_PER_MY_POSTS_PAGE, + skip: (currentPage - 1) * NUM_POSTS_PER_MY_POSTS_PAGE, status, authorId: currentUser.id, ...postQueryVars, }, }) + console.log('componentCurrentUserId', currentUser.id) const posts = (data?.posts?.posts as PostType[]) || [] const count = data?.posts?.count || 0 const showPosts = !loading && posts.length > 0 - const showPagination = count > NUM_POSTS_PER_PAGE + const showPagination = count > NUM_POSTS_PER_MY_POSTS_PAGE const showEmptyState = !loading && posts.length === 0 const pageTitle = t('pageTitle') @@ -92,7 +92,7 @@ const MyPosts: React.FC = ({ currentUser, status }) => { )} diff --git a/packages/web/constants.ts b/packages/web/constants.ts index 05a1aad4..a0d9ed8c 100644 --- a/packages/web/constants.ts +++ b/packages/web/constants.ts @@ -1,2 +1,3 @@ export const POST_BUMP_LIMIT = 3 export const JOURNALY_PREMIUM_URL = '/settings/subscription' +export const NUM_POSTS_PER_MY_POSTS_PAGE = 10 \ No newline at end of file From 3c2dc4886b16479460b6f309216c0017c81d6553 Mon Sep 17 00:00:00 2001 From: Robin MacPherson Date: Thu, 6 Jun 2024 06:35:31 -0700 Subject: [PATCH 13/34] Move getUiLanguage.ts to utils --- packages/web/{lib => utils}/getUiLanguage.ts | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename packages/web/{lib => utils}/getUiLanguage.ts (100%) diff --git a/packages/web/lib/getUiLanguage.ts b/packages/web/utils/getUiLanguage.ts similarity index 100% rename from packages/web/lib/getUiLanguage.ts rename to packages/web/utils/getUiLanguage.ts From 84b3a3a740e7c9022f690022824bf6ba3cc98cb7 Mon Sep 17 00:00:00 2001 From: Robin MacPherson Date: Thu, 6 Jun 2024 06:37:15 -0700 Subject: [PATCH 14/34] Clean up refactored getUiLanguage code --- packages/web/pages/post/[id]/index.tsx | 31 ++++---------------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/packages/web/pages/post/[id]/index.tsx b/packages/web/pages/post/[id]/index.tsx index a36fa7fb..d2144bb2 100644 --- a/packages/web/pages/post/[id]/index.tsx +++ b/packages/web/pages/post/[id]/index.tsx @@ -1,18 +1,18 @@ import React from 'react' -import { NextPage, NextPageContext } from 'next' +import { NextPage } from 'next' import { useRouter } from 'next/router' import Post from '@/components/Dashboard/Post' import LoadingWrapper from '@/components/LoadingWrapper' import DashboardLayout from '@/components/Layouts/DashboardLayout' -import { PostPageDocument, PostStatus, UiLanguage, usePostPageQuery } from '@/generated/graphql' +import { PostPageDocument, PostStatus, usePostPageQuery } from '@/generated/graphql' import PostAuthorCard from '@/components/Dashboard/Post/PostAuthorCard' import PostComments from '@/components/Dashboard/Post/PostComments' -import useUILanguage, { langCodeToUILangMap } from '@/hooks/useUILanguage' +import useUILanguage from '@/hooks/useUILanguage' import theme from '@/theme' import PrivateShareLink from '@/components/PrivateShareLink' import { journalyMiddleware } from '@/lib/journalyMiddleware' -import i18nConfig from '@/config/i18n' +import { getUiLanguage } from '@/utils/getUiLanguage' const PostPage: NextPage = () => { const idStr = useRouter().query.id as string @@ -73,29 +73,6 @@ const PostPage: NextPage = () => { ) } -const getUiLanguage = (ctx: NextPageContext): UiLanguage => { - let langCode - if (ctx.req) { - const i18n = ctx.req.i18n as any - if (!i18n) { - langCode = 'en' - } else { - const { allLanguages, defaultLanguage, fallbackLng } = i18n.options - const fallback = fallbackLng || defaultLanguage - - if (!i18n.languages) { - langCode = typeof fallback === 'string' ? fallback : null - } else { - langCode = i18n.languages.find((lang: string) => allLanguages.includes(lang)) || fallback - } - } - } else { - langCode = i18nConfig.i18n.language - } - - return langCodeToUILangMap[langCode] || UiLanguage.English -} - PostPage.getInitialProps = async (ctx) => { const props = await journalyMiddleware(ctx, async (apolloClient) => { const idStr = ctx.query.id as string From a3e95908521a0cc1a98881258c0b3b22951a1c69 Mon Sep 17 00:00:00 2001 From: Robin MacPherson Date: Thu, 6 Jun 2024 06:39:33 -0700 Subject: [PATCH 15/34] Write `getCurrentUserId` util --- packages/web/package-lock.json | 14 ++++++++++++++ packages/web/package.json | 1 + packages/web/utils/getCurrentUserId.ts | 25 +++++++++++++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 packages/web/utils/getCurrentUserId.ts diff --git a/packages/web/package-lock.json b/packages/web/package-lock.json index 9d436c41..03e8980c 100644 --- a/packages/web/package-lock.json +++ b/packages/web/package-lock.json @@ -39,6 +39,7 @@ "is-url": "^1.2.4", "isomorphic-unfetch": "^3.0.0", "jsonwebtoken": "^8.5.1", + "jwt-decode": "^4.0.0", "lodash": "^4.17.20", "next": "^13.3.4", "next-i18next": "^7.0.1", @@ -12319,6 +12320,14 @@ "safe-buffer": "^5.0.1" } }, + "node_modules/jwt-decode": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jwt-decode/-/jwt-decode-4.0.0.tgz", + "integrity": "sha512-+KJGIyHgkGuIq3IEBNftfhW/LfWhXUIY6OmyVWjliu5KH1y0fw7VQ8YndE2O4qZdMSd9SqbnC8GOcZEy0Om7sA==", + "engines": { + "node": ">=18" + } + }, "node_modules/kleur": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", @@ -27660,6 +27669,11 @@ "safe-buffer": "^5.0.1" } }, + "jwt-decode": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jwt-decode/-/jwt-decode-4.0.0.tgz", + "integrity": "sha512-+KJGIyHgkGuIq3IEBNftfhW/LfWhXUIY6OmyVWjliu5KH1y0fw7VQ8YndE2O4qZdMSd9SqbnC8GOcZEy0Om7sA==" + }, "kleur": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", diff --git a/packages/web/package.json b/packages/web/package.json index 87bded5d..fb1ad96b 100644 --- a/packages/web/package.json +++ b/packages/web/package.json @@ -68,6 +68,7 @@ "is-url": "^1.2.4", "isomorphic-unfetch": "^3.0.0", "jsonwebtoken": "^8.5.1", + "jwt-decode": "^4.0.0", "lodash": "^4.17.20", "next": "^13.3.4", "next-i18next": "^7.0.1", diff --git a/packages/web/utils/getCurrentUserId.ts b/packages/web/utils/getCurrentUserId.ts new file mode 100644 index 00000000..9d9ce5f6 --- /dev/null +++ b/packages/web/utils/getCurrentUserId.ts @@ -0,0 +1,25 @@ +import { NextPageContext } from 'next' +import cookie from 'cookie' +import { jwtDecode } from 'jwt-decode' + +export const getCurrentUserId = (ctx: NextPageContext): number | null => { + try { + let jwt + + if (ctx.req) { + if (ctx.req.headers.cookie) { + jwt = cookie.parse(ctx.req.headers.cookie).token + } else { + return null + } + } else { + jwt = cookie.parse(document.cookie).token + } + + const tokenContent = jwtDecode<{ userId: number }>(jwt) + + return tokenContent.userId + } catch { + return null + } +} From 720afc9b26cd95cba4b095c25c465a44e487a70c Mon Sep 17 00:00:00 2001 From: Robin MacPherson Date: Thu, 6 Jun 2024 06:39:59 -0700 Subject: [PATCH 16/34] Add a note to improve our tokens --- packages/web/resolvers/user.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/web/resolvers/user.ts b/packages/web/resolvers/user.ts index a68f5069..f4293c48 100644 --- a/packages/web/resolvers/user.ts +++ b/packages/web/resolvers/user.ts @@ -354,10 +354,7 @@ const UserMutations = extendType({ }, }) } catch (ex) { - if ( - ex instanceof Prisma.PrismaClientKnownRequestError && - ex.code === 'P2002' - ) { + if (ex instanceof Prisma.PrismaClientKnownRequestError && ex.code === 'P2002') { const target = ex?.meta?.target as string[] | undefined if (target?.find((x: string) => x === 'email')) { @@ -385,6 +382,8 @@ const UserMutations = extendType({ await sendEmailAddressVerificationEmail({ user, verificationToken: emailVerificationToken }) + // TODO: We should update this so the tokens expire. + // Potentially a couple of weeks. const token = jwt.sign({ userId: user.id }, process.env.APP_SECRET!) ctx.response.setHeader( 'Set-Cookie', From bda8a2253ad2259c661085f56475d2fa555c1469 Mon Sep 17 00:00:00 2001 From: Robin MacPherson Date: Thu, 6 Jun 2024 08:05:15 -0700 Subject: [PATCH 17/34] Simple page conversions --- packages/web/pages/pricing.tsx | 3 +-- packages/web/pages/request-reset.tsx | 3 +-- packages/web/pages/reset-password.tsx | 3 +-- packages/web/pages/signup.tsx | 2 +- packages/web/pages/terms-of-service.tsx | 3 +-- 5 files changed, 5 insertions(+), 9 deletions(-) diff --git a/packages/web/pages/pricing.tsx b/packages/web/pages/pricing.tsx index 16d8650b..ede9ec0d 100644 --- a/packages/web/pages/pricing.tsx +++ b/packages/web/pages/pricing.tsx @@ -1,7 +1,6 @@ import React from 'react' import { NextPage } from 'next' -import { withApollo } from '@/lib/apollo' import LandingPageLayout from '@/components/Layouts/LandingPageLayout' import Pricing from '@/components/Site/Pricing' @@ -17,4 +16,4 @@ PricingPage.getInitialProps = async () => ({ namespacesRequired: ['settings'], }) -export default withApollo(PricingPage) +export default PricingPage diff --git a/packages/web/pages/request-reset.tsx b/packages/web/pages/request-reset.tsx index e2d2333a..d6a51606 100644 --- a/packages/web/pages/request-reset.tsx +++ b/packages/web/pages/request-reset.tsx @@ -1,5 +1,4 @@ import { NextPage } from 'next' -import { withApollo } from '@/lib/apollo' import RequestResetPasswordForm from '@/components/RequestResetPasswordForm' import LandingPageLayout from '@/components/Layouts/LandingPageLayout' @@ -18,4 +17,4 @@ RequestResetPasswordPage.getInitialProps = async () => ({ namespacesRequired: ['common', 'authentication'], }) -export default withApollo(RequestResetPasswordPage) +export default RequestResetPasswordPage diff --git a/packages/web/pages/reset-password.tsx b/packages/web/pages/reset-password.tsx index aa939652..5a510bf4 100644 --- a/packages/web/pages/reset-password.tsx +++ b/packages/web/pages/reset-password.tsx @@ -1,6 +1,5 @@ import { NextPage } from 'next' import { useRouter } from 'next/router' -import { withApollo } from '@/lib/apollo' import ResetPasswordForm from '@/components/ResetPasswordForm' import LandingPageLayout from '@/components/Layouts/LandingPageLayout' @@ -24,4 +23,4 @@ ResetPasswordPage.getInitialProps = async () => ({ namespacesRequired: ['common', 'authentication'], }) -export default withApollo(ResetPasswordPage) +export default ResetPasswordPage diff --git a/packages/web/pages/signup.tsx b/packages/web/pages/signup.tsx index 1e6d785c..ee9ae66c 100644 --- a/packages/web/pages/signup.tsx +++ b/packages/web/pages/signup.tsx @@ -18,4 +18,4 @@ SignupPage.getInitialProps = async () => ({ namespacesRequired: ['common', 'authentication'], }) -export default withApollo(SignupPage) +export default SignupPage diff --git a/packages/web/pages/terms-of-service.tsx b/packages/web/pages/terms-of-service.tsx index b5994b5f..03a306fd 100644 --- a/packages/web/pages/terms-of-service.tsx +++ b/packages/web/pages/terms-of-service.tsx @@ -1,6 +1,5 @@ import { NextPage } from 'next' import TermsOfService from '@/components/Site/TermsOfService' -import { withApollo } from '@/lib/apollo' const TermsOfServicePage: NextPage = () => @@ -8,4 +7,4 @@ TermsOfServicePage.getInitialProps = async () => ({ namespacesRequired: ['common'], }) -export default withApollo(TermsOfServicePage) +export default TermsOfServicePage From 7a0b8d6ef2e70d368dbbf7f52de24697c20b6314 Mon Sep 17 00:00:00 2001 From: Robin MacPherson Date: Thu, 6 Jun 2024 08:05:37 -0700 Subject: [PATCH 18/34] Refactor post-related pages --- packages/web/pages/my-feed.tsx | 15 ++++++++-- packages/web/pages/my-posts.tsx | 49 ++++++++++++++++++++++++++++----- packages/web/pages/new-post.tsx | 26 +++++++++++++---- 3 files changed, 75 insertions(+), 15 deletions(-) diff --git a/packages/web/pages/my-feed.tsx b/packages/web/pages/my-feed.tsx index fcfd615b..f24a6c43 100644 --- a/packages/web/pages/my-feed.tsx +++ b/packages/web/pages/my-feed.tsx @@ -8,6 +8,8 @@ import MyFeed from '@/components/Dashboard/MyFeed' import AuthGate from '@/components/AuthGate' import WelcomeModal from '@/components/Modals/WelcomeModal' import { InitialSearchFilters } from '@/components/Dashboard/MyFeed' +import { journalyMiddleware } from '@/lib/journalyMiddleware' +import { PostsDocument } from '@/generated/graphql' interface InitialProps { namespacesRequired: string[] @@ -49,10 +51,19 @@ MyFeedPage.getInitialProps = async (ctx) => { console.log('Error parsing default_search_filters cookie', e) } } + const props = await journalyMiddleware(ctx, async (apolloClient) => { + await apolloClient.query({ + query: PostsDocument, + variables: { + ...initialSearchFilters, + }, + }) + }) return { - namespacesRequired: ['common', 'settings', 'my-feed'], + ...props, initialSearchFilters, + namespacesRequired: ['common', 'settings', 'my-feed'], } } -export default withApollo(MyFeedPage) +export default MyFeedPage diff --git a/packages/web/pages/my-posts.tsx b/packages/web/pages/my-posts.tsx index bfbaa769..b43251bb 100644 --- a/packages/web/pages/my-posts.tsx +++ b/packages/web/pages/my-posts.tsx @@ -1,13 +1,19 @@ import React, { useState } from 'react' import { NextPage } from 'next' -import { withApollo } from '@/lib/apollo' import DashboardLayout from '@/components/Layouts/DashboardLayout' import TabToggle from '@/components/TabToggle' import AuthGate from '@/components/AuthGate' import MyPosts from '@/components/Dashboard/MyPosts' -import { PostStatus as PostStatusType } from '@/generated/graphql' +import { + CurrentUserDocument, + PostStatus as PostStatusType, + PostsDocument, +} from '@/generated/graphql' import theme from '@/theme' import { useTranslation } from '@/config/i18n' +import { journalyMiddleware } from '@/lib/journalyMiddleware' +import { NUM_POSTS_PER_MY_POSTS_PAGE } from '@/constants' +import { getCurrentUserId } from '@/utils/getCurrentUserId' type Tab = { key: PostStatusType @@ -33,7 +39,9 @@ const MyPostsPage: NextPage = () => { {(currentUser) => (
-

{t('pageTitle')}

+

+ {t('pageTitle')} +

@@ -67,8 +75,35 @@ const MyPostsPage: NextPage = () => { ) } -MyPostsPage.getInitialProps = async () => ({ - namespacesRequired: ['my-posts', 'common'], -}) +MyPostsPage.getInitialProps = async (ctx) => { + console.log('getInitialPropsUserId', getCurrentUserId(ctx)) + const props = await journalyMiddleware(ctx, async (apolloClient) => { + await apolloClient.query({ + query: PostsDocument, + variables: { + languages: [], + topics: [], + followedAuthors: false, + needsFeedback: false, + hasInteracted: false, + search: '', + savedPosts: false, + first: NUM_POSTS_PER_MY_POSTS_PAGE, + skip: 0, + status: PostStatusType.Published, + authorId: getCurrentUserId(ctx), + }, + }) -export default withApollo(MyPostsPage) + await apolloClient.query({ + query: CurrentUserDocument, + }) + }) + + return { + ...props, + namespacesRequired: ['my-posts', 'common'], + } +} + +export default MyPostsPage diff --git a/packages/web/pages/new-post.tsx b/packages/web/pages/new-post.tsx index b23bf1ae..2daae7f6 100644 --- a/packages/web/pages/new-post.tsx +++ b/packages/web/pages/new-post.tsx @@ -4,7 +4,6 @@ import { useRouter } from 'next/router' import { toast } from 'react-toastify' import { makeReference } from '@apollo/client' -import { withApollo } from '@/lib/apollo' import DashboardLayout from '@/components/Layouts/DashboardLayout' import { navConstants } from '@/components/Dashboard/Nav' import PostEditor, { @@ -19,12 +18,15 @@ import { useCreatePostMutation, PostStatus as PostStatusType, UserRole, + NewPostDocument, } from '@/generated/graphql' import AuthGate from '@/components/AuthGate' import { useTranslation, Router } from '@/config/i18n' import useUILanguage from '@/hooks/useUILanguage' import useUploadInlineImages from '@/hooks/useUploadInlineImages' import PremiumFeatureModal from '@/components/Modals/PremiumFeatureModal' +import { journalyMiddleware } from '@/lib/journalyMiddleware' +import { getUiLanguage } from '@/utils/getUiLanguage' type NewPostPageProps = { defaultImage: { @@ -330,9 +332,21 @@ const NewPostPage: NextPage = ({ defaultImage }) => { ) } -NewPostPage.getInitialProps = async () => ({ - defaultImage: selectDefaultImage(), - namespacesRequired: ['common', 'post'], -}) +NewPostPage.getInitialProps = async (ctx) => { + const props = await journalyMiddleware(ctx, async (apolloClient) => { + await apolloClient.query({ + query: NewPostDocument, + variables: { + uiLanguage: getUiLanguage(ctx), + }, + }) + }) + + return { + ...props, + defaultImage: selectDefaultImage(), + namespacesRequired: ['common', 'post'], + } +} -export default withApollo(NewPostPage) +export default NewPostPage From 979130526a2c3b67986de86e7bd54e57ab96caae Mon Sep 17 00:00:00 2001 From: Robin MacPherson Date: Thu, 27 Jun 2024 18:25:02 +0100 Subject: [PATCH 19/34] A bit of cleanup --- packages/web/lib/journalyMiddleware.ts | 1 + packages/web/pages/my-posts.tsx | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/web/lib/journalyMiddleware.ts b/packages/web/lib/journalyMiddleware.ts index 7012a69b..e2bb53b7 100644 --- a/packages/web/lib/journalyMiddleware.ts +++ b/packages/web/lib/journalyMiddleware.ts @@ -2,6 +2,7 @@ import { ApolloClient } from '@apollo/client' import { NextPageContext } from 'next' import { initApolloClient } from './apollo' +// TOOD: Add documentation export const journalyMiddleware = async ( ctx: NextPageContext, callback: (apolloClient: ApolloClient) => Promise, diff --git a/packages/web/pages/my-posts.tsx b/packages/web/pages/my-posts.tsx index b43251bb..03cbd1df 100644 --- a/packages/web/pages/my-posts.tsx +++ b/packages/web/pages/my-posts.tsx @@ -76,7 +76,6 @@ const MyPostsPage: NextPage = () => { } MyPostsPage.getInitialProps = async (ctx) => { - console.log('getInitialPropsUserId', getCurrentUserId(ctx)) const props = await journalyMiddleware(ctx, async (apolloClient) => { await apolloClient.query({ query: PostsDocument, From a9f2a0832f774d534658a7497bf6f8e4655d2331 Mon Sep 17 00:00:00 2001 From: Robin MacPherson Date: Thu, 27 Jun 2024 18:25:19 +0100 Subject: [PATCH 20/34] Handle most of the remaining pages --- packages/web/pages/settings/account.tsx | 22 ++++++++++--- packages/web/pages/settings/profile.tsx | 33 ++++++++++++++++---- packages/web/pages/settings/subscription.tsx | 29 +++++++++++++---- packages/web/pages/settings/tutorials.tsx | 19 ++++++++--- packages/web/pages/user/[handle]/index.tsx | 29 ++++++++++++++--- 5 files changed, 107 insertions(+), 25 deletions(-) diff --git a/packages/web/pages/settings/account.tsx b/packages/web/pages/settings/account.tsx index 95049d12..20e0fc4e 100644 --- a/packages/web/pages/settings/account.tsx +++ b/packages/web/pages/settings/account.tsx @@ -8,7 +8,9 @@ import LoadingSpinner from '@/components/Icons/LoadingSpinner' import UpdatePasswordForm from '@/components/Dashboard/Settings/UpdatePasswordForm' import NotificationSettingsForm from '@/components/Dashboard/Settings/NotificationSettingsForm' import UILanguageForm from '@/components/Dashboard/Settings/UILanguageForm' -import { useSettingsFormDataQuery } from '@/generated/graphql' +import { SettingsFormDataDocument, useSettingsFormDataQuery } from '@/generated/graphql' +import { journalyMiddleware } from '@/lib/journalyMiddleware' +import { getUiLanguage } from '@/utils/getUiLanguage' const Account: NextPage = () => { const uiLanguage = useUILanguage() @@ -56,8 +58,20 @@ const Account: NextPage = () => { ) } -Account.getInitialProps = async () => ({ - namespacesRequired: ['common', 'settings'], -}) +Account.getInitialProps = async (ctx) => { + const props = await journalyMiddleware(ctx, async (apolloClient) => { + await apolloClient.query({ + query: SettingsFormDataDocument, + variables: { + uiLanguage: getUiLanguage(ctx), + }, + }) + }) + + return { + ...props, + namespacesRequired: ['common', 'settings'], + } +} export default withApollo(Account) diff --git a/packages/web/pages/settings/profile.tsx b/packages/web/pages/settings/profile.tsx index ced46377..9d78af3f 100644 --- a/packages/web/pages/settings/profile.tsx +++ b/packages/web/pages/settings/profile.tsx @@ -1,6 +1,5 @@ import React from 'react' import { NextPage } from 'next' -import { withApollo } from '@/lib/apollo' import useUILanguage from '@/hooks/useUILanguage' import SettingsPageLayout from '@/components/Layouts/SettingsPageLayout' import LoadingSpinner from '@/components/Icons/LoadingSpinner' @@ -10,7 +9,13 @@ import BioForm from '@/components/Dashboard/Settings/BioForm' import InterestsForm from '@/components/Dashboard/Settings/InterestsForm' import SocialForm from '@/components/Dashboard/Settings/SocialForm' import AuthGate from '@/components/AuthGate' -import { useSettingsFormDataQuery } from '@/generated/graphql' +import { + CurrentUserDocument, + SettingsFormDataDocument, + useSettingsFormDataQuery, +} from '@/generated/graphql' +import { journalyMiddleware } from '@/lib/journalyMiddleware' +import { getUiLanguage } from '@/utils/getUiLanguage' const ProfileInfo: NextPage = () => { const uiLanguage = useUILanguage() @@ -67,8 +72,24 @@ const ProfileInfo: NextPage = () => { ) } -ProfileInfo.getInitialProps = async () => ({ - namespacesRequired: ['settings', 'common', 'badge'], -}) +ProfileInfo.getInitialProps = async (ctx) => { + const props = await journalyMiddleware(ctx, async (apolloClient) => { + await apolloClient.query({ + query: SettingsFormDataDocument, + variables: { + uiLanguage: getUiLanguage(ctx), + }, + }) -export default withApollo(ProfileInfo) + await apolloClient.query({ + query: CurrentUserDocument, + }) + }) + + return { + ...props, + namespacesRequired: ['common', 'settings', 'badge'], + } +} + +export default ProfileInfo diff --git a/packages/web/pages/settings/subscription.tsx b/packages/web/pages/settings/subscription.tsx index e2ab9f6a..2cac2851 100644 --- a/packages/web/pages/settings/subscription.tsx +++ b/packages/web/pages/settings/subscription.tsx @@ -1,11 +1,15 @@ import React from 'react' import { NextPage } from 'next' -import { withApollo } from '@/lib/apollo' import SettingsPageLayout from '@/components/Layouts/SettingsPageLayout' import AuthGate from '@/components/AuthGate' import SubscriptionForm from '@/components/Dashboard/Settings/Subscription/SubscriptionForm' -import { useSubscriptionSettingsPageQuery } from '@/generated/graphql' +import { + CurrentUserDocument, + SubscriptionSettingsPageDocument, + useSubscriptionSettingsPageQuery, +} from '@/generated/graphql' import theme from '@/theme' +import { journalyMiddleware } from '@/lib/journalyMiddleware' const Subscription: NextPage = () => { const { loading, data, refetch: refetchUser } = useSubscriptionSettingsPageQuery() @@ -36,8 +40,21 @@ const Subscription: NextPage = () => { ) } -Subscription.getInitialProps = async () => ({ - namespacesRequired: ['common', 'settings', 'marketing'], -}) +Subscription.getInitialProps = async (ctx) => { + const props = await journalyMiddleware(ctx, async (apolloClient) => { + await apolloClient.query({ + query: SubscriptionSettingsPageDocument, + }) -export default withApollo(Subscription) + await apolloClient.query({ + query: CurrentUserDocument, + }) + }) + + return { + ...props, + namespacesRequired: ['common', 'settings', 'marketing'], + } +} + +export default Subscription diff --git a/packages/web/pages/settings/tutorials.tsx b/packages/web/pages/settings/tutorials.tsx index 961092c5..bb2b2f6f 100644 --- a/packages/web/pages/settings/tutorials.tsx +++ b/packages/web/pages/settings/tutorials.tsx @@ -4,6 +4,8 @@ import { withApollo } from '@/lib/apollo' import SettingsPageLayout from '@/components/Layouts/SettingsPageLayout' import AuthGate from '@/components/AuthGate' import theme from '@/theme' +import { journalyMiddleware } from '@/lib/journalyMiddleware' +import { CurrentUserDocument } from '@/generated/graphql' const Tutorials: NextPage = () => { return ( @@ -247,8 +249,17 @@ const Tutorials: NextPage = () => { ) } -Tutorials.getInitialProps = async () => ({ - namespacesRequired: ['common', 'tutorials'], -}) +Tutorials.getInitialProps = async (ctx) => { + const props = await journalyMiddleware(ctx, async (apolloClient) => { + await apolloClient.query({ + query: CurrentUserDocument, + }) + }) -export default withApollo(Tutorials) + return { + ...props, + namespacesRequired: ['common', 'tutorials'], + } +} + +export default Tutorials diff --git a/packages/web/pages/user/[handle]/index.tsx b/packages/web/pages/user/[handle]/index.tsx index 7eb58921..7c97ff87 100644 --- a/packages/web/pages/user/[handle]/index.tsx +++ b/packages/web/pages/user/[handle]/index.tsx @@ -5,9 +5,10 @@ import { useRouter } from 'next/router' import { withApollo } from '@/lib/apollo' import LoadingWrapper from '@/components/LoadingWrapper' import DashboardLayout from '@/components/Layouts/DashboardLayout' -import { useProfilePageQuery } from '@/generated/graphql' +import { ProfilePageDocument, UiLanguage, useProfilePageQuery } from '@/generated/graphql' import useUILanguage from '@/hooks/useUILanguage' import Profile from '@/components/Dashboard/Profile' +import { journalyMiddleware } from '@/lib/journalyMiddleware' interface InitialProps { namespacesRequired: string[] @@ -40,8 +41,26 @@ const ProfilePage: NextPage = () => { ) } -ProfilePage.getInitialProps = async () => ({ - namespacesRequired: ['common', 'profile', 'post'], -}) +ProfilePage.getInitialProps = async (ctx) => { + const props = await journalyMiddleware(ctx, async (apolloClient) => { + const userHandle = ctx.query.handle as string -export default withApollo(ProfilePage) + // const uiLanguage = useUILanguage() + // const { i18n: { language } } = React.useContext(I18nContext) + // return langCodeToUILangMap[language] || UILanguage.English + + await apolloClient.query({ + query: ProfilePageDocument, + variables: { + uiLanguage: UiLanguage.English, + userHandle, + }, + }) + }) + return { + ...props, + namespacesRequired: ['common', 'profile', 'post'], + } +} + +export default ProfilePage From 49c642bc4f2ba284e9cfd65c51e4953a2c6e1ccb Mon Sep 17 00:00:00 2001 From: Robin MacPherson Date: Thu, 27 Jun 2024 18:30:33 +0100 Subject: [PATCH 21/34] Clean up the old apollo.tsx file --- packages/web/lib/apollo.tsx | 123 +-------------------------------- packages/web/pages/my-feed.tsx | 1 - 2 files changed, 2 insertions(+), 122 deletions(-) diff --git a/packages/web/lib/apollo.tsx b/packages/web/lib/apollo.tsx index 9467b2c7..650843e3 100644 --- a/packages/web/lib/apollo.tsx +++ b/packages/web/lib/apollo.tsx @@ -1,7 +1,6 @@ import React from 'react' -import { ApolloProvider, ApolloClient, InMemoryCache, HttpLink } from '@apollo/client' +import { ApolloClient, InMemoryCache, HttpLink } from '@apollo/client' import fetch from 'isomorphic-unfetch' -import { NextPage } from 'next' export type ApolloClientCache = any @@ -16,130 +15,12 @@ const JournalySSRContext = React.createContext({ }) JournalySSRContext.displayName = 'JournalySSRContext' -interface WithApolloInitialProps { - apolloState?: ApolloClientCache -} - -interface WithApolloProps extends WithApolloInitialProps { - apolloClient?: ApolloClient - ssrContext: JournalySSRContextType -} - -/** - * Creates and provides the apolloContext - * to a next.js PageTree. Use it by wrapping - * your PageComponent via HOC pattern. - * @param {Function|Class} PageComponent - * @param {Object} [config] - * @param {Boolean} [config.ssr=true] - */ -export function withApollo( - PageComponent: NextPage, - { ssr = true } = {}, -) { - const WithApollo: NextPage< - PageProps & WithApolloProps, - PageInitialProps & WithApolloInitialProps - > = ({ apolloClient, apolloState, ssrContext, ...pageProps }) => { - const client = apolloClient || initApolloClient(apolloState) - return ( - - - - - - ) - } - - // Set the correct displayName in development - if (process.env.NODE_ENV !== 'production') { - const displayName = PageComponent.displayName || PageComponent.name || 'Component' - - if (displayName === 'App') { - console.warn('This withApollo HOC only works with PageComponents.') - } - - WithApollo.displayName = `withApollo(${displayName})` - } - - if (ssr || PageComponent.getInitialProps) { - WithApollo.getInitialProps = async (ctx) => { - const { AppTree, req } = ctx - - const headers: any = {} - if (typeof window === 'undefined' && req) { - // If SSR, copy the request cookies into apollo client so it has the same - // auth context as the request for the page. - headers['cookie'] = req.headers.cookie - } - - // Initialize ApolloClient, add it to the ctx object so - // we can use it in `PageComponent.getInitialProp`. - const apolloClient = (ctx.apolloClient = initApolloClient({}, headers)) - - // Run wrapped getInitialProps methods - let pageProps = {} as PageInitialProps - if (PageComponent.getInitialProps) { - pageProps = await PageComponent.getInitialProps(ctx) - } - - // Only on the server: - if (typeof window === 'undefined') { - // When redirecting, the response is finished. - // No point in continuing to render - if (ctx.res && ctx.res.finished) { - return pageProps - } - - // Only if ssr is enabled - if (ssr) { - const ssrContext = { redirectTarget: null } - - try { - // Run all GraphQL queries - const { getDataFromTree } = await import('@apollo/client/react/ssr') - await getDataFromTree( - , - ) - } catch (error) { - // Prevent Apollo Client GraphQL errors from crashing SSR. - // Handle them in components via the data.error prop: - // https://www.apollographql.com/docs/react/api/react-apollo.html#graphql-query-data-error - console.error('Error while running `getDataFromTree`', error) - } - - if (ssrContext.redirectTarget && ctx?.res) { - ;(ctx.res as any).redirect(ssrContext.redirectTarget) - return pageProps - } - } - } - - // Extract query data from the Apollo store - const apolloState = apolloClient.cache.extract() - - return { - ...pageProps, - apolloState, - } - } - } - - return WithApollo -} - /** * Always creates a new apollo client on the server * Creates or reuses apollo client in the browser. * @param {Object} initialState */ -function initApolloClient(initialState?: ApolloClientCache, headers = {}) { +export function initApolloClient(initialState?: ApolloClientCache, headers = {}) { // Make sure to create a new client for every server-side request so that data // isn't shared between connections (which would be bad) if (typeof window === 'undefined') { diff --git a/packages/web/pages/my-feed.tsx b/packages/web/pages/my-feed.tsx index f24a6c43..56975d52 100644 --- a/packages/web/pages/my-feed.tsx +++ b/packages/web/pages/my-feed.tsx @@ -2,7 +2,6 @@ import React from 'react' import { NextPage } from 'next' import cookie from 'cookie' import { Request } from 'express' -import { withApollo } from '@/lib/apollo' import DashboardLayout from '@/components/Layouts/DashboardLayout' import MyFeed from '@/components/Dashboard/MyFeed' import AuthGate from '@/components/AuthGate' From 73e637e20bd3c4ef0360e0bcaa64576ddb840d4e Mon Sep 17 00:00:00 2001 From: Robin MacPherson Date: Thu, 27 Jun 2024 18:40:43 +0100 Subject: [PATCH 22/34] Fix up the final pages! --- packages/web/pages/post/[id]/edit.tsx | 64 +++++++++++++------ packages/web/pages/post/[id]/index.tsx | 6 -- .../web/pages/post/private/[id]/index.tsx | 29 +++++++-- 3 files changed, 68 insertions(+), 31 deletions(-) diff --git a/packages/web/pages/post/[id]/edit.tsx b/packages/web/pages/post/[id]/edit.tsx index 98884006..f5ba80c3 100644 --- a/packages/web/pages/post/[id]/edit.tsx +++ b/packages/web/pages/post/[id]/edit.tsx @@ -1,7 +1,6 @@ import React from 'react' import { NextPage } from 'next' import { useRouter } from 'next/router' -import { withApollo } from '@/lib/apollo' import { useTranslation } from '@/config/i18n' import { TElement } from '@udecode/plate' @@ -13,12 +12,19 @@ import PostEditor, { } from '@/components/PostEditor' import theme from '@/theme' import Button, { ButtonVariant } from '@/components/Button' -import { useEditPostQuery, useUpdatePostMutation } from '@/generated/graphql' +import { + EditPostDocument, + PostPageDocument, + useEditPostQuery, + useUpdatePostMutation, +} from '@/generated/graphql' import AuthGate from '@/components/AuthGate' import ConfirmationModal from '@/components/Modals/ConfirmationModal' import useUILanguage from '@/hooks/useUILanguage' import useAuthCheck from '@/hooks/useAuthCheck' import useUploadInlineImages from '@/hooks/useUploadInlineImages' +import { journalyMiddleware } from '@/lib/journalyMiddleware' +import { getUiLanguage } from '@/utils/getUiLanguage' const EditPostPage: NextPage = () => { const router = useRouter() @@ -123,19 +129,15 @@ const EditPostPage: NextPage = () => { clear() setSaving(false) router.push({ pathname: `/post/${postId}` }) - }, [ - setSaving, - setErrorMessage, - dataRef, - uploadInlineImages, - updatePost, - router, - ]) - - const onSaveClick = React.useCallback((e: React.MouseEvent) => { - e.preventDefault() - savePost() - }, [savePost]) + }, [setSaving, setErrorMessage, dataRef, uploadInlineImages, updatePost, router]) + + const onSaveClick = React.useCallback( + (e: React.MouseEvent) => { + e.preventDefault() + savePost() + }, + [savePost], + ) return ( @@ -225,8 +227,32 @@ const EditPostPage: NextPage = () => { ) } -EditPostPage.getInitialProps = async () => ({ - namespacesRequired: ['common', 'post'], -}) +EditPostPage.getInitialProps = async (ctx) => { + const props = await journalyMiddleware(ctx, async (apolloClient) => { + const idStr = ctx.query.id as string + const id = parseInt(idStr, 10) + + await apolloClient.query({ + query: PostPageDocument, + variables: { + id, + uiLanguage: getUiLanguage(ctx), + }, + }) + + await apolloClient.query({ + query: EditPostDocument, + variables: { + id, + uiLanguage: getUiLanguage(ctx), + }, + }) + }) + + return { + ...props, + namespacesRequired: ['common', 'post'], + } +} -export default withApollo(EditPostPage) +export default EditPostPage diff --git a/packages/web/pages/post/[id]/index.tsx b/packages/web/pages/post/[id]/index.tsx index d2144bb2..10993c6d 100644 --- a/packages/web/pages/post/[id]/index.tsx +++ b/packages/web/pages/post/[id]/index.tsx @@ -78,12 +78,6 @@ PostPage.getInitialProps = async (ctx) => { const idStr = ctx.query.id as string const id = parseInt(idStr, 10) - // const uiLanguage = useUILanguage() - - // const { i18n: { language } } = React.useContext(I18nContext) - - // return langCodeToUILangMap[language] || UILanguage.English - await apolloClient.query({ query: PostPageDocument, variables: { diff --git a/packages/web/pages/post/private/[id]/index.tsx b/packages/web/pages/post/private/[id]/index.tsx index d47a8271..02107402 100644 --- a/packages/web/pages/post/private/[id]/index.tsx +++ b/packages/web/pages/post/private/[id]/index.tsx @@ -2,15 +2,16 @@ import React from 'react' import { NextPage } from 'next' import { useRouter } from 'next/router' -import { withApollo } from '@/lib/apollo' import Post from '@/components/Dashboard/Post' import LoadingWrapper from '@/components/LoadingWrapper' import DashboardLayout from '@/components/Layouts/DashboardLayout' -import { usePrivatePostPageQuery } from '@/generated/graphql' +import { PostPageDocument, usePrivatePostPageQuery } from '@/generated/graphql' import PostAuthorCard from '@/components/Dashboard/Post/PostAuthorCard' import PostComments from '@/components/Dashboard/Post/PostComments' import useUILanguage from '@/hooks/useUILanguage' import theme from '@/theme' +import { journalyMiddleware } from '@/lib/journalyMiddleware' +import { getUiLanguage } from '@/utils/getUiLanguage' const PostPage: NextPage = () => { const privateShareId = useRouter().query.id as string @@ -66,8 +67,24 @@ const PostPage: NextPage = () => { ) } -PostPage.getInitialProps = async () => ({ - namespacesRequired: ['common', 'post', 'comment', 'post-author-card'], -}) +PostPage.getInitialProps = async (ctx) => { + const props = await journalyMiddleware(ctx, async (apolloClient) => { + const idStr = ctx.query.id as string + const id = parseInt(idStr, 10) -export default withApollo(PostPage) + await apolloClient.query({ + query: PostPageDocument, + variables: { + id, + uiLanguage: getUiLanguage(ctx), + }, + }) + }) + + return { + ...props, + namespacesRequired: ['common', 'post', 'comment', 'post-author-card'], + } +} + +export default PostPage From 7a225578a58bf8adcd65d602718fa70cf37e47ba Mon Sep 17 00:00:00 2001 From: Robin MacPherson Date: Thu, 11 Jul 2024 16:58:54 +0100 Subject: [PATCH 23/34] Got stuck in the muck... no fun my feed page --- docs/0-creating-pages.md | 1 + .../components/Dashboard/Filters/Filters.tsx | 22 ++++--- .../components/Dashboard/MyFeed/MyFeed.tsx | 50 ++++++++++++++-- packages/web/pages/api/graphql.ts | 8 ++- packages/web/pages/my-feed.tsx | 58 +++++++++++++++++-- packages/web/pages/settings/tutorials.tsx | 1 - packages/web/pages/signup.tsx | 1 - packages/web/pages/user/[handle]/index.tsx | 1 - packages/web/resolvers/post.ts | 3 +- 9 files changed, 116 insertions(+), 29 deletions(-) diff --git a/docs/0-creating-pages.md b/docs/0-creating-pages.md index b4a31c87..6f49bf05 100644 --- a/docs/0-creating-pages.md +++ b/docs/0-creating-pages.md @@ -2,6 +2,7 @@ When creating a new page, make sure to require a namespace for translations. This ensures that only the translations that are needed are sent along with that page. +// TODO: update to remove withApollo ```jsx const MyPage: NextPage = () => { /* ... */ diff --git a/packages/web/components/Dashboard/Filters/Filters.tsx b/packages/web/components/Dashboard/Filters/Filters.tsx index 014b78eb..fb18fd7e 100644 --- a/packages/web/components/Dashboard/Filters/Filters.tsx +++ b/packages/web/components/Dashboard/Filters/Filters.tsx @@ -1,7 +1,13 @@ import React, { useState, useCallback } from 'react' import isEqual from 'lodash/isEqual' import Button, { ButtonVariant } from '@/components/Button' -import { User as UserType, useTopicsQuery, useLanguagesQuery, UserRole } from '@/generated/graphql' +import { + User as UserType, + useTopicsQuery, + useLanguagesQuery, + UserRole, + LanguagesDocument, +} from '@/generated/graphql' import SearchInput from './SearchInput' import LanguageSelect from './LanguageSelect' import TopicSelect from './TopicSelect' @@ -9,16 +15,8 @@ import useToggle from '@/hooks/useToggle' import useUILanguage from '@/hooks/useUILanguage' import { Router, useTranslation } from '@/config/i18n' import PremiumFeatureModal from '@/components/Modals/PremiumFeatureModal' - -export type PostQueryVarsType = { - languages: number[] - topics: number[] - followedAuthors: boolean - search: string - needsFeedback: boolean - hasInteracted: boolean - savedPosts: boolean -} +import { PostQueryVarsType } from '../MyFeed/MyFeed' +import { useApolloClient } from '@apollo/client' type Props = { currentUser: UserType @@ -143,7 +141,7 @@ const Filters: React.FC = ({ })) resetPagination() }, [resetPagination]) - + const toggleMyLanguagesFilter = useCallback(() => { setPostQueryVars((prevState) => ({ ...prevState, diff --git a/packages/web/components/Dashboard/MyFeed/MyFeed.tsx b/packages/web/components/Dashboard/MyFeed/MyFeed.tsx index d53b9b4e..3e9417bf 100644 --- a/packages/web/components/Dashboard/MyFeed/MyFeed.tsx +++ b/packages/web/components/Dashboard/MyFeed/MyFeed.tsx @@ -13,6 +13,7 @@ import { usePostsQuery, PostCardFragmentFragment, PostStatus, + PostsDocument, } from '@/generated/graphql' import PostCard from '../PostCard' @@ -28,6 +29,7 @@ type Props = { initialSearchFilters: InitialSearchFilters | null } +// TODO: let's consider adding `followedAuthor` here export type InitialSearchFilters = { languages: number[] topics: number[] @@ -37,10 +39,41 @@ export type InitialSearchFilters = { search: string } +export type PostQueryVarsType = { + languages: number[] + topics: number[] + followedAuthors: boolean + search: string + needsFeedback: boolean + hasInteracted: boolean + savedPosts: boolean +} + +export const constructPostQueryVars = ( + postQueryVars: PostQueryVarsType | null, + currentPage: number, +) => { + const variables = { + first: NUM_POSTS_PER_PAGE, + skip: (currentPage - 1) * NUM_POSTS_PER_PAGE, + status: PostStatus.Published, + languages: postQueryVars?.languages || [], + topics: postQueryVars?.topics || [], + followedAuthors: postQueryVars?.followedAuthors || false, + needsFeedback: postQueryVars?.needsFeedback || false, + hasInteracted: postQueryVars?.hasInteracted || false, + search: postQueryVars?.search || '', + savedPosts: postQueryVars?.savedPosts || false, + } + return variables +} + const MyFeed: React.FC = ({ currentUser, initialSearchFilters }) => { const { t } = useTranslation('my-feed') const client = useApolloClient() + console.log('ROOT', client.cache.data.data.ROOT_QUERY) + /** * Pagination handling */ @@ -77,16 +110,21 @@ const MyFeed: React.FC = ({ currentUser, initialSearchFilters }) => { gtag('event', 'myFeedFilterSet', { filters: postQueryVars }) }, [postQueryVars]) + console.log('vars1', constructPostQueryVars(postQueryVars, currentPage)) // fetch posts for the feed! const { loading, error, data } = usePostsQuery({ - variables: { - first: NUM_POSTS_PER_PAGE, - skip: (currentPage - 1) * NUM_POSTS_PER_PAGE, - status: PostStatus.Published, - ...postQueryVars, - }, + variables: constructPostQueryVars(postQueryVars, currentPage), }) + console.log({ loading, error }) + console.log( + 'POSTS_QUERY', + client.readQuery({ + query: PostsDocument, + variables: constructPostQueryVars(postQueryVars, currentPage), + }), + ) + const posts = data?.posts?.posts const count = data?.posts?.count || 0 const showPagination = count > NUM_POSTS_PER_PAGE diff --git a/packages/web/pages/api/graphql.ts b/packages/web/pages/api/graphql.ts index 5dd62f3c..448edb99 100644 --- a/packages/web/pages/api/graphql.ts +++ b/packages/web/pages/api/graphql.ts @@ -32,6 +32,7 @@ export const config = { }; const handler = async (req: any, res: any) => { + console.log('start', req.cookies) const bodyPromise = readBody(req) const { token } = req.cookies req.response = res @@ -46,9 +47,12 @@ const handler = async (req: any, res: any) => { console.log(`GraphQL request took ${gqlDuration} ms`) if (gqlDuration > LOG_QUERY_THRESHOLD) { - console.log(`Request ran longer than ${LOG_QUERY_THRESHOLD}ms, request body is:`, await bodyPromise) + console.log( + `Request ran longer than ${LOG_QUERY_THRESHOLD}ms, request body is:`, + await bodyPromise, + ) } - + console.log('END', await bodyPromise) return response } diff --git a/packages/web/pages/my-feed.tsx b/packages/web/pages/my-feed.tsx index 56975d52..1056f7f0 100644 --- a/packages/web/pages/my-feed.tsx +++ b/packages/web/pages/my-feed.tsx @@ -8,7 +8,14 @@ import AuthGate from '@/components/AuthGate' import WelcomeModal from '@/components/Modals/WelcomeModal' import { InitialSearchFilters } from '@/components/Dashboard/MyFeed' import { journalyMiddleware } from '@/lib/journalyMiddleware' -import { PostsDocument } from '@/generated/graphql' +import { + CurrentUserDocument, + LanguagesDocument, + PostsDocument, + TopicsDocument, +} from '@/generated/graphql' +import { constructPostQueryVars } from '@/components/Dashboard/MyFeed/MyFeed' +import { getUiLanguage } from '@/utils/getUiLanguage' interface InitialProps { namespacesRequired: string[] @@ -50,14 +57,55 @@ MyFeedPage.getInitialProps = async (ctx) => { console.log('Error parsing default_search_filters cookie', e) } } + + console.log({ initialSearchFilters }) + const props = await journalyMiddleware(ctx, async (apolloClient) => { - await apolloClient.query({ + await Promise.all([ + apolloClient.query({ + query: CurrentUserDocument, + }), + apolloClient.query({ + query: PostsDocument, + variables: constructPostQueryVars( + initialSearchFilters, + ctx.query.page ? Math.max(1, parseInt(ctx.query.page as string, 10)) : 1, + ), + }), + apolloClient.query({ + query: TopicsDocument, + variables: { + uiLanguage: getUiLanguage(ctx), + languages: initialSearchFilters?.languages || [], + hasPosts: true, + authoredOnly: false, + }, + }), + apolloClient.query({ + query: LanguagesDocument, + variables: { + hasPosts: true, + authoredOnly: false, + }, + }), + ]) + console.log('POSTS_QUERY_2', { query: PostsDocument, - variables: { - ...initialSearchFilters, - }, + variables: constructPostQueryVars( + initialSearchFilters, + ctx.query.page ? Math.max(1, parseInt(ctx.query.page as string, 10)) : 1, + ), }) }) + + console.log( + 'vars2', + constructPostQueryVars( + initialSearchFilters, + ctx.query.page ? Math.max(1, parseInt(ctx.query.page as string, 10)) : 1, + ), + ) + return { ...props, initialSearchFilters, diff --git a/packages/web/pages/settings/tutorials.tsx b/packages/web/pages/settings/tutorials.tsx index bb2b2f6f..60a7569b 100644 --- a/packages/web/pages/settings/tutorials.tsx +++ b/packages/web/pages/settings/tutorials.tsx @@ -1,6 +1,5 @@ import React from 'react' import { NextPage } from 'next' -import { withApollo } from '@/lib/apollo' import SettingsPageLayout from '@/components/Layouts/SettingsPageLayout' import AuthGate from '@/components/AuthGate' import theme from '@/theme' diff --git a/packages/web/pages/signup.tsx b/packages/web/pages/signup.tsx index ee9ae66c..40e1a0a8 100644 --- a/packages/web/pages/signup.tsx +++ b/packages/web/pages/signup.tsx @@ -1,5 +1,4 @@ import { NextPage } from 'next' -import { withApollo } from '@/lib/apollo' import SignupForm from '@/components/SignupForm' import LandingPageLayout from '@/components/Layouts/LandingPageLayout' diff --git a/packages/web/pages/user/[handle]/index.tsx b/packages/web/pages/user/[handle]/index.tsx index 7c97ff87..00c13d3a 100644 --- a/packages/web/pages/user/[handle]/index.tsx +++ b/packages/web/pages/user/[handle]/index.tsx @@ -2,7 +2,6 @@ import React from 'react' import { NextPage } from 'next' import { useRouter } from 'next/router' -import { withApollo } from '@/lib/apollo' import LoadingWrapper from '@/components/LoadingWrapper' import DashboardLayout from '@/components/Layouts/DashboardLayout' import { ProfilePageDocument, UiLanguage, useProfilePageQuery } from '@/generated/graphql' diff --git a/packages/web/resolvers/post.ts b/packages/web/resolvers/post.ts index 353c3fba..e4b3d5ae 100644 --- a/packages/web/resolvers/post.ts +++ b/packages/web/resolvers/post.ts @@ -294,6 +294,7 @@ const PostQueries = extendType({ }), }, resolve: async (_parent, args, ctx) => { + console.log('start', args) const { userId } = ctx.request const currentUser = userId @@ -419,7 +420,7 @@ const PostQueries = extendType({ `, ctx.db.$queryRaw<{ count: number }[]>`SELECT COUNT(*) ${queryPred};`, ]) - + console.log('THE END') return { posts, count } }, }) From ddf7eaf5e78a97639e183325e08233974d12e760 Mon Sep 17 00:00:00 2001 From: Ryan Lanny Jenkins Date: Mon, 15 Jul 2024 08:58:58 -0500 Subject: [PATCH 24/34] Fixed issue with my feed SSR but why remains a bit of a mystery --- packages/web/components/Dashboard/MyFeed/MyFeed.tsx | 9 --------- packages/web/generated/graphql.tsx | 9 ++++----- packages/web/graphql/fragments.graphql | 3 +-- packages/web/pages/my-feed.tsx | 4 ++-- 4 files changed, 7 insertions(+), 18 deletions(-) diff --git a/packages/web/components/Dashboard/MyFeed/MyFeed.tsx b/packages/web/components/Dashboard/MyFeed/MyFeed.tsx index 3e9417bf..dc8a5444 100644 --- a/packages/web/components/Dashboard/MyFeed/MyFeed.tsx +++ b/packages/web/components/Dashboard/MyFeed/MyFeed.tsx @@ -116,15 +116,6 @@ const MyFeed: React.FC = ({ currentUser, initialSearchFilters }) => { variables: constructPostQueryVars(postQueryVars, currentPage), }) - console.log({ loading, error }) - console.log( - 'POSTS_QUERY', - client.readQuery({ - query: PostsDocument, - variables: constructPostQueryVars(postQueryVars, currentPage), - }), - ) - const posts = data?.posts?.posts const count = data?.posts?.count || 0 const showPagination = count > NUM_POSTS_PER_PAGE diff --git a/packages/web/generated/graphql.tsx b/packages/web/generated/graphql.tsx index 0ae0c6dc..20842cbc 100644 --- a/packages/web/generated/graphql.tsx +++ b/packages/web/generated/graphql.tsx @@ -1565,7 +1565,7 @@ export type PostCardFragmentFragment = { publishedLanguageLevel: LanguageLevel commentCount: number status: PostStatus - headlineImage: { __typename?: 'HeadlineImage'; id: number; smallSize: string } + headlineImage: { __typename?: 'HeadlineImage'; smallSize: string } claps: Array<{ __typename?: 'PostClap'; id: number }> author: { __typename?: 'User' @@ -2560,7 +2560,7 @@ export type ProfilePageQuery = { publishedLanguageLevel: LanguageLevel commentCount: number status: PostStatus - headlineImage: { __typename?: 'HeadlineImage'; id: number; smallSize: string } + headlineImage: { __typename?: 'HeadlineImage'; smallSize: string } claps: Array<{ __typename?: 'PostClap'; id: number }> author: { __typename?: 'User' @@ -2847,7 +2847,7 @@ export type CreatePostMutation = { publishedLanguageLevel: LanguageLevel commentCount: number status: PostStatus - headlineImage: { __typename?: 'HeadlineImage'; id: number; smallSize: string } + headlineImage: { __typename?: 'HeadlineImage'; smallSize: string } claps: Array<{ __typename?: 'PostClap'; id: number }> author: { __typename?: 'User' @@ -3429,7 +3429,7 @@ export type PostsQuery = { publishedLanguageLevel: LanguageLevel commentCount: number status: PostStatus - headlineImage: { __typename?: 'HeadlineImage'; id: number; smallSize: string } + headlineImage: { __typename?: 'HeadlineImage'; smallSize: string } claps: Array<{ __typename?: 'PostClap'; id: number }> author: { __typename?: 'User' @@ -4513,7 +4513,6 @@ export const PostCardFragmentFragmentDoc = gql` commentCount status headlineImage { - id smallSize } claps { diff --git a/packages/web/graphql/fragments.graphql b/packages/web/graphql/fragments.graphql index cf7d7213..29070241 100644 --- a/packages/web/graphql/fragments.graphql +++ b/packages/web/graphql/fragments.graphql @@ -194,7 +194,6 @@ fragment PostCardFragment on Post { commentCount status headlineImage { - id smallSize } claps { @@ -390,4 +389,4 @@ fragment NotificationFragment on InAppNotification { } } } -} \ No newline at end of file +} diff --git a/packages/web/pages/my-feed.tsx b/packages/web/pages/my-feed.tsx index 1056f7f0..e73e36cb 100644 --- a/packages/web/pages/my-feed.tsx +++ b/packages/web/pages/my-feed.tsx @@ -89,13 +89,13 @@ MyFeedPage.getInitialProps = async (ctx) => { }, }), ]) - console.log('POSTS_QUERY_2', { + console.log('POSTS_QUERY_2', apolloClient.readQuery({ query: PostsDocument, variables: constructPostQueryVars( initialSearchFilters, ctx.query.page ? Math.max(1, parseInt(ctx.query.page as string, 10)) : 1, ), - }) + })) }) console.log( From 6a81abd1973660a046b66a9a6a4732bf3530ab66 Mon Sep 17 00:00:00 2001 From: Robin MacPherson Date: Thu, 18 Jul 2024 16:28:31 +0100 Subject: [PATCH 25/34] Update translation files for simpler Profile str --- packages/web/public/static/locales/de/settings.json | 2 +- packages/web/public/static/locales/en/settings.json | 2 +- packages/web/public/static/locales/es/settings.json | 2 +- packages/web/public/static/locales/it/settings.json | 2 +- packages/web/public/static/locales/pt_BR/settings.json | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/web/public/static/locales/de/settings.json b/packages/web/public/static/locales/de/settings.json index d3de427f..dea2e19d 100644 --- a/packages/web/public/static/locales/de/settings.json +++ b/packages/web/public/static/locales/de/settings.json @@ -6,7 +6,7 @@ "subscription": "Mitgliedschaft" }, "nav": { - "profile": "Profil-Informationen", + "profile": "Profil", "account": "Benutzerkonto", "subscription": "Mitgliedschaft" }, diff --git a/packages/web/public/static/locales/en/settings.json b/packages/web/public/static/locales/en/settings.json index b20d64fd..ea3e5b47 100644 --- a/packages/web/public/static/locales/en/settings.json +++ b/packages/web/public/static/locales/en/settings.json @@ -6,7 +6,7 @@ "subscription": "Subscription" }, "nav": { - "profile": "Profile Info", + "profile": "Profile", "account": "Account", "subscription": "Subscription", "tutorials": "Tutorials" diff --git a/packages/web/public/static/locales/es/settings.json b/packages/web/public/static/locales/es/settings.json index 1fa097e3..95fc55e2 100644 --- a/packages/web/public/static/locales/es/settings.json +++ b/packages/web/public/static/locales/es/settings.json @@ -5,7 +5,7 @@ "account": "Cuenta" }, "nav": { - "profile": "Información de perfil", + "profile": "Perfil", "account": "Cuenta" }, "updateButton": "Actualizar", diff --git a/packages/web/public/static/locales/it/settings.json b/packages/web/public/static/locales/it/settings.json index e9b5ad92..9b33e186 100644 --- a/packages/web/public/static/locales/it/settings.json +++ b/packages/web/public/static/locales/it/settings.json @@ -6,7 +6,7 @@ "subscription": "Iscrizione" }, "nav": { - "profile": "Info profilo", + "profile": "Profilo", "account": "Account", "subscription": "Iscrizione" }, diff --git a/packages/web/public/static/locales/pt_BR/settings.json b/packages/web/public/static/locales/pt_BR/settings.json index 119b27a8..1e1499c3 100644 --- a/packages/web/public/static/locales/pt_BR/settings.json +++ b/packages/web/public/static/locales/pt_BR/settings.json @@ -6,7 +6,7 @@ "subscription": "Assinatura" }, "nav": { - "profile": "Informações do perfil", + "profile": "Perfil", "account": "Conta", "subscription": "Assinatura" }, From 9e1397dfd696f29d1e4727a9e9e833643f0b698c Mon Sep 17 00:00:00 2001 From: Robin MacPherson Date: Thu, 18 Jul 2024 16:29:04 +0100 Subject: [PATCH 26/34] Update all GQL query objects to have Ids --- packages/web/generated/graphql.tsx | 49 ++++++++++++++++--- packages/web/graphql/fragments.graphql | 2 + .../language/languagesFormData.graphql | 1 + .../web/graphql/user/settingsFormData.graphql | 2 + 4 files changed, 46 insertions(+), 8 deletions(-) diff --git a/packages/web/generated/graphql.tsx b/packages/web/generated/graphql.tsx index 20842cbc..023d9ca3 100644 --- a/packages/web/generated/graphql.tsx +++ b/packages/web/generated/graphql.tsx @@ -1200,7 +1200,11 @@ export type CurrentUserFragmentFragment = { }> }> savedPosts: Array<{ __typename?: 'Post'; id: number }> - membershipSubscription?: { __typename?: 'MembershipSubscription'; isActive: boolean } | null + membershipSubscription?: { + __typename?: 'MembershipSubscription' + id: number + isActive: boolean + } | null languages: Array<{ __typename?: 'LanguageRelation' id: number @@ -1616,6 +1620,7 @@ export type PostTopicFragmentFragment = { export type UserBadgeFragmentFragment = { __typename?: 'UserBadge' + id: number type: BadgeType createdAt: any } @@ -1818,6 +1823,7 @@ export type LanguagesFormDataQuery = { }> currentUser?: { __typename?: 'User' + id: number languages: Array<{ __typename?: 'LanguageRelation' id: number @@ -2174,7 +2180,11 @@ export type PostPageQuery = { }> }> savedPosts: Array<{ __typename?: 'Post'; id: number }> - membershipSubscription?: { __typename?: 'MembershipSubscription'; isActive: boolean } | null + membershipSubscription?: { + __typename?: 'MembershipSubscription' + id: number + isActive: boolean + } | null languages: Array<{ __typename?: 'LanguageRelation' id: number @@ -2458,7 +2468,11 @@ export type PrivatePostPageQuery = { }> }> savedPosts: Array<{ __typename?: 'Post'; id: number }> - membershipSubscription?: { __typename?: 'MembershipSubscription'; isActive: boolean } | null + membershipSubscription?: { + __typename?: 'MembershipSubscription' + id: number + isActive: boolean + } | null languages: Array<{ __typename?: 'LanguageRelation' id: number @@ -2519,7 +2533,7 @@ export type ProfilePageQuery = { country?: string | null emailAddressVerified: boolean }> - badges: Array<{ __typename?: 'UserBadge'; type: BadgeType; createdAt: any }> + badges: Array<{ __typename?: 'UserBadge'; id: number; type: BadgeType; createdAt: any }> userInterests: Array<{ __typename?: 'UserInterest' topic: { __typename?: 'Topic'; id: number; name?: string | null } @@ -2643,7 +2657,7 @@ export type ProfileUserFragmentFragment = { country?: string | null emailAddressVerified: boolean }> - badges: Array<{ __typename?: 'UserBadge'; type: BadgeType; createdAt: any }> + badges: Array<{ __typename?: 'UserBadge'; id: number; type: BadgeType; createdAt: any }> userInterests: Array<{ __typename?: 'UserInterest' topic: { __typename?: 'Topic'; id: number; name?: string | null } @@ -3063,7 +3077,11 @@ export type EditPostQuery = { }> }> savedPosts: Array<{ __typename?: 'Post'; id: number }> - membershipSubscription?: { __typename?: 'MembershipSubscription'; isActive: boolean } | null + membershipSubscription?: { + __typename?: 'MembershipSubscription' + id: number + isActive: boolean + } | null languages: Array<{ __typename?: 'LanguageRelation' id: number @@ -3274,7 +3292,11 @@ export type NewPostQuery = { }> }> savedPosts: Array<{ __typename?: 'Post'; id: number }> - membershipSubscription?: { __typename?: 'MembershipSubscription'; isActive: boolean } | null + membershipSubscription?: { + __typename?: 'MembershipSubscription' + id: number + isActive: boolean + } | null languages: Array<{ __typename?: 'LanguageRelation' id: number @@ -3820,7 +3842,11 @@ export type CurrentUserQuery = { }> }> savedPosts: Array<{ __typename?: 'Post'; id: number }> - membershipSubscription?: { __typename?: 'MembershipSubscription'; isActive: boolean } | null + membershipSubscription?: { + __typename?: 'MembershipSubscription' + id: number + isActive: boolean + } | null languages: Array<{ __typename?: 'LanguageRelation' id: number @@ -3940,6 +3966,7 @@ export type SettingsFormDataQuery = { topics: Array<{ __typename?: 'Topic'; id: number; name?: string | null }> currentUser?: { __typename?: 'User' + id: number bio?: string | null languages: Array<{ __typename?: 'LanguageRelation' @@ -3959,6 +3986,7 @@ export type SettingsFormDataQuery = { }> configuration?: { __typename?: 'UserConfiguration' + id: number digestEmail: DigestEmailConfiguration } | null socialMedia?: { @@ -4325,6 +4353,7 @@ export const CurrentUserFragmentFragmentDoc = gql` id } membershipSubscription { + id isActive } } @@ -4544,6 +4573,7 @@ export const TopicWithPostCountFragmentFragmentDoc = gql` ` export const UserBadgeFragmentFragmentDoc = gql` fragment UserBadgeFragment on UserBadge { + id type createdAt } @@ -5185,6 +5215,7 @@ export const LanguagesFormDataDocument = gql` ...LanguageFragment } currentUser { + id languages { id level @@ -7258,6 +7289,7 @@ export const SettingsFormDataDocument = gql` ...TopicFragment } currentUser { + id bio languages { id @@ -7271,6 +7303,7 @@ export const SettingsFormDataDocument = gql` } ...SocialMediaFragment configuration { + id digestEmail } } diff --git a/packages/web/graphql/fragments.graphql b/packages/web/graphql/fragments.graphql index 29070241..4e6b228b 100644 --- a/packages/web/graphql/fragments.graphql +++ b/packages/web/graphql/fragments.graphql @@ -37,6 +37,7 @@ fragment CurrentUserFragment on User { id } membershipSubscription { + id isActive } } @@ -236,6 +237,7 @@ fragment PostTopicFragment on PostTopic { } fragment UserBadgeFragment on UserBadge { + id type createdAt } diff --git a/packages/web/graphql/language/languagesFormData.graphql b/packages/web/graphql/language/languagesFormData.graphql index 7bec6c88..acbad3b9 100644 --- a/packages/web/graphql/language/languagesFormData.graphql +++ b/packages/web/graphql/language/languagesFormData.graphql @@ -3,6 +3,7 @@ query languagesFormData { ...LanguageFragment } currentUser { + id languages { id level diff --git a/packages/web/graphql/user/settingsFormData.graphql b/packages/web/graphql/user/settingsFormData.graphql index f6663a5c..d8e94f89 100644 --- a/packages/web/graphql/user/settingsFormData.graphql +++ b/packages/web/graphql/user/settingsFormData.graphql @@ -6,6 +6,7 @@ query settingsFormData($uiLanguage: UILanguage!) { ...TopicFragment } currentUser { + id bio languages { id @@ -19,6 +20,7 @@ query settingsFormData($uiLanguage: UILanguage!) { } ...SocialMediaFragment configuration { + id digestEmail } } From bcd8505de15ca91df4a28bed9a5fb29ad4723588 Mon Sep 17 00:00:00 2001 From: Robin MacPherson Date: Thu, 18 Jul 2024 16:33:24 +0100 Subject: [PATCH 27/34] A bunch of cleanup --- .../web/components/Dashboard/MyFeed/MyFeed.tsx | 3 --- .../components/Dashboard/MyPosts/MyPosts.tsx | 1 - packages/web/components/Dashboard/Post/Post.tsx | 2 -- packages/web/pages/api/graphql.ts | 2 -- packages/web/pages/my-feed.tsx | 17 ----------------- packages/web/pages/settings/account.tsx | 2 +- packages/web/resolvers/post.ts | 2 -- 7 files changed, 1 insertion(+), 28 deletions(-) diff --git a/packages/web/components/Dashboard/MyFeed/MyFeed.tsx b/packages/web/components/Dashboard/MyFeed/MyFeed.tsx index dc8a5444..fa1f64dc 100644 --- a/packages/web/components/Dashboard/MyFeed/MyFeed.tsx +++ b/packages/web/components/Dashboard/MyFeed/MyFeed.tsx @@ -72,8 +72,6 @@ const MyFeed: React.FC = ({ currentUser, initialSearchFilters }) => { const { t } = useTranslation('my-feed') const client = useApolloClient() - console.log('ROOT', client.cache.data.data.ROOT_QUERY) - /** * Pagination handling */ @@ -110,7 +108,6 @@ const MyFeed: React.FC = ({ currentUser, initialSearchFilters }) => { gtag('event', 'myFeedFilterSet', { filters: postQueryVars }) }, [postQueryVars]) - console.log('vars1', constructPostQueryVars(postQueryVars, currentPage)) // fetch posts for the feed! const { loading, error, data } = usePostsQuery({ variables: constructPostQueryVars(postQueryVars, currentPage), diff --git a/packages/web/components/Dashboard/MyPosts/MyPosts.tsx b/packages/web/components/Dashboard/MyPosts/MyPosts.tsx index 75ea85dd..7a2067c6 100644 --- a/packages/web/components/Dashboard/MyPosts/MyPosts.tsx +++ b/packages/web/components/Dashboard/MyPosts/MyPosts.tsx @@ -46,7 +46,6 @@ const MyPosts: React.FC = ({ currentUser, status }) => { ...postQueryVars, }, }) - console.log('componentCurrentUserId', currentUser.id) const posts = (data?.posts?.posts as PostType[]) || [] const count = data?.posts?.count || 0 diff --git a/packages/web/components/Dashboard/Post/Post.tsx b/packages/web/components/Dashboard/Post/Post.tsx index 2e2dd4d7..4cf1234b 100644 --- a/packages/web/components/Dashboard/Post/Post.tsx +++ b/packages/web/components/Dashboard/Post/Post.tsx @@ -543,9 +543,7 @@ const Post = ({ post, currentUser, refetch }: PostProps) => { }, }, update(cache, { data }) { - console.log('before') if (data?.updatePost) { - console.log('after') cache.modify({ id: cache.identify(makeReference('ROOT_QUERY')), fields: { diff --git a/packages/web/pages/api/graphql.ts b/packages/web/pages/api/graphql.ts index 448edb99..efd3e649 100644 --- a/packages/web/pages/api/graphql.ts +++ b/packages/web/pages/api/graphql.ts @@ -32,7 +32,6 @@ export const config = { }; const handler = async (req: any, res: any) => { - console.log('start', req.cookies) const bodyPromise = readBody(req) const { token } = req.cookies req.response = res @@ -52,7 +51,6 @@ const handler = async (req: any, res: any) => { await bodyPromise, ) } - console.log('END', await bodyPromise) return response } diff --git a/packages/web/pages/my-feed.tsx b/packages/web/pages/my-feed.tsx index e73e36cb..193a06e6 100644 --- a/packages/web/pages/my-feed.tsx +++ b/packages/web/pages/my-feed.tsx @@ -58,8 +58,6 @@ MyFeedPage.getInitialProps = async (ctx) => { } } - console.log({ initialSearchFilters }) - const props = await journalyMiddleware(ctx, async (apolloClient) => { await Promise.all([ apolloClient.query({ @@ -89,23 +87,8 @@ MyFeedPage.getInitialProps = async (ctx) => { }, }), ]) - console.log('POSTS_QUERY_2', apolloClient.readQuery({ - query: PostsDocument, - variables: constructPostQueryVars( - initialSearchFilters, - ctx.query.page ? Math.max(1, parseInt(ctx.query.page as string, 10)) : 1, - ), - })) }) - console.log( - 'vars2', - constructPostQueryVars( - initialSearchFilters, - ctx.query.page ? Math.max(1, parseInt(ctx.query.page as string, 10)) : 1, - ), - ) - return { ...props, initialSearchFilters, diff --git a/packages/web/pages/settings/account.tsx b/packages/web/pages/settings/account.tsx index 20e0fc4e..ab6f79db 100644 --- a/packages/web/pages/settings/account.tsx +++ b/packages/web/pages/settings/account.tsx @@ -74,4 +74,4 @@ Account.getInitialProps = async (ctx) => { } } -export default withApollo(Account) +export default Account diff --git a/packages/web/resolvers/post.ts b/packages/web/resolvers/post.ts index e4b3d5ae..8cee8f29 100644 --- a/packages/web/resolvers/post.ts +++ b/packages/web/resolvers/post.ts @@ -294,7 +294,6 @@ const PostQueries = extendType({ }), }, resolve: async (_parent, args, ctx) => { - console.log('start', args) const { userId } = ctx.request const currentUser = userId @@ -420,7 +419,6 @@ const PostQueries = extendType({ `, ctx.db.$queryRaw<{ count: number }[]>`SELECT COUNT(*) ${queryPred};`, ]) - console.log('THE END') return { posts, count } }, }) From fbcc66650f2cfcef4a7ff047eba784586473e53d Mon Sep 17 00:00:00 2001 From: Robin MacPherson Date: Thu, 18 Jul 2024 16:33:40 +0100 Subject: [PATCH 28/34] Make the account settings page work! --- packages/web/pages/settings/account.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/web/pages/settings/account.tsx b/packages/web/pages/settings/account.tsx index ab6f79db..e79fd412 100644 --- a/packages/web/pages/settings/account.tsx +++ b/packages/web/pages/settings/account.tsx @@ -1,6 +1,5 @@ import React from 'react' import { NextPage } from 'next' -import { withApollo } from '@/lib/apollo' import useUILanguage from '@/hooks/useUILanguage' import SettingsPageLayout from '@/components/Layouts/SettingsPageLayout' import AuthGate from '@/components/AuthGate' @@ -8,7 +7,11 @@ import LoadingSpinner from '@/components/Icons/LoadingSpinner' import UpdatePasswordForm from '@/components/Dashboard/Settings/UpdatePasswordForm' import NotificationSettingsForm from '@/components/Dashboard/Settings/NotificationSettingsForm' import UILanguageForm from '@/components/Dashboard/Settings/UILanguageForm' -import { SettingsFormDataDocument, useSettingsFormDataQuery } from '@/generated/graphql' +import { + CurrentUserDocument, + SettingsFormDataDocument, + useSettingsFormDataQuery, +} from '@/generated/graphql' import { journalyMiddleware } from '@/lib/journalyMiddleware' import { getUiLanguage } from '@/utils/getUiLanguage' @@ -66,6 +69,10 @@ Account.getInitialProps = async (ctx) => { uiLanguage: getUiLanguage(ctx), }, }) + + await apolloClient.query({ + query: CurrentUserDocument, + }) }) return { From 3d39b23ceffdde6b7b7dbbaefc3640eb351a0de5 Mon Sep 17 00:00:00 2001 From: Robin MacPherson Date: Thu, 18 Jul 2024 16:33:58 +0100 Subject: [PATCH 29/34] Some last fixes and cleanup --- .../components/Dashboard/Filters/Filters.tsx | 21 +++++++++++-------- .../components/Dashboard/MyFeed/MyFeed.tsx | 14 +------------ .../Dashboard/Settings/SettingsNav.tsx | 4 +--- packages/web/pages/my-feed.tsx | 4 ++-- 4 files changed, 16 insertions(+), 27 deletions(-) diff --git a/packages/web/components/Dashboard/Filters/Filters.tsx b/packages/web/components/Dashboard/Filters/Filters.tsx index fb18fd7e..39a5e1e5 100644 --- a/packages/web/components/Dashboard/Filters/Filters.tsx +++ b/packages/web/components/Dashboard/Filters/Filters.tsx @@ -1,13 +1,7 @@ import React, { useState, useCallback } from 'react' import isEqual from 'lodash/isEqual' import Button, { ButtonVariant } from '@/components/Button' -import { - User as UserType, - useTopicsQuery, - useLanguagesQuery, - UserRole, - LanguagesDocument, -} from '@/generated/graphql' +import { User as UserType, useTopicsQuery, useLanguagesQuery, UserRole } from '@/generated/graphql' import SearchInput from './SearchInput' import LanguageSelect from './LanguageSelect' import TopicSelect from './TopicSelect' @@ -15,8 +9,17 @@ import useToggle from '@/hooks/useToggle' import useUILanguage from '@/hooks/useUILanguage' import { Router, useTranslation } from '@/config/i18n' import PremiumFeatureModal from '@/components/Modals/PremiumFeatureModal' -import { PostQueryVarsType } from '../MyFeed/MyFeed' -import { useApolloClient } from '@apollo/client' + +// TODO: Revisit this, move back, +export type PostQueryVarsType = { + languages: number[] + topics: number[] + followedAuthors: boolean + search: string + needsFeedback: boolean + hasInteracted: boolean + savedPosts: boolean +} type Props = { currentUser: UserType diff --git a/packages/web/components/Dashboard/MyFeed/MyFeed.tsx b/packages/web/components/Dashboard/MyFeed/MyFeed.tsx index fa1f64dc..f69f58e2 100644 --- a/packages/web/components/Dashboard/MyFeed/MyFeed.tsx +++ b/packages/web/components/Dashboard/MyFeed/MyFeed.tsx @@ -13,13 +13,11 @@ import { usePostsQuery, PostCardFragmentFragment, PostStatus, - PostsDocument, } from '@/generated/graphql' import PostCard from '../PostCard' import FeedHeader from './FeedHeader' -import Filters from '../Filters' -import { PostQueryVarsType } from '../Filters' +import Filters, { PostQueryVarsType } from '@/components/Dashboard/Filters' import { makeReference, useApolloClient } from '@apollo/client' const NUM_POSTS_PER_PAGE = 9 @@ -39,16 +37,6 @@ export type InitialSearchFilters = { search: string } -export type PostQueryVarsType = { - languages: number[] - topics: number[] - followedAuthors: boolean - search: string - needsFeedback: boolean - hasInteracted: boolean - savedPosts: boolean -} - export const constructPostQueryVars = ( postQueryVars: PostQueryVarsType | null, currentPage: number, diff --git a/packages/web/components/Dashboard/Settings/SettingsNav.tsx b/packages/web/components/Dashboard/Settings/SettingsNav.tsx index 41efcfb2..4a698a7f 100644 --- a/packages/web/components/Dashboard/Settings/SettingsNav.tsx +++ b/packages/web/components/Dashboard/Settings/SettingsNav.tsx @@ -18,9 +18,7 @@ const SettingsNav: React.FC = () => { {Object.entries(links).map(([page, navText]) => { return ( -
  • - {navText} -
  • +
  • {navText}
  • ) })} diff --git a/packages/web/pages/my-feed.tsx b/packages/web/pages/my-feed.tsx index 193a06e6..33721057 100644 --- a/packages/web/pages/my-feed.tsx +++ b/packages/web/pages/my-feed.tsx @@ -36,7 +36,7 @@ const MyFeedPage: NextPage = ({ initialSearchFilters }) => { } MyFeedPage.getInitialProps = async (ctx) => { - let initialSearchFilters = null + let initialSearchFilters: InitialSearchFilters | null = null if (typeof window !== 'undefined') { try { const defaultSearchFilters = cookie.parse(document.cookie).default_search_filters @@ -92,7 +92,7 @@ MyFeedPage.getInitialProps = async (ctx) => { return { ...props, initialSearchFilters, - namespacesRequired: ['common', 'settings', 'my-feed'], + namespacesRequired: ['common', 'settings', 'my-feed', 'post'], } } From 1bb4bfc5b3db1c131ccbb4ccda9913195874f217 Mon Sep 17 00:00:00 2001 From: Robin MacPherson Date: Tue, 23 Jul 2024 17:23:00 +0100 Subject: [PATCH 30/34] Fix all the type issues! --- .../web/components/Dashboard/Filters/Filters.tsx | 1 - packages/web/components/Dashboard/MyFeed/MyFeed.tsx | 12 +----------- packages/web/components/Dashboard/MyFeed/index.ts | 1 - packages/web/pages/my-feed.tsx | 10 +++++----- packages/web/types/next.d.ts | 8 ++++++++ packages/web/utils/getUiLanguage.ts | 2 +- 6 files changed, 15 insertions(+), 19 deletions(-) diff --git a/packages/web/components/Dashboard/Filters/Filters.tsx b/packages/web/components/Dashboard/Filters/Filters.tsx index 39a5e1e5..3b3003e7 100644 --- a/packages/web/components/Dashboard/Filters/Filters.tsx +++ b/packages/web/components/Dashboard/Filters/Filters.tsx @@ -10,7 +10,6 @@ import useUILanguage from '@/hooks/useUILanguage' import { Router, useTranslation } from '@/config/i18n' import PremiumFeatureModal from '@/components/Modals/PremiumFeatureModal' -// TODO: Revisit this, move back, export type PostQueryVarsType = { languages: number[] topics: number[] diff --git a/packages/web/components/Dashboard/MyFeed/MyFeed.tsx b/packages/web/components/Dashboard/MyFeed/MyFeed.tsx index f69f58e2..2bfabaf9 100644 --- a/packages/web/components/Dashboard/MyFeed/MyFeed.tsx +++ b/packages/web/components/Dashboard/MyFeed/MyFeed.tsx @@ -24,17 +24,7 @@ const NUM_POSTS_PER_PAGE = 9 type Props = { currentUser: UserType - initialSearchFilters: InitialSearchFilters | null -} - -// TODO: let's consider adding `followedAuthor` here -export type InitialSearchFilters = { - languages: number[] - topics: number[] - needsFeedback: boolean - hasInteracted: boolean - savedPosts: boolean - search: string + initialSearchFilters: PostQueryVarsType | null } export const constructPostQueryVars = ( diff --git a/packages/web/components/Dashboard/MyFeed/index.ts b/packages/web/components/Dashboard/MyFeed/index.ts index f0063b59..01478ad4 100644 --- a/packages/web/components/Dashboard/MyFeed/index.ts +++ b/packages/web/components/Dashboard/MyFeed/index.ts @@ -1,2 +1 @@ export { default } from './MyFeed' -export type { InitialSearchFilters } from './MyFeed' \ No newline at end of file diff --git a/packages/web/pages/my-feed.tsx b/packages/web/pages/my-feed.tsx index 33721057..2ee33a75 100644 --- a/packages/web/pages/my-feed.tsx +++ b/packages/web/pages/my-feed.tsx @@ -6,7 +6,7 @@ import DashboardLayout from '@/components/Layouts/DashboardLayout' import MyFeed from '@/components/Dashboard/MyFeed' import AuthGate from '@/components/AuthGate' import WelcomeModal from '@/components/Modals/WelcomeModal' -import { InitialSearchFilters } from '@/components/Dashboard/MyFeed' +import { PostQueryVarsType } from '@/components/Dashboard/Filters' import { journalyMiddleware } from '@/lib/journalyMiddleware' import { CurrentUserDocument, @@ -19,7 +19,7 @@ import { getUiLanguage } from '@/utils/getUiLanguage' interface InitialProps { namespacesRequired: string[] - initialSearchFilters: InitialSearchFilters | null + initialSearchFilters: PostQueryVarsType | null } const MyFeedPage: NextPage = ({ initialSearchFilters }) => { @@ -36,12 +36,12 @@ const MyFeedPage: NextPage = ({ initialSearchFilters }) => { } MyFeedPage.getInitialProps = async (ctx) => { - let initialSearchFilters: InitialSearchFilters | null = null + let initialSearchFilters: PostQueryVarsType | null = null if (typeof window !== 'undefined') { try { const defaultSearchFilters = cookie.parse(document.cookie).default_search_filters initialSearchFilters = defaultSearchFilters - ? (JSON.parse(defaultSearchFilters) as InitialSearchFilters) + ? (JSON.parse(defaultSearchFilters) as PostQueryVarsType) : null } catch (e) { console.log('Error parsing default_search_filters cookie', e) @@ -51,7 +51,7 @@ MyFeedPage.getInitialProps = async (ctx) => { const request = ctx.req as Request const defaultSearchFilters = request.cookies.default_search_filters initialSearchFilters = defaultSearchFilters - ? (JSON.parse(defaultSearchFilters) as InitialSearchFilters) + ? (JSON.parse(defaultSearchFilters) as PostQueryVarsType) : null } catch (e) { console.log('Error parsing default_search_filters cookie', e) diff --git a/packages/web/types/next.d.ts b/packages/web/types/next.d.ts index 46c16849..fcbb0df8 100644 --- a/packages/web/types/next.d.ts +++ b/packages/web/types/next.d.ts @@ -1,8 +1,16 @@ import { ApolloClient } from '@apollo/client' import { ApolloClientCache } from './lib/apollo' +import { IncomingMessage } from 'http' +import { NextI18NextRequest } from 'next-i18next' declare module 'next' { export interface NextPageContext { apolloClient?: ApolloClient } } + +declare module 'http' { + export interface IncomingMessage { + i18n: NextI18NextRequest['i18n'] + } +} diff --git a/packages/web/utils/getUiLanguage.ts b/packages/web/utils/getUiLanguage.ts index ecc9b9e5..e069f3d7 100644 --- a/packages/web/utils/getUiLanguage.ts +++ b/packages/web/utils/getUiLanguage.ts @@ -6,7 +6,7 @@ import i18nConfig from '@/config/i18n' export const getUiLanguage = (ctx: NextPageContext): UiLanguage => { let langCode if (ctx.req) { - const i18n = ctx.req.i18n as any + const i18n = ctx.req.i18n if (!i18n) { langCode = 'en' } else { From 11ce6f1c6527514d81d81c7e097154017da65669 Mon Sep 17 00:00:00 2001 From: Robin MacPherson Date: Tue, 23 Jul 2024 17:23:30 +0100 Subject: [PATCH 31/34] Upgrade Next from 13.3.4 to 14.2.5 --- packages/web/package-lock.json | 369 ++++++++++++++++----------------- packages/web/package.json | 10 +- 2 files changed, 185 insertions(+), 194 deletions(-) diff --git a/packages/web/package-lock.json b/packages/web/package-lock.json index 03e8980c..823d337f 100644 --- a/packages/web/package-lock.json +++ b/packages/web/package-lock.json @@ -41,15 +41,15 @@ "jsonwebtoken": "^8.5.1", "jwt-decode": "^4.0.0", "lodash": "^4.17.20", - "next": "^13.3.4", + "next": "^14.2.5", "next-i18next": "^7.0.1", "nexus": "^1.0.0", "nexus-plugin-prisma": "^0.35.0", "node-fetch": "^2.6.7", "nprogress": "^0.2.0", "query-string": "^7.0.1", - "react": "^18.2.0", - "react-dom": "^18.2.0", + "react": "^18.3.1", + "react-dom": "^18.3.1", "react-hook-form": "^5.7.2", "react-markdown": "^7.0.0", "react-toastify": "^6.0.8", @@ -86,8 +86,8 @@ "@types/jest": "^29.5.8", "@types/node": "^14.14.31", "@types/nprogress": "^0.2.0", - "@types/react": "^18.2.1", - "@types/react-dom": "^18.2.2", + "@types/react": "^18.3.3", + "@types/react-dom": "^18.3.0", "@types/uuid": "^8.3.0", "cli-progress": "^3.9.0", "copy-webpack-plugin": "^9.0.1", @@ -2826,9 +2826,9 @@ } }, "node_modules/@next/env": { - "version": "13.4.4", - "resolved": "https://registry.npmjs.org/@next/env/-/env-13.4.4.tgz", - "integrity": "sha512-q/y7VZj/9YpgzDe64Zi6rY1xPizx80JjlU2BTevlajtaE3w1LqweH1gGgxou2N7hdFosXHjGrI4OUvtFXXhGLg==" + "version": "14.2.5", + "resolved": "https://registry.npmjs.org/@next/env/-/env-14.2.5.tgz", + "integrity": "sha512-/zZGkrTOsraVfYjGP8uM0p6r0BDT6xWpkjdVbcz66PJVSpwXX3yNiRycxAuDfBKGWBrZBXRuK/YVlkNgxHGwmA==" }, "node_modules/@next/eslint-plugin-next": { "version": "13.4.4", @@ -2858,9 +2858,9 @@ } }, "node_modules/@next/swc-darwin-arm64": { - "version": "13.4.4", - "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.4.4.tgz", - "integrity": "sha512-xfjgXvp4KalNUKZMHmsFxr1Ug+aGmmO6NWP0uoh4G3WFqP/mJ1xxfww0gMOeMeSq/Jyr5k7DvoZ2Pv+XOITTtw==", + "version": "14.2.5", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-14.2.5.tgz", + "integrity": "sha512-/9zVxJ+K9lrzSGli1///ujyRfon/ZneeZ+v4ptpiPoOU+GKZnm8Wj8ELWU1Pm7GHltYRBklmXMTUqM/DqQ99FQ==", "cpu": [ "arm64" ], @@ -2873,9 +2873,9 @@ } }, "node_modules/@next/swc-darwin-x64": { - "version": "13.4.4", - "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-13.4.4.tgz", - "integrity": "sha512-ZY9Ti1hkIwJsxGus3nlubIkvYyB0gNOYxKrfsOrLEqD0I2iCX8D7w8v6QQZ2H+dDl6UT29oeEUdDUNGk4UEpfg==", + "version": "14.2.5", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-14.2.5.tgz", + "integrity": "sha512-vXHOPCwfDe9qLDuq7U1OYM2wUY+KQ4Ex6ozwsKxp26BlJ6XXbHleOUldenM67JRyBfVjv371oneEvYd3H2gNSA==", "cpu": [ "x64" ], @@ -2888,9 +2888,9 @@ } }, "node_modules/@next/swc-linux-arm64-gnu": { - "version": "13.4.4", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.4.4.tgz", - "integrity": "sha512-+KZnDeMShYkpkqAvGCEDeqYTRADJXc6SY1jWXz+Uo6qWQO/Jd9CoyhTJwRSxvQA16MoYzvILkGaDqirkRNctyA==", + "version": "14.2.5", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-14.2.5.tgz", + "integrity": "sha512-vlhB8wI+lj8q1ExFW8lbWutA4M2ZazQNvMWuEDqZcuJJc78iUnLdPPunBPX8rC4IgT6lIx/adB+Cwrl99MzNaA==", "cpu": [ "arm64" ], @@ -2903,9 +2903,9 @@ } }, "node_modules/@next/swc-linux-arm64-musl": { - "version": "13.4.4", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.4.4.tgz", - "integrity": "sha512-evC1twrny2XDT4uOftoubZvW3EG0zs0ZxMwEtu/dDGVRO5n5pT48S8qqEIBGBUZYu/Xx4zzpOkIxx1vpWdE+9A==", + "version": "14.2.5", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-14.2.5.tgz", + "integrity": "sha512-NpDB9NUR2t0hXzJJwQSGu1IAOYybsfeB+LxpGsXrRIb7QOrYmidJz3shzY8cM6+rO4Aojuef0N/PEaX18pi9OA==", "cpu": [ "arm64" ], @@ -2918,9 +2918,9 @@ } }, "node_modules/@next/swc-linux-x64-gnu": { - "version": "13.4.4", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.4.4.tgz", - "integrity": "sha512-PX706XcCHr2FfkyhP2lpf+pX/tUvq6/ke7JYnnr0ykNdEMo+sb7cC/o91gnURh4sPYSiZJhsF2gbIqg9rciOHQ==", + "version": "14.2.5", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-14.2.5.tgz", + "integrity": "sha512-8XFikMSxWleYNryWIjiCX+gU201YS+erTUidKdyOVYi5qUQo/gRxv/3N1oZFCgqpesN6FPeqGM72Zve+nReVXQ==", "cpu": [ "x64" ], @@ -2933,9 +2933,9 @@ } }, "node_modules/@next/swc-linux-x64-musl": { - "version": "13.4.4", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.4.4.tgz", - "integrity": "sha512-TKUUx3Ftd95JlHV6XagEnqpT204Y+IsEa3awaYIjayn0MOGjgKZMZibqarK3B1FsMSPaieJf2FEAcu9z0yT5aA==", + "version": "14.2.5", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-14.2.5.tgz", + "integrity": "sha512-6QLwi7RaYiQDcRDSU/os40r5o06b5ue7Jsk5JgdRBGGp8l37RZEh9JsLSM8QF0YDsgcosSeHjglgqi25+m04IQ==", "cpu": [ "x64" ], @@ -2948,9 +2948,9 @@ } }, "node_modules/@next/swc-win32-arm64-msvc": { - "version": "13.4.4", - "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.4.4.tgz", - "integrity": "sha512-FP8AadgSq4+HPtim7WBkCMGbhr5vh9FePXiWx9+YOdjwdQocwoCK5ZVC3OW8oh3TWth6iJ0AXJ/yQ1q1cwSZ3A==", + "version": "14.2.5", + "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-14.2.5.tgz", + "integrity": "sha512-1GpG2VhbspO+aYoMOQPQiqc/tG3LzmsdBH0LhnDS3JrtDx2QmzXe0B6mSZZiN3Bq7IOMXxv1nlsjzoS1+9mzZw==", "cpu": [ "arm64" ], @@ -2963,9 +2963,9 @@ } }, "node_modules/@next/swc-win32-ia32-msvc": { - "version": "13.4.4", - "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.4.4.tgz", - "integrity": "sha512-3WekVmtuA2MCdcAOrgrI+PuFiFURtSyyrN1I3UPtS0ckR2HtLqyqmS334Eulf15g1/bdwMteePdK363X/Y9JMg==", + "version": "14.2.5", + "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-14.2.5.tgz", + "integrity": "sha512-Igh9ZlxwvCDsu6438FXlQTHlRno4gFpJzqPjSIBZooD22tKeI4fE/YMRoHVJHmrQ2P5YL1DoZ0qaOKkbeFWeMg==", "cpu": [ "ia32" ], @@ -2978,9 +2978,9 @@ } }, "node_modules/@next/swc-win32-x64-msvc": { - "version": "13.4.4", - "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.4.4.tgz", - "integrity": "sha512-AHRITu/CrlQ+qzoqQtEMfaTu7GHaQ6bziQln/pVWpOYC1wU+Mq6VQQFlsDtMCnDztPZtppAXdvvbNS7pcfRzlw==", + "version": "14.2.5", + "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-14.2.5.tgz", + "integrity": "sha512-tEQ7oinq1/CjSG9uSTerca3v4AZ+dFa+4Yu6ihaG8Ud8ddqLQgFGcnwYls13H5X5CPDPZJdYxyeMui6muOLd4g==", "cpu": [ "x64" ], @@ -4030,11 +4030,17 @@ "url": "https://github.com/sponsors/gregberge" } }, + "node_modules/@swc/counter": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@swc/counter/-/counter-0.1.3.tgz", + "integrity": "sha512-e2BR4lsJkkRlKZ/qCHPw9ZaSxc0MVUd7gtbtaB7aMvHeJVYe8sOB8DBZkP2DtISHGSku9sCK6T6cnY0CtXrOCQ==" + }, "node_modules/@swc/helpers": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.1.tgz", - "integrity": "sha512-sJ902EfIzn1Fa+qYmjdQqh8tPsoxyBz+8yBKC2HKUxyezKJFwPGOn7pv4WY6QuQW//ySQi5lJjA/ZT9sNWWNTg==", + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.5.tgz", + "integrity": "sha512-KGYxvIOXcceOAbEk4bi/dVLEK9z8sZ0uBB3Il5b1rhfClSpcX0yfRO0KmTkqR2cnQDymwLB+25ZyMzICg/cm/A==", "dependencies": { + "@swc/counter": "^0.1.3", "tslib": "^2.4.0" } }, @@ -4458,29 +4464,23 @@ "integrity": "sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==" }, "node_modules/@types/react": { - "version": "18.2.7", - "resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.7.tgz", - "integrity": "sha512-ojrXpSH2XFCmHm7Jy3q44nXDyN54+EYKP2lBhJ2bqfyPj6cIUW/FZW/Csdia34NQgq7KYcAlHi5184m4X88+yw==", + "version": "18.3.3", + "resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.3.tgz", + "integrity": "sha512-hti/R0pS0q1/xx+TsI73XIqk26eBsISZ2R0wUijXIngRK9R/e7Xw/cXVxQK7R5JjW+SV4zGcn5hXjudkN/pLIw==", "dependencies": { "@types/prop-types": "*", - "@types/scheduler": "*", "csstype": "^3.0.2" } }, "node_modules/@types/react-dom": { - "version": "18.2.4", - "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.2.4.tgz", - "integrity": "sha512-G2mHoTMTL4yoydITgOGwWdWMVd8sNgyEP85xVmMKAPUBwQWm9wBPQUmvbeF4V3WBY1P7mmL4BkjQ0SqUpf1snw==", + "version": "18.3.0", + "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.3.0.tgz", + "integrity": "sha512-EhwApuTmMBmXuFOikhQLIBUn6uFg81SwLMOAUgodJF14SOBOCMdU04gDoYi0WOJJHD144TL32z4yDqCW3dnkQg==", "devOptional": true, "dependencies": { "@types/react": "*" } }, - "node_modules/@types/scheduler": { - "version": "0.16.3", - "resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.3.tgz", - "integrity": "sha512-5cJ8CB4yAx7BH1oMvdU0Jh9lrEXyPkar6F9G/ERswkCuvP4KQZfZkSjcMbAICCpQTN4OuZn8tz0HiKv9TGZgrQ==" - }, "node_modules/@types/send": { "version": "0.17.1", "resolved": "https://registry.npmjs.org/@types/send/-/send-0.17.1.tgz", @@ -7361,9 +7361,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001489", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001489.tgz", - "integrity": "sha512-x1mgZEXK8jHIfAxm+xgdpHpk50IN3z3q3zP261/WS+uvePxW8izXuCu6AHz0lkuYTlATDehiZ/tNyYBdSQsOUQ==", + "version": "1.0.30001643", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001643.tgz", + "integrity": "sha512-ERgWGNleEilSrHM6iUz/zJNSQTP8Mr21wDWpdgvRwcTXGAq6jMtOUPP4dqFPTdKqZ2wKTdtB+uucZ3MRpAUSmg==", "funding": [ { "type": "opencollective", @@ -13732,38 +13732,38 @@ "peer": true }, "node_modules/next": { - "version": "13.4.4", - "resolved": "https://registry.npmjs.org/next/-/next-13.4.4.tgz", - "integrity": "sha512-C5S0ysM0Ily9McL4Jb48nOQHT1BukOWI59uC3X/xCMlYIh9rJZCv7nzG92J6e1cOBqQbKovlpgvHWFmz4eKKEA==", + "version": "14.2.5", + "resolved": "https://registry.npmjs.org/next/-/next-14.2.5.tgz", + "integrity": "sha512-0f8aRfBVL+mpzfBjYfQuLWh2WyAwtJXCRfkPF4UJ5qd2YwrHczsrSzXU4tRMV0OAxR8ZJZWPFn6uhSC56UTsLA==", "dependencies": { - "@next/env": "13.4.4", - "@swc/helpers": "0.5.1", + "@next/env": "14.2.5", + "@swc/helpers": "0.5.5", "busboy": "1.6.0", - "caniuse-lite": "^1.0.30001406", - "postcss": "8.4.14", - "styled-jsx": "5.1.1", - "zod": "3.21.4" + "caniuse-lite": "^1.0.30001579", + "graceful-fs": "^4.2.11", + "postcss": "8.4.31", + "styled-jsx": "5.1.1" }, "bin": { "next": "dist/bin/next" }, "engines": { - "node": ">=16.8.0" + "node": ">=18.17.0" }, "optionalDependencies": { - "@next/swc-darwin-arm64": "13.4.4", - "@next/swc-darwin-x64": "13.4.4", - "@next/swc-linux-arm64-gnu": "13.4.4", - "@next/swc-linux-arm64-musl": "13.4.4", - "@next/swc-linux-x64-gnu": "13.4.4", - "@next/swc-linux-x64-musl": "13.4.4", - "@next/swc-win32-arm64-msvc": "13.4.4", - "@next/swc-win32-ia32-msvc": "13.4.4", - "@next/swc-win32-x64-msvc": "13.4.4" + "@next/swc-darwin-arm64": "14.2.5", + "@next/swc-darwin-x64": "14.2.5", + "@next/swc-linux-arm64-gnu": "14.2.5", + "@next/swc-linux-arm64-musl": "14.2.5", + "@next/swc-linux-x64-gnu": "14.2.5", + "@next/swc-linux-x64-musl": "14.2.5", + "@next/swc-win32-arm64-msvc": "14.2.5", + "@next/swc-win32-ia32-msvc": "14.2.5", + "@next/swc-win32-x64-msvc": "14.2.5" }, "peerDependencies": { "@opentelemetry/api": "^1.1.0", - "fibers": ">= 3.1.0", + "@playwright/test": "^1.41.2", "react": "^18.2.0", "react-dom": "^18.2.0", "sass": "^1.3.0" @@ -13772,7 +13772,7 @@ "@opentelemetry/api": { "optional": true }, - "fibers": { + "@playwright/test": { "optional": true }, "sass": { @@ -14634,9 +14634,9 @@ } }, "node_modules/postcss": { - "version": "8.4.14", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.14.tgz", - "integrity": "sha512-E398TUmfAYFPBSdzgeieK2Y1+1cpdxJx8yXbK/m57nRhKSmk1GB2tO4lbLBtlkfPQTDKfe4Xqv1ASWPpayPEig==", + "version": "8.4.31", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.31.tgz", + "integrity": "sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==", "funding": [ { "type": "opencollective", @@ -14645,10 +14645,14 @@ { "type": "tidelift", "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" } ], "dependencies": { - "nanoid": "^3.3.4", + "nanoid": "^3.3.6", "picocolors": "^1.0.0", "source-map-js": "^1.0.2" }, @@ -14959,9 +14963,9 @@ } }, "node_modules/react": { - "version": "18.2.0", - "resolved": "https://registry.npmjs.org/react/-/react-18.2.0.tgz", - "integrity": "sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==", + "version": "18.3.1", + "resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz", + "integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==", "dependencies": { "loose-envify": "^1.1.0" }, @@ -15009,15 +15013,15 @@ } }, "node_modules/react-dom": { - "version": "18.2.0", - "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.2.0.tgz", - "integrity": "sha512-6IMTriUmvsjHUjNtEDudZfuDQUoWXVxKHhlEGSk81n4YFS+r/Kl99wXiwlVXtPBtJenozv2P+hxDsw9eA7Xo6g==", + "version": "18.3.1", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.3.1.tgz", + "integrity": "sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==", "dependencies": { "loose-envify": "^1.1.0", - "scheduler": "^0.23.0" + "scheduler": "^0.23.2" }, "peerDependencies": { - "react": "^18.2.0" + "react": "^18.3.1" } }, "node_modules/react-hook-form": { @@ -16075,9 +16079,9 @@ "integrity": "sha512-8I2a3LovHTOpm7NV5yOyO8IHqgVsfK4+UuySrXU8YXkSRX7k6hCV9b3HrkKCr3nMpgj+0bmocaJJWpvp1oc7ZA==" }, "node_modules/scheduler": { - "version": "0.23.0", - "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.0.tgz", - "integrity": "sha512-CtuThmgHNg7zIZWAXi3AsyIzA3n4xx7aNyjwC2VJldO2LMVDhFK+63xGqq6CsJH4rTAt6/M+N4GhZiDYPx9eUw==", + "version": "0.23.2", + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.2.tgz", + "integrity": "sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ==", "dependencies": { "loose-envify": "^1.1.0" } @@ -16443,9 +16447,9 @@ } }, "node_modules/source-map-js": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", - "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.0.tgz", + "integrity": "sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==", "engines": { "node": ">=0.10.0" } @@ -18681,14 +18685,6 @@ "zen-observable": "0.8.15" } }, - "node_modules/zod": { - "version": "3.21.4", - "resolved": "https://registry.npmjs.org/zod/-/zod-3.21.4.tgz", - "integrity": "sha512-m46AKbrzKVzOzs/DZgVnG5H55N1sv1M8qZU3A8RIKbs3mrACDNeIOeilDymVb2HdmP8uwshOCF4uJ8uM9rCqJw==", - "funding": { - "url": "https://github.com/sponsors/colinhacks" - } - }, "node_modules/zustand": { "version": "3.7.2", "resolved": "https://registry.npmjs.org/zustand/-/zustand-3.7.2.tgz", @@ -20795,9 +20791,9 @@ } }, "@next/env": { - "version": "13.4.4", - "resolved": "https://registry.npmjs.org/@next/env/-/env-13.4.4.tgz", - "integrity": "sha512-q/y7VZj/9YpgzDe64Zi6rY1xPizx80JjlU2BTevlajtaE3w1LqweH1gGgxou2N7hdFosXHjGrI4OUvtFXXhGLg==" + "version": "14.2.5", + "resolved": "https://registry.npmjs.org/@next/env/-/env-14.2.5.tgz", + "integrity": "sha512-/zZGkrTOsraVfYjGP8uM0p6r0BDT6xWpkjdVbcz66PJVSpwXX3yNiRycxAuDfBKGWBrZBXRuK/YVlkNgxHGwmA==" }, "@next/eslint-plugin-next": { "version": "13.4.4", @@ -20823,57 +20819,57 @@ } }, "@next/swc-darwin-arm64": { - "version": "13.4.4", - "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.4.4.tgz", - "integrity": "sha512-xfjgXvp4KalNUKZMHmsFxr1Ug+aGmmO6NWP0uoh4G3WFqP/mJ1xxfww0gMOeMeSq/Jyr5k7DvoZ2Pv+XOITTtw==", + "version": "14.2.5", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-14.2.5.tgz", + "integrity": "sha512-/9zVxJ+K9lrzSGli1///ujyRfon/ZneeZ+v4ptpiPoOU+GKZnm8Wj8ELWU1Pm7GHltYRBklmXMTUqM/DqQ99FQ==", "optional": true }, "@next/swc-darwin-x64": { - "version": "13.4.4", - "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-13.4.4.tgz", - "integrity": "sha512-ZY9Ti1hkIwJsxGus3nlubIkvYyB0gNOYxKrfsOrLEqD0I2iCX8D7w8v6QQZ2H+dDl6UT29oeEUdDUNGk4UEpfg==", + "version": "14.2.5", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-14.2.5.tgz", + "integrity": "sha512-vXHOPCwfDe9qLDuq7U1OYM2wUY+KQ4Ex6ozwsKxp26BlJ6XXbHleOUldenM67JRyBfVjv371oneEvYd3H2gNSA==", "optional": true }, "@next/swc-linux-arm64-gnu": { - "version": "13.4.4", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.4.4.tgz", - "integrity": "sha512-+KZnDeMShYkpkqAvGCEDeqYTRADJXc6SY1jWXz+Uo6qWQO/Jd9CoyhTJwRSxvQA16MoYzvILkGaDqirkRNctyA==", + "version": "14.2.5", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-14.2.5.tgz", + "integrity": "sha512-vlhB8wI+lj8q1ExFW8lbWutA4M2ZazQNvMWuEDqZcuJJc78iUnLdPPunBPX8rC4IgT6lIx/adB+Cwrl99MzNaA==", "optional": true }, "@next/swc-linux-arm64-musl": { - "version": "13.4.4", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.4.4.tgz", - "integrity": "sha512-evC1twrny2XDT4uOftoubZvW3EG0zs0ZxMwEtu/dDGVRO5n5pT48S8qqEIBGBUZYu/Xx4zzpOkIxx1vpWdE+9A==", + "version": "14.2.5", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-14.2.5.tgz", + "integrity": "sha512-NpDB9NUR2t0hXzJJwQSGu1IAOYybsfeB+LxpGsXrRIb7QOrYmidJz3shzY8cM6+rO4Aojuef0N/PEaX18pi9OA==", "optional": true }, "@next/swc-linux-x64-gnu": { - "version": "13.4.4", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.4.4.tgz", - "integrity": "sha512-PX706XcCHr2FfkyhP2lpf+pX/tUvq6/ke7JYnnr0ykNdEMo+sb7cC/o91gnURh4sPYSiZJhsF2gbIqg9rciOHQ==", + "version": "14.2.5", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-14.2.5.tgz", + "integrity": "sha512-8XFikMSxWleYNryWIjiCX+gU201YS+erTUidKdyOVYi5qUQo/gRxv/3N1oZFCgqpesN6FPeqGM72Zve+nReVXQ==", "optional": true }, "@next/swc-linux-x64-musl": { - "version": "13.4.4", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.4.4.tgz", - "integrity": "sha512-TKUUx3Ftd95JlHV6XagEnqpT204Y+IsEa3awaYIjayn0MOGjgKZMZibqarK3B1FsMSPaieJf2FEAcu9z0yT5aA==", + "version": "14.2.5", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-14.2.5.tgz", + "integrity": "sha512-6QLwi7RaYiQDcRDSU/os40r5o06b5ue7Jsk5JgdRBGGp8l37RZEh9JsLSM8QF0YDsgcosSeHjglgqi25+m04IQ==", "optional": true }, "@next/swc-win32-arm64-msvc": { - "version": "13.4.4", - "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.4.4.tgz", - "integrity": "sha512-FP8AadgSq4+HPtim7WBkCMGbhr5vh9FePXiWx9+YOdjwdQocwoCK5ZVC3OW8oh3TWth6iJ0AXJ/yQ1q1cwSZ3A==", + "version": "14.2.5", + "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-14.2.5.tgz", + "integrity": "sha512-1GpG2VhbspO+aYoMOQPQiqc/tG3LzmsdBH0LhnDS3JrtDx2QmzXe0B6mSZZiN3Bq7IOMXxv1nlsjzoS1+9mzZw==", "optional": true }, "@next/swc-win32-ia32-msvc": { - "version": "13.4.4", - "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.4.4.tgz", - "integrity": "sha512-3WekVmtuA2MCdcAOrgrI+PuFiFURtSyyrN1I3UPtS0ckR2HtLqyqmS334Eulf15g1/bdwMteePdK363X/Y9JMg==", + "version": "14.2.5", + "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-14.2.5.tgz", + "integrity": "sha512-Igh9ZlxwvCDsu6438FXlQTHlRno4gFpJzqPjSIBZooD22tKeI4fE/YMRoHVJHmrQ2P5YL1DoZ0qaOKkbeFWeMg==", "optional": true }, "@next/swc-win32-x64-msvc": { - "version": "13.4.4", - "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.4.4.tgz", - "integrity": "sha512-AHRITu/CrlQ+qzoqQtEMfaTu7GHaQ6bziQln/pVWpOYC1wU+Mq6VQQFlsDtMCnDztPZtppAXdvvbNS7pcfRzlw==", + "version": "14.2.5", + "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-14.2.5.tgz", + "integrity": "sha512-tEQ7oinq1/CjSG9uSTerca3v4AZ+dFa+4Yu6ihaG8Ud8ddqLQgFGcnwYls13H5X5CPDPZJdYxyeMui6muOLd4g==", "optional": true }, "@nodelib/fs.scandir": { @@ -21501,11 +21497,17 @@ "svgo": "^1.2.2" } }, + "@swc/counter": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@swc/counter/-/counter-0.1.3.tgz", + "integrity": "sha512-e2BR4lsJkkRlKZ/qCHPw9ZaSxc0MVUd7gtbtaB7aMvHeJVYe8sOB8DBZkP2DtISHGSku9sCK6T6cnY0CtXrOCQ==" + }, "@swc/helpers": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.1.tgz", - "integrity": "sha512-sJ902EfIzn1Fa+qYmjdQqh8tPsoxyBz+8yBKC2HKUxyezKJFwPGOn7pv4WY6QuQW//ySQi5lJjA/ZT9sNWWNTg==", + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.5.tgz", + "integrity": "sha512-KGYxvIOXcceOAbEk4bi/dVLEK9z8sZ0uBB3Il5b1rhfClSpcX0yfRO0KmTkqR2cnQDymwLB+25ZyMzICg/cm/A==", "requires": { + "@swc/counter": "^0.1.3", "tslib": "^2.4.0" } }, @@ -21924,29 +21926,23 @@ "integrity": "sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==" }, "@types/react": { - "version": "18.2.7", - "resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.7.tgz", - "integrity": "sha512-ojrXpSH2XFCmHm7Jy3q44nXDyN54+EYKP2lBhJ2bqfyPj6cIUW/FZW/Csdia34NQgq7KYcAlHi5184m4X88+yw==", + "version": "18.3.3", + "resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.3.tgz", + "integrity": "sha512-hti/R0pS0q1/xx+TsI73XIqk26eBsISZ2R0wUijXIngRK9R/e7Xw/cXVxQK7R5JjW+SV4zGcn5hXjudkN/pLIw==", "requires": { "@types/prop-types": "*", - "@types/scheduler": "*", "csstype": "^3.0.2" } }, "@types/react-dom": { - "version": "18.2.4", - "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.2.4.tgz", - "integrity": "sha512-G2mHoTMTL4yoydITgOGwWdWMVd8sNgyEP85xVmMKAPUBwQWm9wBPQUmvbeF4V3WBY1P7mmL4BkjQ0SqUpf1snw==", + "version": "18.3.0", + "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.3.0.tgz", + "integrity": "sha512-EhwApuTmMBmXuFOikhQLIBUn6uFg81SwLMOAUgodJF14SOBOCMdU04gDoYi0WOJJHD144TL32z4yDqCW3dnkQg==", "devOptional": true, "requires": { "@types/react": "*" } }, - "@types/scheduler": { - "version": "0.16.3", - "resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.3.tgz", - "integrity": "sha512-5cJ8CB4yAx7BH1oMvdU0Jh9lrEXyPkar6F9G/ERswkCuvP4KQZfZkSjcMbAICCpQTN4OuZn8tz0HiKv9TGZgrQ==" - }, "@types/send": { "version": "0.17.1", "resolved": "https://registry.npmjs.org/@types/send/-/send-0.17.1.tgz", @@ -23986,9 +23982,9 @@ "peer": true }, "caniuse-lite": { - "version": "1.0.30001489", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001489.tgz", - "integrity": "sha512-x1mgZEXK8jHIfAxm+xgdpHpk50IN3z3q3zP261/WS+uvePxW8izXuCu6AHz0lkuYTlATDehiZ/tNyYBdSQsOUQ==" + "version": "1.0.30001643", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001643.tgz", + "integrity": "sha512-ERgWGNleEilSrHM6iUz/zJNSQTP8Mr21wDWpdgvRwcTXGAq6jMtOUPP4dqFPTdKqZ2wKTdtB+uucZ3MRpAUSmg==" }, "capital-case": { "version": "1.0.4", @@ -28614,26 +28610,26 @@ "peer": true }, "next": { - "version": "13.4.4", - "resolved": "https://registry.npmjs.org/next/-/next-13.4.4.tgz", - "integrity": "sha512-C5S0ysM0Ily9McL4Jb48nOQHT1BukOWI59uC3X/xCMlYIh9rJZCv7nzG92J6e1cOBqQbKovlpgvHWFmz4eKKEA==", - "requires": { - "@next/env": "13.4.4", - "@next/swc-darwin-arm64": "13.4.4", - "@next/swc-darwin-x64": "13.4.4", - "@next/swc-linux-arm64-gnu": "13.4.4", - "@next/swc-linux-arm64-musl": "13.4.4", - "@next/swc-linux-x64-gnu": "13.4.4", - "@next/swc-linux-x64-musl": "13.4.4", - "@next/swc-win32-arm64-msvc": "13.4.4", - "@next/swc-win32-ia32-msvc": "13.4.4", - "@next/swc-win32-x64-msvc": "13.4.4", - "@swc/helpers": "0.5.1", + "version": "14.2.5", + "resolved": "https://registry.npmjs.org/next/-/next-14.2.5.tgz", + "integrity": "sha512-0f8aRfBVL+mpzfBjYfQuLWh2WyAwtJXCRfkPF4UJ5qd2YwrHczsrSzXU4tRMV0OAxR8ZJZWPFn6uhSC56UTsLA==", + "requires": { + "@next/env": "14.2.5", + "@next/swc-darwin-arm64": "14.2.5", + "@next/swc-darwin-x64": "14.2.5", + "@next/swc-linux-arm64-gnu": "14.2.5", + "@next/swc-linux-arm64-musl": "14.2.5", + "@next/swc-linux-x64-gnu": "14.2.5", + "@next/swc-linux-x64-musl": "14.2.5", + "@next/swc-win32-arm64-msvc": "14.2.5", + "@next/swc-win32-ia32-msvc": "14.2.5", + "@next/swc-win32-x64-msvc": "14.2.5", + "@swc/helpers": "0.5.5", "busboy": "1.6.0", - "caniuse-lite": "^1.0.30001406", - "postcss": "8.4.14", - "styled-jsx": "5.1.1", - "zod": "3.21.4" + "caniuse-lite": "^1.0.30001579", + "graceful-fs": "^4.2.11", + "postcss": "8.4.31", + "styled-jsx": "5.1.1" } }, "next-i18next": { @@ -29266,11 +29262,11 @@ "integrity": "sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==" }, "postcss": { - "version": "8.4.14", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.14.tgz", - "integrity": "sha512-E398TUmfAYFPBSdzgeieK2Y1+1cpdxJx8yXbK/m57nRhKSmk1GB2tO4lbLBtlkfPQTDKfe4Xqv1ASWPpayPEig==", + "version": "8.4.31", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.31.tgz", + "integrity": "sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==", "requires": { - "nanoid": "^3.3.4", + "nanoid": "^3.3.6", "picocolors": "^1.0.0", "source-map-js": "^1.0.2" } @@ -29486,9 +29482,9 @@ } }, "react": { - "version": "18.2.0", - "resolved": "https://registry.npmjs.org/react/-/react-18.2.0.tgz", - "integrity": "sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==", + "version": "18.3.1", + "resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz", + "integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==", "requires": { "loose-envify": "^1.1.0" } @@ -29516,12 +29512,12 @@ } }, "react-dom": { - "version": "18.2.0", - "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.2.0.tgz", - "integrity": "sha512-6IMTriUmvsjHUjNtEDudZfuDQUoWXVxKHhlEGSk81n4YFS+r/Kl99wXiwlVXtPBtJenozv2P+hxDsw9eA7Xo6g==", + "version": "18.3.1", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.3.1.tgz", + "integrity": "sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==", "requires": { "loose-envify": "^1.1.0", - "scheduler": "^0.23.0" + "scheduler": "^0.23.2" } }, "react-hook-form": { @@ -30247,9 +30243,9 @@ "integrity": "sha512-8I2a3LovHTOpm7NV5yOyO8IHqgVsfK4+UuySrXU8YXkSRX7k6hCV9b3HrkKCr3nMpgj+0bmocaJJWpvp1oc7ZA==" }, "scheduler": { - "version": "0.23.0", - "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.0.tgz", - "integrity": "sha512-CtuThmgHNg7zIZWAXi3AsyIzA3n4xx7aNyjwC2VJldO2LMVDhFK+63xGqq6CsJH4rTAt6/M+N4GhZiDYPx9eUw==", + "version": "0.23.2", + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.2.tgz", + "integrity": "sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ==", "requires": { "loose-envify": "^1.1.0" } @@ -30553,9 +30549,9 @@ "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" }, "source-map-js": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", - "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==" + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.0.tgz", + "integrity": "sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==" }, "source-map-support": { "version": "0.5.21", @@ -32154,11 +32150,6 @@ "zen-observable": "0.8.15" } }, - "zod": { - "version": "3.21.4", - "resolved": "https://registry.npmjs.org/zod/-/zod-3.21.4.tgz", - "integrity": "sha512-m46AKbrzKVzOzs/DZgVnG5H55N1sv1M8qZU3A8RIKbs3mrACDNeIOeilDymVb2HdmP8uwshOCF4uJ8uM9rCqJw==" - }, "zustand": { "version": "3.7.2", "resolved": "https://registry.npmjs.org/zustand/-/zustand-3.7.2.tgz", diff --git a/packages/web/package.json b/packages/web/package.json index fb1ad96b..ffe1edb4 100644 --- a/packages/web/package.json +++ b/packages/web/package.json @@ -70,15 +70,15 @@ "jsonwebtoken": "^8.5.1", "jwt-decode": "^4.0.0", "lodash": "^4.17.20", - "next": "^13.3.4", + "next": "^14.2.5", "next-i18next": "^7.0.1", "nexus": "^1.0.0", "nexus-plugin-prisma": "^0.35.0", "node-fetch": "^2.6.7", "nprogress": "^0.2.0", "query-string": "^7.0.1", - "react": "^18.2.0", - "react-dom": "^18.2.0", + "react": "^18.3.1", + "react-dom": "^18.3.1", "react-hook-form": "^5.7.2", "react-markdown": "^7.0.0", "react-toastify": "^6.0.8", @@ -115,8 +115,8 @@ "@types/jest": "^29.5.8", "@types/node": "^14.14.31", "@types/nprogress": "^0.2.0", - "@types/react": "^18.2.1", - "@types/react-dom": "^18.2.2", + "@types/react": "^18.3.3", + "@types/react-dom": "^18.3.0", "@types/uuid": "^8.3.0", "cli-progress": "^3.9.0", "copy-webpack-plugin": "^9.0.1", From 58c09e9d4bdf08c692bb3b8fb96e05cc62bc956b Mon Sep 17 00:00:00 2001 From: Robin MacPherson Date: Tue, 10 Sep 2024 14:57:02 +0100 Subject: [PATCH 32/34] Update j-db-client version due to merged code --- packages/j-db-client/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/j-db-client/package.json b/packages/j-db-client/package.json index bdf9b692..3efde18e 100644 --- a/packages/j-db-client/package.json +++ b/packages/j-db-client/package.json @@ -1,6 +1,6 @@ { "name": "@journaly/j-db-client", - "version": "13.21.0", + "version": "13.23.0", "description": "Journaly's internal database client.", "main": "dist/index", "scripts": { From 232fb63c47f93429fa8ddb870f097092dd347531 Mon Sep 17 00:00:00 2001 From: Robin MacPherson Date: Thu, 19 Sep 2024 17:06:23 +0100 Subject: [PATCH 33/34] Bump j-db-client version for J-Mail --- packages/j-mail/package-lock.json | 14 +++++++------- packages/j-mail/package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/j-mail/package-lock.json b/packages/j-mail/package-lock.json index 397cf3fd..588cb783 100644 --- a/packages/j-mail/package-lock.json +++ b/packages/j-mail/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.0", "license": "ISC", "dependencies": { - "@journaly/j-db-client": "^13.20.0", + "@journaly/j-db-client": "^13.23.0", "@types/nodemailer": "^6.4.0", "aws-sdk": "^2.737.0", "date-fns": "^2.16.1", @@ -56,9 +56,9 @@ } }, "node_modules/@journaly/j-db-client": { - "version": "13.20.0", - "resolved": "https://registry.npmjs.org/@journaly/j-db-client/-/j-db-client-13.20.0.tgz", - "integrity": "sha512-azX4mKZhicDmomFZqtliVhRaEjlu2Y9gz9u+NkrN1epDewov4SvwAoSn98/90cRr6W2Vh6GbjfxjUddzs7YraQ==", + "version": "13.23.0", + "resolved": "https://registry.npmjs.org/@journaly/j-db-client/-/j-db-client-13.23.0.tgz", + "integrity": "sha512-orb9a6bWIgoBO/VVXhOc6e7bNlyXdH7brofvvgZQfOVqNpR5dlaMotLEuX/L2xt6QFmofDpQDNuKDm2WzAgThw==", "dependencies": { "@prisma/client": "^3.15.2" } @@ -2415,9 +2415,9 @@ } }, "@journaly/j-db-client": { - "version": "13.20.0", - "resolved": "https://registry.npmjs.org/@journaly/j-db-client/-/j-db-client-13.20.0.tgz", - "integrity": "sha512-azX4mKZhicDmomFZqtliVhRaEjlu2Y9gz9u+NkrN1epDewov4SvwAoSn98/90cRr6W2Vh6GbjfxjUddzs7YraQ==", + "version": "13.23.0", + "resolved": "https://registry.npmjs.org/@journaly/j-db-client/-/j-db-client-13.23.0.tgz", + "integrity": "sha512-orb9a6bWIgoBO/VVXhOc6e7bNlyXdH7brofvvgZQfOVqNpR5dlaMotLEuX/L2xt6QFmofDpQDNuKDm2WzAgThw==", "requires": { "@prisma/client": "^3.15.2" } diff --git a/packages/j-mail/package.json b/packages/j-mail/package.json index ed0b8cf2..f7064c80 100644 --- a/packages/j-mail/package.json +++ b/packages/j-mail/package.json @@ -36,7 +36,7 @@ "typescript": "4.2.4" }, "dependencies": { - "@journaly/j-db-client": "^13.22.0", + "@journaly/j-db-client": "^13.23.0", "@types/nodemailer": "^6.4.0", "aws-sdk": "^2.737.0", "date-fns": "^2.16.1", From bd3399a45072b714038cd45aa5d417364c6d12dd Mon Sep 17 00:00:00 2001 From: Robin MacPherson Date: Thu, 19 Sep 2024 17:23:59 +0100 Subject: [PATCH 34/34] Upgrade `next-18next` and try to make it work --- docs/1-internationalization.md | 4 +- packages/web/components/Badge/Badge.tsx | 2 +- .../components/Dashboard/Filters/Filters.tsx | 2 +- .../Dashboard/Filters/LanguageSelect.tsx | 2 +- .../Dashboard/Filters/SearchInput.tsx | 2 +- .../Dashboard/Filters/TopicSelect.tsx | 2 +- .../components/Dashboard/MyFeed/MyFeed.tsx | 2 +- .../components/Dashboard/MyPosts/MyPosts.tsx | 2 +- packages/web/components/Dashboard/Nav/Nav.tsx | 2 +- .../web/components/Dashboard/Post/Post.tsx | 2 +- .../Dashboard/Post/PostAuthorCard.tsx | 2 +- .../components/Dashboard/Post/PostComment.tsx | 2 +- .../Dashboard/Post/PostComments.tsx | 2 +- .../web/components/Dashboard/Post/helpers.ts | 2 +- .../Dashboard/PostCard/PostCard.tsx | 2 +- .../components/Dashboard/Profile/PostList.tsx | 2 +- .../components/Dashboard/Profile/Profile.tsx | 2 +- .../Dashboard/Profile/ProfileCard.tsx | 2 +- .../Dashboard/Profile/ProfileStats.tsx | 2 +- .../components/Dashboard/Settings/BioForm.tsx | 2 +- .../Dashboard/Settings/Breadcrumbs.tsx | 2 +- .../Dashboard/Settings/DetailsForm.tsx | 2 +- .../Dashboard/Settings/InterestsForm.tsx | 2 +- .../Dashboard/Settings/LanguagesForm.tsx | 2 +- .../Settings/NotificationSettingsForm.tsx | 2 +- .../Dashboard/Settings/SettingsNav.tsx | 2 +- .../Dashboard/Settings/SocialForm.tsx | 2 +- .../Dashboard/Settings/SocialFormField.tsx | 2 +- .../Settings/Subscription/CardOnFile.tsx | 2 +- .../Settings/Subscription/PaymentForm.tsx | 2 +- .../Subscription/PaymentFormModal.tsx | 2 +- .../Subscription/SubscriptionForm.tsx | 2 +- .../Subscription/SubscriptionPlanSelect.tsx | 2 +- .../Settings/Subscription/UpdateCardForm.tsx | 2 +- .../Subscription/UpdateCardFormModal.tsx | 2 +- .../Dashboard/Settings/UILanguageForm.tsx | 2 +- .../Dashboard/Settings/UpdatePasswordForm.tsx | 2 +- .../FeatureComparisonTable.tsx | 2 +- .../InlineFeedbackPopover/Comment.tsx | 6 +- .../InlineFeedbackPopover/Thread.tsx | 2 +- .../InterestFormField/InterestFormField.tsx | 2 +- .../Toolbar/InsertImageButton.tsx | 2 +- .../JournalyEditor/Toolbar/Toolbar.tsx | 2 +- .../JournalyEditor/Toolbar/ToolbarButton.tsx | 2 +- .../LanguageFormField/LanguageFormField.tsx | 2 +- .../LoadingWrapper/LoadingWrapper.tsx | 2 +- .../web/components/LoginForm/LoginForm.tsx | 2 +- .../ConfirmationModal/ConfirmationModal.tsx | 2 +- .../ImageUploadModal/ImageUploadModal.tsx | 2 +- .../ImageUploadModal/SearchUnsplash.tsx | 2 +- .../Modals/ImageUploadModal/UploadImage.tsx | 2 +- .../PremiumFeatureModal.tsx | 2 +- .../Modals/WelcomeModal/WelcomeModalBody.tsx | 2 +- .../NotificationFeed/NotificationFeed.tsx | 2 +- .../NotificationFeed/Notifications.tsx | 2 +- .../web/components/Pagination/Pagination.tsx | 2 +- .../web/components/PostEditor/PostEditor.tsx | 2 +- .../web/components/PostHeader/PostHeader.tsx | 2 +- .../PrivateShareLink/PrivateShareLink.tsx | 2 +- .../RequestResetPasswordForm.tsx | 2 +- .../ResetPasswordForm/ResetPasswordForm.tsx | 2 +- .../web/components/SignupForm/SignupForm.tsx | 2 +- .../components/Site/Home/FeatureSection.tsx | 2 +- .../components/Site/Home/ReasonsSection.tsx | 2 +- .../Site/Home/TestimonialsSection.tsx | 2 +- .../web/components/Site/Home/TopSection.tsx | 2 +- .../web/components/Site/Home/VideoSection.tsx | 2 +- packages/web/components/Site/Nav/Nav.tsx | 2 +- .../web/components/Site/Pricing/Pricing.tsx | 2 +- .../SwipeableElement/SwipeableElement.tsx | 2 +- .../UILanguageSelect/UILanguageSelect.tsx | 2 +- packages/web/hooks/useImageUpload.ts | 2 +- packages/web/hooks/useUILanguage.ts | 3 +- .../i18n.js => next-i18next.config.js} | 19 +- packages/web/next.config.js | 6 + packages/web/package-lock.json | 405 +++++------------- packages/web/package.json | 2 +- packages/web/pages/_app.tsx | 16 +- packages/web/pages/_document.tsx | 4 +- packages/web/pages/_error.tsx | 2 +- packages/web/pages/my-posts.tsx | 2 +- packages/web/pages/new-post.tsx | 2 +- packages/web/pages/post/[id]/edit.tsx | 2 +- packages/web/server/index.js | 3 +- packages/web/utils/getUiLanguage.ts | 4 +- 85 files changed, 230 insertions(+), 390 deletions(-) rename packages/web/{config/i18n.js => next-i18next.config.js} (55%) diff --git a/docs/1-internationalization.md b/docs/1-internationalization.md index b352f9e9..16e01471 100644 --- a/docs/1-internationalization.md +++ b/docs/1-internationalization.md @@ -13,7 +13,7 @@ When using translations in a React component, default to using the [useTranslati ```jsx import React from 'react' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' export function MyComponent() { const { t } = useTranslation() @@ -32,7 +32,7 @@ For simple interpolation, follow this pattern: ```jsx import React from 'react' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' export function MyComponent() { const { t } = useTranslation() diff --git a/packages/web/components/Badge/Badge.tsx b/packages/web/components/Badge/Badge.tsx index bed60793..897a8a74 100644 --- a/packages/web/components/Badge/Badge.tsx +++ b/packages/web/components/Badge/Badge.tsx @@ -1,7 +1,7 @@ import React from 'react' import { UserBadgeFragmentFragment as Badge, BadgeType } from '@/generated/graphql' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import theme from '@/theme' type Props = { diff --git a/packages/web/components/Dashboard/Filters/Filters.tsx b/packages/web/components/Dashboard/Filters/Filters.tsx index 3b3003e7..aae182dd 100644 --- a/packages/web/components/Dashboard/Filters/Filters.tsx +++ b/packages/web/components/Dashboard/Filters/Filters.tsx @@ -7,7 +7,7 @@ import LanguageSelect from './LanguageSelect' import TopicSelect from './TopicSelect' import useToggle from '@/hooks/useToggle' import useUILanguage from '@/hooks/useUILanguage' -import { Router, useTranslation } from '@/config/i18n' +import { Router, useTranslation } from 'next-i18next' import PremiumFeatureModal from '@/components/Modals/PremiumFeatureModal' export type PostQueryVarsType = { diff --git a/packages/web/components/Dashboard/Filters/LanguageSelect.tsx b/packages/web/components/Dashboard/Filters/LanguageSelect.tsx index e3b57f15..526c26c4 100644 --- a/packages/web/components/Dashboard/Filters/LanguageSelect.tsx +++ b/packages/web/components/Dashboard/Filters/LanguageSelect.tsx @@ -1,7 +1,7 @@ import React from 'react' import MultiSelect from '@/components/MultiSelect' import { LanguagesQuery } from '@/generated/graphql' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' type Props = { languagesData: LanguagesQuery | undefined diff --git a/packages/web/components/Dashboard/Filters/SearchInput.tsx b/packages/web/components/Dashboard/Filters/SearchInput.tsx index 4ff8c4b3..7509bb86 100644 --- a/packages/web/components/Dashboard/Filters/SearchInput.tsx +++ b/packages/web/components/Dashboard/Filters/SearchInput.tsx @@ -1,6 +1,6 @@ import React, { useCallback, useState } from 'react' import _ from 'lodash' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' type Props = { defaultValue: string diff --git a/packages/web/components/Dashboard/Filters/TopicSelect.tsx b/packages/web/components/Dashboard/Filters/TopicSelect.tsx index ed2c5a7a..b043d9f2 100644 --- a/packages/web/components/Dashboard/Filters/TopicSelect.tsx +++ b/packages/web/components/Dashboard/Filters/TopicSelect.tsx @@ -1,7 +1,7 @@ import React from 'react' import MultiSelect from '@/components/MultiSelect' import { Topic } from '@/generated/graphql' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' type Props = { topics: Topic[] | undefined diff --git a/packages/web/components/Dashboard/MyFeed/MyFeed.tsx b/packages/web/components/Dashboard/MyFeed/MyFeed.tsx index 2bfabaf9..c16f9377 100644 --- a/packages/web/components/Dashboard/MyFeed/MyFeed.tsx +++ b/packages/web/components/Dashboard/MyFeed/MyFeed.tsx @@ -4,7 +4,7 @@ import { useRouter } from 'next/router' import { toast } from 'react-toastify' import _ from 'lodash' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import { gtag } from '@/components/GoogleAnalytics' import Pagination from '@/components/Pagination' import LoadingWrapper from '@/components/LoadingWrapper' diff --git a/packages/web/components/Dashboard/MyPosts/MyPosts.tsx b/packages/web/components/Dashboard/MyPosts/MyPosts.tsx index 7a2067c6..07ccdd53 100644 --- a/packages/web/components/Dashboard/MyPosts/MyPosts.tsx +++ b/packages/web/components/Dashboard/MyPosts/MyPosts.tsx @@ -6,7 +6,7 @@ import { User as UserType, usePostsQuery, } from '@/generated/graphql' -import { useTranslation, Trans } from '@/config/i18n' +import { useTranslation, Trans } from 'next-i18next' import TranslationLink from '@/components/TranslationLink' import LoadingSpinner from '@/components/Icons/LoadingSpinner' import PostCard from '../PostCard' diff --git a/packages/web/components/Dashboard/Nav/Nav.tsx b/packages/web/components/Dashboard/Nav/Nav.tsx index 5b9ba49c..6bb5d98e 100644 --- a/packages/web/components/Dashboard/Nav/Nav.tsx +++ b/packages/web/components/Dashboard/Nav/Nav.tsx @@ -2,7 +2,7 @@ import React, { useCallback, useState, useEffect, useRef } from 'react' import Link from 'next/link' import classNames from 'classnames' -import { Router, useTranslation } from '@/config/i18n' +import { Router, useTranslation } from 'next-i18next' import { navConstants } from './nav-constants' import theme from '@/theme' import { diff --git a/packages/web/components/Dashboard/Post/Post.tsx b/packages/web/components/Dashboard/Post/Post.tsx index 4cf1234b..59254b74 100644 --- a/packages/web/components/Dashboard/Post/Post.tsx +++ b/packages/web/components/Dashboard/Post/Post.tsx @@ -23,7 +23,7 @@ import Button, { ButtonVariant } from '@/components/Button' import theme from '@/theme' import PostBodyStyles from '@/components/PostBodyStyles' import InlineFeedbackPopover, { PendingThreadData } from '@/components/InlineFeedbackPopover' -import { Router, useTranslation } from '@/config/i18n' +import { Router, useTranslation } from 'next-i18next' import PostHeader from '@/components/PostHeader' import ConfirmationModal from '@/components/Modals/ConfirmationModal' import PremiumFeatureModal from '@/components/Modals/PremiumFeatureModal' diff --git a/packages/web/components/Dashboard/Post/PostAuthorCard.tsx b/packages/web/components/Dashboard/Post/PostAuthorCard.tsx index a01f4c43..55adcf11 100644 --- a/packages/web/components/Dashboard/Post/PostAuthorCard.tsx +++ b/packages/web/components/Dashboard/Post/PostAuthorCard.tsx @@ -7,7 +7,7 @@ import { useUnfollowUserMutation, useFollowingUsersQuery, } from '@/generated/graphql' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import { languageNameWithDialect } from '@/utils/languages' import Button, { ButtonVariant } from '@/components/Button' import LevelGauge from '@/components/LevelGauge' diff --git a/packages/web/components/Dashboard/Post/PostComment.tsx b/packages/web/components/Dashboard/Post/PostComment.tsx index ed63e3f2..ba65a026 100644 --- a/packages/web/components/Dashboard/Post/PostComment.tsx +++ b/packages/web/components/Dashboard/Post/PostComment.tsx @@ -6,7 +6,7 @@ import { useDeletePostCommentMutation, PostCommentFragmentFragment as PostCommentType, } from '@/generated/graphql' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import EditableMarkdown from '@/components/EditableMarkdown' import Button, { ButtonSize, ButtonVariant } from '@/components/Button' diff --git a/packages/web/components/Dashboard/Post/PostComments.tsx b/packages/web/components/Dashboard/Post/PostComments.tsx index 15992672..33266291 100644 --- a/packages/web/components/Dashboard/Post/PostComments.tsx +++ b/packages/web/components/Dashboard/Post/PostComments.tsx @@ -12,7 +12,7 @@ import { PostPageQueryVariables, LanguageLevel, } from '@/generated/graphql' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import theme from '@/theme' import PostComment from './PostComment' diff --git a/packages/web/components/Dashboard/Post/helpers.ts b/packages/web/components/Dashboard/Post/helpers.ts index b9af7a01..79f071ad 100644 --- a/packages/web/components/Dashboard/Post/helpers.ts +++ b/packages/web/components/Dashboard/Post/helpers.ts @@ -1,5 +1,5 @@ import { PostClapFragmentFragment as PostClapType } from '@/generated/graphql' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import { isChildOf } from '@/utils' // Elements whose boundaries a comment can cross diff --git a/packages/web/components/Dashboard/PostCard/PostCard.tsx b/packages/web/components/Dashboard/PostCard/PostCard.tsx index 08c1d994..89f76dd2 100644 --- a/packages/web/components/Dashboard/PostCard/PostCard.tsx +++ b/packages/web/components/Dashboard/PostCard/PostCard.tsx @@ -1,7 +1,7 @@ import React from 'react' import Link from 'next/link' import classNames from 'classnames' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import { formatShortDate } from '@/utils/date' import { PostStatus as PostStatusType, diff --git a/packages/web/components/Dashboard/Profile/PostList.tsx b/packages/web/components/Dashboard/Profile/PostList.tsx index 556da74a..522d9194 100644 --- a/packages/web/components/Dashboard/Profile/PostList.tsx +++ b/packages/web/components/Dashboard/Profile/PostList.tsx @@ -1,5 +1,5 @@ import React from 'react' -import { useTranslation, Trans } from '@/config/i18n' +import { useTranslation, Trans } from 'next-i18next' import { PostCardFragmentFragment as PostType, UserWithLanguagesFragmentFragment as UserType, diff --git a/packages/web/components/Dashboard/Profile/Profile.tsx b/packages/web/components/Dashboard/Profile/Profile.tsx index 9dd3c6dd..3dc624a9 100644 --- a/packages/web/components/Dashboard/Profile/Profile.tsx +++ b/packages/web/components/Dashboard/Profile/Profile.tsx @@ -1,7 +1,7 @@ import React, { useState } from 'react' import theme from '@/theme' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import { ProfileUserFragmentFragment as UserType, PostCardFragmentFragment as PostCardType, diff --git a/packages/web/components/Dashboard/Profile/ProfileCard.tsx b/packages/web/components/Dashboard/Profile/ProfileCard.tsx index 29a66082..df02422e 100644 --- a/packages/web/components/Dashboard/Profile/ProfileCard.tsx +++ b/packages/web/components/Dashboard/Profile/ProfileCard.tsx @@ -1,5 +1,5 @@ import React, { useMemo, useState } from 'react' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import FacebookIcon from '@/components/Icons/FacebookIcon' import InstagramIcon from '@/components/Icons/InstagramIcon' import YoutubeIcon from '@/components/Icons/YoutubeIcon' diff --git a/packages/web/components/Dashboard/Profile/ProfileStats.tsx b/packages/web/components/Dashboard/Profile/ProfileStats.tsx index cac6327a..9ca981c7 100644 --- a/packages/web/components/Dashboard/Profile/ProfileStats.tsx +++ b/packages/web/components/Dashboard/Profile/ProfileStats.tsx @@ -1,5 +1,5 @@ import React, { useState, useMemo, useCallback } from 'react' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import chroma from 'chroma-js' import differenceInCalendarWeeks from 'date-fns/differenceInCalendarWeeks' diff --git a/packages/web/components/Dashboard/Settings/BioForm.tsx b/packages/web/components/Dashboard/Settings/BioForm.tsx index ce915fe3..72d9728c 100644 --- a/packages/web/components/Dashboard/Settings/BioForm.tsx +++ b/packages/web/components/Dashboard/Settings/BioForm.tsx @@ -2,7 +2,7 @@ import React from 'react' import { useForm } from 'react-hook-form' import { toast } from 'react-toastify' import { sanitize } from '@/utils' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import FormError from '@/components/FormError' import SettingsForm from '@/components/Dashboard/Settings/SettingsForm' import SettingsFieldset from '@/components/Dashboard/Settings/SettingsFieldset' diff --git a/packages/web/components/Dashboard/Settings/Breadcrumbs.tsx b/packages/web/components/Dashboard/Settings/Breadcrumbs.tsx index f7c4156f..f87d105c 100644 --- a/packages/web/components/Dashboard/Settings/Breadcrumbs.tsx +++ b/packages/web/components/Dashboard/Settings/Breadcrumbs.tsx @@ -1,6 +1,6 @@ import React from 'react' import { useRouter } from 'next/router' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import theme from '@/theme' const Breadcrumbs: React.FC = () => { diff --git a/packages/web/components/Dashboard/Settings/DetailsForm.tsx b/packages/web/components/Dashboard/Settings/DetailsForm.tsx index 3026c23d..6cdfed29 100644 --- a/packages/web/components/Dashboard/Settings/DetailsForm.tsx +++ b/packages/web/components/Dashboard/Settings/DetailsForm.tsx @@ -1,6 +1,6 @@ import React, { useState, useRef, useCallback } from 'react' import { useForm } from 'react-hook-form' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import FormError from '@/components/FormError' import SettingsForm from '@/components/Dashboard/Settings/SettingsForm' import SettingsFieldset from '@/components/Dashboard/Settings/SettingsFieldset' diff --git a/packages/web/components/Dashboard/Settings/InterestsForm.tsx b/packages/web/components/Dashboard/Settings/InterestsForm.tsx index de12562f..d74bf88b 100644 --- a/packages/web/components/Dashboard/Settings/InterestsForm.tsx +++ b/packages/web/components/Dashboard/Settings/InterestsForm.tsx @@ -1,5 +1,5 @@ import React from 'react' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import { TopicFragmentFragment as TopicType, UserInterestFragmentFragment as UserInterestType, diff --git a/packages/web/components/Dashboard/Settings/LanguagesForm.tsx b/packages/web/components/Dashboard/Settings/LanguagesForm.tsx index bcb187de..a7cf4cae 100644 --- a/packages/web/components/Dashboard/Settings/LanguagesForm.tsx +++ b/packages/web/components/Dashboard/Settings/LanguagesForm.tsx @@ -1,5 +1,5 @@ import React from 'react' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import { LanguageFragmentFragment as LanguageType, LanguageRelation as LanguageRelationType, diff --git a/packages/web/components/Dashboard/Settings/NotificationSettingsForm.tsx b/packages/web/components/Dashboard/Settings/NotificationSettingsForm.tsx index bd0e6ed7..466e85dd 100644 --- a/packages/web/components/Dashboard/Settings/NotificationSettingsForm.tsx +++ b/packages/web/components/Dashboard/Settings/NotificationSettingsForm.tsx @@ -1,5 +1,5 @@ import React, { useState } from 'react' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import { DigestEmailConfiguration as DigestEmailConfigurationType, useUpdateUserConfigurationMutation, diff --git a/packages/web/components/Dashboard/Settings/SettingsNav.tsx b/packages/web/components/Dashboard/Settings/SettingsNav.tsx index 4a698a7f..1b8090a7 100644 --- a/packages/web/components/Dashboard/Settings/SettingsNav.tsx +++ b/packages/web/components/Dashboard/Settings/SettingsNav.tsx @@ -1,5 +1,5 @@ import React from 'react' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import NavLink from '@/components/NavLink' import theme from '@/theme' diff --git a/packages/web/components/Dashboard/Settings/SocialForm.tsx b/packages/web/components/Dashboard/Settings/SocialForm.tsx index 6e8acd2c..5e746aa7 100644 --- a/packages/web/components/Dashboard/Settings/SocialForm.tsx +++ b/packages/web/components/Dashboard/Settings/SocialForm.tsx @@ -2,7 +2,7 @@ import React from 'react' import { useForm } from 'react-hook-form' import { toast } from 'react-toastify' import { ApolloError } from '@apollo/client' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import SettingsForm from '@/components/Dashboard/Settings/SettingsForm' import SettingsFieldset from '@/components/Dashboard/Settings/SettingsFieldset' import Button, { ButtonVariant } from '@/components/Button' diff --git a/packages/web/components/Dashboard/Settings/SocialFormField.tsx b/packages/web/components/Dashboard/Settings/SocialFormField.tsx index a9947552..d8f09ec8 100644 --- a/packages/web/components/Dashboard/Settings/SocialFormField.tsx +++ b/packages/web/components/Dashboard/Settings/SocialFormField.tsx @@ -1,6 +1,6 @@ import React from 'react' import { FieldError, ValidationOptions } from 'react-hook-form' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import FacebookIcon from '@/components/Icons/FacebookIcon' import GlobeIcon from '@/components/Icons/GlobeIcon' import InstagramIcon from '@/components/Icons/InstagramIcon' diff --git a/packages/web/components/Dashboard/Settings/Subscription/CardOnFile.tsx b/packages/web/components/Dashboard/Settings/Subscription/CardOnFile.tsx index 5e1c903d..9461ad30 100644 --- a/packages/web/components/Dashboard/Settings/Subscription/CardOnFile.tsx +++ b/packages/web/components/Dashboard/Settings/Subscription/CardOnFile.tsx @@ -2,7 +2,7 @@ import React, { useState } from 'react' import theme from '@/theme' import Button, { ButtonSize, ButtonVariant } from '@/components/Button' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import UpdateCardFormModal from './UpdateCardFormModal' type CardOnFileProps = { diff --git a/packages/web/components/Dashboard/Settings/Subscription/PaymentForm.tsx b/packages/web/components/Dashboard/Settings/Subscription/PaymentForm.tsx index 040b0f9f..ff678ddc 100644 --- a/packages/web/components/Dashboard/Settings/Subscription/PaymentForm.tsx +++ b/packages/web/components/Dashboard/Settings/Subscription/PaymentForm.tsx @@ -9,7 +9,7 @@ import { } from '@/generated/graphql' import Button from '@/components/Button' import SubscriptionPlanSelect from './SubscriptionPlanSelect' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import theme from '@/theme' type PaymentFormProps = { diff --git a/packages/web/components/Dashboard/Settings/Subscription/PaymentFormModal.tsx b/packages/web/components/Dashboard/Settings/Subscription/PaymentFormModal.tsx index b0a561b5..14d55b53 100644 --- a/packages/web/components/Dashboard/Settings/Subscription/PaymentFormModal.tsx +++ b/packages/web/components/Dashboard/Settings/Subscription/PaymentFormModal.tsx @@ -1,7 +1,7 @@ import React from 'react' import Modal from '@/components/Modal' import PaymentForm from './PaymentForm' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' type PaymentFormModalProps = { onClose: () => void diff --git a/packages/web/components/Dashboard/Settings/Subscription/SubscriptionForm.tsx b/packages/web/components/Dashboard/Settings/Subscription/SubscriptionForm.tsx index a4288bab..9ad95837 100644 --- a/packages/web/components/Dashboard/Settings/Subscription/SubscriptionForm.tsx +++ b/packages/web/components/Dashboard/Settings/Subscription/SubscriptionForm.tsx @@ -3,7 +3,7 @@ import { toast } from 'react-toastify' import Button, { ButtonVariant } from '@/components/Button' import { useConfirmationModal } from '@/components/Modals/ConfirmationModal' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import { MembershipSubscriptionPeriod, UserWithSubscriptionFragmentFragment as UserType, diff --git a/packages/web/components/Dashboard/Settings/Subscription/SubscriptionPlanSelect.tsx b/packages/web/components/Dashboard/Settings/Subscription/SubscriptionPlanSelect.tsx index d0b23c0c..08b1d752 100644 --- a/packages/web/components/Dashboard/Settings/Subscription/SubscriptionPlanSelect.tsx +++ b/packages/web/components/Dashboard/Settings/Subscription/SubscriptionPlanSelect.tsx @@ -1,7 +1,7 @@ import React, { useMemo } from 'react' import { MembershipSubscriptionPeriod } from '@/generated/graphql' import Select from '@/components/Select' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' type SubscriptionPlanSelectProps = { selectedOption: MembershipSubscriptionPeriod diff --git a/packages/web/components/Dashboard/Settings/Subscription/UpdateCardForm.tsx b/packages/web/components/Dashboard/Settings/Subscription/UpdateCardForm.tsx index 28605b4a..b6880a19 100644 --- a/packages/web/components/Dashboard/Settings/Subscription/UpdateCardForm.tsx +++ b/packages/web/components/Dashboard/Settings/Subscription/UpdateCardForm.tsx @@ -7,7 +7,7 @@ import { useUpdateSubscriptionPaymentMethodMutation, } from '@/generated/graphql' import Button from '@/components/Button' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import theme from '@/theme' type UpdateCardFormProps = { diff --git a/packages/web/components/Dashboard/Settings/Subscription/UpdateCardFormModal.tsx b/packages/web/components/Dashboard/Settings/Subscription/UpdateCardFormModal.tsx index bb8f3860..2046feee 100644 --- a/packages/web/components/Dashboard/Settings/Subscription/UpdateCardFormModal.tsx +++ b/packages/web/components/Dashboard/Settings/Subscription/UpdateCardFormModal.tsx @@ -1,7 +1,7 @@ import React from 'react' import Modal from '@/components/Modal' import UpdateCardForm from './UpdateCardForm' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' type UpdateCardFormModalProps = { onClose: () => void diff --git a/packages/web/components/Dashboard/Settings/UILanguageForm.tsx b/packages/web/components/Dashboard/Settings/UILanguageForm.tsx index db1ac2f8..2b63e863 100644 --- a/packages/web/components/Dashboard/Settings/UILanguageForm.tsx +++ b/packages/web/components/Dashboard/Settings/UILanguageForm.tsx @@ -1,5 +1,5 @@ import React from 'react' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import SettingsForm from '@/components/Dashboard/Settings/SettingsForm' import SettingsFieldset from '@/components/Dashboard/Settings/SettingsFieldset' diff --git a/packages/web/components/Dashboard/Settings/UpdatePasswordForm.tsx b/packages/web/components/Dashboard/Settings/UpdatePasswordForm.tsx index da3d67de..3afa1179 100644 --- a/packages/web/components/Dashboard/Settings/UpdatePasswordForm.tsx +++ b/packages/web/components/Dashboard/Settings/UpdatePasswordForm.tsx @@ -1,7 +1,7 @@ import React from 'react' import { useForm } from 'react-hook-form' import { toast } from 'react-toastify' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import FormError from '@/components/FormError' import SettingsForm from '@/components/Dashboard/Settings/SettingsForm' import SettingsFieldset from '@/components/Dashboard/Settings/SettingsFieldset' diff --git a/packages/web/components/FeatureComparisonTable/FeatureComparisonTable.tsx b/packages/web/components/FeatureComparisonTable/FeatureComparisonTable.tsx index 2eb3d8db..fedfea5f 100644 --- a/packages/web/components/FeatureComparisonTable/FeatureComparisonTable.tsx +++ b/packages/web/components/FeatureComparisonTable/FeatureComparisonTable.tsx @@ -1,6 +1,6 @@ import theme from '@/theme' import React from 'react' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import CheckmarkCircleIcon from '../Icons/CheckmarkCircleIcon' type FeatureProps = { diff --git a/packages/web/components/InlineFeedbackPopover/Comment.tsx b/packages/web/components/InlineFeedbackPopover/Comment.tsx index e22050b1..cd4a2b6d 100644 --- a/packages/web/components/InlineFeedbackPopover/Comment.tsx +++ b/packages/web/components/InlineFeedbackPopover/Comment.tsx @@ -15,7 +15,7 @@ import { useApplySuggestionMutation, } from '@/generated/graphql' import theme from '@/theme' -import { Router, useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import EditableMarkdown from '@/components/EditableMarkdown' import Button, { ButtonSize, ButtonVariant } from '@/components/Button' import { useConfirmationModal } from '@/components/Modals/ConfirmationModal' @@ -28,6 +28,7 @@ import LevelGauge from '../LevelGauge' import UserAvatar from '../UserAvatar' import PremiumFeatureModal from '../Modals/PremiumFeatureModal' import { JOURNALY_PREMIUM_URL } from '@/constants' +import { useRouter } from 'next/router' type CommentProps = { comment: CommentType @@ -52,6 +53,7 @@ const Comment = ({ currentContentInPost, postAuthorId, }: CommentProps) => { + const router = useRouter() const { t } = useTranslation('comment') const [isEditMode, setIsEditMode] = useState(false) const [updatingCommentBody, setUpdatingCommentBody] = useState(comment.body) @@ -310,7 +312,7 @@ const Comment = ({ featureExplanation={t('acceptSuggestionPremiumFeatureExplanation')} onAcknowledge={() => setDisplayPremiumFeatureModal(false)} onGoToPremium={() => { - Router.push(JOURNALY_PREMIUM_URL) + router.push(JOURNALY_PREMIUM_URL) setDisplayPremiumFeatureModal(false) }} /> diff --git a/packages/web/components/InlineFeedbackPopover/Thread.tsx b/packages/web/components/InlineFeedbackPopover/Thread.tsx index 56245c1a..c664c38d 100644 --- a/packages/web/components/InlineFeedbackPopover/Thread.tsx +++ b/packages/web/components/InlineFeedbackPopover/Thread.tsx @@ -1,6 +1,6 @@ import React, { useEffect, useRef } from 'react' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import { useCreateCommentMutation, useCreateThreadMutation, diff --git a/packages/web/components/InterestFormField/InterestFormField.tsx b/packages/web/components/InterestFormField/InterestFormField.tsx index 05ba80b4..c0b20d59 100644 --- a/packages/web/components/InterestFormField/InterestFormField.tsx +++ b/packages/web/components/InterestFormField/InterestFormField.tsx @@ -7,7 +7,7 @@ import { } from '@/generated/graphql' import Button, { ButtonVariant } from '@/components/Button' import { OptionPills } from '@/components/MultiSelect' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import Select from '../Select' type Props = { diff --git a/packages/web/components/JournalyEditor/Toolbar/InsertImageButton.tsx b/packages/web/components/JournalyEditor/Toolbar/InsertImageButton.tsx index 12581bed..c9170189 100644 --- a/packages/web/components/JournalyEditor/Toolbar/InsertImageButton.tsx +++ b/packages/web/components/JournalyEditor/Toolbar/InsertImageButton.tsx @@ -1,7 +1,7 @@ import React, { useCallback } from 'react' import { useSlate } from 'slate-react' -import { useTranslation, Router } from '@/config/i18n' +import { useTranslation, Router } from 'next-i18next' import BaseToolbarButton from './BaseToolbarButton' import { insertImage } from '../helpers' import PremiumFeatureModal from '@/components/Modals/PremiumFeatureModal' diff --git a/packages/web/components/JournalyEditor/Toolbar/Toolbar.tsx b/packages/web/components/JournalyEditor/Toolbar/Toolbar.tsx index 988c0787..c1998195 100644 --- a/packages/web/components/JournalyEditor/Toolbar/Toolbar.tsx +++ b/packages/web/components/JournalyEditor/Toolbar/Toolbar.tsx @@ -30,7 +30,7 @@ import ToolbarButton from './ToolbarButton' import InsertImageButton from './InsertImageButton' import { isTableActive } from '../helpers' import SwitchToggle from '@/components/SwitchToggle' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import useIntersectionObserver from '@/hooks/userIntersectionObserver' type ToolbarProps = { diff --git a/packages/web/components/JournalyEditor/Toolbar/ToolbarButton.tsx b/packages/web/components/JournalyEditor/Toolbar/ToolbarButton.tsx index a6ce18bc..0a1ad485 100644 --- a/packages/web/components/JournalyEditor/Toolbar/ToolbarButton.tsx +++ b/packages/web/components/JournalyEditor/Toolbar/ToolbarButton.tsx @@ -1,7 +1,7 @@ import React, { useCallback } from 'react' import { useSlate } from 'slate-react' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import BaseToolbarButton from './BaseToolbarButton' import { ButtonType, toogleByType, isTypeActive } from '../helpers' diff --git a/packages/web/components/LanguageFormField/LanguageFormField.tsx b/packages/web/components/LanguageFormField/LanguageFormField.tsx index ca625329..08407246 100644 --- a/packages/web/components/LanguageFormField/LanguageFormField.tsx +++ b/packages/web/components/LanguageFormField/LanguageFormField.tsx @@ -11,7 +11,7 @@ import Button, { ButtonVariant } from '@/components/Button' import { OptionPills } from '@/components/MultiSelect' import { languageNameWithDialect } from '@/utils/languages' import theme from '@/theme' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' type Props = { languages: LanguageType[] diff --git a/packages/web/components/LoadingWrapper/LoadingWrapper.tsx b/packages/web/components/LoadingWrapper/LoadingWrapper.tsx index cee56a03..06479eab 100644 --- a/packages/web/components/LoadingWrapper/LoadingWrapper.tsx +++ b/packages/web/components/LoadingWrapper/LoadingWrapper.tsx @@ -1,7 +1,7 @@ import React from 'react' import { ApolloError } from '@apollo/client' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import LoadingSpinner from '@/components/Icons/LoadingSpinner' import theme from '@/theme' diff --git a/packages/web/components/LoginForm/LoginForm.tsx b/packages/web/components/LoginForm/LoginForm.tsx index 52505fd5..eb528485 100644 --- a/packages/web/components/LoginForm/LoginForm.tsx +++ b/packages/web/components/LoginForm/LoginForm.tsx @@ -3,7 +3,7 @@ import Link from 'next/link' import { useRouter } from 'next/router' import { useForm, ErrorMessage } from 'react-hook-form' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import { useLoginUserMutation, CurrentUserDocument, useCurrentUserQuery } from '@/generated/graphql' import FormError from '@/components/FormError' import Button from '@/components/Button' diff --git a/packages/web/components/Modals/ConfirmationModal/ConfirmationModal.tsx b/packages/web/components/Modals/ConfirmationModal/ConfirmationModal.tsx index 5a0ed89b..ff1a3398 100644 --- a/packages/web/components/Modals/ConfirmationModal/ConfirmationModal.tsx +++ b/packages/web/components/Modals/ConfirmationModal/ConfirmationModal.tsx @@ -1,5 +1,5 @@ import React from 'react' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import Button, { ButtonVariant } from '@/components/Button' import Modal from '@/components/Modal' diff --git a/packages/web/components/Modals/ImageUploadModal/ImageUploadModal.tsx b/packages/web/components/Modals/ImageUploadModal/ImageUploadModal.tsx index a1a7950b..b1d7bb66 100644 --- a/packages/web/components/Modals/ImageUploadModal/ImageUploadModal.tsx +++ b/packages/web/components/Modals/ImageUploadModal/ImageUploadModal.tsx @@ -1,5 +1,5 @@ import React, { useState } from 'react' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import Button, { ButtonVariant } from '@/components/Button' import Modal from '@/components/Modal' import theme from '@/theme' diff --git a/packages/web/components/Modals/ImageUploadModal/SearchUnsplash.tsx b/packages/web/components/Modals/ImageUploadModal/SearchUnsplash.tsx index fda65333..89098919 100644 --- a/packages/web/components/Modals/ImageUploadModal/SearchUnsplash.tsx +++ b/packages/web/components/Modals/ImageUploadModal/SearchUnsplash.tsx @@ -4,7 +4,7 @@ import { toast } from 'react-toastify' import { InitiatePostImageUploadResponse } from '@/generated/graphql' import theme from '@/theme' import SearchInput from '@/components/Dashboard/Filters/SearchInput' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' /** * PostEditor diff --git a/packages/web/components/Modals/ImageUploadModal/UploadImage.tsx b/packages/web/components/Modals/ImageUploadModal/UploadImage.tsx index b20bdf68..c8da22c3 100644 --- a/packages/web/components/Modals/ImageUploadModal/UploadImage.tsx +++ b/packages/web/components/Modals/ImageUploadModal/UploadImage.tsx @@ -5,7 +5,7 @@ import { ButtonVariant } from '@/components/Button' import usePostImageUpload from '@/hooks/usePostImageUpload' import { InitiatePostImageUploadResponse } from '@/generated/graphql' import { HTMLInputEvent } from '@/hooks/useImageUpload' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' type UploadImageProps = { onImageSelect: (image: InitiatePostImageUploadResponse | null) => void diff --git a/packages/web/components/Modals/PremiumFeatureModal/PremiumFeatureModal.tsx b/packages/web/components/Modals/PremiumFeatureModal/PremiumFeatureModal.tsx index af70dcdc..0015eb8b 100644 --- a/packages/web/components/Modals/PremiumFeatureModal/PremiumFeatureModal.tsx +++ b/packages/web/components/Modals/PremiumFeatureModal/PremiumFeatureModal.tsx @@ -1,5 +1,5 @@ import React from 'react' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import Button, { ButtonVariant } from '@/components/Button' import Modal from '@/components/Modal' diff --git a/packages/web/components/Modals/WelcomeModal/WelcomeModalBody.tsx b/packages/web/components/Modals/WelcomeModal/WelcomeModalBody.tsx index fa892514..d1c091f2 100644 --- a/packages/web/components/Modals/WelcomeModal/WelcomeModalBody.tsx +++ b/packages/web/components/Modals/WelcomeModal/WelcomeModalBody.tsx @@ -1,5 +1,5 @@ import React from 'react' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import { ApolloQueryResult } from '@apollo/client' import { LanguagesFormDataQuery, diff --git a/packages/web/components/NotificationFeed/NotificationFeed.tsx b/packages/web/components/NotificationFeed/NotificationFeed.tsx index 98040399..3b6ada40 100644 --- a/packages/web/components/NotificationFeed/NotificationFeed.tsx +++ b/packages/web/components/NotificationFeed/NotificationFeed.tsx @@ -17,7 +17,7 @@ import GenericErrorBoundary from '@/components/GenericErrorBoundary' import XIcon from '../Icons/XIcon' import { useNotificationContext } from './NotificationContext' import NotificationLevelTwo from './NotificationLevelTwo' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import useOnClickOut from '@/hooks/useOnClickOut' import { findEventTargetParent } from '@/utils' diff --git a/packages/web/components/NotificationFeed/Notifications.tsx b/packages/web/components/NotificationFeed/Notifications.tsx index 35019d85..230ed045 100644 --- a/packages/web/components/NotificationFeed/Notifications.tsx +++ b/packages/web/components/NotificationFeed/Notifications.tsx @@ -10,7 +10,7 @@ import { import theme from '@/theme' import ClapIcon from '../Icons/ClapIcon' import UserList from '../UserList' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import LikeIcon from '../Icons/LikeIcon' import UserAvatar from '../UserAvatar' import MultiuserAvatar from '../MultiuserAvatar' diff --git a/packages/web/components/Pagination/Pagination.tsx b/packages/web/components/Pagination/Pagination.tsx index 4fe555fe..1738bc65 100644 --- a/packages/web/components/Pagination/Pagination.tsx +++ b/packages/web/components/Pagination/Pagination.tsx @@ -2,7 +2,7 @@ import React from 'react' import Head from 'next/head' import { useRouter } from 'next/router' import Link from 'next/link' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' type Props = { currentPage: number diff --git a/packages/web/components/PostEditor/PostEditor.tsx b/packages/web/components/PostEditor/PostEditor.tsx index 9e11c2b0..1b61e6b9 100644 --- a/packages/web/components/PostEditor/PostEditor.tsx +++ b/packages/web/components/PostEditor/PostEditor.tsx @@ -18,7 +18,7 @@ import { InitiatePostImageUploadResponse, } from '@/generated/graphql' import { languageNameWithDialect } from '@/utils/languages' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import ImageUploadModal from '../Modals/ImageUploadModal' type BasePostData = { diff --git a/packages/web/components/PostHeader/PostHeader.tsx b/packages/web/components/PostHeader/PostHeader.tsx index 58fe8421..5e5acc5c 100644 --- a/packages/web/components/PostHeader/PostHeader.tsx +++ b/packages/web/components/PostHeader/PostHeader.tsx @@ -7,7 +7,7 @@ import { LanguageFragmentFragment as LanguageType, LanguageLevel, } from '@/generated/graphql' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import { formatLongDate } from '@/utils' import theme from '@/theme' diff --git a/packages/web/components/PrivateShareLink/PrivateShareLink.tsx b/packages/web/components/PrivateShareLink/PrivateShareLink.tsx index c867a23e..6ab9df04 100644 --- a/packages/web/components/PrivateShareLink/PrivateShareLink.tsx +++ b/packages/web/components/PrivateShareLink/PrivateShareLink.tsx @@ -3,7 +3,7 @@ import { toast } from 'react-toastify' import Button, { ButtonVariant } from '@/components/Button' import ContentCopyIcon from '../Icons/ContentCopyIcon' import theme from '@/theme' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' type PrivateShareLinkProps = { privateShareId: string diff --git a/packages/web/components/RequestResetPasswordForm/RequestResetPasswordForm.tsx b/packages/web/components/RequestResetPasswordForm/RequestResetPasswordForm.tsx index f7dc2b34..5162522c 100644 --- a/packages/web/components/RequestResetPasswordForm/RequestResetPasswordForm.tsx +++ b/packages/web/components/RequestResetPasswordForm/RequestResetPasswordForm.tsx @@ -4,7 +4,7 @@ import { useRouter } from 'next/router' import { useForm, ErrorMessage } from 'react-hook-form' import { toast } from 'react-toastify' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import { useRequestResetPasswordMutation } from '@/generated/graphql' import FormError from '@/components/FormError' import Button from '@/components/Button' diff --git a/packages/web/components/ResetPasswordForm/ResetPasswordForm.tsx b/packages/web/components/ResetPasswordForm/ResetPasswordForm.tsx index 0ebd6668..dd1827ba 100644 --- a/packages/web/components/ResetPasswordForm/ResetPasswordForm.tsx +++ b/packages/web/components/ResetPasswordForm/ResetPasswordForm.tsx @@ -3,7 +3,7 @@ import { useRouter } from 'next/router' import { useForm, ErrorMessage } from 'react-hook-form' import { toast } from 'react-toastify' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import { useResetPasswordMutation } from '@/generated/graphql' import FormError from '@/components/FormError' import Button from '@/components/Button' diff --git a/packages/web/components/SignupForm/SignupForm.tsx b/packages/web/components/SignupForm/SignupForm.tsx index bbf11819..4f2cf70a 100644 --- a/packages/web/components/SignupForm/SignupForm.tsx +++ b/packages/web/components/SignupForm/SignupForm.tsx @@ -3,7 +3,7 @@ import Link from 'next/link' import { useRouter } from 'next/router' import { useForm, ErrorMessage } from 'react-hook-form' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import { useCreateUserMutation, useCurrentUserQuery } from '@/generated/graphql' import FormError from '@/components/FormError' import Button from '@/components/Button' diff --git a/packages/web/components/Site/Home/FeatureSection.tsx b/packages/web/components/Site/Home/FeatureSection.tsx index 60b30cba..38023187 100644 --- a/packages/web/components/Site/Home/FeatureSection.tsx +++ b/packages/web/components/Site/Home/FeatureSection.tsx @@ -1,4 +1,4 @@ -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import FeatureComparisonTable from '@/components/FeatureComparisonTable' import HomeSection from './HomeSection' diff --git a/packages/web/components/Site/Home/ReasonsSection.tsx b/packages/web/components/Site/Home/ReasonsSection.tsx index 136bcbfa..4d8a4f4e 100644 --- a/packages/web/components/Site/Home/ReasonsSection.tsx +++ b/packages/web/components/Site/Home/ReasonsSection.tsx @@ -1,5 +1,5 @@ import HomeSection from './HomeSection' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' type ReasonCardProps = { image: string diff --git a/packages/web/components/Site/Home/TestimonialsSection.tsx b/packages/web/components/Site/Home/TestimonialsSection.tsx index 41bdd22a..a0815c7b 100644 --- a/packages/web/components/Site/Home/TestimonialsSection.tsx +++ b/packages/web/components/Site/Home/TestimonialsSection.tsx @@ -1,4 +1,4 @@ -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import React from 'react' import HomeSection from './HomeSection' import Testimonial from './Testimonial' diff --git a/packages/web/components/Site/Home/TopSection.tsx b/packages/web/components/Site/Home/TopSection.tsx index acc40b64..cad85357 100644 --- a/packages/web/components/Site/Home/TopSection.tsx +++ b/packages/web/components/Site/Home/TopSection.tsx @@ -1,7 +1,7 @@ import Link from 'next/link' import theme from '@/theme' import Button, { ButtonSize } from '@/components/Button' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' const TopSection = () => { const { t } = useTranslation('common') diff --git a/packages/web/components/Site/Home/VideoSection.tsx b/packages/web/components/Site/Home/VideoSection.tsx index f330a48a..2491abbb 100644 --- a/packages/web/components/Site/Home/VideoSection.tsx +++ b/packages/web/components/Site/Home/VideoSection.tsx @@ -1,4 +1,4 @@ -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import HomeSection from './HomeSection' const VideoSection = () => { diff --git a/packages/web/components/Site/Nav/Nav.tsx b/packages/web/components/Site/Nav/Nav.tsx index 9521ca03..5af650ea 100644 --- a/packages/web/components/Site/Nav/Nav.tsx +++ b/packages/web/components/Site/Nav/Nav.tsx @@ -1,5 +1,5 @@ import { useCurrentUserQuery, User as UserType } from '@/generated/graphql' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import NavLink from '@/components/NavLink' import Logo from '@/components/Logo' import theme from '@/theme' diff --git a/packages/web/components/Site/Pricing/Pricing.tsx b/packages/web/components/Site/Pricing/Pricing.tsx index 488b7e4f..5ae3b3ab 100644 --- a/packages/web/components/Site/Pricing/Pricing.tsx +++ b/packages/web/components/Site/Pricing/Pricing.tsx @@ -1,6 +1,6 @@ import FeatureComparisonTable from '@/components/FeatureComparisonTable' import theme from '@/theme' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' const Pricing = () => { const { t } = useTranslation('settings') diff --git a/packages/web/components/SwipeableElement/SwipeableElement.tsx b/packages/web/components/SwipeableElement/SwipeableElement.tsx index 7084739b..8d680ff0 100644 --- a/packages/web/components/SwipeableElement/SwipeableElement.tsx +++ b/packages/web/components/SwipeableElement/SwipeableElement.tsx @@ -3,7 +3,7 @@ import React, { useRef } from 'react' import Button, { ButtonVariant } from '@/components/Button' import CheckmarkIcon from '../Icons/CheckmarkIcon' import DeleteIcon from '../Icons/DeleteIcon' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' type SwipeableElementProps = { nonDestructiveAction: () => void diff --git a/packages/web/components/UILanguageSelect/UILanguageSelect.tsx b/packages/web/components/UILanguageSelect/UILanguageSelect.tsx index e46c3d88..096583b8 100644 --- a/packages/web/components/UILanguageSelect/UILanguageSelect.tsx +++ b/packages/web/components/UILanguageSelect/UILanguageSelect.tsx @@ -1,6 +1,6 @@ import React from 'react' import { I18nContext } from 'react-i18next' -import { useTranslation, i18n } from '@/config/i18n' +import { useTranslation, i18n } from 'next-i18next' import Select from '@/components/Select' diff --git a/packages/web/hooks/useImageUpload.ts b/packages/web/hooks/useImageUpload.ts index 28fa3941..aa3a72ac 100644 --- a/packages/web/hooks/useImageUpload.ts +++ b/packages/web/hooks/useImageUpload.ts @@ -1,7 +1,7 @@ import React, { useState } from 'react' import { toast } from 'react-toastify' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import { uploadFile, BaseUploadData } from '@/utils/images' export interface HTMLInputEvent extends React.FormEvent { diff --git a/packages/web/hooks/useUILanguage.ts b/packages/web/hooks/useUILanguage.ts index 0c94a686..3300e73d 100644 --- a/packages/web/hooks/useUILanguage.ts +++ b/packages/web/hooks/useUILanguage.ts @@ -14,7 +14,8 @@ export const langCodeToUILangMap: { [key: string]: UILanguage } = { } const useUILanguage = () => { - const { i18n: { language } } = React.useContext(I18nContext) + const { i18n } = React.useContext(I18nContext) + const language = i18n?.language return langCodeToUILangMap[language] || UILanguage.English } diff --git a/packages/web/config/i18n.js b/packages/web/next-i18next.config.js similarity index 55% rename from packages/web/config/i18n.js rename to packages/web/next-i18next.config.js index 8a10539b..98d50f08 100644 --- a/packages/web/config/i18n.js +++ b/packages/web/next-i18next.config.js @@ -1,5 +1,4 @@ const path = require('path') -const NextI18Next = require('next-i18next').default const getLocalePath = () => { if (typeof window === 'undefined') { @@ -14,13 +13,15 @@ const getLocalePath = () => { } } -module.exports = new NextI18Next({ - defaultLanguage: 'en', - // Other languages will be added here once there are translations for them, e.g. ['es', 'de'] - otherLanguages: ['de', 'es', 'zh_CN', 'zh_TW', 'it', 'pt_BR'], - // The "dev" fallback language will show the translation key, indicating there is a missing translation - fallbackLng: process.env.NODE_ENV === 'production' ? 'en' : 'dev', - // Help nexti18next figure out how to load in a serverless env +module.exports = { + i18n: { + // The "dev" fallback language will show the translation key, indicating there is a missing translation + defaultLocale: process.env.NODE_ENV === 'production' ? 'en-US' : 'dev', + // These are all the locales that we support in the application. + // Other languages will be added here once there are translations for them. + locales: ['en-US', 'de', 'es', 'zh_CN', 'zh_TW', 'it', 'pt_BR', 'dev'], + // Help nexti18next figure out how to load in a serverless env + }, localePath: getLocalePath(), ns: [ 'common', @@ -35,4 +36,4 @@ module.exports = new NextI18Next({ 'marketing', ], defaultNS: 'common', -}) +} diff --git a/packages/web/next.config.js b/packages/web/next.config.js index 22445598..fb4d3918 100644 --- a/packages/web/next.config.js +++ b/packages/web/next.config.js @@ -1,7 +1,13 @@ +const { i18n } = require('./next-i18next.config') + const CopyPlugin = require("copy-webpack-plugin") +/** + * @type {import('next').NextConfig} + */ let config = { productionBrowserSourceMaps: true, + i18n, webpack: (config, { isServer }) => { // This is a workaround due to: https://github.com/prisma/prisma/issues/6564 // Should be able to remove this when: https://github.com/prisma/prisma/pull/7931 is merged diff --git a/packages/web/package-lock.json b/packages/web/package-lock.json index 7a14d297..b4b4ddd7 100644 --- a/packages/web/package-lock.json +++ b/packages/web/package-lock.json @@ -42,7 +42,7 @@ "jwt-decode": "^4.0.0", "lodash": "^4.17.20", "next": "^14.2.5", - "next-i18next": "^7.0.1", + "next-i18next": "^15.3.1", "nexus": "^1.0.0", "nexus-plugin-prisma": "^0.35.0", "node-fetch": "^2.6.7", @@ -1362,11 +1362,11 @@ } }, "node_modules/@babel/runtime": { - "version": "7.22.0", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.22.0.tgz", - "integrity": "sha512-TT6NB0oszYQ4oxLNUdG+FNHIc3MohXVCKA2BeyQ4WeM2VCSC6wBZ6P0Yfkdzxv+87D8Xk0LJyHeCKlWMvpZt0g==", + "version": "7.25.6", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.25.6.tgz", + "integrity": "sha512-VBj9MYyDb9tuLq7yzqjgzt6Q+IBQLrGZfdjOekyEirZPHxXWoTSGUTMrpsfi58Up73d13NfYLv8HT9vmznjzhQ==", "dependencies": { - "regenerator-runtime": "^0.13.11" + "regenerator-runtime": "^0.14.0" }, "engines": { "node": ">=6.9.0" @@ -4264,6 +4264,15 @@ "@types/unist": "*" } }, + "node_modules/@types/hoist-non-react-statics": { + "version": "3.3.5", + "resolved": "https://registry.npmjs.org/@types/hoist-non-react-statics/-/hoist-non-react-statics-3.3.5.tgz", + "integrity": "sha512-SbcrWzkKBw2cdwRTwQAswfpB9g9LJWfjtUeW/jvNwbhC8cpmmNYVePa+ncbUe0rGTQ7G3Ff6mYUN2VMfLVr+Sg==", + "dependencies": { + "@types/react": "*", + "hoist-non-react-statics": "^3.3.0" + } + }, "node_modules/@types/http-assert": { "version": "1.5.3", "resolved": "https://registry.npmjs.org/@types/http-assert/-/http-assert-1.5.3.tgz", @@ -7889,9 +7898,9 @@ } }, "node_modules/core-js": { - "version": "3.30.2", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.30.2.tgz", - "integrity": "sha512-uBJiDmwqsbJCWHAwjrx3cvjbMXP7xD72Dmsn5LOJpiRmE3WbBbN5rCqQ2Qh6Ek6/eOrjlWngEynBWo4VxerQhg==", + "version": "3.38.1", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.38.1.tgz", + "integrity": "sha512-OP35aUorbU3Zvlx7pjsFdu1rGNnD4pgw/CWoYzRY3t2EzoVT7shKHY1dlAy3f41cGIO7ZDPQimhGFTlEYkG/Hw==", "hasInstallScript": true, "funding": { "type": "opencollective", @@ -10283,6 +10292,7 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/html-parse-stringify/-/html-parse-stringify-3.0.1.tgz", "integrity": "sha512-KknJ50kTInJ7qIScF3jeaFRpMpE8/lfiTdzf/twXyPBLAGrLRTmkz3AdTnKeh40X8k9L2fdYwEp/42WGXIRGcg==", + "peer": true, "dependencies": { "void-elements": "3.1.0" } @@ -10358,65 +10368,32 @@ "integrity": "sha512-ygGZLjmXfPHj+ZWh6LwbC37l43MhfztxetbFCoYTM2VjkIUpeHgSNn7QIyVFj7YQ1Wl9Cbw5sholVJPzWvC2MQ==" }, "node_modules/i18next": { - "version": "19.9.2", - "resolved": "https://registry.npmjs.org/i18next/-/i18next-19.9.2.tgz", - "integrity": "sha512-0i6cuo6ER6usEOtKajUUDj92zlG+KArFia0857xxiEHAQcUwh/RtOQocui1LPJwunSYT574Pk64aNva1kwtxZg==", - "dependencies": { - "@babel/runtime": "^7.12.0" - } - }, - "node_modules/i18next-browser-languagedetector": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/i18next-browser-languagedetector/-/i18next-browser-languagedetector-5.0.1.tgz", - "integrity": "sha512-7K4A6DJ2rNz3Yd835Y493UgkzUxgpGsCeIMKLGkt6Ps0cbgSaJ+LdATFNFA+ujp2brmsUM9BeDThXKhabXUbUw==", + "version": "23.15.1", + "resolved": "https://registry.npmjs.org/i18next/-/i18next-23.15.1.tgz", + "integrity": "sha512-wB4abZ3uK7EWodYisHl/asf8UYEhrI/vj/8aoSsrj/ZDxj4/UXPOa1KvFt1Fq5hkUHquNqwFlDprmjZ8iySgYA==", + "funding": [ + { + "type": "individual", + "url": "https://locize.com" + }, + { + "type": "individual", + "url": "https://locize.com/i18next.html" + }, + { + "type": "individual", + "url": "https://www.i18next.com/how-to/faq#i18next-is-awesome.-how-can-i-support-the-project" + } + ], + "peer": true, "dependencies": { - "@babel/runtime": "^7.5.5" + "@babel/runtime": "^7.23.2" } }, "node_modules/i18next-fs-backend": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/i18next-fs-backend/-/i18next-fs-backend-1.2.0.tgz", - "integrity": "sha512-pUx3AcgXCbur0jpFA7U67Z2RJflAcIi698Y8VL+phdOqUchahxriV3Cs+M6UkPNQSS/zPEzWLfdJ8EgjB7HVxg==" - }, - "node_modules/i18next-http-backend": { - "version": "1.4.5", - "resolved": "https://registry.npmjs.org/i18next-http-backend/-/i18next-http-backend-1.4.5.tgz", - "integrity": "sha512-tLuHWuLWl6CmS07o+UB6EcQCaUjrZ1yhdseIN7sfq0u7phsMePJ8pqlGhIAdRDPF/q7ooyo5MID5DRFBCH+x5w==", - "dependencies": { - "cross-fetch": "3.1.5" - } - }, - "node_modules/i18next-http-backend/node_modules/cross-fetch": { - "version": "3.1.5", - "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.5.tgz", - "integrity": "sha512-lvb1SBsI0Z7GDwmuid+mU3kWVBwTVUbe7S0H52yaaAdQOXq2YktTCZdlAcNKFzE6QtRz0snpw9bNiPeOIkkQvw==", - "dependencies": { - "node-fetch": "2.6.7" - } - }, - "node_modules/i18next-http-backend/node_modules/node-fetch": { - "version": "2.6.7", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", - "integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==", - "dependencies": { - "whatwg-url": "^5.0.0" - }, - "engines": { - "node": "4.x || >=6.0.0" - }, - "peerDependencies": { - "encoding": "^0.1.0" - }, - "peerDependenciesMeta": { - "encoding": { - "optional": true - } - } - }, - "node_modules/i18next-http-middleware": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/i18next-http-middleware/-/i18next-http-middleware-3.3.1.tgz", - "integrity": "sha512-mWUsdeV9SJSnrcLryUPhc5DZUewOXJd1Gx+UuEZYMtUv/Di4Zzt2I/A92x6/49ZFV2iRZ70oHgQGbqyrArIycw==" + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/i18next-fs-backend/-/i18next-fs-backend-2.3.2.tgz", + "integrity": "sha512-LIwUlkqDZnUI8lnUxBnEj8K/FrHQTT/Sc+1rvDm9E8YvvY5YxzoEAASNx+W5M9DfD5s77lI5vSAFWeTp26B/3Q==" }, "node_modules/iconv-lite": { "version": "0.4.24", @@ -13781,47 +13758,38 @@ } }, "node_modules/next-i18next": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/next-i18next/-/next-i18next-7.0.1.tgz", - "integrity": "sha512-x97lSfB11q/5Flf1Ocz02WoXeIRuVi7oJQ+8p9kNSfoIJExz1nTLPpJmWr2SF8wDxaljzL/kjlETUOyptGhSjQ==", + "version": "15.3.1", + "resolved": "https://registry.npmjs.org/next-i18next/-/next-i18next-15.3.1.tgz", + "integrity": "sha512-+pa2pZJb7B6k5PKW3TLVMmAodqkNaOBWVYlpWX56mgcEJz0UMW+MKSdKM9Z72CHp6Bp48g7OWwDnLqxXNp/84w==", + "funding": [ + { + "type": "individual", + "url": "https://locize.com/i18next.html" + }, + { + "type": "individual", + "url": "https://www.i18next.com/how-to/faq#i18next-is-awesome.-how-can-i-support-the-project" + }, + { + "type": "individual", + "url": "https://locize.com" + } + ], "dependencies": { - "@types/express": "^4.16.1", + "@babel/runtime": "^7.23.2", + "@types/hoist-non-react-statics": "^3.3.4", "core-js": "^3", - "hoist-non-react-statics": "^3.2.0", - "i18next": "^19.6.3", - "i18next-browser-languagedetector": "^5.0.0", - "i18next-fs-backend": "^1.0.7", - "i18next-http-backend": "^1.0.17", - "i18next-http-middleware": "^3.0.2", - "path-match": "^1.2.4", - "prop-types": "^15.6.2", - "react-i18next": "^11.7.3", - "url": "^0.11.0" + "hoist-non-react-statics": "^3.3.2", + "i18next-fs-backend": "^2.3.2" }, "engines": { - "node": ">=10" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/isaachinman" + "node": ">=14" }, "peerDependencies": { - "next": ">= 9.5.0", - "react": ">= 16.8.0" - } - }, - "node_modules/next-i18next/node_modules/punycode": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", - "integrity": "sha512-RofWgt/7fL5wP1Y7fxE7/EmTLzQVnB0ycyibJ0OOHIlJqTNzglYFxVwETOcIoJqJmpDXJ9xImDv+Fq34F/d4Dw==" - }, - "node_modules/next-i18next/node_modules/url": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/url/-/url-0.11.0.tgz", - "integrity": "sha512-kbailJa29QrtXnxgq+DdCEGlbTeYM2eJUxsz6vjZavrCYPMIFHMKQmSKYAIuUK2i7hgPm28a8piX5NTUtM/LKQ==", - "dependencies": { - "punycode": "1.3.2", - "querystring": "0.2.0" + "i18next": ">= 23.7.13", + "next": ">= 12.0.0", + "react": ">= 17.0.2", + "react-i18next": ">= 13.5.0" } }, "node_modules/nexus": { @@ -14449,53 +14417,6 @@ "node": ">=8" } }, - "node_modules/path-match": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/path-match/-/path-match-1.2.4.tgz", - "integrity": "sha512-UWlehEdqu36jmh4h5CWJ7tARp1OEVKGHKm6+dg9qMq5RKUTV5WJrGgaZ3dN2m7WFAXDbjlHzvJvL/IUpy84Ktw==", - "dependencies": { - "http-errors": "~1.4.0", - "path-to-regexp": "^1.0.0" - } - }, - "node_modules/path-match/node_modules/http-errors": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.4.0.tgz", - "integrity": "sha512-oLjPqve1tuOl5aRhv8GK5eHpqP1C9fb+Ol+XTLjKfLltE44zdDbEdjPSbU7Ch5rSNsVFqZn97SrMmZLdu1/YMw==", - "dependencies": { - "inherits": "2.0.1", - "statuses": ">= 1.2.1 < 2" - }, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/path-match/node_modules/inherits": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", - "integrity": "sha512-8nWq2nLTAwd02jTqJExUYFSD/fKq6VH9Y/oG2accc/kdI0V98Bag8d5a4gi3XHz73rDWa2PvTtvcWYquKqSENA==" - }, - "node_modules/path-match/node_modules/isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==" - }, - "node_modules/path-match/node_modules/path-to-regexp": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.8.0.tgz", - "integrity": "sha512-n43JRhlUKUAlibEJhPeir1ncUID16QnEjNpwzNdO3Lm4ywrBpBZ5oLD0I6br9evr1Y9JTqwRtAh7JLoOzAQdVA==", - "dependencies": { - "isarray": "0.0.1" - } - }, - "node_modules/path-match/node_modules/statuses": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", - "integrity": "sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA==", - "engines": { - "node": ">= 0.6" - } - }, "node_modules/path-parse": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", @@ -15042,15 +14963,16 @@ } }, "node_modules/react-i18next": { - "version": "11.18.6", - "resolved": "https://registry.npmjs.org/react-i18next/-/react-i18next-11.18.6.tgz", - "integrity": "sha512-yHb2F9BiT0lqoQDt8loZ5gWP331GwctHz9tYQ8A2EIEUu+CcEdjBLQWli1USG3RdWQt3W+jqQLg/d4rrQR96LA==", + "version": "15.0.2", + "resolved": "https://registry.npmjs.org/react-i18next/-/react-i18next-15.0.2.tgz", + "integrity": "sha512-z0W3/RES9Idv3MmJUcf0mDNeeMOUXe+xoL0kPfQPbDoZHmni/XsIoq5zgT2MCFUiau283GuBUK578uD/mkAbLQ==", + "peer": true, "dependencies": { - "@babel/runtime": "^7.14.5", + "@babel/runtime": "^7.25.0", "html-parse-stringify": "^3.0.1" }, "peerDependencies": { - "i18next": ">= 19.0.0", + "i18next": ">= 23.2.3", "react": ">= 16.8.0" }, "peerDependenciesMeta": { @@ -15366,9 +15288,9 @@ } }, "node_modules/regenerator-runtime": { - "version": "0.13.11", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz", - "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==" + "version": "0.14.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz", + "integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==" }, "node_modules/regexp.prototype.flags": { "version": "1.5.0", @@ -18211,6 +18133,7 @@ "version": "3.1.0", "resolved": "https://registry.npmjs.org/void-elements/-/void-elements-3.1.0.tgz", "integrity": "sha512-Dhxzh5HZuiHQhbvTW9AMetFfBHDMYpo23Uo9btPXgdYP+3T5S+p+jgNy7spra+veYhBP2dCSgxR/i2Y02h5/6w==", + "peer": true, "engines": { "node": ">=0.10.0" } @@ -19600,11 +19523,11 @@ } }, "@babel/runtime": { - "version": "7.22.0", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.22.0.tgz", - "integrity": "sha512-TT6NB0oszYQ4oxLNUdG+FNHIc3MohXVCKA2BeyQ4WeM2VCSC6wBZ6P0Yfkdzxv+87D8Xk0LJyHeCKlWMvpZt0g==", + "version": "7.25.6", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.25.6.tgz", + "integrity": "sha512-VBj9MYyDb9tuLq7yzqjgzt6Q+IBQLrGZfdjOekyEirZPHxXWoTSGUTMrpsfi58Up73d13NfYLv8HT9vmznjzhQ==", "requires": { - "regenerator-runtime": "^0.13.11" + "regenerator-runtime": "^0.14.0" } }, "@babel/template": { @@ -21726,6 +21649,15 @@ "@types/unist": "*" } }, + "@types/hoist-non-react-statics": { + "version": "3.3.5", + "resolved": "https://registry.npmjs.org/@types/hoist-non-react-statics/-/hoist-non-react-statics-3.3.5.tgz", + "integrity": "sha512-SbcrWzkKBw2cdwRTwQAswfpB9g9LJWfjtUeW/jvNwbhC8cpmmNYVePa+ncbUe0rGTQ7G3Ff6mYUN2VMfLVr+Sg==", + "requires": { + "@types/react": "*", + "hoist-non-react-statics": "^3.3.0" + } + }, "@types/http-assert": { "version": "1.5.3", "resolved": "https://registry.npmjs.org/@types/http-assert/-/http-assert-1.5.3.tgz", @@ -24377,9 +24309,9 @@ } }, "core-js": { - "version": "3.30.2", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.30.2.tgz", - "integrity": "sha512-uBJiDmwqsbJCWHAwjrx3cvjbMXP7xD72Dmsn5LOJpiRmE3WbBbN5rCqQ2Qh6Ek6/eOrjlWngEynBWo4VxerQhg==" + "version": "3.38.1", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.38.1.tgz", + "integrity": "sha512-OP35aUorbU3Zvlx7pjsFdu1rGNnD4pgw/CWoYzRY3t2EzoVT7shKHY1dlAy3f41cGIO7ZDPQimhGFTlEYkG/Hw==" }, "core-js-pure": { "version": "3.30.2", @@ -26202,6 +26134,7 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/html-parse-stringify/-/html-parse-stringify-3.0.1.tgz", "integrity": "sha512-KknJ50kTInJ7qIScF3jeaFRpMpE8/lfiTdzf/twXyPBLAGrLRTmkz3AdTnKeh40X8k9L2fdYwEp/42WGXIRGcg==", + "peer": true, "requires": { "void-elements": "3.1.0" } @@ -26261,56 +26194,18 @@ "integrity": "sha512-ygGZLjmXfPHj+ZWh6LwbC37l43MhfztxetbFCoYTM2VjkIUpeHgSNn7QIyVFj7YQ1Wl9Cbw5sholVJPzWvC2MQ==" }, "i18next": { - "version": "19.9.2", - "resolved": "https://registry.npmjs.org/i18next/-/i18next-19.9.2.tgz", - "integrity": "sha512-0i6cuo6ER6usEOtKajUUDj92zlG+KArFia0857xxiEHAQcUwh/RtOQocui1LPJwunSYT574Pk64aNva1kwtxZg==", - "requires": { - "@babel/runtime": "^7.12.0" - } - }, - "i18next-browser-languagedetector": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/i18next-browser-languagedetector/-/i18next-browser-languagedetector-5.0.1.tgz", - "integrity": "sha512-7K4A6DJ2rNz3Yd835Y493UgkzUxgpGsCeIMKLGkt6Ps0cbgSaJ+LdATFNFA+ujp2brmsUM9BeDThXKhabXUbUw==", + "version": "23.15.1", + "resolved": "https://registry.npmjs.org/i18next/-/i18next-23.15.1.tgz", + "integrity": "sha512-wB4abZ3uK7EWodYisHl/asf8UYEhrI/vj/8aoSsrj/ZDxj4/UXPOa1KvFt1Fq5hkUHquNqwFlDprmjZ8iySgYA==", + "peer": true, "requires": { - "@babel/runtime": "^7.5.5" + "@babel/runtime": "^7.23.2" } }, "i18next-fs-backend": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/i18next-fs-backend/-/i18next-fs-backend-1.2.0.tgz", - "integrity": "sha512-pUx3AcgXCbur0jpFA7U67Z2RJflAcIi698Y8VL+phdOqUchahxriV3Cs+M6UkPNQSS/zPEzWLfdJ8EgjB7HVxg==" - }, - "i18next-http-backend": { - "version": "1.4.5", - "resolved": "https://registry.npmjs.org/i18next-http-backend/-/i18next-http-backend-1.4.5.tgz", - "integrity": "sha512-tLuHWuLWl6CmS07o+UB6EcQCaUjrZ1yhdseIN7sfq0u7phsMePJ8pqlGhIAdRDPF/q7ooyo5MID5DRFBCH+x5w==", - "requires": { - "cross-fetch": "3.1.5" - }, - "dependencies": { - "cross-fetch": { - "version": "3.1.5", - "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.5.tgz", - "integrity": "sha512-lvb1SBsI0Z7GDwmuid+mU3kWVBwTVUbe7S0H52yaaAdQOXq2YktTCZdlAcNKFzE6QtRz0snpw9bNiPeOIkkQvw==", - "requires": { - "node-fetch": "2.6.7" - } - }, - "node-fetch": { - "version": "2.6.7", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", - "integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==", - "requires": { - "whatwg-url": "^5.0.0" - } - } - } - }, - "i18next-http-middleware": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/i18next-http-middleware/-/i18next-http-middleware-3.3.1.tgz", - "integrity": "sha512-mWUsdeV9SJSnrcLryUPhc5DZUewOXJd1Gx+UuEZYMtUv/Di4Zzt2I/A92x6/49ZFV2iRZ70oHgQGbqyrArIycw==" + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/i18next-fs-backend/-/i18next-fs-backend-2.3.2.tgz", + "integrity": "sha512-LIwUlkqDZnUI8lnUxBnEj8K/FrHQTT/Sc+1rvDm9E8YvvY5YxzoEAASNx+W5M9DfD5s77lI5vSAFWeTp26B/3Q==" }, "iconv-lite": { "version": "0.4.24", @@ -28633,38 +28528,15 @@ } }, "next-i18next": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/next-i18next/-/next-i18next-7.0.1.tgz", - "integrity": "sha512-x97lSfB11q/5Flf1Ocz02WoXeIRuVi7oJQ+8p9kNSfoIJExz1nTLPpJmWr2SF8wDxaljzL/kjlETUOyptGhSjQ==", + "version": "15.3.1", + "resolved": "https://registry.npmjs.org/next-i18next/-/next-i18next-15.3.1.tgz", + "integrity": "sha512-+pa2pZJb7B6k5PKW3TLVMmAodqkNaOBWVYlpWX56mgcEJz0UMW+MKSdKM9Z72CHp6Bp48g7OWwDnLqxXNp/84w==", "requires": { - "@types/express": "^4.16.1", + "@babel/runtime": "^7.23.2", + "@types/hoist-non-react-statics": "^3.3.4", "core-js": "^3", - "hoist-non-react-statics": "^3.2.0", - "i18next": "^19.6.3", - "i18next-browser-languagedetector": "^5.0.0", - "i18next-fs-backend": "^1.0.7", - "i18next-http-backend": "^1.0.17", - "i18next-http-middleware": "^3.0.2", - "path-match": "^1.2.4", - "prop-types": "^15.6.2", - "react-i18next": "^11.7.3", - "url": "^0.11.0" - }, - "dependencies": { - "punycode": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", - "integrity": "sha512-RofWgt/7fL5wP1Y7fxE7/EmTLzQVnB0ycyibJ0OOHIlJqTNzglYFxVwETOcIoJqJmpDXJ9xImDv+Fq34F/d4Dw==" - }, - "url": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/url/-/url-0.11.0.tgz", - "integrity": "sha512-kbailJa29QrtXnxgq+DdCEGlbTeYM2eJUxsz6vjZavrCYPMIFHMKQmSKYAIuUK2i7hgPm28a8piX5NTUtM/LKQ==", - "requires": { - "punycode": "1.3.2", - "querystring": "0.2.0" - } - } + "hoist-non-react-statics": "^3.3.2", + "i18next-fs-backend": "^2.3.2" } }, "nexus": { @@ -29118,49 +28990,6 @@ "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==" }, - "path-match": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/path-match/-/path-match-1.2.4.tgz", - "integrity": "sha512-UWlehEdqu36jmh4h5CWJ7tARp1OEVKGHKm6+dg9qMq5RKUTV5WJrGgaZ3dN2m7WFAXDbjlHzvJvL/IUpy84Ktw==", - "requires": { - "http-errors": "~1.4.0", - "path-to-regexp": "^1.0.0" - }, - "dependencies": { - "http-errors": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.4.0.tgz", - "integrity": "sha512-oLjPqve1tuOl5aRhv8GK5eHpqP1C9fb+Ol+XTLjKfLltE44zdDbEdjPSbU7Ch5rSNsVFqZn97SrMmZLdu1/YMw==", - "requires": { - "inherits": "2.0.1", - "statuses": ">= 1.2.1 < 2" - } - }, - "inherits": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", - "integrity": "sha512-8nWq2nLTAwd02jTqJExUYFSD/fKq6VH9Y/oG2accc/kdI0V98Bag8d5a4gi3XHz73rDWa2PvTtvcWYquKqSENA==" - }, - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==" - }, - "path-to-regexp": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.8.0.tgz", - "integrity": "sha512-n43JRhlUKUAlibEJhPeir1ncUID16QnEjNpwzNdO3Lm4ywrBpBZ5oLD0I6br9evr1Y9JTqwRtAh7JLoOzAQdVA==", - "requires": { - "isarray": "0.0.1" - } - }, - "statuses": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", - "integrity": "sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA==" - } - } - }, "path-parse": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", @@ -29533,11 +29362,12 @@ "requires": {} }, "react-i18next": { - "version": "11.18.6", - "resolved": "https://registry.npmjs.org/react-i18next/-/react-i18next-11.18.6.tgz", - "integrity": "sha512-yHb2F9BiT0lqoQDt8loZ5gWP331GwctHz9tYQ8A2EIEUu+CcEdjBLQWli1USG3RdWQt3W+jqQLg/d4rrQR96LA==", + "version": "15.0.2", + "resolved": "https://registry.npmjs.org/react-i18next/-/react-i18next-15.0.2.tgz", + "integrity": "sha512-z0W3/RES9Idv3MmJUcf0mDNeeMOUXe+xoL0kPfQPbDoZHmni/XsIoq5zgT2MCFUiau283GuBUK578uD/mkAbLQ==", + "peer": true, "requires": { - "@babel/runtime": "^7.14.5", + "@babel/runtime": "^7.25.0", "html-parse-stringify": "^3.0.1" } }, @@ -29738,9 +29568,9 @@ } }, "regenerator-runtime": { - "version": "0.13.11", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz", - "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==" + "version": "0.14.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz", + "integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==" }, "regexp.prototype.flags": { "version": "1.5.0", @@ -31807,7 +31637,8 @@ "void-elements": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/void-elements/-/void-elements-3.1.0.tgz", - "integrity": "sha512-Dhxzh5HZuiHQhbvTW9AMetFfBHDMYpo23Uo9btPXgdYP+3T5S+p+jgNy7spra+veYhBP2dCSgxR/i2Y02h5/6w==" + "integrity": "sha512-Dhxzh5HZuiHQhbvTW9AMetFfBHDMYpo23Uo9btPXgdYP+3T5S+p+jgNy7spra+veYhBP2dCSgxR/i2Y02h5/6w==", + "peer": true }, "walker": { "version": "1.0.8", diff --git a/packages/web/package.json b/packages/web/package.json index 9c6b3813..c7f7fabd 100644 --- a/packages/web/package.json +++ b/packages/web/package.json @@ -71,7 +71,7 @@ "jwt-decode": "^4.0.0", "lodash": "^4.17.20", "next": "^14.2.5", - "next-i18next": "^7.0.1", + "next-i18next": "^15.3.1", "nexus": "^1.0.0", "nexus-plugin-prisma": "^0.35.0", "node-fetch": "^2.6.7", diff --git a/packages/web/pages/_app.tsx b/packages/web/pages/_app.tsx index b4b827d8..09641694 100644 --- a/packages/web/pages/_app.tsx +++ b/packages/web/pages/_app.tsx @@ -1,10 +1,10 @@ import React from 'react' -import App from 'next/app' +import {AppProps} from 'next/app' import Head from 'next/head' -import Router, { withRouter } from 'next/router' +import Router from 'next/router' import NProgress from 'nprogress' import { ToastContainer } from 'react-toastify' -import nexti18Next from '@/config/i18n' +import {appWithTranslation} from 'next-i18next' import GoogleAnalytics from '@/components/GoogleAnalytics' @@ -20,11 +20,10 @@ import { initApolloClient } from '@/lib/apollo' Router.events.on('routeChangeStart', () => NProgress.start()) Router.events.on('routeChangeError', () => NProgress.done()) Router.events.on('routeChangeComplete', () => NProgress.done()) -class JournalyApp extends App { - componentDidMount() {} - render() { - const { Component, pageProps } = this.props +const JournalyApp = (props: AppProps) => { + const { Component, pageProps } = props + const client = initApolloClient(pageProps.apolloState) return ( @@ -39,7 +38,6 @@ class JournalyApp extends App { ) - } } -export default nexti18Next.appWithTranslation(withRouter(JournalyApp)) +export default appWithTranslation(JournalyApp) diff --git a/packages/web/pages/_document.tsx b/packages/web/pages/_document.tsx index 7afae5f1..481af7e8 100644 --- a/packages/web/pages/_document.tsx +++ b/packages/web/pages/_document.tsx @@ -8,7 +8,7 @@ import Document, { DocumentProps, } from 'next/document' -import { i18n } from '@/config/i18n' +import { i18n } from 'next-i18next' interface CustomProps { language: string @@ -19,7 +19,7 @@ class MyDocument extends Document = ({ statusCode }) => { diff --git a/packages/web/pages/my-posts.tsx b/packages/web/pages/my-posts.tsx index 03cbd1df..27bf2f0b 100644 --- a/packages/web/pages/my-posts.tsx +++ b/packages/web/pages/my-posts.tsx @@ -10,7 +10,7 @@ import { PostsDocument, } from '@/generated/graphql' import theme from '@/theme' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import { journalyMiddleware } from '@/lib/journalyMiddleware' import { NUM_POSTS_PER_MY_POSTS_PAGE } from '@/constants' import { getCurrentUserId } from '@/utils/getCurrentUserId' diff --git a/packages/web/pages/new-post.tsx b/packages/web/pages/new-post.tsx index 2daae7f6..3b8ae2be 100644 --- a/packages/web/pages/new-post.tsx +++ b/packages/web/pages/new-post.tsx @@ -21,7 +21,7 @@ import { NewPostDocument, } from '@/generated/graphql' import AuthGate from '@/components/AuthGate' -import { useTranslation, Router } from '@/config/i18n' +import { useTranslation, Router } from 'next-i18next' import useUILanguage from '@/hooks/useUILanguage' import useUploadInlineImages from '@/hooks/useUploadInlineImages' import PremiumFeatureModal from '@/components/Modals/PremiumFeatureModal' diff --git a/packages/web/pages/post/[id]/edit.tsx b/packages/web/pages/post/[id]/edit.tsx index f5ba80c3..c954856e 100644 --- a/packages/web/pages/post/[id]/edit.tsx +++ b/packages/web/pages/post/[id]/edit.tsx @@ -1,7 +1,7 @@ import React from 'react' import { NextPage } from 'next' import { useRouter } from 'next/router' -import { useTranslation } from '@/config/i18n' +import { useTranslation } from 'next-i18next' import { TElement } from '@udecode/plate' import DashboardLayout from '@/components/Layouts/DashboardLayout' diff --git a/packages/web/server/index.js b/packages/web/server/index.js index a275aefc..e230ff53 100644 --- a/packages/web/server/index.js +++ b/packages/web/server/index.js @@ -1,6 +1,7 @@ const express = require('express') const next = require('next') -const nextI18next = require('../config/i18n') +// const nextI18next = require('../next-i18next.config') +const nextI18next = require('next-i18next') const port = parseInt(process.env.PORT || '3000', 10) const dev = process.env.NODE_ENV !== 'production' diff --git a/packages/web/utils/getUiLanguage.ts b/packages/web/utils/getUiLanguage.ts index e069f3d7..97e09d3b 100644 --- a/packages/web/utils/getUiLanguage.ts +++ b/packages/web/utils/getUiLanguage.ts @@ -1,7 +1,7 @@ import { NextPageContext } from 'next' import { langCodeToUILangMap } from '@/hooks/useUILanguage' import { UiLanguage } from '@/generated/graphql' -import i18nConfig from '@/config/i18n' +import i18nConfig from 'next-i18next' export const getUiLanguage = (ctx: NextPageContext): UiLanguage => { let langCode @@ -20,7 +20,7 @@ export const getUiLanguage = (ctx: NextPageContext): UiLanguage => { } } } else { - langCode = i18nConfig.i18n.language + langCode = i18nConfig?.i18n?.language } return langCodeToUILangMap[langCode] || UiLanguage.English