import { InvalidationAction } from '@dvn/core/models/actions';
export class FormHandlerDeleteDomain {
  constructor(apiDamga, sourceViewId) {
    this.sourceViewId = sourceViewId;
    this.api = apiDamga;
  }
  onSubmit(event) {
    const { values: { domainId } } = event.detail;
    return new Promise((resolve, reject) => {
      this.api.deleteDomain(domainId).then(() => {
        resolve({
          events: [
            new InvalidationAction(this.sourceViewId, 'table-list-view-domain'),
          ],
          navigation: {
            type: 'navigation',
            direction: 'back'
          }
        });
      }).catch(() => {
        reject(['Unexpected error']);
      });
    });
  }
}
