import { InvalidationAction } from '@dvn/core/models/actions';
export class FormHandlerCreateWorkspace {
  constructor(apiDevingen) {
    this.api = apiDevingen;
  }
  onSubmit(event) {
    const { values: { name } } = event.detail;
    return new Promise((resolve, reject) => {
      this.api.createWorkspace(name).then(() => {
        resolve({
          events: [
            new InvalidationAction('', ''),
          ],
          navigation: {
            type: 'navigation',
            direction: 'back'
          }
        });
      }).catch(() => {
        reject(['Unexpected error']);
      });
    });
  }
}
