'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const index = require('./index-cba1c3ae.js');
const hardwareBackButton = require('./overlays-7ec575fc.js');
require('./ionic-global-01cd0200.js');
require('./helpers-c2496722.js');

const appUserCss = "app-user ion-card,app-user ion-card ion-list{overflow:visible !important;contain:none !important}";

const AppUser = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    this.floodteamOpenModal = index.createEvent(this, "floodteamOpenModal", 7);
    this.floodteamCloseModal = index.createEvent(this, "floodteamCloseModal", 7);
    this.fireenjinFetch = index.createEvent(this, "fireenjinFetch", 7);
    this.user = {};
    this.jobs = [];
  }
  async onSuccess(event) {
    var _a, _b, _c, _d, _e, _f;
    if (event.detail.endpoint === "addUser") {
      const routerEl = document.querySelector("ion-router");
      if (!routerEl || !((_c = (_b = (_a = event === null || event === void 0 ? void 0 : event.detail) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.addUser) === null || _c === void 0 ? void 0 : _c.id))
        return;
      routerEl.push(`/users/${event.detail.data.addUser.id}`);
    }
    else if (event.detail.endpoint === "editUser") {
      this.presentToast();
    }
    else if (((_d = event === null || event === void 0 ? void 0 : event.detail) === null || _d === void 0 ? void 0 : _d.endpoint) === "findUser") {
      this.user = (_f = (_e = event === null || event === void 0 ? void 0 : event.detail) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.user;
    }
  }
  async presentToast() {
    const toast = await hardwareBackButton.toastController.create({
      message: "The user has been updated.",
      duration: 2000,
    });
    toast.present();
  }
  render() {
    return [
      index.h("ion-content", { scrollEvents: true, class: "ion-padding" }, index.h("floodteam-title-bar", { pin: {
          icon: "person",
          href: `/users/${this.userId}`,
          name: this.user.firstName || "User",
        } }, index.h("ion-router-link", { href: "/users" }, "Users")), index.h("ion-grid", null, index.h("ion-row", null, index.h("ion-col", null, index.h("ion-card", { class: "ion-padding" }, index.h("floodteam-form-user", { userId: this.userId, showPhoto: true }))), index.h("ion-col", null, index.h("fireenjin-pagination", { ref: (el) => (this.paginationEl = el), disableVirtualScroll: true, listEl: ({ result: job }) => (index.h("floodteam-item-job", { job: job })), endpoint: "listJobs", limit: 4, fetchParams: {
          withPayables: true,
        }, fetchData: { userId: this.userId }, resultsKey: "jobs", query: this.query, removeDuplicates: true }))))),
      index.h("floodteam-navigation-footer", null),
    ];
  }
};
AppUser.style = appUserCss;

exports.app_user = AppUser;
