diff --git a/src/components/common/Anchor/index.tsx b/src/components/common/Anchor/index.tsx new file mode 100644 index 00000000..7b5a87c3 --- /dev/null +++ b/src/components/common/Anchor/index.tsx @@ -0,0 +1,16 @@ +import React, { VFC } from 'react'; +import { LinkProps } from '~/utils/types'; +import { CONFIG } from '~/utils/config'; +import NextLink from 'next/link'; +import { Link } from 'react-router-dom'; + +interface AnchorProps extends LinkProps {} + +const Anchor: VFC = ({ ref, href, ...rest }) => + CONFIG.isNextEnvironment ? ( + + ) : ( + + ); + +export { Anchor }; diff --git a/src/components/flow/FlowRecentItem/index.tsx b/src/components/flow/FlowRecentItem/index.tsx index 381ac07b..dd78b588 100644 --- a/src/components/flow/FlowRecentItem/index.tsx +++ b/src/components/flow/FlowRecentItem/index.tsx @@ -4,9 +4,9 @@ import styles from './styles.module.scss'; import { URLS } from '~/constants/urls'; import { NodeRelatedItem } from '~/components/node/NodeRelatedItem'; import { getPrettyDate } from '~/utils/dom'; -import { Link } from 'react-router-dom'; import classNames from 'classnames'; import { Icon } from '~/components/input/Icon'; +import { Anchor } from '~/components/common/Anchor'; interface IProps { node: Partial; @@ -15,7 +15,7 @@ interface IProps { const FlowRecentItem: FC = ({ node, has_new }) => { return ( - +
= ({ node, has_new }) => { {getPrettyDate(node.created_at)}
- +
); }; diff --git a/src/components/main/Logo/index.tsx b/src/components/main/Logo/index.tsx index bf91d9b3..286c5321 100644 --- a/src/components/main/Logo/index.tsx +++ b/src/components/main/Logo/index.tsx @@ -1,9 +1,10 @@ import React from 'react'; import styles from './styles.module.scss'; -import { Link } from 'react-router-dom'; +import { Anchor } from '~/components/common/Anchor'; +import { URLS } from '~/constants/urls'; export const Logo = () => ( - + VAULT - + ); diff --git a/src/components/node/NodeRelatedBlock/index.tsx b/src/components/node/NodeRelatedBlock/index.tsx index c377e975..ba7e0dfc 100644 --- a/src/components/node/NodeRelatedBlock/index.tsx +++ b/src/components/node/NodeRelatedBlock/index.tsx @@ -4,7 +4,7 @@ import { NodeRelated } from '~/components/node/NodeRelated'; import { URLS } from '~/constants/urls'; import { INode } from '~/types'; import { INodeRelated } from '~/types/node'; -import { Link } from 'react-router-dom'; +import { Anchor } from '~/components/common/Anchor'; interface IProps { isLoading: boolean; @@ -27,7 +27,9 @@ const NodeRelatedBlock: FC = ({ isLoading, node, related }) => { .map(album => ( {album} + + {album} + } items={related.albums[album]} key={album} diff --git a/src/components/profile/ProfileSidebarMenu/index.tsx b/src/components/profile/ProfileSidebarMenu/index.tsx index dafbae33..99d47d21 100644 --- a/src/components/profile/ProfileSidebarMenu/index.tsx +++ b/src/components/profile/ProfileSidebarMenu/index.tsx @@ -1,7 +1,7 @@ import React, { FC } from 'react'; import styles from './styles.module.scss'; import { Icon } from '~/components/input/Icon'; -import { Link } from 'react-router-dom'; +import { Anchor } from '~/components/common/Anchor'; interface IProps { path: string; @@ -12,10 +12,10 @@ const ProfileSidebarMenu: FC = ({ path }) => { return (
- + Настройки - +
diff --git a/src/constants/api.ts b/src/constants/api.ts index d49683f2..a64dda1b 100644 --- a/src/constants/api.ts +++ b/src/constants/api.ts @@ -3,10 +3,10 @@ import { OAuthProvider } from '~/types/auth'; import { CONFIG } from '~/utils/config'; export const API = { - BASE: CONFIG.API_HOST, + BASE: CONFIG.apiHost, USER: { LOGIN: '/user/login', - OAUTH_WINDOW: (provider: OAuthProvider) => `${CONFIG.API_HOST}oauth/${provider}/redirect`, + OAUTH_WINDOW: (provider: OAuthProvider) => `${CONFIG.apiHost}oauth/${provider}/redirect`, ME: '/user/', PROFILE: (username: string) => `/user/user/${username}/profile`, MESSAGES: (username: string) => `/user/user/${username}/messages`, diff --git a/src/containers/main/Header/index.tsx b/src/containers/main/Header/index.tsx index 492892d9..7a7d91ad 100644 --- a/src/containers/main/Header/index.tsx +++ b/src/containers/main/Header/index.tsx @@ -1,5 +1,4 @@ import React, { FC, useCallback, useMemo } from 'react'; -import { Link } from 'react-router-dom'; import { Logo } from '~/components/main/Logo'; import { Filler } from '~/components/containers/Filler'; @@ -19,6 +18,7 @@ import { useModal } from '~/hooks/modal/useModal'; import { useScrollTop } from '~/hooks/dom/useScrollTop'; import { useFlow } from '~/hooks/flow/useFlow'; import { useUpdates } from '~/hooks/updates/useUpdates'; +import { Anchor } from '~/components/common/Anchor'; type HeaderProps = {}; @@ -62,32 +62,32 @@ const Header: FC = observer(() => {
- ФЛОУ - + - ЛАБ - + - БОРИС - +
diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index 13d559e0..1397b5ed 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -15,10 +15,13 @@ import { AudioPlayerProvider } from '~/utils/providers/AudioPlayerProvider'; import { MetadataProvider } from '~/utils/providers/MetadataProvider'; import { AuthProvider } from '~/utils/providers/AuthProvider'; import { MainLayout } from '~/containers/main/MainLayout'; +import { useGlobalLoader } from '~/hooks/dom/useGlobalLoader'; const mobxStore = getMOBXStore(); export default function MyApp({ Component, pageProps }) { + useGlobalLoader(); + return ( diff --git a/src/store/auth/AuthStore.ts b/src/store/auth/AuthStore.ts index edca1ec5..d5c9cc0d 100644 --- a/src/store/auth/AuthStore.ts +++ b/src/store/auth/AuthStore.ts @@ -13,7 +13,7 @@ export class AuthStore { makeAutoObservable(this); void makePersistable(this, { - name: `vault48_auth_${CONFIG.API_HOST}`, + name: `vault48_auth_${CONFIG.apiHost}`, properties: ['token', 'user', 'isTesterInternal'], storage: typeof window !== 'undefined' ? window.localStorage : undefined, }); diff --git a/src/utils/config/index.ts b/src/utils/config/index.ts index 7a306c68..52f4e9bb 100644 --- a/src/utils/config/index.ts +++ b/src/utils/config/index.ts @@ -1,5 +1,7 @@ export const CONFIG = { - API_HOST: process.env.REACT_APP_API_HOST || process.env.NEXT_PUBLIC_API_HOST || '', - REMOTE_CURRENT: + apiHost: process.env.REACT_APP_API_HOST || process.env.NEXT_PUBLIC_API_HOST || '', + remoteCurrent: process.env.REACT_APP_REMOTE_CURRENT || process.env.NEXT_PUBLIC_REMOTE_CURRENT || '', + // transitional prop, marks migration to nextjs + isNextEnvironment: false, }; diff --git a/src/utils/dom.ts b/src/utils/dom.ts index 0021a296..22c2c5ba 100644 --- a/src/utils/dom.ts +++ b/src/utils/dom.ts @@ -68,10 +68,10 @@ export const getURLFromString = ( size?: typeof PRESETS[keyof typeof PRESETS] ): string => { if (size) { - return (url || '').replace('REMOTE_CURRENT://', `${CONFIG.REMOTE_CURRENT}cache/${size}/`); + return (url || '').replace('REMOTE_CURRENT://', `${CONFIG.remoteCurrent}cache/${size}/`); } - return (url || '').replace('REMOTE_CURRENT://', CONFIG.REMOTE_CURRENT); + return (url || '').replace('REMOTE_CURRENT://', CONFIG.remoteCurrent); }; export const getURL = ( diff --git a/src/utils/types.ts b/src/utils/types.ts index 438d56d3..21f1e758 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -16,3 +16,8 @@ export type ButtonProps = React.DetailedHTMLProps< React.ButtonHTMLAttributes, HTMLButtonElement >; + +export type LinkProps = React.DetailedHTMLProps< + React.AnchorHTMLAttributes, + HTMLAnchorElement +>;