converts all filters in collection views to find

This commit is contained in:
James
2018-09-17 20:11:56 -04:00
parent 251a656da6
commit 70e76d80ef
14 changed files with 65 additions and 34 deletions

View File

@@ -21,8 +21,8 @@ class Sidebar extends Component {
</Link>
<Label>Collections</Label>
<nav>
{Object.keys(this.props.collections).map((key, i) => {
const href = `/collections/${key}`;
{this.props.collections.map((item, i) => {
const href = `/collections/${item.slug}`;
const classes = this.props.location.pathname.indexOf(href) > -1
? 'active'
: undefined;
@@ -30,7 +30,7 @@ class Sidebar extends Component {
return (
<Link className={classes} key={i} to={href}>
<Arrow />
{this.props.collections[key].plural}
{this.props.collections[i].plural}
</Link>
);
})}

View File

@@ -3,14 +3,17 @@ import { Switch, Route } from 'react-router-dom';
import CollectionComponents from 'local/client/components/collections';
export default props => {
return Object.keys(props.collections).map((key, i) => {
return (
<Switch key={i}>
<Route path={`/collections/${key}/add-new`} exact component={CollectionComponents[key].
Add} />
<Route path={`/collections/${key}`} exact component={CollectionComponents[key].Archive} />
<Route path={`/collections/${key}/:id`} component={CollectionComponents[key].Edit} />
</Switch>
);
return props.collections.map((collection, i) => {
if (collection) {
return (
<Switch key={i}>
<Route path={`/collections/${collection.slug}/add-new`} exact component={CollectionComponents[collection.slug].Add} />
<Route path={`/collections/${collection.slug}`} exact component={CollectionComponents[collection.slug].Archive} />
<Route path={`/collections/${collection.slug}/:id`} component={CollectionComponents[collection.slug].Edit} />
</Switch>
);
}
return null;
});
};

View File

@@ -8,9 +8,7 @@ export default (state = defaultState, action) => {
return {
...state,
all: {
[action.payload.slug]: action.payload
}
all: action.payload
};
default: