30 lines
677 B
TypeScript
Raw Normal View History

import logger from 'app/services/logger';
2016-08-02 21:59:29 +03:00
import AbstractState from './AbstractState';
import CompleteState from './CompleteState';
export default class AcceptRulesState extends AbstractState {
enter(context) {
const { user } = context.getState();
2016-08-02 21:59:29 +03:00
if (user.shouldAcceptRules) {
context.navigate('/accept-rules');
} else {
context.setState(new CompleteState());
2016-08-02 21:59:29 +03:00
}
}
2016-08-02 21:59:29 +03:00
resolve(context) {
context
.run('acceptRules')
.then(() => context.setState(new CompleteState()))
.catch(
(err = {}) => err.errors || logger.warn('Error accepting rules', err),
);
}
2016-08-02 21:59:29 +03:00
reject(context) {
context.run('logout');
}
2016-08-02 21:59:29 +03:00
}