import { AccountMainSection as l, AccountMainSectionBody as d } from "./accelbyte-widgets122.mjs";
import { DatePicker as o } from "./accelbyte-widgets519.mjs";
import { Loading as h } from "./accelbyte-widgets136.mjs";
import { Pagination as g } from "./accelbyte-widgets256.mjs";
import t, { Component as D } from "react";
import { Trans as c } from "react-i18next";
import { AccountHistoryErrorFetchingData as u } from "./accelbyte-widgets520.mjs";
class N extends D {
  constructor() {
    super(...arguments), this.renderFilter = () => /* @__PURE__ */ t.createElement("div", { className: "datepicker" }, /* @__PURE__ */ t.createElement(c, { i18nKey: "AccountHistoryPage.Detail.dateRange" }, "Date Range:"), /* @__PURE__ */ t.createElement("div", { className: "startDatePicker" }, /* @__PURE__ */ t.createElement(
      o,
      {
        key: "startDatePicker",
        selected: new Date(this.props.startDate),
        onChange: (e) => this.props.changeStartDate(e),
        value: this.props.startDate,
        maxDate: new Date(this.props.endDate)
      }
    )), /* @__PURE__ */ t.createElement(
      o,
      {
        key: "endDatePicker",
        onChange: (e) => this.props.changeEndDate(e),
        value: this.props.endDate,
        minDate: new Date(this.props.startDate),
        maxDate: new Date()
      }
    )), this.renderPagination = () => {
      const { editHistory: e, startDate: r, endDate: a } = this.props;
      if (!e)
        return;
      const { paging: s } = e, p = !!s.next, m = !!s.previous, i = this.props.page, n = new URLSearchParams();
      return n.append("startdate", r), n.append("enddate", a), /* @__PURE__ */ t.createElement("div", { className: "paginationContainer" }, /* @__PURE__ */ t.createElement(
        g,
        {
          next: p && `${this.props.paginationPath}?page=${i + 1}&${n}`,
          prev: m && `${this.props.paginationPath}?page=${i - 1}&${n}`
        }
      ));
    };
  }
  render() {
    const { isFetching: e, fetchError: r, editHistory: a } = this.props;
    return /* @__PURE__ */ t.createElement(l, { className: "editHistoryPage" }, /* @__PURE__ */ t.createElement(d, null, !e && this.renderFilter(), !e && r && /* @__PURE__ */ t.createElement(u, null), !e && !r && a && a.data && a.data.length === 0 && /* @__PURE__ */ t.createElement("p", { className: "noData" }, /* @__PURE__ */ t.createElement(c, { i18nKey: "AccountHistoryPage.Detail.noData" }, "There is no history to show here")), !e && !r && a && a.data && a.data.length > 0 && this.props.renderTableHistories(a.data), e && /* @__PURE__ */ t.createElement(h, { className: "loading" }), !e && a && a.data && a.data && this.renderPagination()));
  }
}
export {
  N as AccountHistoryPageDetail
};
