feat: add navigation keys and routing check (#24)
This commit is contained in:
parent
897602c471
commit
bc629eabdf
9
package-lock.json
generated
9
package-lock.json
generated
@ -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",
|
||||
|
@ -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
24
src/__data__/urls.ts
Normal 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 });
|
||||
}
|
||||
}
|
||||
};
|
@ -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>
|
||||
);
|
||||
|
@ -1,3 +1,5 @@
|
||||
import { Order } from "../../models";
|
||||
|
||||
type ReviewItem = {
|
||||
id: string;
|
||||
firstname: string;
|
||||
@ -31,4 +33,10 @@ export const mockReviews: ReviewItem[] = [
|
||||
picture: 'https://img.freepik.com/free-photo/portrait-young-blonde-woman-with-plait-polka-dot-blouse_273609-10490.jpg',
|
||||
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
src/models/index.ts
Normal file
1
src/models/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export * as Order from './order';
|
5
src/models/order.ts
Normal file
5
src/models/order.ts
Normal file
@ -0,0 +1,5 @@
|
||||
export type Id = string;
|
||||
|
||||
export type View = {
|
||||
id: Id;
|
||||
};
|
@ -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;
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user