Fixed router.

This commit is contained in:
WildScotsmen 2018-12-11 16:52:23 -05:00
parent 6d4d73afdd
commit 8b2fe49b31
3 changed files with 43 additions and 26 deletions

View File

@ -224,17 +224,17 @@ class ResponsiveDrawer extends React.Component {
</ListItem>
<Collapse in={this.state.open} timeout="auto" unmountOnExit>
<List component="div" disablePadding>
<Link to='/quiz-easy'>
<Link to={{pathname: '/quiz-easy', state: {difficulty: 'Easy'}}}>
<ListItem button className={classes.nested}>
<ListItemText inset primary="Easy" />
</ListItem>
</Link>
<Link to='/quiz-intermediate'>
<Link to={{pathname: '/quiz-intermediate', state: {difficulty: 'Intermediate'}}}>
<ListItem button className={classes.nested}>
<ListItemText inset primary="Intermediate" />
</ListItem>
</Link>
<Link to='/quiz-advanced'>
<Link to={{pathname: '/quiz-advanced', state: {difficulty: 'Advanced'}}}>
<ListItem button className={classes.nested}>
<ListItemText inset primary="Advanced" />
</ListItem>
@ -262,22 +262,22 @@ class ResponsiveDrawer extends React.Component {
</ListItem>
<Collapse in={this.state.open2} timeout="auto" unmountOnExit>
<List component="div" disablePadding>
<Link to='galleries-martens-and-kits'>
<Link to={{pathname: 'galleries-martens-and-kits', state: {galleryName: 'martensAndKits'}}}>
<ListItem button className={classes.nested}>
<ListItemText inset primary="Martens and Kits" />
</ListItem>
</Link>
<Link to='galleries-martens-at-night'>
<Link to={{pathname: 'galleries-martens-at-night', state: {galleryName: 'martensAtNight'}}}>
<ListItem button className={classes.nested}>
<ListItemText inset primary="Martens at Night" />
</ListItem>
</Link>
<Link to='galleries-martens-by-day'>
<Link to={{pathname: 'galleries-martens-by-day', state: {galleryName: 'martensBeingMartens'}}}>
<ListItem button className={classes.nested}>
<ListItemText inset primary="Martens by Day" />
</ListItem>
</Link>
<Link to='galleries-species-similar-to-martens'>
<Link to={{pathname: 'galleries-species-similar-to-martens', state: {galleryName: 'similarSpecies'}}}>
<ListItem button className={classes.nested}>
<ListItemText inset primary="Species Similar to Martens" />
</ListItem>
@ -348,19 +348,19 @@ class ResponsiveDrawer extends React.Component {
<main className={classes.content}>
<div className={classes.toolbar} />
<Switch>
<Route path="/" exact={true} render={Home} />
<Route path="/report" render={ (props) => { return <Report {...props}/> }} />
<Route path="/view-map" render={ (props) => { return <ViewMap {...props}/> }} />
<Route path="/sighting-list" render={ (props) => { return <SightingList {...props} themeName={this.state.themeName}/> }} />
<Route path="/about" render={ (props) => { return <About {...props}/> }} />
<Route path="/contact" render={ (props) => { return <Contact {...props}/> }} />
<Route path="/quiz-easy" render={ (props) => { return <Quiz {...props} difficulty='Easy'/> }} />
<Route path="/quiz-intermediate" render={ (props) => { return <Quiz {...props} difficulty='Intermediate'/> }} />
<Route path="/quiz-advanced" render={ (props) => { return <Quiz {...props} difficulty='Advanced'/> }} />
<Route path="/galleries-martens-and-kits" render={ (props) => { return <FlameLinkCollectionGallery {...props} galleryName={'martensAndKits'}/> }} />
<Route path="/galleries-martens-at-night" render={ (props) => { return <FlameLinkCollectionGallery {...props} galleryName={'martensAtNight'}/> }} />
<Route path="/galleries-martens-by-day" render={ (props) => { return <FlameLinkCollectionGallery {...props} galleryName={'martensBeingMartens'}/> }} />
<Route path="/galleries-species-similar-to-martens" render={ (props) => { return <FlameLinkCollectionGallery {...props} galleryName={'similarSpecies'}/> }} />
<Route path="/" component={Home} exact={true} />
<Route path="/report" component={Report} />
<Route path="/view-map" component={ViewMap} />
<Route path="/sighting-list" component={SightingList} />
<Route path="/about" component={About} />
<Route path="/contact" component={Contact} />
<Route path="/quiz-easy" component={Quiz} key={"Easy"}/>
<Route path="/quiz-intermediate" component={Quiz} key={"Intermediate"}/>
<Route path="/quiz-advanced" component={Quiz} key={"Advanced"} />
<Route path="/galleries-martens-and-kits" component={FlameLinkCollectionGallery} key={"martensAndKits"}/>
<Route path="/galleries-martens-at-night" component={FlameLinkCollectionGallery} key={"martensAtNight"} />
<Route path="/galleries-martens-by-day" component={FlameLinkCollectionGallery} key={"martensByDay"} />
<Route path="/galleries-species-similar-to-martens" component={FlameLinkCollectionGallery} key={"similarSpecies"} />
</Switch>
</main>
</div>

View File

@ -44,25 +44,41 @@ class FlameLinkCollectionGallery extends Component {
constructor(props) {
super(props);
var galleryName, showTitle;
if (this.props.galleryName !== undefined) {
galleryName = this.props.galleryName;
} else {
galleryName = this.props.location.state.galleryName;
}
if (this.props.showTitle !== undefined) {
showTitle = this.props.showTitle;
} else {
showTitle = this.props.location.state.showTitle;
}
this.state = {
galleryName: galleryName,
showTitle: showTitle,
schemaDetails: '',
schemaContent: '',
schemaDescription: '',
};
flamelinkApp.schemas.getFields(this.props.galleryName, { fields: ['title', 'key', 'type', 'gridColumns', 'description', 'options'] })
flamelinkApp.schemas.getFields(this.state.galleryName, { fields: ['title', 'key', 'type', 'gridColumns', 'description', 'options'] })
.then(result => this.setState({
schemaDetails: result
}))
flamelinkApp.content.get(this.props.galleryName)
flamelinkApp.content.get(this.state.galleryName)
.then(result => this.setState({
schemaContent: result
}))
if (this.props.showTitle === false) {
if (this.state.showTitle === false) {
} else {
flamelinkApp.schemas.get(this.props.galleryName)
flamelinkApp.schemas.get(this.state.galleryName)
.then(result => this.setState({
schemaDescription: result.title
}))

View File

@ -3,13 +3,14 @@ import QuizGame from '../components/QuizGame';
class QuizPage extends Component {
componentDidMount() {
componentWillMount() {
document.title = 'Marten Tracker | Quiz';
this.setState({difficulty: this.props.location.state.difficulty});
}
render() {
return (
<QuizGame difficulty={this.props.difficulty}/>
<QuizGame difficulty={this.state.difficulty}/>
);
}
}