'use strict';

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

const index = require('./index-fd2bbf0b.js');
const hardwareBackButton = require('./overlays-de05dc6a.js');
const store = require('./store-9988299d.js');
require('./ionic-global-1340f737.js');
require('./helpers-c2496722.js');
require('./index-81aa1bcb.js');
require('./getCache-901b0f67.js');

const modalEditUsersCss = "modal-edit-users .banner{background-color:var(--ion-color-secondary)}modal-edit-users h1{color:#fff}modal-edit-users p{margin:0 0 15px 0;color:rgba(255, 255, 255, 0.8);font-weight:normal}.modal-edit-users{--width:700px;--max-width:700px}@media only screen and (max-width: 800px){.modal-edit-users{--width:100%;--max-width:auto}}";

let ModalEditUsers = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    this.users = [];
  }
  onReset(event) {
    var _a;
    if (((_a = event.detail) === null || _a === void 0 ? void 0 : _a.endpoint) === "bulkUpdateUsers") {
      const sendEmailModalEl = document.querySelector("ion-modal.modal-edit-users");
      if (sendEmailModalEl === null || sendEmailModalEl === void 0 ? void 0 : sendEmailModalEl.dismiss) {
        sendEmailModalEl.dismiss();
      }
    }
  }
  async onSuccess(event) {
    var _a;
    if (((_a = event.detail) === null || _a === void 0 ? void 0 : _a.endpoint) === "bulkUpdateUsers") {
      const sendEmailModalEl = document.querySelector("ion-modal.modal-edit-users");
      if (sendEmailModalEl === null || sendEmailModalEl === void 0 ? void 0 : sendEmailModalEl.dismiss) {
        await sendEmailModalEl.dismiss();
        this.presentToast();
      }
    }
  }
  async presentToast() {
    var _a;
    const toast = await hardwareBackButton.toastController.create({
      message: `Updated ${(_a = this.users) === null || _a === void 0 ? void 0 : _a.length} users.`,
      duration: 2000,
    });
    toast.present();
  }
  render() {
    return (index.h("ion-content", null, index.h("fireenjin-form", { class: "ion-padding", endpoint: "bulkUpdateUsers", beforeSubmit: async (data) => ({
        data,
        userIds: this.users.map((user) => user.id),
      }), disableLoader: true, resetButtonColor: "medium" }, index.h("fireenjin-select", { name: "companyId", label: "Company", labelPosition: "stacked", endpoint: "listCompanies", limit: 100, dataPropsMap: {
        companies: "results",
      } }), index.h("fireenjin-select", { label: "Location", name: "locationId", options: ((store.state === null || store.state === void 0 ? void 0 : store.state.locations) || []).map((location) => ({
        label: (location === null || location === void 0 ? void 0 : location.name) || "No Location Name",
        value: location === null || location === void 0 ? void 0 : location.id,
      })) }), index.h("fireenjin-select-tags", { name: "tags", label: "Tags", labelPosition: "stacked", multiple: true, allowAdding: true, options: [
        {
          label: "Important",
          value: "important",
        },
      ] }))));
  }
};
ModalEditUsers.style = modalEditUsersCss;

exports.modal_edit_users = ModalEditUsers;

//# sourceMappingURL=modal-edit-users.cjs.entry.js.map