dry-wash-pl/src/components/LayoutArm/LayoutArm.tsx
ilnaz dee3a04310
Some checks failed
it-academy/dry-wash-pl/pipeline/pr-main There was a failure building this commit
it-academy/dry-wash-pl/pipeline/head There was a failure building this commit
feat: add dynamic routing (#25)
2024-11-24 14:50:51 +03:00

38 lines
980 B
TypeScript

import { Box, Flex } from '@chakra-ui/react';
import React from 'react';
import { Navigate, Route, Routes } from 'react-router-dom';
import Sidebar from '../Sidebar';
import Orders from '../Orders';
import Masters from '../Masters';
import { URLs } from '../../__data__/urls';
const LayoutArm = () => {
let defaultRedirect = null;
if (URLs.armOrder.isOn) {
defaultRedirect = URLs.armOrder.url;
} else if (URLs.armMaster.isOn) {
defaultRedirect = URLs.armMaster.url;
}
return (
<Flex h='100vh'>
<Sidebar />
<Box flex='1' bg='gray.50'>
<Routes>
<Route index element={<Navigate to={defaultRedirect} replace />} />
{URLs.armOrder.isOn && (
<Route path={URLs.armOrder.url} element={<Orders />} />
)}
{URLs.armMaster.isOn && (
<Route path={URLs.armMaster.url} element={<Masters />} />
)}
</Routes>
</Box>
</Flex>
);
};
export default LayoutArm;