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 {
|
2024-12-18 03:41:39 +05:30
|
|
|
return context.run('acceptRules').then(() => context.setState(new CompleteState()));
|
2020-05-24 04:38:24 +05:30
|
|
|
}
|
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
|
|
|
}
|