Sha256: 18fa19ed91518d925f5e67d10deffe20aff7ec113cf334203904b3a252f01847

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

Contents

import { UI, Views } from "loco-js";

import User from "models/User";
import Flash from "views/shared/Flash";

class UserRegistrationForm extends Views.Base {
  constructor(opts = {}) {
    super(opts);
  }

  render() {
    const form = new UI.Form({
      for: new User(),
      delegator: this,
      callbackSuccess: "_created"
    });
    form.render();
  }

  receivedSignal(signal) {
    switch (signal) {
      case "confirming":
        this._confirming();
        break;
      case "confirmed":
        this._confirmed();
    }
  }

  _created(data) {
    this.connectWith(new User({ id: data.id }));
    document.querySelector("form").style.display = "none";
    document.getElementById("sign_in_paragraph").classList.remove("none");
    document.getElementById("verification_info").classList.remove("none");
    const flash = new Flash({ notice: data.notice });
    flash.render();
  }

  _confirming() {
    document.getElementById(
      "verification_info"
    ).textContent = document.getElementById(
      "verification_progress"
    ).textContent;
  }

  _confirmed() {
    window.location.href = "/user/sessions/new?event=confirmed";
  }
}

export default UserRegistrationForm;

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
loco-rails-3.0.5 test/dummy/frontend/js/views/main/users/UserRegistrationForm.js
loco-rails-3.0.4 test/dummy/frontend/js/views/main/users/UserRegistrationForm.js