Created
June 23, 2017 15:23
-
-
Save skayred/e2454b16c255f6f06668c8b3a71272bf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const createCategorizedList = (routeCategory?: string) => { | |
return asyncConnect( | |
[{ | |
promise: (props: AsyncProps) => { | |
const page = props.location.query.page || 1; | |
const ordering = props.location.query.ordering || '-date_publish'; | |
const tag = props.location.query.tag || ''; | |
const category = routeCategory ? routeCategory : categoryFromProps(props); | |
const params = { page, ordering, tag, category }; | |
const requests = [ | |
{ | |
type: 'stati', | |
request: getArticles(params), | |
}, | |
]; | |
return selectedRequest(requests, props); | |
}, | |
}, | |
{ | |
promise: (props: AsyncProps) => { | |
const category = routeCategory ? routeCategory : categoryFromProps(props); | |
const tag = props.location.query.tag; | |
const crumbs: IBreadItem[] = [ | |
{ path: '/magazine' }, | |
{ path: '/stati' }, | |
]; | |
if (!!tag) { | |
const name = tag[0].toUpperCase() + tag.substr(1); | |
crumbs.push({ | |
path: tag, | |
url: `/stati?tag=${tag}`, | |
name, | |
}); | |
} else if (!!category) { | |
crumbs.push({ path: category }); | |
} | |
return props.store.dispatch(setBreadCrumb(crumbs)); | |
}, | |
}, | |
{ | |
promise: (props: AsyncProps) => props.store.dispatch(getDiscussed()), | |
}], | |
)(ArticlesConnected); | |
} | |
export const Articles = createCategorizedList(); | |
export const InterviewArticles = createCategorizedList('interview'); | |
export const ReviewArticles = createCategorizedList('review'); | |
export const AnalyticsArticles = createCategorizedList('analytics'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment