fixes bug in client side routing
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import React, { useState, useEffect, Fragment } from 'react';
|
||||
import {
|
||||
Route, Switch, withRouter, Redirect,
|
||||
} from 'react-router-dom';
|
||||
@@ -70,52 +70,59 @@ const Routes = () => {
|
||||
{config.collections.map((collection) => {
|
||||
const components = collection.components ? collection.components : {};
|
||||
return (
|
||||
<Switch key={collection.slug}>
|
||||
<Route
|
||||
path={`${match.url}/collections/${collection.slug}/create`}
|
||||
exact
|
||||
render={(routeProps) => {
|
||||
return (
|
||||
<Edit
|
||||
{...routeProps}
|
||||
collection={collection}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
|
||||
<Route
|
||||
path={`${match.url}/collections/${collection.slug}/:id`}
|
||||
exact
|
||||
render={(routeProps) => {
|
||||
return (
|
||||
<Edit
|
||||
{...routeProps}
|
||||
collection={collection}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
|
||||
<Route
|
||||
path={`${match.url}/collections/${collection.slug}`}
|
||||
exact
|
||||
render={(routeProps) => {
|
||||
const ListComponent = components.List ? components.List : List;
|
||||
return (
|
||||
<ListComponent
|
||||
{...routeProps}
|
||||
collection={collection}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
<Route>
|
||||
<NotFound />
|
||||
</Route>
|
||||
</Switch>
|
||||
<Route
|
||||
key={collection.slug}
|
||||
path={`${match.url}/collections/${collection.slug}`}
|
||||
exact
|
||||
render={(routeProps) => {
|
||||
const ListComponent = components.List ? components.List : List;
|
||||
return (
|
||||
<ListComponent
|
||||
{...routeProps}
|
||||
collection={collection}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
{config.collections.map((collection) => {
|
||||
return (
|
||||
<Route
|
||||
key={collection.slug}
|
||||
path={`${match.url}/collections/${collection.slug}/:id`}
|
||||
exact
|
||||
render={(routeProps) => {
|
||||
return (
|
||||
<Edit
|
||||
{...routeProps}
|
||||
collection={collection}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
{config.collections.map((collection) => {
|
||||
return (
|
||||
<Route
|
||||
key={collection.slug}
|
||||
path={`${match.url}/collections/${collection.slug}/create`}
|
||||
exact
|
||||
render={(routeProps) => {
|
||||
return (
|
||||
<Edit
|
||||
{...routeProps}
|
||||
collection={collection}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
<Route path={`${match.url}*`}>
|
||||
<NotFound />
|
||||
</Route>
|
||||
</Switch>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,26 +1,23 @@
|
||||
import React, { useEffect } from 'react';
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { useStepNav } from '../../../modules/StepNav';
|
||||
import DefaultTemplate from '../../../layout/DefaultTemplate';
|
||||
|
||||
import './index.scss';
|
||||
|
||||
const ListView = (props) => {
|
||||
const { setStepNav } = useStepNav();
|
||||
|
||||
const { collection } = props;
|
||||
|
||||
useEffect(() => {
|
||||
setStepNav([
|
||||
{
|
||||
label: collection.labels.plural,
|
||||
},
|
||||
]);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<article className="collection-list">
|
||||
<DefaultTemplate
|
||||
className="collection-list"
|
||||
stepNav={[
|
||||
{
|
||||
label: collection.labels.plural,
|
||||
},
|
||||
]}
|
||||
>
|
||||
<h1>{collection.labels.plural}</h1>
|
||||
</article>
|
||||
</DefaultTemplate>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user