mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-11-10 10:02:02 +05:30
30 lines
677 B
TypeScript
30 lines
677 B
TypeScript
import logger from 'app/services/logger';
|
|
|
|
import AbstractState from './AbstractState';
|
|
import CompleteState from './CompleteState';
|
|
|
|
export default class AcceptRulesState extends AbstractState {
|
|
enter(context) {
|
|
const { user } = context.getState();
|
|
|
|
if (user.shouldAcceptRules) {
|
|
context.navigate('/accept-rules');
|
|
} else {
|
|
context.setState(new CompleteState());
|
|
}
|
|
}
|
|
|
|
resolve(context) {
|
|
context
|
|
.run('acceptRules')
|
|
.then(() => context.setState(new CompleteState()))
|
|
.catch(
|
|
(err = {}) => err.errors || logger.warn('Error accepting rules', err),
|
|
);
|
|
}
|
|
|
|
reject(context) {
|
|
context.run('logout');
|
|
}
|
|
}
|