import { Build, h, } from "@stencil/core";
import { toastController } from "@ionic/core";
import state from "../../../store";
import getParameter from "../../../helpers/getParameter";
export class AppJobNew {
  constructor() {
    this.referring = false;
    this.isAgent = false;
    this.locationId = undefined;
    this.agentId = undefined;
    this.campaignId = undefined;
    this.to = undefined;
    this.name = undefined;
  }
  async onSuccess(event) {
    if (event.detail.name === "recommendation") {
      this.to = null;
      this.name = null;
      (await toastController.create({
        message: `Successfully sent recommendation(s).`,
        duration: 3000,
      })).present();
    }
  }
  onBeforeSubmit(formData) {
    var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
    return {
      templateId: "BaGYHYB6q7UBmgvoPATx",
      from: "info@thefloodteam.com",
      emails: ((_b = (_a = formData === null || formData === void 0 ? void 0 : formData.to) === null || _a === void 0 ? void 0 : _a.split) === null || _b === void 0 ? void 0 : _b.call(_a, ",")) || [],
      data: {
        firstName: (formData === null || formData === void 0 ? void 0 : formData.name) || "there",
        url: `${state.config.url}?referredBy=${(_c = state.profile) === null || _c === void 0 ? void 0 : _c.id}`,
        partner: {
          id: (_d = state === null || state === void 0 ? void 0 : state.session) === null || _d === void 0 ? void 0 : _d.uid,
          name: `${((_e = state === null || state === void 0 ? void 0 : state.profile) === null || _e === void 0 ? void 0 : _e.firstName) || ""} ${((_f = state === null || state === void 0 ? void 0 : state.profile) === null || _f === void 0 ? void 0 : _f.lastName) || ""}`,
          company: ((_h = (_g = state === null || state === void 0 ? void 0 : state.profile) === null || _g === void 0 ? void 0 : _g.company) === null || _h === void 0 ? void 0 : _h.name) || "The Flood Team",
          title: ((_j = state === null || state === void 0 ? void 0 : state.profile) === null || _j === void 0 ? void 0 : _j.type) || "Mitigation Specialist",
          phone: (_k = state === null || state === void 0 ? void 0 : state.profile) === null || _k === void 0 ? void 0 : _k.phone,
          location: (_m = (_l = state === null || state === void 0 ? void 0 : state.profile) === null || _l === void 0 ? void 0 : _l.location) === null || _m === void 0 ? void 0 : _m.name,
        },
      },
    };
  }
  componentDidLoad() {
    if (!(Build === null || Build === void 0 ? void 0 : Build.isBrowser))
      return;
    console.log(this.locationId);
  }
  render() {
    var _a, _b, _c, _d;
    const locationId = this.locationId || getParameter("location") || ((_a = state === null || state === void 0 ? void 0 : state.claims) === null || _a === void 0 ? void 0 : _a.locationId);
    return [
      h("ion-content", { class: "ion-padding" }, h("floodteam-title-bar", null, h("ion-router-link", { href: "/jobs" }, "Jobs")), h("ion-card", { style: {
          width: "90%",
          maxWidth: "800px",
          margin: "10% auto",
        } }, h("floodteam-book-flow", { campaignId: this.campaignId || getParameter("campaign") || null, agentId: (this.isAgent && this.agentId) || null, referralId: (this.referring && ((_b = state === null || state === void 0 ? void 0 : state.session) === null || _b === void 0 ? void 0 : _b.uid)) || null, googleMapsKey: (_d = (_c = state === null || state === void 0 ? void 0 : state.config) === null || _c === void 0 ? void 0 : _c.firebase) === null || _d === void 0 ? void 0 : _d.apiKey, locationId: locationId }))),
      h("floodteam-navigation-footer", null),
    ];
  }
  static get is() { return "app-job-new"; }
  static get originalStyleUrls() {
    return {
      "$": ["app-job-new.css"]
    };
  }
  static get styleUrls() {
    return {
      "$": ["app-job-new.css"]
    };
  }
  static get properties() {
    return {
      "referring": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": ""
        },
        "attribute": "referring",
        "reflect": false,
        "defaultValue": "false"
      },
      "isAgent": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": ""
        },
        "attribute": "is-agent",
        "reflect": false,
        "defaultValue": "false"
      },
      "locationId": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": ""
        },
        "attribute": "location-id",
        "reflect": false
      },
      "agentId": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": ""
        },
        "attribute": "agent-id",
        "reflect": false
      },
      "campaignId": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": ""
        },
        "attribute": "campaign-id",
        "reflect": false
      }
    };
  }
  static get states() {
    return {
      "to": {},
      "name": {}
    };
  }
  static get listeners() {
    return [{
        "name": "fireenjinSuccess",
        "method": "onSuccess",
        "target": "body",
        "capture": false,
        "passive": false
      }];
  }
}
