import { apiService } from '../net/ApiService';
import { ToastUtils } from '../utils/ToastUtils';
import { BaseViewModel } from './BaseViewModel';

@ObservedV2
export class SettingsViewModel extends BaseViewModel {
  @Trace destroy?: object;

  async userDestroy() {
    this.showLoading();
    try {
      const result = await apiService.userDestroy();
      if (result.isSuccess()) {
        this.destroy = new Object();
      } else {
        ToastUtils.show(result.message, true);
      }
      this.dismissLoading();
    } catch (e) {
      console.log(e);
      ToastUtils.show(e);
      this.dismissLoading();
    }
  }
}