2016-12-07 02:38:51 +05:30
|
|
|
import logger from 'services/logger';
|
|
|
|
|
2016-08-03 00:29:29 +05:30
|
|
|
import AbstractState from './AbstractState';
|
|
|
|
import CompleteState from './CompleteState';
|
|
|
|
|
|
|
|
export default class AcceptRulesState extends AbstractState {
|
2019-11-27 14:33:32 +05:30
|
|
|
enter(context) {
|
|
|
|
const { user } = context.getState();
|
2016-08-03 00:29:29 +05:30
|
|
|
|
2019-11-27 14:33:32 +05:30
|
|
|
if (user.shouldAcceptRules) {
|
|
|
|
context.navigate('/accept-rules');
|
|
|
|
} else {
|
|
|
|
context.setState(new CompleteState());
|
2016-08-03 00:29:29 +05:30
|
|
|
}
|
2019-11-27 14:33:32 +05:30
|
|
|
}
|
2016-08-03 00:29:29 +05:30
|
|
|
|
2019-11-27 14:33:32 +05:30
|
|
|
resolve(context) {
|
|
|
|
context
|
|
|
|
.run('acceptRules')
|
|
|
|
.then(() => context.setState(new CompleteState()))
|
|
|
|
.catch(
|
|
|
|
(err = {}) => err.errors || logger.warn('Error accepting rules', err),
|
|
|
|
);
|
|
|
|
}
|
2016-08-03 00:29:29 +05:30
|
|
|
|
2019-11-27 14:33:32 +05:30
|
|
|
reject(context) {
|
|
|
|
context.run('logout');
|
|
|
|
}
|
2016-08-03 00:29:29 +05:30
|
|
|
}
|