Binary files /dev/null and b/public/images/network-error.png differ @@ -52,6 +52,15 @@ axios.interceptors.response.use(async (response) => { return response }) +axios.interceptors.response.use( + (response) => response, + (error) => { + if (!error.response) { + window.location.href = '/network-error' + } + return error + } +) const inter = Raleway({ subsets: ['latin'] }) @@ -0,0 +1,6 @@ +import { NetworkError } from '#/views/network-error/' +import { getDefaultLayout } from '#/widgets/layouts' + +NetworkError.getLayout = getDefaultLayout({ titlePage: 'Сетевая ошибка' }) + +export default NetworkError @@ -4,3 +4,13 @@ export const api = axios.create({ validateStatus: () => true, baseURL: process.env.NEXT_PUBLIC_API_HOST, }) + +api.interceptors.response.use( + (response) => response, + (error) => { + if (!error.response) { + window.location.href = '/network-error' + } + return error + } +) @@ -0,0 +1 @@ +export * from './info-page-template' @@ -1,9 +1,9 @@ import Link from 'next/link' import { CommonButton } from '../../button' -import styles from './service-page.module.scss' +import styles from './info-page-template.module.scss' import Image from 'next/image' -interface ServicePageProps { +interface InfoPageTemplateProps { primaryTitle: string secondaryTitle: string description: string @@ -13,7 +13,15 @@ interface ServicePageProps { imageAlt: string } -export const ServicePage = ({ primaryTitle, secondaryTitle, description, buttonText, buttonOnClick, imageUrl, imageAlt }: ServicePageProps) => { +export const InfoPageTemplate = ({ + primaryTitle, + secondaryTitle, + description, + buttonText, + buttonOnClick, + imageUrl, + imageAlt, +}: InfoPageTemplateProps) => { return ( <>
@@ -1 +0,0 @@ -export * from './service-page' @@ -0,0 +1 @@ +export * from './network-error' @@ -0,0 +1,22 @@ +import React from 'react' +import { useRouter } from 'next/router' +import { NextPageWithLayout } from '#/pages/_app' +import { InfoPageTemplate } from '#/shared/ui/info-page-template' + +export const NetworkError: NextPageWithLayout = () => { + const { push } = useRouter() + + return ( + <> + push('/')} + buttonText='На главную' + imageUrl='/images/network-error.png' + imageAlt='network-error' + /> + + ) +} @@ -0,0 +1 @@ +export * from './ui' @@ -1,20 +1,20 @@ import React, { useEffect } from 'react' import { useRouter } from 'next/router' import { NextPageWithLayout } from '#/pages/_app' -import { ServicePage } from '#/shared/ui/service-page' +import { InfoPageTemplate } from '#/shared/ui/info-page-template' const NotFoundPage: NextPageWithLayout = () => { const { push } = useRouter() - // useEffect(() => { - // const timeout = setTimeout(() => push('/'), 7000) + useEffect(() => { + const timeout = setTimeout(() => push('/'), 7000) - // return () => clearTimeout(timeout) - // }, []) + return () => clearTimeout(timeout) + }, []) return ( <> - { const { push } = useRouter() return ( <> -