import { Component, Event, Host, h, Prop } from "@stencil/core";
export class ItemUser {
  constructor() {
    this.disabled = false;
  }
  async removeUserFromJob(user) {
    if (confirm(`Are you sure you want to remove ${(user === null || user === void 0 ? void 0 : user.firstName) ? user.firstName : "this user"} from the job?`)) {
      this.fireenjinFetch.emit({
        endpoint: "removeUserFromJob",
        params: {
          data: {
            jobId: this.jobId,
            userId: user.id,
          },
        },
      });
    }
    if (this.slidingEl)
      this.slidingEl.close();
  }
  render() {
    var _a, _b, _c, _d, _e, _f;
    return (h(Host, null,
      h("ion-item-sliding", { ref: (el) => (this.slidingEl = el), disabled: this.disabled },
        h("ion-item", { href: this.disabled ? null : `/users/${this.user.id}`, detail: true },
          h("fireenjin-avatar", { style: {
              marginInlineEnd: "8px",
            }, src: this.user.photo, initials: `${((_a = this.user) === null || _a === void 0 ? void 0 : _a.firstName) ? this.user.firstName.charAt(0) : ""}${((_b = this.user) === null || _b === void 0 ? void 0 : _b.lastName) ? this.user.lastName.charAt(0) : ""}`, slot: "start" }),
          h("ion-label", null,
            h("h2", null,
              ((_c = this.user) === null || _c === void 0 ? void 0 : _c.firstName) || "",
              " ",
              ((_d = this.user) === null || _d === void 0 ? void 0 : _d.lastName) || ""),
            h("p", null, ((_e = this.user) === null || _e === void 0 ? void 0 : _e.email) || "")),
          h("floodteam-select-role", { jobId: this.jobId, userId: (_f = this.user) === null || _f === void 0 ? void 0 : _f.id, value: this.role, slot: "end" })),
        h("ion-item-options", null,
          h("ion-item-option", { color: "danger", onClick: () => this.removeUserFromJob(this.user) },
            h("ion-icon", { slot: "end", name: "close-circle" }),
            "Remove")))));
  }
  static get is() { return "floodteam-item-user"; }
  static get originalStyleUrls() { return {
    "$": ["item-user.css"]
  }; }
  static get styleUrls() { return {
    "$": ["item-user.css"]
  }; }
  static get properties() { return {
    "user": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "Partial<User>",
        "resolved": "{ __typename?: \"User\"; active?: boolean; address?: Address; billingAddress?: Address; birthday?: string; certifications?: Certification[]; company?: Company; createdAt?: string; createdBy?: User; email?: string; feed?: Feed[]; firstName?: string; floodbotId?: string; friends?: User[]; id?: string; isFranchise?: boolean; isFranchiseOwner?: boolean; isOnboarded?: boolean; isSearchable?: boolean; isSetup?: boolean; isStripeOAuth?: boolean; jobs?: Job[]; lastName?: string; lastOnline?: string; location?: Location; online?: boolean; phone?: string; photo?: string; plaidAccessToken?: string; rating?: number; referredBy?: User; role?: string; slackHandle?: string; stripeId?: string; tags?: string[]; trade?: string; type?: string; updatedAt?: string; updatedBy?: User; vehicles?: Vehicle[]; }",
        "references": {
          "Partial": {
            "location": "global"
          },
          "User": {
            "location": "import",
            "path": "../../../sdk"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    },
    "jobId": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "job-id",
      "reflect": false
    },
    "role": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "role",
      "reflect": false
    },
    "disabled": {
      "type": "boolean",
      "mutable": false,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "disabled",
      "reflect": false,
      "defaultValue": "false"
    }
  }; }
  static get events() { return [{
      "method": "fireenjinFetch",
      "name": "fireenjinFetch",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [],
        "text": ""
      },
      "complexType": {
        "original": "any",
        "resolved": "any",
        "references": {}
      }
    }]; }
}
//# sourceMappingURL=item-user.js.map