import React, { Fragment, lazy, Suspense } from 'react';
import { Redirect, Route, Switch } from 'react-router-dom';
import MainLayout from './layouts/MainLayout';
import LoadingScreen from './components/LoadingScreen';
import RegisterLayout from './layouts/RegisterLayout';
const routesConfig = [
{
exact: true,
path: '/',
component: () => ,
},
{
exact: true,
path: '/404',
layout: MainLayout,
component: lazy(() => import('./components/NotFound')),
},
{
path: '/auth',
layout: RegisterLayout,
routes: [
{
exact: true,
path: '/auth/register',
component: lazy(() => import('./views/Register')),
},
{
component: () => ,
},
],
},
{
path: '*',
layout: MainLayout,
routes: [
{
exact: true,
path: '/home',
component: lazy(() => import('./views/Home')),
},
{
exact: true,
path: '/topics/:id(\\bnew\\b|\\d+)',
component: lazy(() => import('./views/Topic')),
},
{
component: () => ,
},
],
},
];
const renderRoutes = (routes) => (routes ? (
}>
{routes.map((route, i) => {
const Layout = route.layout || Fragment;
const Component = route.component;
const key = route.path ? route.path.concat(i) : ''.concat(i);
return (
(
{route.routes
? renderRoutes(route.routes)
: }
)}
/>
);
})}
) : null);
function Routes() {
return renderRoutes(routesConfig);
}
export default Routes;