Fixed router.
This commit is contained in:
parent
6d4d73afdd
commit
8b2fe49b31
|
@ -224,17 +224,17 @@ class ResponsiveDrawer extends React.Component {
|
||||||
</ListItem>
|
</ListItem>
|
||||||
<Collapse in={this.state.open} timeout="auto" unmountOnExit>
|
<Collapse in={this.state.open} timeout="auto" unmountOnExit>
|
||||||
<List component="div" disablePadding>
|
<List component="div" disablePadding>
|
||||||
<Link to='/quiz-easy'>
|
<Link to={{pathname: '/quiz-easy', state: {difficulty: 'Easy'}}}>
|
||||||
<ListItem button className={classes.nested}>
|
<ListItem button className={classes.nested}>
|
||||||
<ListItemText inset primary="Easy" />
|
<ListItemText inset primary="Easy" />
|
||||||
</ListItem>
|
</ListItem>
|
||||||
</Link>
|
</Link>
|
||||||
<Link to='/quiz-intermediate'>
|
<Link to={{pathname: '/quiz-intermediate', state: {difficulty: 'Intermediate'}}}>
|
||||||
<ListItem button className={classes.nested}>
|
<ListItem button className={classes.nested}>
|
||||||
<ListItemText inset primary="Intermediate" />
|
<ListItemText inset primary="Intermediate" />
|
||||||
</ListItem>
|
</ListItem>
|
||||||
</Link>
|
</Link>
|
||||||
<Link to='/quiz-advanced'>
|
<Link to={{pathname: '/quiz-advanced', state: {difficulty: 'Advanced'}}}>
|
||||||
<ListItem button className={classes.nested}>
|
<ListItem button className={classes.nested}>
|
||||||
<ListItemText inset primary="Advanced" />
|
<ListItemText inset primary="Advanced" />
|
||||||
</ListItem>
|
</ListItem>
|
||||||
|
@ -262,22 +262,22 @@ class ResponsiveDrawer extends React.Component {
|
||||||
</ListItem>
|
</ListItem>
|
||||||
<Collapse in={this.state.open2} timeout="auto" unmountOnExit>
|
<Collapse in={this.state.open2} timeout="auto" unmountOnExit>
|
||||||
<List component="div" disablePadding>
|
<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}>
|
<ListItem button className={classes.nested}>
|
||||||
<ListItemText inset primary="Martens and Kits" />
|
<ListItemText inset primary="Martens and Kits" />
|
||||||
</ListItem>
|
</ListItem>
|
||||||
</Link>
|
</Link>
|
||||||
<Link to='galleries-martens-at-night'>
|
<Link to={{pathname: 'galleries-martens-at-night', state: {galleryName: 'martensAtNight'}}}>
|
||||||
<ListItem button className={classes.nested}>
|
<ListItem button className={classes.nested}>
|
||||||
<ListItemText inset primary="Martens at Night" />
|
<ListItemText inset primary="Martens at Night" />
|
||||||
</ListItem>
|
</ListItem>
|
||||||
</Link>
|
</Link>
|
||||||
<Link to='galleries-martens-by-day'>
|
<Link to={{pathname: 'galleries-martens-by-day', state: {galleryName: 'martensBeingMartens'}}}>
|
||||||
<ListItem button className={classes.nested}>
|
<ListItem button className={classes.nested}>
|
||||||
<ListItemText inset primary="Martens by Day" />
|
<ListItemText inset primary="Martens by Day" />
|
||||||
</ListItem>
|
</ListItem>
|
||||||
</Link>
|
</Link>
|
||||||
<Link to='galleries-species-similar-to-martens'>
|
<Link to={{pathname: 'galleries-species-similar-to-martens', state: {galleryName: 'similarSpecies'}}}>
|
||||||
<ListItem button className={classes.nested}>
|
<ListItem button className={classes.nested}>
|
||||||
<ListItemText inset primary="Species Similar to Martens" />
|
<ListItemText inset primary="Species Similar to Martens" />
|
||||||
</ListItem>
|
</ListItem>
|
||||||
|
@ -348,19 +348,19 @@ class ResponsiveDrawer extends React.Component {
|
||||||
<main className={classes.content}>
|
<main className={classes.content}>
|
||||||
<div className={classes.toolbar} />
|
<div className={classes.toolbar} />
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route path="/" exact={true} render={Home} />
|
<Route path="/" component={Home} exact={true} />
|
||||||
<Route path="/report" render={ (props) => { return <Report {...props}/> }} />
|
<Route path="/report" component={Report} />
|
||||||
<Route path="/view-map" render={ (props) => { return <ViewMap {...props}/> }} />
|
<Route path="/view-map" component={ViewMap} />
|
||||||
<Route path="/sighting-list" render={ (props) => { return <SightingList {...props} themeName={this.state.themeName}/> }} />
|
<Route path="/sighting-list" component={SightingList} />
|
||||||
<Route path="/about" render={ (props) => { return <About {...props}/> }} />
|
<Route path="/about" component={About} />
|
||||||
<Route path="/contact" render={ (props) => { return <Contact {...props}/> }} />
|
<Route path="/contact" component={Contact} />
|
||||||
<Route path="/quiz-easy" render={ (props) => { return <Quiz {...props} difficulty='Easy'/> }} />
|
<Route path="/quiz-easy" component={Quiz} key={"Easy"}/>
|
||||||
<Route path="/quiz-intermediate" render={ (props) => { return <Quiz {...props} difficulty='Intermediate'/> }} />
|
<Route path="/quiz-intermediate" component={Quiz} key={"Intermediate"}/>
|
||||||
<Route path="/quiz-advanced" render={ (props) => { return <Quiz {...props} difficulty='Advanced'/> }} />
|
<Route path="/quiz-advanced" component={Quiz} key={"Advanced"} />
|
||||||
<Route path="/galleries-martens-and-kits" render={ (props) => { return <FlameLinkCollectionGallery {...props} galleryName={'martensAndKits'}/> }} />
|
<Route path="/galleries-martens-and-kits" component={FlameLinkCollectionGallery} key={"martensAndKits"}/>
|
||||||
<Route path="/galleries-martens-at-night" render={ (props) => { return <FlameLinkCollectionGallery {...props} galleryName={'martensAtNight'}/> }} />
|
<Route path="/galleries-martens-at-night" component={FlameLinkCollectionGallery} key={"martensAtNight"} />
|
||||||
<Route path="/galleries-martens-by-day" render={ (props) => { return <FlameLinkCollectionGallery {...props} galleryName={'martensBeingMartens'}/> }} />
|
<Route path="/galleries-martens-by-day" component={FlameLinkCollectionGallery} key={"martensByDay"} />
|
||||||
<Route path="/galleries-species-similar-to-martens" render={ (props) => { return <FlameLinkCollectionGallery {...props} galleryName={'similarSpecies'}/> }} />
|
<Route path="/galleries-species-similar-to-martens" component={FlameLinkCollectionGallery} key={"similarSpecies"} />
|
||||||
</Switch>
|
</Switch>
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -44,25 +44,41 @@ class FlameLinkCollectionGallery extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(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 = {
|
this.state = {
|
||||||
|
galleryName: galleryName,
|
||||||
|
showTitle: showTitle,
|
||||||
schemaDetails: '',
|
schemaDetails: '',
|
||||||
schemaContent: '',
|
schemaContent: '',
|
||||||
schemaDescription: '',
|
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({
|
.then(result => this.setState({
|
||||||
schemaDetails: result
|
schemaDetails: result
|
||||||
}))
|
}))
|
||||||
|
|
||||||
flamelinkApp.content.get(this.props.galleryName)
|
flamelinkApp.content.get(this.state.galleryName)
|
||||||
.then(result => this.setState({
|
.then(result => this.setState({
|
||||||
schemaContent: result
|
schemaContent: result
|
||||||
}))
|
}))
|
||||||
|
|
||||||
if (this.props.showTitle === false) {
|
if (this.state.showTitle === false) {
|
||||||
} else {
|
} else {
|
||||||
flamelinkApp.schemas.get(this.props.galleryName)
|
flamelinkApp.schemas.get(this.state.galleryName)
|
||||||
.then(result => this.setState({
|
.then(result => this.setState({
|
||||||
schemaDescription: result.title
|
schemaDescription: result.title
|
||||||
}))
|
}))
|
||||||
|
|
|
@ -3,13 +3,14 @@ import QuizGame from '../components/QuizGame';
|
||||||
|
|
||||||
|
|
||||||
class QuizPage extends Component {
|
class QuizPage extends Component {
|
||||||
componentDidMount() {
|
componentWillMount() {
|
||||||
document.title = 'Marten Tracker | Quiz';
|
document.title = 'Marten Tracker | Quiz';
|
||||||
|
this.setState({difficulty: this.props.location.state.difficulty});
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<QuizGame difficulty={this.props.difficulty}/>
|
<QuizGame difficulty={this.state.difficulty}/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue