mirror of
https://github.com/ascribe/onion.git
synced 2025-01-08 20:55:59 +01:00
Redirect if no artworks are found
This commit is contained in:
parent
1aa2863b80
commit
5ea6095f6a
@ -20,7 +20,7 @@ import AppConstants from '../constants/application_constants';
|
|||||||
|
|
||||||
let PieceList = React.createClass({
|
let PieceList = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
query: React.PropTypes.object
|
redirectTo: React.PropTypes.string
|
||||||
},
|
},
|
||||||
|
|
||||||
mixins: [Router.Navigation, Router.State],
|
mixins: [Router.Navigation, Router.State],
|
||||||
@ -30,7 +30,7 @@ let PieceList = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
let page = this.props.query.page || 1;
|
let page = this.getQuery().page || 1;
|
||||||
PieceListStore.listen(this.onChange);
|
PieceListStore.listen(this.onChange);
|
||||||
if (this.state.pieceList.length === 0){
|
if (this.state.pieceList.length === 0){
|
||||||
PieceListActions.fetchPieceList(page, this.state.pageSize, this.state.search, this.state.orderBy, this.state.orderAsc)
|
PieceListActions.fetchPieceList(page, this.state.pageSize, this.state.search, this.state.orderBy, this.state.orderAsc)
|
||||||
@ -38,6 +38,12 @@ let PieceList = React.createClass({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
componentDidUpdate() {
|
||||||
|
if (this.props.redirectTo && this.state.pieceListCount === 0) {
|
||||||
|
this.transitionTo(this.props.redirectTo);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
PieceListStore.unlisten(this.onChange);
|
PieceListStore.unlisten(this.onChange);
|
||||||
},
|
},
|
||||||
@ -67,7 +73,7 @@ let PieceList = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
getPagination() {
|
getPagination() {
|
||||||
let currentPage = parseInt(this.props.query.page, 10) || 1;
|
let currentPage = parseInt(this.getQuery().page, 10) || 1;
|
||||||
let totalPages = Math.ceil(this.state.pieceListCount / this.state.pageSize);
|
let totalPages = Math.ceil(this.state.pieceListCount / this.state.pageSize);
|
||||||
|
|
||||||
if (this.state.pieceListCount > 10) {
|
if (this.state.pieceListCount > 10) {
|
||||||
|
15
js/components/whitelabel/prize/components/piece_list.js
Normal file
15
js/components/whitelabel/prize/components/piece_list.js
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
import React from 'react';
|
||||||
|
import PieceList from '../../../piece_list';
|
||||||
|
|
||||||
|
|
||||||
|
let PrizePieceList = React.createClass({
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<PieceList redirectTo="register_piece" />
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export default PrizePieceList;
|
@ -8,7 +8,7 @@ import LoginContainer from './components/login_container';
|
|||||||
import SignupContainer from './components/signup_container';
|
import SignupContainer from './components/signup_container';
|
||||||
import PasswordResetContainer from '../../../components/password_reset_container';
|
import PasswordResetContainer from '../../../components/password_reset_container';
|
||||||
import RegisterPiece from '../../../components/register_piece';
|
import RegisterPiece from '../../../components/register_piece';
|
||||||
import PieceList from '../../../components/piece_list';
|
import PrizePieceList from './components/piece_list';
|
||||||
|
|
||||||
import App from './app';
|
import App from './app';
|
||||||
import AppConstants from '../../../constants/application_constants';
|
import AppConstants from '../../../constants/application_constants';
|
||||||
@ -25,7 +25,7 @@ function getRoutes(commonRoutes) {
|
|||||||
<Route name="signup" path="signup" handler={SignupContainer} />
|
<Route name="signup" path="signup" handler={SignupContainer} />
|
||||||
<Route name="password_reset" path="password_reset" handler={PasswordResetContainer} />
|
<Route name="password_reset" path="password_reset" handler={PasswordResetContainer} />
|
||||||
<Route name="register_piece" path="register_piece" handler={RegisterPiece} />
|
<Route name="register_piece" path="register_piece" handler={RegisterPiece} />
|
||||||
<Route name="pieces" path="collection" handler={PieceList} />
|
<Route name="pieces" path="collection" handler={PrizePieceList} />
|
||||||
</Route>
|
</Route>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user