feat: add router to the arm page (#14)
This commit is contained in:
parent
9b3a204657
commit
116e883e91
@ -3,13 +3,19 @@ import Sidebar from '../Sidebar';
|
||||
import Orders from '../Orders';
|
||||
import Masters from '../Masters';
|
||||
import React from 'react';
|
||||
import { Navigate, Route, Routes } from 'react-router-dom';
|
||||
|
||||
const LayoutArm = ({ currentPage, onSelectPage }) => (
|
||||
const LayoutArm = () => (
|
||||
<Flex h='100vh'>
|
||||
<Sidebar onSelectPage={onSelectPage} />
|
||||
<Sidebar />
|
||||
<Box flex='1' bg='gray.50'>
|
||||
{currentPage === 'orders' && <Orders />}
|
||||
{currentPage === 'masters' && <Masters />}
|
||||
<Routes>
|
||||
<Route>
|
||||
<Route index element={<Navigate to='orders' replace />} />
|
||||
<Route path='orders' element={<Orders />} />
|
||||
<Route path='masters' element={<Masters />} />
|
||||
</Route>
|
||||
</Routes>
|
||||
</Box>
|
||||
</Flex>
|
||||
);
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { Box, Button, Heading, VStack } from '@chakra-ui/react';
|
||||
import React from 'react';
|
||||
import { Divider } from '@chakra-ui/react';
|
||||
|
||||
const Sidebar = ({ onSelectPage }) => (
|
||||
import { Link } from 'react-router-dom';
|
||||
const Sidebar = () => (
|
||||
<Box
|
||||
borderRight='1px solid black'
|
||||
bg='gray.50'
|
||||
@ -17,23 +17,17 @@ const Sidebar = ({ onSelectPage }) => (
|
||||
|
||||
<VStack align='start' spacing='4'>
|
||||
<Divider />
|
||||
<Button
|
||||
onClick={() => onSelectPage('orders')}
|
||||
w='100%'
|
||||
colorScheme='green'
|
||||
variant='ghost'
|
||||
>
|
||||
Заказы
|
||||
</Button>
|
||||
<Link to='orders'>
|
||||
<Button w='100%' colorScheme='green' variant='ghost'>
|
||||
Заказы
|
||||
</Button>
|
||||
</Link>
|
||||
<Divider />
|
||||
<Button
|
||||
onClick={() => onSelectPage('masters')}
|
||||
w='100%'
|
||||
colorScheme='green'
|
||||
variant='ghost'
|
||||
>
|
||||
Мастера
|
||||
</Button>
|
||||
<Link to='masters'>
|
||||
<Button w='100%' colorScheme='green' variant='ghost'>
|
||||
Мастера
|
||||
</Button>
|
||||
</Link>
|
||||
<Divider />
|
||||
</VStack>
|
||||
</Box>
|
||||
|
@ -2,9 +2,7 @@ import React, { useState } from 'react';
|
||||
import LayoutArm from '../../components/LayoutArm';
|
||||
|
||||
const Page = () => {
|
||||
const [currentPage, setCurrentPage] = useState('orders');
|
||||
|
||||
return <LayoutArm currentPage={currentPage} onSelectPage={setCurrentPage} />;
|
||||
return <LayoutArm />;
|
||||
};
|
||||
|
||||
export default Page;
|
||||
|
@ -9,7 +9,7 @@ const Routers = () => {
|
||||
<Routes>
|
||||
<Route path='/dry-wash' element={<Landing />}></Route>
|
||||
<Route path='/dry-wash/order' element={<Order />}></Route>
|
||||
<Route path='/dry-wash/arm' element={<Arm />}></Route>
|
||||
<Route path='/dry-wash/arm/*' element={<Arm />}></Route>
|
||||
</Routes>
|
||||
);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user