Compare commits
1 Commits
cba5beda72
...
feature/er
| Author | SHA1 | Date | |
|---|---|---|---|
| d1d92c63e8 |
@@ -28,6 +28,8 @@
|
|||||||
"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": "Перезагрузить страницу"
|
||||||
}
|
}
|
||||||
|
|||||||
9
package-lock.json
generated
9
package-lock.json
generated
@@ -9,7 +9,7 @@
|
|||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@brojs/cli": "^1.6.2",
|
"@brojs/cli": "^1.6.1",
|
||||||
"@chakra-ui/icons": "^2.2.4",
|
"@chakra-ui/icons": "^2.2.4",
|
||||||
"@chakra-ui/react": "^2.4.2",
|
"@chakra-ui/react": "^2.4.2",
|
||||||
"@emotion/react": "^11.4.1",
|
"@emotion/react": "^11.4.1",
|
||||||
@@ -1564,10 +1564,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@brojs/cli": {
|
"node_modules/@brojs/cli": {
|
||||||
"version": "1.6.2",
|
"version": "1.6.1",
|
||||||
"resolved": "https://git.bro-js.ru/api/packages/bro-js/npm/%40brojs%2Fcli/-/1.6.2/cli-1.6.2.tgz",
|
"resolved": "https://git.bro-js.ru/api/packages/bro-js/npm/%40brojs%2Fcli/-/1.6.1/cli-1.6.1.tgz",
|
||||||
"integrity": "sha512-IDGX5SMt1VQxW2TfY6onazeSjQgUaRut4rwRZVWgBfzHrdp7cHgobciQkF65baT8SfAeaM3w/XHaQr8X1VKGEg==",
|
"integrity": "sha512-jcRv68xUxQKYdVOH+eFcuV2DquOU1qHqduozghho02aGNUN8/oB2RL5WQ8ssi4wPJ+HpwRpmpqcqQAnnb9F7Cg==",
|
||||||
"license": "ISC",
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@brojs/dev-server": "^1.6.1",
|
"@brojs/dev-server": "^1.6.1",
|
||||||
"@brojs/fire.app": "^1.6.1",
|
"@brojs/fire.app": "^1.6.1",
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@brojs/cli": "^1.6.2",
|
"@brojs/cli": "^1.6.1",
|
||||||
"@chakra-ui/icons": "^2.2.4",
|
"@chakra-ui/icons": "^2.2.4",
|
||||||
"@chakra-ui/react": "^2.4.2",
|
"@chakra-ui/react": "^2.4.2",
|
||||||
"@emotion/react": "^11.4.1",
|
"@emotion/react": "^11.4.1",
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
import { generatePath } from "react-router-dom";
|
|
||||||
import { getNavigationValue } from "@brojs/cli";
|
|
||||||
import { Order } from "../models";
|
|
||||||
|
|
||||||
export const URLs = {
|
|
||||||
landing: {
|
|
||||||
url: getNavigationValue("dry-wash.main"),
|
|
||||||
getUrl() {
|
|
||||||
return this.url;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
orderForm: {
|
|
||||||
url: getNavigationValue("dry-wash.create"),
|
|
||||||
getUrl() {
|
|
||||||
return this.url;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
orderView: {
|
|
||||||
url: getNavigationValue("dry-wash.view.order"),
|
|
||||||
getUrl(orderId: Order.Id) {
|
|
||||||
return generatePath(this.url, { orderId });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -2,13 +2,16 @@ 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}>
|
||||||
<BrowserRouter>
|
<ErrorBoundary>
|
||||||
<Routers></Routers>
|
<BrowserRouter>
|
||||||
</BrowserRouter>
|
<Routers />
|
||||||
|
</BrowserRouter>
|
||||||
|
</ErrorBoundary>
|
||||||
</ChakraProvider>
|
</ChakraProvider>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
64
src/components/ErrorBoundary/ErrorBoundary.tsx
Normal file
64
src/components/ErrorBoundary/ErrorBoundary.tsx
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
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
src/components/ErrorBoundary/index.ts
Normal file
1
src/components/ErrorBoundary/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export { default } from './ErrorBoundary';
|
||||||
@@ -1,11 +1,10 @@
|
|||||||
import React, { FC } from 'react';
|
import React, { FC } from 'react';
|
||||||
import { Link as RouterLink } from 'react-router-dom';
|
import { Link as RouterLink } from 'react-router-dom';
|
||||||
import { ButtonProps, Button } from '@chakra-ui/react';
|
import { ButtonProps, Button } from '@chakra-ui/react';
|
||||||
import { URLs } from '../../../__data__/urls';
|
|
||||||
|
|
||||||
export const CtaButton: FC<ButtonProps> = (props) => {
|
export const CtaButton: FC<ButtonProps> = (props) => {
|
||||||
return (
|
return (
|
||||||
<Button as={RouterLink} to={URLs.orderForm.getUrl()} colorScheme='primary' {...props}>
|
<Button as={RouterLink} to='/dry-wash/order-form' colorScheme='primary' {...props}>
|
||||||
Сделать заказ
|
Сделать заказ
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import { Order } from "../../models";
|
|
||||||
|
|
||||||
type ReviewItem = {
|
type ReviewItem = {
|
||||||
id: string;
|
id: string;
|
||||||
firstname: string;
|
firstname: string;
|
||||||
@@ -33,10 +31,4 @@ export const mockReviews: ReviewItem[] = [
|
|||||||
picture: 'https://img.freepik.com/free-photo/portrait-young-blonde-woman-with-plait-polka-dot-blouse_273609-10490.jpg',
|
picture: 'https://img.freepik.com/free-photo/portrait-young-blonde-woman-with-plait-polka-dot-blouse_273609-10490.jpg',
|
||||||
text: "К сожалению, мой опыт с сухой мойкой автомобилей оказался неудачным. Ожидала увидеть чистую машину после процедуры, но многие участки остались незаделанными. Кроме того, процедура заняла больше времени, чем мне обещали. Возможно, в этом конкретном центре что-то пошло не так, но я бы не стала повторно обращаться за этой услугой."
|
text: "К сожалению, мой опыт с сухой мойкой автомобилей оказался неудачным. Ожидала увидеть чистую машину после процедуры, но многие участки остались незаделанными. Кроме того, процедура заняла больше времени, чем мне обещали. Возможно, в этом конкретном центре что-то пошло не так, но я бы не стала повторно обращаться за этой услугой."
|
||||||
},
|
},
|
||||||
].map((data, i) => ({ id: `review${i}`, ...data }));
|
].map((data, i) => ({ id: `review${i}`, ...data }));
|
||||||
|
|
||||||
export const mockOrders: Order.View[] = [
|
|
||||||
{ id: 'id1' },
|
|
||||||
{ id: 'id2' },
|
|
||||||
{ id: 'id3' },
|
|
||||||
];
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
export * as Order from './order';
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
export type Id = string;
|
|
||||||
|
|
||||||
export type View = {
|
|
||||||
id: Id;
|
|
||||||
};
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import React, { FC } from 'react';
|
import React, { FC } from 'react';
|
||||||
import { Container, VStack } from '@chakra-ui/react';
|
import { Box, Container, VStack } from '@chakra-ui/react';
|
||||||
import {
|
import {
|
||||||
BenefitsSection,
|
BenefitsSection,
|
||||||
Footer,
|
Footer,
|
||||||
@@ -19,12 +19,14 @@ const Page: FC = () => {
|
|||||||
bg='white'
|
bg='white'
|
||||||
centerContent
|
centerContent
|
||||||
>
|
>
|
||||||
<VStack w='full' h='full' alignItems='stretch' flexGrow={1}>
|
<VStack w='full' h='full' alignItems='stretch'>
|
||||||
<HeroSection flexShrink={0} />
|
<HeroSection flexShrink={0} />
|
||||||
<VStack as='main' flexGrow={1}>
|
<Box flexGrow={1}>
|
||||||
<BenefitsSection />
|
<VStack as='main'>
|
||||||
<SocialProofSection />
|
<BenefitsSection />
|
||||||
</VStack>
|
<SocialProofSection />
|
||||||
|
</VStack>
|
||||||
|
</Box>
|
||||||
<Footer />
|
<Footer />
|
||||||
</VStack>
|
</VStack>
|
||||||
</Container>
|
</Container>
|
||||||
|
|||||||
@@ -1,20 +1,7 @@
|
|||||||
import React from 'react';
|
import React from "react";
|
||||||
import { Link as RouterLink } from 'react-router-dom';
|
|
||||||
import { Button } from '@chakra-ui/react';
|
|
||||||
import { URLs } from '../../__data__/urls';
|
|
||||||
import { mockOrders } from '../../mocks/landing';
|
|
||||||
|
|
||||||
const Page = () => {
|
const Page = () => {
|
||||||
return (
|
return <h1>Order form </h1>;
|
||||||
<>
|
|
||||||
<h1>Order form</h1>
|
|
||||||
{mockOrders.map(({ id }) => (
|
|
||||||
<Button key={id} as={RouterLink} to={URLs.orderView.getUrl(id)}>
|
|
||||||
Посмотреть заказ {id}
|
|
||||||
</Button>
|
|
||||||
))}
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Page;
|
export default Page;
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import React, { lazy, Suspense } from 'react';
|
|||||||
import { Routes, Route } from 'react-router-dom';
|
import { Routes, Route } from 'react-router-dom';
|
||||||
import { PageSpinner } from './components';
|
import { PageSpinner } from './components';
|
||||||
import Arm from './pages/arm';
|
import Arm from './pages/arm';
|
||||||
import { URLs } from './__data__/urls';
|
|
||||||
|
|
||||||
const Landing = lazy(() => import('./pages/landing'));
|
const Landing = lazy(() => import('./pages/landing'));
|
||||||
const OrderForm = lazy(() => import('./pages/order-form'));
|
const OrderForm = lazy(() => import('./pages/order-form'));
|
||||||
@@ -12,9 +11,11 @@ const Routers = () => {
|
|||||||
return (
|
return (
|
||||||
<Suspense fallback={<PageSpinner />}>
|
<Suspense fallback={<PageSpinner />}>
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path={URLs.landing.url} element={<Landing />} />
|
<Route path='/dry-wash'>
|
||||||
<Route path={URLs.orderForm.url} element={<OrderForm />} />
|
<Route index element={<Landing />} />
|
||||||
<Route path={URLs.orderView.url} element={<OrderView />} />
|
<Route path='order-form' element={<OrderForm />} />
|
||||||
|
<Route path='order-view' element={<OrderView />} />
|
||||||
|
</Route>
|
||||||
<Route path='/dry-wash/arm' element={<Arm />}></Route>
|
<Route path='/dry-wash/arm' element={<Arm />}></Route>
|
||||||
</Routes>
|
</Routes>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
|
|||||||
Reference in New Issue
Block a user