import { r as registerInstance, d as createEvent, h } from './index-33e43734.js';
import { t as toastController } from './overlays-97615cf7.js';
import { g as getStatusOptions } from './getStatusOptions-bebaf81a.js';
import { s as state } from './store-729235b6.js';
import './ionic-global-bd76bde2.js';
import './helpers-a9270f9e.js';
import './index-91eb4513.js';
import './getCache-f7c123d8.js';
import './_commonjsHelpers-cca61ea8.js';
import './logic-2eecfe1e.js';
import './index-964da72a.js';

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

let ModalJobEdit = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.floodteamCloseModal = createEvent(this, "floodteamCloseModal", 7);
    this.steps = ["info", "cause", "payment"];
    this.payModels = [];
  }
  onReset(event) {
    var _a;
    if (((_a = event.detail) === null || _a === void 0 ? void 0 : _a.endpoint) === "editJob") {
      const modalEl = document.querySelector("ion-modal.modal-edit-job");
      if (modalEl === null || modalEl === void 0 ? void 0 : modalEl.dismiss) {
        modalEl.dismiss();
      }
    }
  }
  async onSuccess(event) {
    var _a;
    if (((_a = event.detail) === null || _a === void 0 ? void 0 : _a.endpoint) === "editJob") {
      const photoCarouselModalEl = document.querySelector("ion-modal.modal-edit-job");
      if (photoCarouselModalEl === null || photoCarouselModalEl === void 0 ? void 0 : photoCarouselModalEl.dismiss) {
        await photoCarouselModalEl.dismiss();
        this.presentToast();
      }
    }
  }
  onTabClick(tabName) {
    let stopUnderline = false;
    this.tabBarEl.querySelectorAll("ion-tab-button").forEach((tabButtonEl) => {
      tabButtonEl.style.borderBottom = "none";
      if (tabName === tabButtonEl.tab)
        stopUnderline = true;
      if (!stopUnderline)
        tabButtonEl.style.borderBottom = "2px solid var(--ion-color-success)";
    });
  }
  async presentToast() {
    const toast = await toastController.create({
      message: `Job has been edited successfully!`,
      duration: 2000,
    });
    toast.present();
  }
  render() {
    var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
    return [
      h("ion-header", null, h("ion-toolbar", null, h("ion-title", null, "Edit Job"), h("ion-buttons", { slot: "end" }, h("ion-button", { onClick: () => this.floodteamCloseModal.emit() }, h("ion-icon", { slot: "icon-only", name: "close-circle-outline" }))))),
      h("ion-content", null, h("ion-tabs", { ref: (el) => (this.tabsEl = el) }, h("ion-tab-bar", { ref: (el) => (this.tabBarEl = el), slot: "top" }, h("ion-tab-button", { tab: "info", onClick: () => this.onTabClick("info") }, h("ion-icon", { name: "information-circle" }), h("ion-label", null, "Info")), h("ion-tab-button", { tab: "cause", onClick: () => this.onTabClick("cause") }, h("ion-icon", { name: "water" }), h("ion-label", null, "Cause")), h("ion-tab-button", { tab: "payment", onClick: () => this.onTabClick("payment") }, h("ion-icon", { name: "cash" }), h("ion-label", null, "Payment"))), h("ion-tab", { tab: "info" }, h("ion-content", null, h("ion-card", null, h("fireenjin-form", { class: "ion-padding", endpoint: "editJob", documentId: (_a = state.job) === null || _a === void 0 ? void 0 : _a.id, disableLoader: true, disableEnterButton: true, submitButton: "Next", resetButtonColor: "medium" }, h("fireenjin-input", { label: "Title", labelPosition: "stacked", placeholder: "Title of the Job", name: "title", value: (_b = state.job) === null || _b === void 0 ? void 0 : _b.title }), h("fireenjin-input-address", { label: "Address", labelPosition: "stacked", placeholder: "The street address of the job", name: "address", value: (_c = state.job) === null || _c === void 0 ? void 0 : _c.address }), 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,
        })), value: (_e = (_d = state.job) === null || _d === void 0 ? void 0 : _d.location) === null || _e === void 0 ? void 0 : _e.id }), h("fireenjin-select", { name: "status", label: "Status", value: (_f = state.job) === null || _f === void 0 ? void 0 : _f.status, options: getStatusOptions() }), h("fireenjin-input", { name: "claimNumber", label: "Claim Number", labelPosition: "stacked", value: (_g = state.job) === null || _g === void 0 ? void 0 : _g.claimNumber }), h("fireenjin-input", { type: "date", name: "dateOfLoss", label: "Date of Loss", labelPosition: "stacked", value: (_h = state.job) === null || _h === void 0 ? void 0 : _h.dateOfLoss }), h("fireenjin-input", { name: "matterportModelId", label: "Matterport Model ID", labelPosition: "stacked", value: (_j = state.job) === null || _j === void 0 ? void 0 : _j.matterportModelId }), h("fireenjin-select-tags", { name: "tags", label: "Tags", labelPosition: "stacked", value: (_k = state.job) === null || _k === void 0 ? void 0 : _k.tags, allowAdding: true, options: [
          {
            label: "Important",
            value: "important",
          },
          {
            label: "Referral",
            value: "referral",
          },
          {
            label: "Plumber",
            value: "plumber",
          },
          {
            label: "Staff",
            value: "staff",
          },
          {
            label: "Agent",
            value: "agent",
          },
          {
            label: "Property Manager",
            value: "property manager",
          },
          {
            label: "PEU",
            value: "peu",
          },
        ] }))))), h("ion-tab", { tab: "cause" }, h("ion-content", null, h("ion-card", { class: "ion-padding" }, h("fireenjin-form", { name: "cause", endpoint: "editJob", beforeSubmit: (data) => ({
          ...data,
          category: data.category ? parseInt(data.category) : 1,
        }), documentId: (_l = state.job) === null || _l === void 0 ? void 0 : _l.id, submitButton: "Next", resetButton: "Back", resetButtonColor: "medium", disableLoader: true }, h("fireenjin-input", { label: "Category", labelPosition: "stacked", placeholder: "The category of water loss", name: "category", value: (_m = state.job) === null || _m === void 0 ? void 0 : _m.category, type: "number", min: "1", max: "3" }), h("fireenjin-input", { label: "Cause", labelPosition: "stacked", placeholder: "The cause of the water loss", name: "cause", value: (_o = state.job) === null || _o === void 0 ? void 0 : _o.cause }))))), h("ion-tab", { tab: "payment" }, h("ion-content", null, h("ion-card", { class: "ion-padding" }, h("fireenjin-form", { name: "payment", endpoint: "editJob", submitButton: "Next", resetButton: "Back", documentId: (_p = state.job) === null || _p === void 0 ? void 0 : _p.id, resetButtonColor: "medium", beforeSubmit: (data) => ({
          ...data,
          isFranchise: data.isFranchise === "on",
        }), disableLoader: true }, h("ion-item", null, h("ion-label", null, "Franchise Job"), h("ion-toggle", { name: "isFranchise", checked: (_q = state.job) === null || _q === void 0 ? void 0 : _q.isFranchise, slot: "end" })), h("fireenjin-select", { label: "Pay Model", name: "payModelId", endpoint: "listPayModels", resultsKey: "payModels", limit: 100, value: (_s = (_r = state.job) === null || _r === void 0 ? void 0 : _r.payModel) === null || _s === void 0 ? void 0 : _s.id }))))))),
    ];
  }
};
ModalJobEdit.style = modalJobEditCss;

export { ModalJobEdit as modal_job_edit };

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