mirror of
https://github.com/rjNemo/melon_frontend
synced 2026-06-12 13:26:43 +00:00
* chore: update deps to fix CVEs * cleanup * use variable for app routes * refactor * ⬆️ react router * ⬆️ react * delete pem files
62 lines
1.2 KiB
TypeScript
62 lines
1.2 KiB
TypeScript
import { Route, Routes } from 'react-router-dom';
|
|
import BillPage from './pages/bill';
|
|
import BillsPage from './pages/bills';
|
|
import HomePage from './pages/home';
|
|
import NewBillPage from './pages/newBill';
|
|
import NotFoundPage from './pages/notFound';
|
|
import ReportPage from './pages/report';
|
|
|
|
type Params = {
|
|
path: string;
|
|
component: ({ ...props }: any) => JSX.Element;
|
|
};
|
|
|
|
export const AppRoutes = {
|
|
home: '/',
|
|
bills: '/bills',
|
|
reports: '/reports',
|
|
catchAll: '*'
|
|
};
|
|
|
|
export default function Router() {
|
|
const routes: Params[] = [
|
|
// Home
|
|
{
|
|
path: AppRoutes.home,
|
|
component: HomePage
|
|
},
|
|
// Bills
|
|
{
|
|
path: `${AppRoutes.bills}/new`,
|
|
component: NewBillPage
|
|
},
|
|
{
|
|
path: AppRoutes.bills,
|
|
component: BillsPage
|
|
},
|
|
{
|
|
path: `${AppRoutes.bills}/:id`,
|
|
component: BillPage
|
|
},
|
|
// Reports
|
|
{
|
|
path: AppRoutes.reports,
|
|
component: ReportPage
|
|
},
|
|
// … rest
|
|
{
|
|
path: AppRoutes.catchAll,
|
|
component: NotFoundPage
|
|
}
|
|
];
|
|
|
|
return (
|
|
<>
|
|
<Routes>
|
|
{routes.map(({ path, component: Component }) => (
|
|
<Route key={path} path={path} element={<Component />} />
|
|
))}
|
|
</Routes>
|
|
</>
|
|
);
|
|
}
|