GraphQL API and utilities for the rpdata project
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

43 lines
1.5 KiB

import React, { Component } from "react"
import { Route, Switch } from "react-router-dom";
import { Query } from "react-apollo"
import StoryMenu from "./StoryMenu"
import Background from "../../common/Background"
import { LoadingScreen } from "../../common/LoadingScreen"
import storyRootQuery from "./gql/StoryRoot"
import StoryList from "./StoryList";
import StoryTags from "./StoryTags";
export class StoryIndex extends Component {
render() {
const categories = this.props.categoryType.enumValues.map(ev => ev.name).sort()
return (
<div className="StoryIndex theme-story">
<Background />
<StoryMenu categories={categories} />
<Switch>
<Route exact path="/story/" component={() => <StoryList filter={{}} />} />
<Route exact path="/story/open/" component={() => <StoryList filter={{open: true}} />} />
<Route exact path="/story/tags/" component={StoryTags} />
<Route exact path="/story/tag/:kind/:name/" component={({match}) => <StoryList filter={{tags: [match.params]}} />} />
<Route exact path="/story/category/:category/" component={({match: {params: {category}}}) => <StoryList filter={{category}} />} />
</Switch>
</div>
)
}
}
export default () => (
<Query query={storyRootQuery}>
{({ loading, error, data }) => {
if (loading) return <LoadingScreen className="theme-story" />
if (error) return `Error! ${error.message}`
return <StoryIndex {...data} />
}}
</Query>
)