Compare commits
3 Commits
feature/er
...
3ade6f83cc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3ade6f83cc | ||
|
|
897602c471 | ||
|
|
d2b74a1467 |
@@ -28,8 +28,6 @@
|
|||||||
"dry-wash.arm.master.drawer.button.cancel": "Отменить",
|
"dry-wash.arm.master.drawer.button.cancel": "Отменить",
|
||||||
"dry-wash.arm.master.sideBar.title": " Сухой мастер",
|
"dry-wash.arm.master.sideBar.title": " Сухой мастер",
|
||||||
"dry-wash.arm.master.sideBar.title.master": "Мастера",
|
"dry-wash.arm.master.sideBar.title.master": "Мастера",
|
||||||
"dry-wash.arm.master.sideBar.title.orders": "Заказы",
|
"dry-wash.arm.master.sideBar.title.orders": "Заказы"
|
||||||
"dry-wash.errorBoundary.title":"Что-то пошло не так",
|
|
||||||
"dry-wash.errorBoundary.description": " Мы уже работаем над исправлением проблемы",
|
|
||||||
"dry-wash.errorBoundary.button.reload": "Перезагрузить страницу"
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,16 +2,13 @@ import React from 'react';
|
|||||||
import { BrowserRouter } from 'react-router-dom';
|
import { BrowserRouter } from 'react-router-dom';
|
||||||
import Routers from './routes';
|
import Routers from './routes';
|
||||||
import { ChakraProvider, theme as chakraTheme } from '@chakra-ui/react';
|
import { ChakraProvider, theme as chakraTheme } from '@chakra-ui/react';
|
||||||
import ErrorBoundary from './components/ErrorBoundary';
|
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
return (
|
return (
|
||||||
<ChakraProvider theme={chakraTheme}>
|
<ChakraProvider theme={chakraTheme}>
|
||||||
<ErrorBoundary>
|
|
||||||
<BrowserRouter>
|
<BrowserRouter>
|
||||||
<Routers />
|
<Routers></Routers>
|
||||||
</BrowserRouter>
|
</BrowserRouter>
|
||||||
</ErrorBoundary>
|
|
||||||
</ChakraProvider>
|
</ChakraProvider>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,64 +0,0 @@
|
|||||||
import React, { Component, ErrorInfo, ReactNode } from 'react';
|
|
||||||
import { Heading, Text, Button, Center, VStack } from '@chakra-ui/react';
|
|
||||||
import i18next from 'i18next';
|
|
||||||
|
|
||||||
interface ErrorBoundaryState {
|
|
||||||
hasError: boolean;
|
|
||||||
error: Error | null;
|
|
||||||
errorInfo: ErrorInfo | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ErrorBoundaryProps {
|
|
||||||
children: ReactNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
|
|
||||||
constructor(props: ErrorBoundaryProps) {
|
|
||||||
super(props);
|
|
||||||
this.state = {
|
|
||||||
hasError: false,
|
|
||||||
error: null,
|
|
||||||
errorInfo: null,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
static getDerivedStateFromError(): Partial<ErrorBoundaryState> {
|
|
||||||
return { hasError: true };
|
|
||||||
}
|
|
||||||
|
|
||||||
componentDidCatch(error: Error, errorInfo: ErrorInfo): void {
|
|
||||||
console.error('Error caught by ErrorBoundary:', error, errorInfo);
|
|
||||||
this.setState({ error, errorInfo });
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
|
||||||
const { hasError } = this.state;
|
|
||||||
//TODO: добавить анимацию после залива 404 страницы
|
|
||||||
if (hasError) {
|
|
||||||
return (
|
|
||||||
<Center minH='100vh'>
|
|
||||||
<VStack spacing={4} textAlign='center'>
|
|
||||||
<Heading as='h1' size='2xl'>
|
|
||||||
{i18next.t('dry-wash.errorBoundary.title')}
|
|
||||||
</Heading>
|
|
||||||
<Text fontSize='lg'>
|
|
||||||
{i18next.t('dry-wash.errorBoundary.description')}
|
|
||||||
</Text>
|
|
||||||
<Button
|
|
||||||
colorScheme='teal'
|
|
||||||
size='lg'
|
|
||||||
variant='outline'
|
|
||||||
onClick={() => window.location.reload()}
|
|
||||||
>
|
|
||||||
{i18next.t('dry-wash.errorBoundary.button.reload')}
|
|
||||||
</Button>
|
|
||||||
</VStack>
|
|
||||||
</Center>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.props.children;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default ErrorBoundary;
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
export { default } from './ErrorBoundary';
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import React, { FC } from 'react';
|
import React, { FC } from 'react';
|
||||||
import { Box, Container, VStack } from '@chakra-ui/react';
|
import { Container, VStack } from '@chakra-ui/react';
|
||||||
import {
|
import {
|
||||||
BenefitsSection,
|
BenefitsSection,
|
||||||
Footer,
|
Footer,
|
||||||
@@ -19,14 +19,12 @@ const Page: FC = () => {
|
|||||||
bg='white'
|
bg='white'
|
||||||
centerContent
|
centerContent
|
||||||
>
|
>
|
||||||
<VStack w='full' h='full' alignItems='stretch'>
|
<VStack w='full' h='full' alignItems='stretch' flexGrow={1}>
|
||||||
<HeroSection flexShrink={0} />
|
<HeroSection flexShrink={0} />
|
||||||
<Box flexGrow={1}>
|
<VStack as='main' flexGrow={1}>
|
||||||
<VStack as='main'>
|
|
||||||
<BenefitsSection />
|
<BenefitsSection />
|
||||||
<SocialProofSection />
|
<SocialProofSection />
|
||||||
</VStack>
|
</VStack>
|
||||||
</Box>
|
|
||||||
<Footer />
|
<Footer />
|
||||||
</VStack>
|
</VStack>
|
||||||
</Container>
|
</Container>
|
||||||
|
|||||||
Reference in New Issue
Block a user