2016-08-02 21:59:29 +03:00
|
|
|
import AbstractState from './AbstractState';
|
2020-01-17 23:37:52 +03:00
|
|
|
import { AuthContext } from './AuthFlow';
|
2016-08-02 21:59:29 +03:00
|
|
|
import CompleteState from './CompleteState';
|
|
|
|
|
|
|
|
export default class AcceptRulesState extends AbstractState {
|
2020-05-24 02:08:24 +03:00
|
|
|
enter(context: AuthContext): Promise<void> | void {
|
|
|
|
const { user } = context.getState();
|
2016-08-02 21:59:29 +03:00
|
|
|
|
2020-08-01 22:19:00 +03:00
|
|
|
if (!user.isDeleted && user.shouldAcceptRules) {
|
2020-05-24 02:08:24 +03:00
|
|
|
context.navigate('/accept-rules');
|
|
|
|
} else {
|
|
|
|
context.setState(new CompleteState());
|
|
|
|
}
|
2016-08-02 21:59:29 +03:00
|
|
|
}
|
|
|
|
|
2020-05-24 02:08:24 +03:00
|
|
|
resolve(context: AuthContext): Promise<void> | void {
|
2024-12-17 23:11:39 +01:00
|
|
|
return context.run('acceptRules').then(() => context.setState(new CompleteState()));
|
2020-05-24 02:08:24 +03:00
|
|
|
}
|
2016-08-02 21:59:29 +03:00
|
|
|
|
2020-08-01 01:40:11 +03:00
|
|
|
reject(context: AuthContext, payload: Record<string, any>): void {
|
|
|
|
if (payload.deleteAccount) {
|
|
|
|
context.navigate('/profile/delete');
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-05-24 02:08:24 +03:00
|
|
|
context.run('logout');
|
|
|
|
}
|
2016-08-02 21:59:29 +03:00
|
|
|
}
|