/
lizardking
/
react_final
Обзор
Документация
Войти
/
lizardking
/
react_final
Код
Запросы
1
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
old
src/app/router.tsx
76 строк
2 KB
LizardKing
Initial commit
22 ноя 2025, 15:56
22 ноя 2025, 15:56
0df0d9e
Код
Авторство
О чём код?
import { CartPage } from 'pages/CartPage' import { FavoritesPage } from 'pages/FavoritesPage' import { HomePage } from 'pages/HomePage' import { NotFoundPage } from 'pages/NotFoundPage' import { ProductPage } from 'pages/ProductPage' import { ProfilePage } from 'pages/ProfilePage' import { SignInPage } from 'pages/SignInPage' import { SignUpPage } from 'pages/SignUpPage' import { createBrowserRouter } from 'react-router-dom' import { Layout } from './Layout' enum AppRoutes { HOME = 'home', FAVORITES = 'favorites', PRODUCTS = 'products', PROFILE = 'profile', CART = 'cart', SIGNUP = 'signup', SIGNIN = 'signin', NOT_FOUND = 'not_found', } const RoutePath: Record<AppRoutes, `/${string}` | '*'> = { [AppRoutes.HOME]: '/', [AppRoutes.FAVORITES]: '/favorites', [AppRoutes.PRODUCTS]: '/products/:productId', [AppRoutes.PROFILE]: '/profile', [AppRoutes.CART]: '/cart', [AppRoutes.SIGNUP]: '/signup', [AppRoutes.SIGNIN]: '/signin', [AppRoutes.NOT_FOUND]: '*', } export const router = createBrowserRouter([ { path: RoutePath.home, element: <Layout />, children: [ { index: true, element: <HomePage />, }, { path: RoutePath.favorites, element: <FavoritesPage />, }, { path: RoutePath.products, element: <ProductPage />, }, { path: RoutePath.profile, element: <ProfilePage />, }, { path: RoutePath.cart, element: <CartPage />, }, { path: RoutePath.signup, element: <SignUpPage />, }, { path: RoutePath.signin, element: <SignInPage />, }, // last route { path: RoutePath.not_found, element: <NotFoundPage />, }, ], }, ])