import { Build, h, } from "@stencil/core";
import state from "../../../store";
export class AppEquipmentList {
  constructor() {
    this.query = undefined;
  }
  onSearchInput(event) {
    this.query = event.target.value;
  }
  componentDidLoad() {
    if (!(Build === null || Build === void 0 ? void 0 : Build.isBrowser))
      return;
  }
  render() {
    var _a, _b, _c, _d, _e, _f;
    return [
      h("ion-content", { class: "ion-padding" }, h("div", { class: "ion-padding" }, h("fireenjin-search-bar", { ref: (el) => (this.filterBarEl = el), paginationEl: this.paginationEl, filters: ((_a = state === null || state === void 0 ? void 0 : state.claims) === null || _a === void 0 ? void 0 : _a.tester) || ((_b = state === null || state === void 0 ? void 0 : state.claims) === null || _b === void 0 ? void 0 : _b.admin)
          ? [
            {
              name: "tags",
              label: "Tags",
              icon: "pricetags",
              multiple: true,
              options: [
                {
                  label: "Imported",
                  value: "imported",
                },
              ],
            },
            {
              name: "locationId",
              label: "Location",
              icon: "business",
              options: ((_c = state === null || state === void 0 ? void 0 : state.locations) === null || _c === void 0 ? void 0 : _c.length)
                ? state.locations.map((location) => ({
                  label: location.name,
                  value: location.id,
                }))
                : [],
              value: ((_d = state === null || state === void 0 ? void 0 : state.claims) === null || _d === void 0 ? void 0 : _d.tester) && ((_f = (_e = state === null || state === void 0 ? void 0 : state.profile) === null || _e === void 0 ? void 0 : _e.location) === null || _f === void 0 ? void 0 : _f.id)
                ? state.profile.location.id
                : null,
            },
          ]
          : null }), h("fireenjin-pagination", { ref: (el) => (this.paginationEl = el), name: "equipment", resultsKey: "equipment", disableVirtualScroll: true, removeDuplicates: true, listEl: ({ result: equipment }) => (h("ion-item", { href: `/equipment/${equipment.id}`, detail: true, lines: "full" }, h("ion-grid", null, h("ion-row", { class: "ion-align-items-center ion-justify-content-between" }, h("ion-col", null, h("ion-label", null, h("h2", null, equipment.name || "No name", " "))))))), endpoint: "listEquipment", limit: 20, display: "list", query: this.query }))),
      h("floodteam-navigation-footer", null, h("floodteam-title-bar", { back: "/dashboard" }, h("ion-breadcrumbs", null, h("ion-breadcrumb", { href: "/equipment" }, h("ion-icon", { class: "ft-icon-style", slot: "start", name: "hammer" }), "Equipment")), h("ion-buttons", { slot: "end" }, h("ion-button", { fill: "solid", color: "primary", href: "/equipment/new" }, "Add")))),
    ];
  }
  static get is() { return "app-equipment-list"; }
  static get originalStyleUrls() {
    return {
      "$": ["app-equipment-list.css"]
    };
  }
  static get styleUrls() {
    return {
      "$": ["app-equipment-list.css"]
    };
  }
  static get states() {
    return {
      "query": {}
    };
  }
  static get listeners() {
    return [{
        "name": "ionInput",
        "method": "onSearchInput",
        "target": undefined,
        "capture": false,
        "passive": false
      }];
  }
}
