import { r as registerInstance, h } from './index-33e43734.js';
import { t as toastController } from './overlays-85a0d940.js';
import { s as state } from './store-97abe726.js';
import './ionic-global-bd76bde2.js';
import './helpers-7e937ffa.js';
import './index-91eb4513.js';
import './getCache-f7c123d8.js';
import './_commonjsHelpers-4ed75ef8.js';
import './logic-88140d62.js';
import './index-964da72a.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) {
    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 toastController.create({
      message: `Updated ${(_a = this.users) === null || _a === void 0 ? void 0 : _a.length} users.`,
      duration: 2000,
    });
    toast.present();
  }
  render() {
    return (h("ion-content", null, h("fireenjin-form", { class: "ion-padding", endpoint: "bulkUpdateUsers", beforeSubmit: async (data) => ({
        data,
        userIds: this.users.map((user) => user.id),
      }), disableLoader: true, resetButtonColor: "medium" }, h("fireenjin-select", { name: "companyId", label: "Company", labelPosition: "stacked", endpoint: "listCompanies", limit: 100, dataPropsMap: {
        companies: "results",
      } }), h("fireenjin-select", { label: "Location", name: "locationId", options: ((state === null || state === void 0 ? void 0 : 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,
      })) }), h("fireenjin-select-tags", { name: "tags", label: "Tags", labelPosition: "stacked", allowAdding: true, options: [
        {
          label: "Important",
          value: "important",
        },
      ] }))));
  }
};
ModalEditUsers.style = modalEditUsersCss;

export { ModalEditUsers as modal_edit_users };

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