Compare commits

..

6 Commits

Author SHA1 Message Date
RustamRu
95d26e58a3 Merge branch 'feat/landing' of ssh://85.143.175.152:222/dry_wash_inc/dry-wash-pl into feat/landing
All checks were successful
it-academy/dry-wash-pl/pipeline/head This commit looks good
2024-11-16 19:38:06 +03:00
RustamRu
bc629eabdf feat: add navigation keys and routing check (#24) 2024-11-16 19:37:50 +03:00
RustamRu
cba5beda72 feat: add navigation keys and routing check (#24)
All checks were successful
it-academy/dry-wash-pl/pipeline/head This commit looks good
2024-11-16 15:41:14 +03:00
RustamRu
3ade6f83cc Merge branch 'feat/landing' of ssh://85.143.175.152:222/dry_wash_inc/dry-wash-pl into feat/landing
All checks were successful
it-academy/dry-wash-pl/pipeline/head This commit looks good
2024-11-16 14:24:05 +03:00
RustamRu
897602c471 fix: align footer to bottom (#7) 2024-11-16 14:24:02 +03:00
RustamRu
d2b74a1467 fix: align footer to bottom (#7)
All checks were successful
it-academy/dry-wash-pl/pipeline/head This commit looks good
2024-11-10 12:34:01 +03:00
14 changed files with 77 additions and 97 deletions

View File

@@ -28,8 +28,6 @@
"dry-wash.arm.master.drawer.button.cancel": "Отменить",
"dry-wash.arm.master.sideBar.title": " Сухой мастер",
"dry-wash.arm.master.sideBar.title.master": "Мастера",
"dry-wash.arm.master.sideBar.title.orders": "Заказы",
"dry-wash.errorBoundary.title":"Что-то пошло не так",
"dry-wash.errorBoundary.description": " Мы уже работаем над исправлением проблемы",
"dry-wash.errorBoundary.button.reload": "Перезагрузить страницу"
"dry-wash.arm.master.sideBar.title.orders": "Заказы"
}

9
package-lock.json generated
View File

@@ -9,7 +9,7 @@
"version": "0.0.0",
"license": "ISC",
"dependencies": {
"@brojs/cli": "^1.6.1",
"@brojs/cli": "^1.6.2",
"@chakra-ui/icons": "^2.2.4",
"@chakra-ui/react": "^2.4.2",
"@emotion/react": "^11.4.1",
@@ -1564,9 +1564,10 @@
}
},
"node_modules/@brojs/cli": {
"version": "1.6.1",
"resolved": "https://git.bro-js.ru/api/packages/bro-js/npm/%40brojs%2Fcli/-/1.6.1/cli-1.6.1.tgz",
"integrity": "sha512-jcRv68xUxQKYdVOH+eFcuV2DquOU1qHqduozghho02aGNUN8/oB2RL5WQ8ssi4wPJ+HpwRpmpqcqQAnnb9F7Cg==",
"version": "1.6.2",
"resolved": "https://git.bro-js.ru/api/packages/bro-js/npm/%40brojs%2Fcli/-/1.6.2/cli-1.6.2.tgz",
"integrity": "sha512-IDGX5SMt1VQxW2TfY6onazeSjQgUaRut4rwRZVWgBfzHrdp7cHgobciQkF65baT8SfAeaM3w/XHaQr8X1VKGEg==",
"license": "ISC",
"dependencies": {
"@brojs/dev-server": "^1.6.1",
"@brojs/fire.app": "^1.6.1",

View File

@@ -17,7 +17,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"@brojs/cli": "^1.6.1",
"@brojs/cli": "^1.6.2",
"@chakra-ui/icons": "^2.2.4",
"@chakra-ui/react": "^2.4.2",
"@emotion/react": "^11.4.1",

24
src/__data__/urls.ts Normal file
View File

@@ -0,0 +1,24 @@
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 });
}
}
};

View File

@@ -2,16 +2,13 @@ import React from 'react';
import { BrowserRouter } from 'react-router-dom';
import Routers from './routes';
import { ChakraProvider, theme as chakraTheme } from '@chakra-ui/react';
import ErrorBoundary from './components/ErrorBoundary';
const App = () => {
return (
<ChakraProvider theme={chakraTheme}>
<ErrorBoundary>
<BrowserRouter>
<Routers />
<Routers></Routers>
</BrowserRouter>
</ErrorBoundary>
</ChakraProvider>
);
};

View File

@@ -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;

View File

@@ -1 +0,0 @@
export { default } from './ErrorBoundary';

View File

@@ -1,10 +1,11 @@
import React, { FC } from 'react';
import { Link as RouterLink } from 'react-router-dom';
import { ButtonProps, Button } from '@chakra-ui/react';
import { URLs } from '../../../__data__/urls';
export const CtaButton: FC<ButtonProps> = (props) => {
return (
<Button as={RouterLink} to='/dry-wash/order-form' colorScheme='primary' {...props}>
<Button as={RouterLink} to={URLs.orderForm.getUrl()} colorScheme='primary' {...props}>
Сделать заказ
</Button>
);

View File

@@ -1,3 +1,5 @@
import { Order } from "../../models";
type ReviewItem = {
id: string;
firstname: string;
@@ -32,3 +34,9 @@ export const mockReviews: ReviewItem[] = [
text: "К сожалению, мой опыт с сухой мойкой автомобилей оказался неудачным. Ожидала увидеть чистую машину после процедуры, но многие участки остались незаделанными. Кроме того, процедура заняла больше времени, чем мне обещали. Возможно, в этом конкретном центре что-то пошло не так, но я бы не стала повторно обращаться за этой услугой."
},
].map((data, i) => ({ id: `review${i}`, ...data }));
export const mockOrders: Order.View[] = [
{ id: 'id1' },
{ id: 'id2' },
{ id: 'id3' },
];

1
src/models/index.ts Normal file
View File

@@ -0,0 +1 @@
export * as Order from './order';

5
src/models/order.ts Normal file
View File

@@ -0,0 +1,5 @@
export type Id = string;
export type View = {
id: Id;
};

View File

@@ -1,5 +1,5 @@
import React, { FC } from 'react';
import { Box, Container, VStack } from '@chakra-ui/react';
import { Container, VStack } from '@chakra-ui/react';
import {
BenefitsSection,
Footer,
@@ -19,14 +19,12 @@ const Page: FC = () => {
bg='white'
centerContent
>
<VStack w='full' h='full' alignItems='stretch'>
<VStack w='full' h='full' alignItems='stretch' flexGrow={1}>
<HeroSection flexShrink={0} />
<Box flexGrow={1}>
<VStack as='main'>
<VStack as='main' flexGrow={1}>
<BenefitsSection />
<SocialProofSection />
</VStack>
</Box>
<Footer />
</VStack>
</Container>

View File

@@ -1,7 +1,20 @@
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 = () => {
return <h1>Order form </h1>;
return (
<>
<h1>Order form</h1>
{mockOrders.map(({ id }) => (
<Button key={id} as={RouterLink} to={URLs.orderView.getUrl(id)}>
Посмотреть заказ {id}
</Button>
))}
</>
);
};
export default Page;

View File

@@ -2,6 +2,7 @@ import React, { lazy, Suspense } from 'react';
import { Routes, Route } from 'react-router-dom';
import { PageSpinner } from './components';
import Arm from './pages/arm';
import { URLs } from './__data__/urls';
const Landing = lazy(() => import('./pages/landing'));
const OrderForm = lazy(() => import('./pages/order-form'));
@@ -11,11 +12,9 @@ const Routers = () => {
return (
<Suspense fallback={<PageSpinner />}>
<Routes>
<Route path='/dry-wash'>
<Route index element={<Landing />} />
<Route path='order-form' element={<OrderForm />} />
<Route path='order-view' element={<OrderView />} />
</Route>
<Route path={URLs.landing.url} element={<Landing />} />
<Route path={URLs.orderForm.url} element={<OrderForm />} />
<Route path={URLs.orderView.url} element={<OrderView />} />
<Route path='/dry-wash/arm' element={<Arm />}></Route>
</Routes>
</Suspense>