feat: update i18n, next core

This commit is contained in:
SD 2025-02-17 01:01:39 +04:00
parent 9ecb7d6981
commit ccc3e2cb79
57 changed files with 446 additions and 425 deletions

View File

@ -1,5 +1,6 @@
// @ts-check
const withNextIntl = require('next-intl/plugin')();
const createNextIntlPlugin = require('next-intl/plugin');
const withNextIntl = createNextIntlPlugin();
const path = require('path');
const json = require('./package.json');

579
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -23,20 +23,20 @@ export const useSessionTracking = (locale: string, sessionId: number) => {
useEffect(() => {
return () => {
window.clearInterval(timer.current);
window?.clearInterval(timer.current);
}
}, []);
const start = () => {
window.clearInterval(timer.current);
window?.clearInterval(timer.current);
timer.current = window.setInterval(() => {
timer.current = window?.setInterval(() => {
fetchData();
}, DURATION);
};
const stop = () => {
window.clearInterval(timer.current);
window?.clearInterval(timer.current);
};
return {

View File

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

View File

@ -1,10 +1,10 @@
import React from 'react';
import { unstable_setRequestLocale } from 'next-intl/server';
// import { unstable_setRequestLocale } from 'next-intl/server';
import { useTranslations } from 'next-intl';
import { Experts } from '../../../../components/Experts/Experts';
export default function ExpertsPage({ params: { locale } }: { params: { locale: string } }) {
unstable_setRequestLocale(locale);
// unstable_setRequestLocale(locale);
const t = useTranslations('Experts');
return (

View File

@ -1,12 +1,12 @@
import React from 'react';
// import { useTranslations } from 'next-intl';
import Link from 'next/link';
import { getTranslations, unstable_setRequestLocale } from 'next-intl/server';
import { getTranslations } from 'next-intl/server';
import { i18nText } from '../../../../i18nKeys';
import { fetchBlogPosts } from '../../../../lib/contentful/blogPosts';
export default async function News({params: {locale}}: { params: { locale: string } }) {
unstable_setRequestLocale(locale);
// unstable_setRequestLocale(locale);
const t = await getTranslations('Main');
const { data, total } = await fetchBlogPosts({preview: false, sticky: true})

View File

@ -1,5 +1,5 @@
import React from 'react';
import { Link } from '../../../../../../navigation';
import { Link } from '../../../../../../i18n/routing';
import { CustomSelect } from '../../../../../../components/view/CustomSelect';
export default function AddOffer() {

View File

@ -1,5 +1,5 @@
import React from 'react';
import { Link } from '../../../../../../navigation';
import { Link } from '../../../../../../i18n/routing';
import { CustomSelect } from '../../../../../../components/view/CustomSelect';
export default function NewTopic() {

View File

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

View File

@ -1,6 +1,6 @@
'use client'
import React from 'react';
import { Link } from '../../../../../../navigation';
import { Link } from '../../../../../../i18n/routing';
import { i18nText } from '../../../../../../i18nKeys';
import {ChatMessages} from "../../../../../../components/Chat/ChatMessages";
/*

View File

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

View File

@ -1,10 +1,10 @@
import React from 'react';
import { unstable_setRequestLocale } from 'next-intl/server';
import { Link } from '../../../../../../navigation';
// import { unstable_setRequestLocale } from 'next-intl/server';
import { Link } from '../../../../../../i18n/routing';
import { i18nText } from '../../../../../../i18nKeys/';
export default function ChangePassword({ params: { locale } }: { params: { locale: string } }) {
unstable_setRequestLocale(locale);
// unstable_setRequestLocale(locale);
return (
<>

View File

@ -1,10 +1,10 @@
import React, { Suspense } from 'react';
import { unstable_setRequestLocale } from 'next-intl/server';
// import { unstable_setRequestLocale } from 'next-intl/server';
import { ProfileSettings } from '../../../../../components/Account';
import { i18nText } from '../../../../../i18nKeys';
export default function Settings({ params: { locale } }: { params: { locale: string } }) {
unstable_setRequestLocale(locale);
// unstable_setRequestLocale(locale);
return (
<>

View File

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

View File

@ -1,5 +1,5 @@
import React, { Suspense } from 'react';
import { unstable_setRequestLocale } from 'next-intl/server';
// import { unstable_setRequestLocale } from 'next-intl/server';
import { notFound } from 'next/navigation';
import { AccountMenu, RoomDetails, RoomsTabs } from '../../../../../../components/Account';
import { RoomsType } from '../../../../../../types/rooms';
@ -13,7 +13,7 @@ export async function generateStaticParams({
}
export default function RoomsDetailItem({ params: { locale, slug } }: { params: { locale: string, slug?: string[] } }) {
unstable_setRequestLocale(locale);
// unstable_setRequestLocale(locale);
const roomType: string = slug?.length > 0 && slug[0] || '';
const roomId: number | null = slug?.length > 1 && Number(slug[1]) || null;

View File

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

View File

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

View File

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

View File

@ -1,7 +1,7 @@
import React from 'react';
import type { Metadata } from 'next';
import { draftMode } from 'next/headers'
import {unstable_setRequestLocale} from "next-intl/server";
// import {unstable_setRequestLocale} from "next-intl/server";
import Link from "next/link";
import {fetchBlogPosts} from "../../../../../lib/contentful/blogPosts";
import {fetchBlogPostCategories} from "../../../../../lib/contentful/blogPostsCategories";
@ -20,9 +20,9 @@ interface BlogPostPageProps {
params: BlogPostPageParams
}
export default async function Blog({params, searchParams}: { params: BlogPostPageParams, searhParams?: {page: number} }) {
unstable_setRequestLocale(params.locale);
const page = searchParams.page || undefined
export default async function Blog({params, searchParams}: { params: BlogPostPageParams, searchParams?: {page: number} }) {
// unstable_setRequestLocale(params.locale);
const page = searchParams?.page || undefined
return (
<BlogPosts basePath={'/'+params.locale+'/blog/'} locale={params.locale} currentCat={params.slug} page={page}/>
);

View File

@ -2,7 +2,7 @@ import React from 'react';
import type { Metadata } from 'next';
import * as Util from "node:util";
import {fetchBlogPosts} from "../../../lib/contentful/blogPosts";
import {unstable_setRequestLocale} from "next-intl/server";
// import {unstable_setRequestLocale} from "next-intl/server";
import Link from "next/link";
import {fetchBlogPostCategories} from "../../../lib/contentful/blogPostsCategories";
import {CustomPagination} from "../../../components/view/CustomPagination";
@ -24,10 +24,10 @@ export async function generateStaticParams(): Promise<BlogPostPageParams[]> {
}
export default async function Blog({ params: { locale }, searchParams }: { params: { locale: string }, searhParams?: {page: number} }) {
unstable_setRequestLocale(locale);
export default async function Blog({ params: { locale }, searchParams }: { params: { locale: string }, searchParams?: {page: number} }) {
// unstable_setRequestLocale(locale);
const pageSize = DEFAULT_PAGE_SIZE
const page = searchParams.page || undefined
const page = searchParams?.page || undefined
// BlogPosts('/'+locale+'/blog/', locale, pageSize)
return (
@ -36,7 +36,6 @@ export default async function Blog({ params: { locale }, searchParams }: { param
locale={locale}
pageSize={pageSize}
page={page}
>
</BlogPosts>
/>
);
}

View File

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

View File

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

View File

@ -1,6 +1,7 @@
import React, { ReactNode, Suspense } from 'react';
import { Metadata } from 'next';
import { unstable_setRequestLocale } from 'next-intl/server';
import { NextIntlClientProvider } from 'next-intl';
import { getMessages } from 'next-intl/server';
import { notFound } from 'next/navigation';
import { ConfigProvider } from 'antd';
import { AntdRegistry } from '@ant-design/nextjs-registry';
@ -8,6 +9,7 @@ import { GoogleOAuthProvider } from '@react-oauth/google';
import theme from '../../constants/theme';
import { ALLOWED_LOCALES } from '../../constants/locale';
import { Header, Footer, AppConfig } from '../../components/Page';
import { routing } from '../../i18n/routing';
type LayoutProps = {
children: ReactNode;
@ -22,12 +24,15 @@ export const metadata: Metadata = {
title: 'Bbuddy'
};
export default function LocaleLayout({ children, params: { locale } }: LayoutProps) {
if (!ALLOWED_LOCALES.includes(locale as any)) notFound();
export default async function LocaleLayout({ children, params: { locale } }: LayoutProps) {
if (!routing.locales.includes(locale as any)) {
notFound();
}
unstable_setRequestLocale(locale);
const messages = await getMessages();
return (
<NextIntlClientProvider messages={messages}>
<AntdRegistry>
<GoogleOAuthProvider clientId={process.env.NEXT_PUBLIC_GOOGLE_CLIENT_ID || ''}>
<ConfigProvider theme={theme}>
@ -44,5 +49,6 @@ export default function LocaleLayout({ children, params: { locale } }: LayoutPro
</ConfigProvider>
</GoogleOAuthProvider>
</AntdRegistry>
</NextIntlClientProvider>
);
}

View File

@ -8,7 +8,7 @@ import { getLoginByApple } from '../../../../actions/auth';
import { getUserData } from '../../../../actions/profile';
import { AUTH_TOKEN_KEY, AUTH_USER } from '../../../../constants/common';
import { useLocalStorage } from '../../../../hooks/useLocalStorage';
import { useRouter } from '../../../../navigation';
import { useRouter } from '../../../../i18n/routing';
export default function AppleLoginPage({ params: { locale } }: { params: { locale: string } }) {
const params = useSearchParams();

View File

@ -8,7 +8,7 @@ import { getRegisterByApple } from '../../../../actions/auth';
import { getUserData } from '../../../../actions/profile';
import { AUTH_TOKEN_KEY, AUTH_USER } from '../../../../constants/common';
import { useLocalStorage } from "../../../../hooks/useLocalStorage";
import { useRouter } from '../../../../navigation';
import { useRouter } from '../../../../i18n/routing';
export default function AppleRegisterPage({ params: { locale } }: { params: { locale: string } }) {
const params = useSearchParams();

View File

@ -1,14 +1,14 @@
'use client';
import { useEffect, useState } from 'react';
import { Button } from 'antd';
import { useSelectedLayoutSegment, usePathname } from 'next/navigation';
import { Link } from '../../navigation';
import { Link } from '../../i18n/routing';
import { AUTH_TOKEN_KEY, AUTH_USER } from '../../constants/common';
import {deleteStorageKey, useLocalStorage} from '../../hooks/useLocalStorage';
import { i18nText } from '../../i18nKeys';
import { getMenuConfig } from '../../utils/account';
import {useEffect, useState} from "react";
import {getChatList} from "../../actions/chat/groups";
import { getChatList } from '../../actions/chat/groups';
export const AccountMenu = ({ locale }: { locale: string }) => {
const selectedLayoutSegment = useSelectedLayoutSegment();

View File

@ -5,7 +5,7 @@ import { Form, message, Upload } from 'antd';
import type { UploadFile } from 'antd';
import ImgCrop from 'antd-img-crop';
import { CameraOutlined, DeleteOutlined } from '@ant-design/icons';
import { useRouter } from '../../navigation';
import { useRouter } from '../../i18n/routing';
import { i18nText } from '../../i18nKeys';
import { ProfileRequest } from '../../types/profile';
import { validateImage } from '../../utils/account';

View File

@ -5,7 +5,7 @@ import { EditRoomForm } from './EditRoomForm';
import debounce from 'lodash/debounce';
import { createRoom } from '../../../actions/rooms';
import { Loader } from '../../view/Loader';
import { useRouter } from '../../../navigation';
import { useRouter } from '../../../i18n/routing';
import { RoomsType } from '../../../types/rooms';

View File

@ -5,7 +5,7 @@ import { Button, notification, Tag } from 'antd';
import { DeleteOutlined, LeftOutlined } from '@ant-design/icons';
import dayjs from 'dayjs';
import Image from 'next/image';
import { useRouter } from '../../../navigation';
import { useRouter } from '../../../i18n/routing';
import { Report, Room, RoomsType } from '../../../types/rooms';
import { i18nText } from '../../../i18nKeys';
import { LinkButton } from '../../view/LinkButton';

View File

@ -14,7 +14,7 @@ import { getRecentRooms, getUpcomingRooms } from '../../../actions/rooms';
import { Loader } from '../../view/Loader';
import { useLocalStorage } from '../../../hooks/useLocalStorage';
import { AUTH_TOKEN_KEY } from '../../../constants/common';
import { usePathname, useRouter } from '../../../navigation';
import { usePathname, useRouter } from '../../../i18n/routing';
import { i18nText } from '../../../i18nKeys';
import { CreateRoom } from './CreateRoom';

View File

@ -5,7 +5,7 @@ import { Button, Empty, notification, Tag } from 'antd';
import { LeftOutlined, PlusOutlined, RightOutlined } from '@ant-design/icons';
import Image from 'next/image';
import dayjs from 'dayjs';
import { Link, useRouter } from '../../../navigation';
import { Link, useRouter } from '../../../i18n/routing';
import { i18nText } from '../../../i18nKeys';
import { getDuration, getPrice } from '../../../utils/expert';
import { PublicUser, Session, SessionState, SessionType } from '../../../types/sessions';

View File

@ -14,7 +14,7 @@ import { useLocalStorage } from '../../../hooks/useLocalStorage';
import { AUTH_TOKEN_KEY, AUTH_USER } from '../../../constants/common';
import { getRecentSessions, getRequestedSessions, getUpcomingSessions } from '../../../actions/sessions';
import { Session, Sessions, SessionType } from '../../../types/sessions';
import { useRouter, usePathname } from '../../../navigation';
import { useRouter, usePathname } from '../../../i18n/routing';
import { i18nText } from '../../../i18nKeys';
type SessionsTabsProps = {

View File

@ -10,7 +10,7 @@ type PostsProps = {
basePath: string;
locale: string;
pageSize?: number;
currentCat: string;
currentCat?: string;
page?: number
};

View File

@ -3,7 +3,7 @@ import React, {useEffect, useState} from 'react';
import {AUTH_TOKEN_KEY} from '../../constants/common';
import {getChatList, getChatMessages} from "../../actions/chat/groups";
import {useLocalStorage} from "../../hooks/useLocalStorage";
import {Link} from "../../navigation";
import { Link } from "../../i18n/routing";
import dayjs from "dayjs";
import relativeTime from "dayjs/plugin/relativeTime";
import {message} from "antd";

View File

@ -20,7 +20,7 @@ type CompProps = {
export const ChatMessages = ({ locale, groupId }: CompProps) => {
const [jwt] = useLocalStorage(AUTH_TOKEN_KEY, '');
const { newMessage, joinChat, readMessages, addListener } = SignalrConnection({ jwt });
const { newMessage, joinChat, readMessages, addListener } = SignalrConnection({ jwt }) || {};
//const messages = await getChatMessages(locale, jwt, groupId)
const [loading, setLoading] = useState<boolean>(false);
const [text, setText] = useState('');
@ -60,7 +60,7 @@ export const ChatMessages = ({ locale, groupId }: CompProps) => {
const onConnected = (flag: boolean) =>{
if (flag) {
if (flag && joinChat) {
joinChat(groupId)
readUreaded()
}
@ -73,7 +73,7 @@ export const ChatMessages = ({ locale, groupId }: CompProps) => {
msgs.push(message.id)
}
})
readMessages(msgs)
readMessages && readMessages(msgs);
}
const onReceiveMessage = (payload: any) => {
@ -103,7 +103,7 @@ export const ChatMessages = ({ locale, groupId }: CompProps) => {
} else {
setMessages([msg, ..._messages]);
}
readMessages([msg.id])
readMessages && readMessages([msg.id]);
}
@ -120,16 +120,18 @@ export const ChatMessages = ({ locale, groupId }: CompProps) => {
}
useEffect(() => {
addListener('onConnected', onConnected)
addListener('ReceiveMessage', onReceiveMessage)
addListener('MessageWasRead', onOpponentRead)
if (addListener) {
addListener('onConnected', onConnected);
addListener('ReceiveMessage', onReceiveMessage);
addListener('MessageWasRead', onOpponentRead);
}
}, [messages, me, setMessages]);
const handleSendMessages = () => {
newMessage({
newMessage && newMessage({
GroupId: groupId.toString(),
CreatorId: me.id,
Content: text

View File

@ -3,7 +3,7 @@
import React, { useCallback, useEffect, useState } from 'react';
import { useSearchParams } from 'next/navigation';
import debounce from 'lodash/debounce';
import { useRouter } from '../../navigation';
import { useRouter } from '../../i18n/routing';
import { AdditionalFilter } from '../../types/experts';
import { getObjectByFilter, getObjectByAdditionalFilter, getSearchParamsString } from '../../utils/filter';
import { CustomInput } from '../view/CustomInput';

View File

@ -16,7 +16,7 @@ import { AUTH_TOKEN_KEY, SESSION_DATA } from '../../constants/common';
import { ScheduleModal } from '../Modals/ScheduleModal';
import { ScheduleModalResult } from '../Modals/ScheduleModalResult';
import SignalrConnection from '../../lib/signalr-connection';
import { useRouter } from '../../navigation';
import { useRouter } from '../../i18n/routing';
import { useLocalStorage } from '../../hooks/useLocalStorage';
type ExpertDetailsProps = {
@ -38,7 +38,7 @@ export const ExpertCard: FC<ExpertDetailsProps> = ({ expert, locale, expertId })
const isRus = locale === Locale.ru;
const { publicCoachDetails: { tags = [], sessionCost = 0, sessionDuration = 0, coachLanguages = [] , id, botUserId} } = expert || {};
const [jwt] = useLocalStorage(AUTH_TOKEN_KEY, '');
const { joinChatPerson, closeConnection } = SignalrConnection({ jwt });
const { joinChatPerson, closeConnection } = SignalrConnection({ jwt }) || {};
const router = useRouter();
@ -46,13 +46,13 @@ export const ExpertCard: FC<ExpertDetailsProps> = ({ expert, locale, expertId })
document?.addEventListener('show_pay_form', handleShowPayForm);
return () => {
closeConnection();
if (closeConnection) closeConnection();
document?.removeEventListener('show_pay_form', handleShowPayForm);
}
}, []);
const handleJoinChat = (id?: number) => {
if (id) {
if (id && joinChatPerson) {
joinChatPerson(id).then((res: any) => {
router.push(`/account/messages/${res.id}` as string);
})

View File

@ -6,7 +6,7 @@ import { List, Tag } from 'antd';
import { RightOutlined } from '@ant-design/icons';
import isEqual from 'lodash/isEqual';
import Image from 'next/image';
import { Link, useRouter } from '../../navigation';
import { Link, useRouter } from '../../i18n/routing';
import { ExpertsData, Filter, GeneralFilter } from '../../types/experts';
import { getObjectByFilter, getObjectByAdditionalFilter, getSearchParamsString } from '../../utils/filter';
import { getDuration, getPrice } from '../../utils/expert';

View File

@ -4,7 +4,7 @@ import React, { useCallback, useEffect, useState } from 'react';
import { Button, Collapse, List } from 'antd';
import type { CollapseProps } from 'antd';
import { useSearchParams } from 'next/navigation';
import { useRouter } from '../../navigation';
import { useRouter } from '../../i18n/routing';
import { Filter } from '../../types/experts';
import { Languages, SearchData, Tag } from '../../types/tags';
import { getObjectByFilter, getObjectByAdditionalFilter, getSearchParamsString } from '../../utils/filter';

View File

@ -7,7 +7,7 @@ import { Modal, Form, notification } from 'antd';
import { CloseOutlined } from '@ant-design/icons';
import { RegisterContent, ResetContent, FinishContent, EnterContent } from './authModalContent';
import { i18nText } from '../../i18nKeys';
import { useRouter } from '../../navigation';
import { useRouter } from '../../i18n/routing';
import { AUTH_USER} from '../../constants/common';
import { getRegisterByApple, getLoginByApple } from '../../actions/auth';
import { getUserData } from '../../actions/profile';

View File

@ -3,7 +3,8 @@
import React, { useEffect, useState } from 'react';
import { Modal, Result } from 'antd';
import { CloseOutlined } from '@ant-design/icons';
import { useSearchParams, useRouter } from 'next/navigation';
import { useSearchParams } from 'next/navigation';
import { useRouter } from '../../i18n/routing';
import { Stripe } from 'stripe';
import { getStripePaymentStatus } from '../../actions/stripe';
import { sessionPaymentConfirm } from '../../actions/sessions';

View File

@ -1,7 +1,7 @@
import React from 'react';
import Link from 'next/link';
import { useTranslations } from 'next-intl';
import { Link as IntlLink } from '../../../navigation';
import { Link as IntlLink } from '../../../i18n/routing';
import { i18nText } from '../../../i18nKeys';
export const Footer = ({ locale }: { locale: string }) => {

View File

@ -3,7 +3,7 @@
import React, { useState, useEffect } from 'react';
import { Button } from 'antd';
import { useSelectedLayoutSegment } from 'next/navigation';
import { Link } from '../../../navigation';
import { Link } from '../../../i18n/routing';
import { AUTH_TOKEN_KEY } from '../../../constants/common';
import { useLocalStorage } from '../../../hooks/useLocalStorage';
import { AuthModal } from '../../Modals/AuthModal';

View File

@ -3,7 +3,7 @@
import React from 'react';
import { useSelectedLayoutSegment } from 'next/navigation';
import dynamic from 'next/dynamic';
import { Link } from '../../../navigation';
import { Link } from '../../../i18n/routing';
type HeaderMenuProps = {
locale: string;

View File

@ -3,7 +3,7 @@
import React, { FC, useState } from 'react';
import dynamic from 'next/dynamic';
import { useSelectedLayoutSegment } from 'next/navigation';
import { Link } from '../../../navigation';
import { Link } from '../../../i18n/routing';
type HeaderMenuMobileProps = {
locale: string;

View File

@ -4,7 +4,7 @@ import React, { useTransition, useState } from 'react';
import { Dropdown } from 'antd';
import type { MenuProps } from 'antd';
import { CaretDownOutlined, CaretUpOutlined } from '@ant-design/icons';
import { useRouter, usePathname } from '../../../navigation';
import { useRouter, usePathname } from '../../../i18n/routing';
import { LOCALES } from '../../../constants/locale';
import { Locale } from '../../../types/locale';

View File

@ -3,7 +3,7 @@ import { HeaderMenu } from './HeaderMenu';
import { LanguageSwitcher } from './LanguageSwitcher';
import { HeaderMobileMenu } from './HeaderMobileMenu';
import { HEAD_ROUTES } from '../../../constants/routes';
import { Link } from '../../../navigation';
import { Link } from '../../../i18n/routing';
import { i18nText } from '../../../i18nKeys';
type HeaderProps = {

View File

@ -81,7 +81,7 @@ export const CheckoutForm: FC<PaymentFormProps> = ({ amount, sessionId, locale }
elements,
clientSecret,
confirmParams: {
return_url: window.location.href,
return_url: window?.location?.href || '',
payment_method_data: {
allow_redisplay: 'limited',
// billing_details: {

View File

@ -2,7 +2,6 @@ import { Locale } from '../types/locale';
export const DEFAULT_LOCALE = Locale.en;
export const ALLOWED_LOCALES = [Locale.en, Locale.ru, Locale.de, Locale.it, Locale.es, Locale.fr] as const;
export const LOCALE_PREFIX = undefined;
export const LOCALES = {
[Locale.en]: 'En',

View File

@ -2,14 +2,14 @@ import { useState, useEffect } from 'react';
export function getStorageValue (key: string, defaultValue: any) {
if (typeof window !== 'undefined') {
const saved = localStorage.getItem(key);
const saved = localStorage?.getItem(key);
return saved || defaultValue;
}
};
export function deleteStorageKey (key: string) {
if (typeof window !== 'undefined') {
localStorage.removeItem(key);
localStorage?.removeItem(key);
}
};
@ -19,7 +19,7 @@ export const useLocalStorage = (key: string, defaultValue: any) => {
});
useEffect(() => {
localStorage.setItem(key, value);
localStorage?.setItem(key, value);
}, [key, value]);
return [value, setValue];

View File

@ -14,21 +14,21 @@ export const useOauthWindow = () => {
if (data.messageType === 'oAuth') {
messageHandler(event);
window.removeEventListener('message', handler);
window?.removeEventListener('message', handler);
}
}
window.removeEventListener('message', handler);
window?.removeEventListener('message', handler);
if (!oauthWindow || oauthWindow.closed) {
// окно ещё не существует, либо было закрыто
oauthWindow = window.open(url, name, params)!;
oauthWindow = window?.open(url, name, params)!;
} else {
// окно уже существует
oauthWindow!.focus();
}
window.addEventListener('message', handler);
window?.addEventListener('message', handler);
}
return {

15
src/i18n/request.ts Normal file
View File

@ -0,0 +1,15 @@
import { getRequestConfig } from 'next-intl/server';
import { routing } from './routing';
export default getRequestConfig(async ({ requestLocale }) => {
let locale = await requestLocale;
if (!locale || !routing.locales.includes(locale as any)) {
locale = routing.defaultLocale;
}
return {
locale,
messages: (await import(`../../messages/${locale}.json`)).default
};
});

10
src/i18n/routing.ts Normal file
View File

@ -0,0 +1,10 @@
import { defineRouting } from 'next-intl/routing';
import { createNavigation } from 'next-intl/navigation';
import { ALLOWED_LOCALES, DEFAULT_LOCALE } from '../constants/locale';
export const routing = defineRouting({
locales: ALLOWED_LOCALES,
defaultLocale: DEFAULT_LOCALE
});
export const { Link, redirect, usePathname, useRouter, getPathname } = createNavigation(routing);

View File

@ -25,7 +25,7 @@ const chatsReceiveMessageMethodName = 'ChatsMessageCreated';
class SignalConnector {
private connection: HubConnection;
private events = {} as any;
static instance: SignalConnector;
static instance?: SignalConnector;
constructor({ jwt }: { jwt?: string}) {
const options = {
accessTokenFactory: () => jwt
@ -69,10 +69,17 @@ class SignalConnector {
this.connection.invoke(sendChatMessagesSeenMethodName, messagesId).then(x => console.log(sendChatMessagesSeenMethodName, x))
}
public static getInstance({ jwt }: { jwt?: string }): SignalConnector {
if (!SignalConnector.instance)
public static getInstance({ jwt }: { jwt?: string }): SignalConnector | undefined {
if (!SignalConnector.instance) {
if (jwt) {
SignalConnector.instance = new SignalConnector({ jwt });
return SignalConnector.instance;
} else {
return undefined;
}
} else {
return SignalConnector.instance;
}
}
}

View File

@ -1,11 +1,7 @@
import createMiddleware from 'next-intl/middleware';
import { ALLOWED_LOCALES, DEFAULT_LOCALE, LOCALE_PREFIX } from './constants/locale';
import { routing } from './i18n/routing';
export default createMiddleware({
locales: ALLOWED_LOCALES,
localePrefix: LOCALE_PREFIX,
defaultLocale: DEFAULT_LOCALE
});
export default createMiddleware(routing);
export const config = {
matcher: ['/', '/(en|ru|de|it|es|fr)/:path*']

View File

@ -1,5 +1,5 @@
.b-slider {
margin-top: -105px;
//margin-top: -105px;
h2 {
margin: 40px 0 20px;