import { InvalidationAction } from '@dvn/core/models/actions';
export class FormHandlerCreateProduct {
  constructor(apiDevingen) {
    this.api = apiDevingen;
  }
  onSubmit(event) {
    const { values: { name, workspaceId, type } } = event.detail;
    return new Promise((resolve, reject) => {
      this.api.createProduct({ name, workspace: { _id: workspaceId }, type }).then(() => {
        resolve({
          events: [
            new InvalidationAction('', ''),
          ],
          navigation: {
            type: 'navigation',
            direction: 'back'
          }
        });
      }).catch((error) => {
        var _a;
        reject(((_a = error.data) === null || _a === void 0 ? void 0 : _a.error) ? [error.data.error] : ['Unexpected error']);
      });
    });
  }
}
