2019-12-08 00:32:00 +05:30
|
|
|
import logger from 'app/services/logger';
|
2016-12-07 02:38:51 +05:30
|
|
|
|
2016-08-03 00:29:29 +05:30
|
|
|
import AbstractState from './AbstractState';
|
2020-01-18 02:07:52 +05:30
|
|
|
import { AuthContext } from './AuthFlow';
|
2016-08-03 00:29:29 +05:30
|
|
|
import CompleteState from './CompleteState';
|
|
|
|
|
|
|
|
export default class AcceptRulesState extends AbstractState {
|
2020-05-24 04:38:24 +05:30
|
|
|
enter(context: AuthContext): Promise<void> | void {
|
|
|
|
const { user } = context.getState();
|
2016-08-03 00:29:29 +05:30
|
|
|
|
2020-08-02 00:49:00 +05:30
|
|
|
if (!user.isDeleted && user.shouldAcceptRules) {
|
2020-05-24 04:38:24 +05:30
|
|
|
context.navigate('/accept-rules');
|
|
|
|
} else {
|
|
|
|
context.setState(new CompleteState());
|
|
|
|
}
|
2016-08-03 00:29:29 +05:30
|
|
|
}
|
|
|
|
|
2020-05-24 04:38:24 +05:30
|
|
|
resolve(context: AuthContext): Promise<void> | void {
|
|
|
|
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
|
|
|
|
2020-08-01 04:10:11 +05:30
|
|
|
reject(context: AuthContext, payload: Record<string, any>): void {
|
|
|
|
if (payload.deleteAccount) {
|
|
|
|
context.navigate('/profile/delete');
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-05-24 04:38:24 +05:30
|
|
|
context.run('logout');
|
|
|
|
}
|
2016-08-03 00:29:29 +05:30
|
|
|
}
|