I'm working in a project where i need to divide the browser router in two, one for the public users and other for the admins, this is my idea:
<BrowserRouter>
<Layout>
<Route exact path="/" component="{Home}">
<Switch>
<Route exact path="/cart" component="{Cart}" />
<Route exact path="/product/:productId" component="{ProductPage}" />
<Route component="{NotFound}" />
</Switch>
</Route>
</Layout>
<AdminLayout>
<Route exact path="/admin" component="{AdminHome}">
<Switch>
<Route exact path="/products" component="{AdminProductsList}" />
<Route
exact
path="/product/:productId"
component="{AdminEditProduct}"
/>
<Route component="{NotFound}" />
</Switch>
</Route>
</AdminLayout>
</BrowserRouter>
it clearly doesn't work this way but i would like to know which is the best way to make this work
UPDATE
now i've been working on it and i got to this
<BrowserRouter>
<Switch>
<Layout>
<Route path="/">
<Switch>
<Route exact path="/" component="{Home}" />
<Route exact path="/cart" component="{Cart}" />
<Route exact path="/product/:productId" component="{ProductPage}" />
<Route component="{NotFound}" />
</Switch>
</Route>
</Layout>
<AdminLayout>
<Route path="/admin">
<Switch>
<Route exact path="/" component="{AdminHome}" />
<Route exact path="/products" component="{AdminProductsList}" />
<Route
exact
path="/product/:productId"
component="{AdminEditProduct}"
/>
<Route component="{NotFound}" />
</Switch>
</Route>
</AdminLayout>
</Switch>
</BrowserRouter>
the public("/") route works just fine but the admin("/admin") throws me a 404