feat: fix next-intl bugs

This commit is contained in:
SD 2024-07-02 19:47:28 +04:00
parent 035286823e
commit 456e2a7cdf
22 changed files with 6302 additions and 3588 deletions

View File

@ -1,3 +1,8 @@
node_modules/ node_modules/
.next .next
.idea .idea
Dockerfile
.dockerignore
npm-debug.log
README.md
.git

View File

@ -1,13 +1,13 @@
FROM node:20.10.0 as dependencies FROM node:20.10.0 as dependencies
WORKDIR /app WORKDIR /app
COPY package.json yarn.lock ./ COPY package.json package-lock.json ./
RUN yarn install --frozen-lockfile RUN npm ci --verbose
FROM node:20.10.0 as builder FROM node:20.10.0 as builder
WORKDIR /app WORKDIR /app
COPY . . COPY . .
COPY --from=dependencies /app/node_modules ./node_modules COPY --from=dependencies /app/node_modules ./node_modules
RUN yarn build RUN npm run build --debug --verbose
FROM node:20.10.0 as runner FROM node:20.10.0 as runner
WORKDIR /app WORKDIR /app
@ -20,4 +20,4 @@ COPY --from=builder /app/.next ./.next
COPY --from=dependencies /app/node_modules ./node_modules COPY --from=dependencies /app/node_modules ./node_modules
EXPOSE 4200 EXPOSE 4200
CMD ["yarn", "start"] CMD ["npm", "start"]

34
Dockerfile_standalone Normal file
View File

@ -0,0 +1,34 @@
FROM node:18-alpine AS base
FROM base AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN yarn build
FROM base AS runner
WORKDIR /app
ENV NODE_ENV production
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
COPY --from=builder /app/public ./public
RUN mkdir .next
RUN chown nextjs:nodejs .next
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
USER nextjs
EXPOSE 4200
ENV PORT 4200
CMD HOSTNAME="0.0.0.0" node server.js

View File

@ -28,6 +28,7 @@ const nextConfig = {
taint: true, taint: true,
// typedRoutes: true // typedRoutes: true
}, },
// output: 'standalone',
poweredByHeader: false, poweredByHeader: false,
productionBrowserSourceMaps: true, productionBrowserSourceMaps: true,
trailingSlash: true trailingSlash: true

6215
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,9 @@
import React from 'react'; import React from 'react';
import { unstable_setRequestLocale } from 'next-intl/server';
export default function Directions({ params: { locale } }: { params: { locale: string } }) {
unstable_setRequestLocale(locale);
export default function Directions() {
return ( return (
<div className="main-popular"> <div className="main-popular">
<div className="b-inner"> <div className="b-inner">

View File

@ -1,8 +1,10 @@
import React from 'react'; import React from 'react';
import { unstable_setRequestLocale } from 'next-intl/server';
import { useTranslations } from 'next-intl'; import { useTranslations } from 'next-intl';
import { Experts } from '../../../../components/Experts/Experts'; import { Experts } from '../../../../components/Experts/Experts';
export default function ExpertsPage({ params }: { params: { locale: string } }) { export default function ExpertsPage({ params: { locale } }: { params: { locale: string } }) {
unstable_setRequestLocale(locale);
const t = useTranslations('Experts'); const t = useTranslations('Experts');
return ( return (
@ -14,7 +16,7 @@ export default function ExpertsPage({ params }: { params: { locale: string } })
<img src="/images/options-outline.svg" className="" alt=""/> <img src="/images/options-outline.svg" className="" alt=""/>
</div> </div>
</div> </div>
<Experts locale={params.locale} /> <Experts locale={locale} />
</div> </div>
</div> </div>
); );

View File

@ -1,5 +1,6 @@
import React from 'react'; import React from 'react';
import type { Metadata } from 'next'; import type { Metadata } from 'next';
import { unstable_setRequestLocale } from 'next-intl/server';
import { useTranslations } from 'next-intl'; import { useTranslations } from 'next-intl';
import { i18nText } from '../../../../../i18nKeys'; import { i18nText } from '../../../../../i18nKeys';
@ -9,6 +10,7 @@ export const metadata: Metadata = {
}; };
export default function Information({ params: { locale } }: { params: { locale: string } }) { export default function Information({ params: { locale } }: { params: { locale: string } }) {
unstable_setRequestLocale(locale);
const t = useTranslations('Account.LegalInformation'); const t = useTranslations('Account.LegalInformation');
return ( return (

View File

@ -1,5 +1,5 @@
import React from 'react'; import React from 'react';
import { useTranslations } from 'next-intl'; import { unstable_setRequestLocale } from 'next-intl/server';
import { Link } from '../../../../../../navigation'; import { Link } from '../../../../../../navigation';
import { i18nText } from '../../../../../../i18nKeys'; import { i18nText } from '../../../../../../i18nKeys';
@ -17,7 +17,7 @@ export function generateStaticParams({
} }
export default function Message({ params }: { params: { locale: string, textId: string } }) { export default function Message({ params }: { params: { locale: string, textId: string } }) {
const t = useTranslations('Account.Messages'); unstable_setRequestLocale(params.locale);
return ( return (
<> <>

View File

@ -1,11 +1,12 @@
'use client'
import React, { Suspense } from 'react'; import React, { Suspense } from 'react';
import { unstable_setRequestLocale } from 'next-intl/server';
import { Link } from '../../../../../navigation'; import { Link } from '../../../../../navigation';
import { CustomInput } from '../../../../../components/view/CustomInput'; import { CustomInput } from '../../../../../components/view/CustomInput';
import { i18nText } from '../../../../../i18nKeys'; import { i18nText } from '../../../../../i18nKeys';
export default function Messages({ params: { locale } }: { params: { locale: string } }) { export default function Messages({ params: { locale } }: { params: { locale: string } }) {
unstable_setRequestLocale(locale);
return ( return (
<> <>
<ol className="breadcrumb"> <ol className="breadcrumb">

View File

@ -1,5 +1,6 @@
import React from 'react'; import React from 'react';
import type { Metadata } from 'next'; import type { Metadata } from 'next';
import { unstable_setRequestLocale } from 'next-intl/server';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import 'dayjs/locale/ru'; import 'dayjs/locale/ru';
import 'dayjs/locale/en'; import 'dayjs/locale/en';
@ -15,6 +16,7 @@ export const metadata: Metadata = {
}; };
export default function Notifications({ params: { locale } }: { params: { locale: string } }) { export default function Notifications({ params: { locale } }: { params: { locale: string } }) {
unstable_setRequestLocale(locale);
const date = dayjs('2022-05-22').locale(locale); const date = dayjs('2022-05-22').locale(locale);
return ( return (

View File

@ -1,8 +1,11 @@
import React from 'react'; import React from 'react';
import { unstable_setRequestLocale } from 'next-intl/server';
import { Link } from '../../../../../../navigation'; import { Link } from '../../../../../../navigation';
import { i18nText } from '../../../../../../i18nKeys/'; import { i18nText } from '../../../../../../i18nKeys/';
export default function ChangePassword({ params: { locale } }: { params: { locale: string } }) { export default function ChangePassword({ params: { locale } }: { params: { locale: string } }) {
unstable_setRequestLocale(locale);
return ( return (
<> <>
<ol className="breadcrumb"> <ol className="breadcrumb">

View File

@ -1,5 +1,6 @@
import React, { Suspense } from 'react'; import React, { Suspense } from 'react';
import type { Metadata } from 'next'; import type { Metadata } from 'next';
import { unstable_setRequestLocale } from 'next-intl/server';
import { useTranslations } from 'next-intl'; import { useTranslations } from 'next-intl';
import { ProfileSettings } from '../../../../../components/Account'; import { ProfileSettings } from '../../../../../components/Account';
import { i18nText } from '../../../../../i18nKeys'; import { i18nText } from '../../../../../i18nKeys';
@ -10,6 +11,7 @@ export const metadata: Metadata = {
}; };
export default function Settings({ params: { locale } }: { params: { locale: string } }) { export default function Settings({ params: { locale } }: { params: { locale: string } }) {
unstable_setRequestLocale(locale);
const t = useTranslations('Account.Settings'); const t = useTranslations('Account.Settings');
return ( return (

View File

@ -1,4 +1,5 @@
import React from 'react'; import React from 'react';
import { unstable_setRequestLocale } from 'next-intl/server';
import type { Metadata } from 'next'; import type { Metadata } from 'next';
import { i18nText } from '../../../../../i18nKeys'; import { i18nText } from '../../../../../i18nKeys';
@ -8,6 +9,8 @@ export const metadata: Metadata = {
}; };
export default function Support({ params: { locale } }: { params: { locale: string } }) { export default function Support({ params: { locale } }: { params: { locale: string } }) {
unstable_setRequestLocale(locale);
return ( return (
<> <>
<ol className="breadcrumb"> <ol className="breadcrumb">

View File

@ -1,5 +1,6 @@
import React from 'react'; import React from 'react';
import type { Metadata } from 'next'; import type { Metadata } from 'next';
import { unstable_setRequestLocale } from 'next-intl/server';
import { useTranslations } from 'next-intl'; import { useTranslations } from 'next-intl';
import { i18nText } from '../../../../../i18nKeys'; import { i18nText } from '../../../../../i18nKeys';
@ -9,6 +10,7 @@ export const metadata: Metadata = {
}; };
export default function WorkWithUs({ params: { locale } }: { params: { locale: string } }) { export default function WorkWithUs({ params: { locale } }: { params: { locale: string } }) {
unstable_setRequestLocale(locale);
const t = useTranslations('Account.WorkWithUs'); const t = useTranslations('Account.WorkWithUs');
return ( return (

View File

@ -1,4 +1,5 @@
import React, { Suspense } from 'react'; import React, { Suspense } from 'react';
import { unstable_setRequestLocale } from 'next-intl/server';
import { notFound } from 'next/navigation'; import { notFound } from 'next/navigation';
import { AccountMenu, SessionDetails, SessionsTabs } from '../../../../../../components/Account'; import { AccountMenu, SessionDetails, SessionsTabs } from '../../../../../../components/Account';
import { SessionType } from '../../../../../../types/sessions'; import { SessionType } from '../../../../../../types/sessions';
@ -12,6 +13,7 @@ export async function generateStaticParams({
} }
export default function SessionDetailItem({ params: { locale, slug } }: { params: { locale: string, slug?: string[] } }) { export default function SessionDetailItem({ params: { locale, slug } }: { params: { locale: string, slug?: string[] } }) {
unstable_setRequestLocale(locale);
const sessionType: string = slug?.length > 0 && slug[0] || ''; const sessionType: string = slug?.length > 0 && slug[0] || '';
const sessionId: number | null = slug?.length > 1 && Number(slug[1]) || null; const sessionId: number | null = slug?.length > 1 && Number(slug[1]) || null;

View File

@ -1,5 +1,6 @@
import React from 'react'; import React from 'react';
import type { Metadata } from 'next'; import type { Metadata } from 'next';
import { unstable_setRequestLocale } from 'next-intl/server';
import { useTranslations } from 'next-intl'; import { useTranslations } from 'next-intl';
import { GeneralTopSection } from '../../../components/Page'; import { GeneralTopSection } from '../../../components/Page';
@ -8,7 +9,8 @@ export const metadata: Metadata = {
description: 'Bbuddy desc Take the lead with BB' description: 'Bbuddy desc Take the lead with BB'
}; };
export default function BbClientPage() { export default function BbClientPage({ params: { locale } }: { params: { locale: string } }) {
unstable_setRequestLocale(locale);
const t = useTranslations('BbClient'); const t = useTranslations('BbClient');
return ( return (

View File

@ -1,5 +1,6 @@
import React from 'react'; import React from 'react';
import type { Metadata } from 'next'; import type { Metadata } from 'next';
import { unstable_setRequestLocale } from 'next-intl/server';
import { useTranslations } from 'next-intl'; import { useTranslations } from 'next-intl';
import { GeneralTopSection } from '../../../components/Page'; import { GeneralTopSection } from '../../../components/Page';
import { ScreenCarousel } from '../../../components/Page/ScreenCarousel/index'; import { ScreenCarousel } from '../../../components/Page/ScreenCarousel/index';
@ -9,7 +10,8 @@ export const metadata: Metadata = {
description: 'Bbuddy desc Become a BB expert' description: 'Bbuddy desc Become a BB expert'
}; };
export default function BbExpertPage() { export default function BbExpertPage({ params: { locale } }: { params: { locale: string } }) {
unstable_setRequestLocale(locale);
const t = useTranslations('BbExpert'); const t = useTranslations('BbExpert');
return ( return (

View File

@ -1,5 +1,6 @@
import React, { Suspense } from 'react'; import React, { Suspense } from 'react';
import type { Metadata } from 'next'; import type { Metadata } from 'next';
import { unstable_setRequestLocale } from 'next-intl/server';
import { notFound } from 'next/navigation'; import { notFound } from 'next/navigation';
import { getExpertById, getExpertsList } from '../../../../actions/experts'; import { getExpertById, getExpertsList } from '../../../../actions/experts';
import { import {
@ -19,6 +20,7 @@ export const metadata: Metadata = {
export async function generateStaticParams({ export async function generateStaticParams({
params: { locale }, params: { locale },
}: { params: { locale: string } }) { }: { params: { locale: string } }) {
unstable_setRequestLocale(locale);
const result: { locale: string, expertId: string }[] = []; const result: { locale: string, expertId: string }[] = [];
const experts = await getExpertsList(locale, { themesTagIds: [] }); const experts = await getExpertsList(locale, { themesTagIds: [] });

View File

@ -1,5 +1,6 @@
import React from 'react'; import React from 'react';
import type { Metadata } from 'next'; import type { Metadata } from 'next';
import { unstable_setRequestLocale } from 'next-intl/server';
import { useTranslations } from 'next-intl'; import { useTranslations } from 'next-intl';
import { Experts } from '../../../components/Experts/Experts'; import { Experts } from '../../../components/Experts/Experts';
@ -8,7 +9,8 @@ export const metadata: Metadata = {
description: 'Bbuddy desc experts' description: 'Bbuddy desc experts'
}; };
export default function ExpertsPage({ params }: { params: { locale: string } }) { export default function ExpertsPage({ params: { locale } }: { params: { locale: string } }) {
unstable_setRequestLocale(locale);
const t = useTranslations('Experts'); const t = useTranslations('Experts');
return ( return (
@ -22,7 +24,7 @@ export default function ExpertsPage({ params }: { params: { locale: string } })
</div> </div>
</div> </div>
<Experts <Experts
locale={params.locale} locale={locale}
basePath="/experts" basePath="/experts"
/> />
</div> </div>

View File

@ -178,7 +178,7 @@ export const SessionDetailsContent = ({ session, locale, activeType, startSessio
className="card-detail__apply" className="card-detail__apply"
onClick={onApproveSession} onClick={onApproveSession}
loading={approveLoading} loading={approveLoading}
disable={finishLoading} disabled={finishLoading}
> >
{activeType === SessionType.UPCOMING {activeType === SessionType.UPCOMING
? (session?.state === SessionState.STARTED ? 'Join Session' : 'Start Session') ? (session?.state === SessionState.STARTED ? 'Join Session' : 'Start Session')

3571
yarn.lock

File diff suppressed because it is too large Load Diff