'use strict';

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

const index = require('./index-fd2bbf0b.js');
const hardwareBackButton = require('./overlays-0248227e.js');
const getStatusOptions = require('./getStatusOptions-64f3eefc.js');
const store = require('./store-d6f21087.js');
require('./ionic-global-1340f737.js');
require('./helpers-c2496722.js');
require('./index-81aa1bcb.js');
require('./getHandlebarsHelpers-7b2b1728.js');
require('./_commonjsHelpers-a5111d61.js');
require('./logic-d8c34975.js');
require('./index-1f381af8.js');
require('./localforage-af1b8c0e.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) {
    index.registerInstance(this, hostRef);
    this.floodteamCloseModal = index.createEvent(this, "floodteamCloseModal", 7);
    this.steps = ["info", "cause", "payment"];
    this.payModels = [];
    this.step = "info";
  }
  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 hardwareBackButton.toastController.create({
      message: `Job has been edited successfully!`,
      duration: 2000,
    });
    toast.present();
  }
  componentDidLoad() {
    if (!(index.Build === null || index.Build === void 0 ? void 0 : index.Build.isBrowser))
      return;
    this.tabsEl.select(this.step);
  }
  render() {
    var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
    return [
      index.h("ion-header", null, index.h("ion-toolbar", null, index.h("ion-title", null, "Edit Job"), index.h("ion-buttons", { slot: "end" }, index.h("ion-button", { onClick: () => this.floodteamCloseModal.emit() }, index.h("ion-icon", { slot: "icon-only", name: "close-circle-outline" }))))),
      index.h("ion-content", null, index.h("ion-tabs", { ref: (el) => (this.tabsEl = el) }, index.h("ion-tab-bar", { ref: (el) => (this.tabBarEl = el), slot: "top" }, index.h("ion-tab-button", { tab: "info", onClick: () => this.onTabClick("info") }, index.h("ion-icon", { name: "information-circle" }), index.h("ion-label", null, "Info")), index.h("ion-tab-button", { tab: "cause", onClick: () => this.onTabClick("cause") }, index.h("ion-icon", { name: "water" }), index.h("ion-label", null, "Cause")), index.h("ion-tab-button", { tab: "payment", onClick: () => this.onTabClick("payment") }, index.h("ion-icon", { name: "cash" }), index.h("ion-label", null, "Payment"))), index.h("ion-tab", { tab: "info" }, index.h("ion-content", null, index.h("ion-card", null, index.h("fireenjin-form", { class: "ion-padding", endpoint: "editJob", documentId: (_a = store.state === null || store.state === void 0 ? void 0 : store.state.job) === null || _a === void 0 ? void 0 : _a.id, disableLoader: true, disableEnterButton: true, beforeSubmit: (data) => ({
          ...data,
          afterhours: this.afterhoursEl.checked,
        }), submitButton: "Next", resetButtonColor: "medium" }, index.h("fireenjin-input", { label: "Title", labelPosition: "stacked", placeholder: "Title of the Job", name: "title", value: (_b = store.state === null || store.state === void 0 ? void 0 : store.state.job) === null || _b === void 0 ? void 0 : _b.title }), index.h("fireenjin-input-address", { label: "Address", labelPosition: "stacked", placeholder: "The street address of the job", name: "address", value: (_c = store.state === null || store.state === void 0 ? void 0 : store.state.job) === null || _c === void 0 ? void 0 : _c.address }), 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,
        })), value: (_e = (_d = store.state === null || store.state === void 0 ? void 0 : store.state.job) === null || _d === void 0 ? void 0 : _d.location) === null || _e === void 0 ? void 0 : _e.id }), index.h("fireenjin-select", { name: "status", label: "Status", value: (_f = store.state === null || store.state === void 0 ? void 0 : store.state.job) === null || _f === void 0 ? void 0 : _f.status, options: getStatusOptions.getStatusOptions() }), index.h("fireenjin-input", { name: "claimNumber", label: "Claim Number", labelPosition: "stacked", value: (_g = store.state === null || store.state === void 0 ? void 0 : store.state.job) === null || _g === void 0 ? void 0 : _g.claimNumber }), index.h("fireenjin-input", { name: "matterportModelId", label: "Matterport Model ID", labelPosition: "stacked", value: (_h = store.state === null || store.state === void 0 ? void 0 : store.state.job) === null || _h === void 0 ? void 0 : _h.matterportModelId }), index.h("fireenjin-select-tags", { name: "tags", label: "Tags", labelPosition: "stacked", value: (_j = store.state === null || store.state === void 0 ? void 0 : store.state.job) === null || _j === void 0 ? void 0 : _j.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",
          },
        ] }), index.h("ion-item", null, index.h("ion-label", null, "Afterhours Service Call?"), index.h("ion-toggle", { name: "afterhours", ref: (el) => (this.afterhoursEl = el), checked: (_k = store.state === null || store.state === void 0 ? void 0 : store.state.job) === null || _k === void 0 ? void 0 : _k.afterhours })))))), index.h("ion-tab", { tab: "cause" }, index.h("ion-content", null, index.h("ion-card", { class: "ion-padding" }, index.h("fireenjin-form", { name: "cause", endpoint: "editJob", beforeSubmit: (data) => ({
          ...data,
          category: data.category ? parseInt(data.category) : 1,
        }), documentId: (_l = store.state === null || store.state === void 0 ? void 0 : store.state.job) === null || _l === void 0 ? void 0 : _l.id, submitButton: "Next", resetButton: "Back", resetButtonColor: "medium", disableLoader: true }, index.h("fireenjin-input", { label: "Category", labelPosition: "stacked", placeholder: "The category of water loss", name: "category", value: (_m = store.state === null || store.state === void 0 ? void 0 : store.state.job) === null || _m === void 0 ? void 0 : _m.category, type: "number", min: "1", max: "3" }), index.h("fireenjin-input", { label: "Cause", labelPosition: "stacked", placeholder: "The cause of the water loss", name: "cause", value: (_o = store.state === null || store.state === void 0 ? void 0 : store.state.job) === null || _o === void 0 ? void 0 : _o.cause }), index.h("fireenjin-input", { type: "date", name: "dateOfLoss", placeholder: "No Date Set", label: "Date of Loss", labelPosition: "stacked", value: ((_p = store.state === null || store.state === void 0 ? void 0 : store.state.job) === null || _p === void 0 ? void 0 : _p.dateOfLoss) || undefined }))))), index.h("ion-tab", { tab: "payment" }, index.h("ion-content", null, index.h("ion-card", { class: "ion-padding" }, index.h("fireenjin-form", { name: "payment", endpoint: "editJob", submitButton: "Next", resetButton: "Back", documentId: (_q = store.state === null || store.state === void 0 ? void 0 : store.state.job) === null || _q === void 0 ? void 0 : _q.id, resetButtonColor: "medium", beforeSubmit: (data) => ({
          ...data,
          isFranchise: data.isFranchise === "on",
        }), disableLoader: true }, index.h("ion-item", null, index.h("ion-label", null, "Franchise Job"), index.h("ion-toggle", { name: "isFranchise", checked: (_r = store.state === null || store.state === void 0 ? void 0 : store.state.job) === null || _r === void 0 ? void 0 : _r.isFranchise, slot: "end" })), index.h("fireenjin-select", { label: "Pay Model", name: "payModelId", endpoint: "listPayModels", resultsKey: "payModels", limit: 100, value: (_t = (_s = store.state === null || store.state === void 0 ? void 0 : store.state.job) === null || _s === void 0 ? void 0 : _s.payModel) === null || _t === void 0 ? void 0 : _t.id }))))))),
    ];
  }
};
ModalJobEdit.style = modalJobEditCss;

exports.modal_job_edit = ModalJobEdit;

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