import { T as Trans, F as FeUtils, a as Ctx, j as Alert, h as AlertType, i as CommonError, L as Loading } from "./index.js";
import React__default from "react";
import { A as AccountMainSection, b as AccountMainSectionHeader, a as AccountMainSectionBody } from "./AccountMainSection.js";
import { a1 as v2 } from "./dateFns.js";
import "./validator.js";
import "./reactPlayer.js";
import "react-router-dom";
import "./reactSlick.js";
const privacyRecordsTable = "privacyRecordsTable _privacyRecordsTable_85474";
var styles$1 = {
  privacyRecordsTable
};
const PrivacyRecordItem = ({ agreement }) => {
  return /* @__PURE__ */ React__default.createElement("tr", null, /* @__PURE__ */ React__default.createElement("td", null, agreement.policyName), /* @__PURE__ */ React__default.createElement("td", null, agreement.displayVersion), /* @__PURE__ */ React__default.createElement("td", null, FeUtils.formatDate(v2.legacyParse(agreement.signingDate || ""), "LL")));
};
const PrivacyRecords = ({ agreements }) => {
  return /* @__PURE__ */ React__default.createElement("table", {
    className: styles$1.privacyRecordsTable
  }, /* @__PURE__ */ React__default.createElement("thead", null, /* @__PURE__ */ React__default.createElement("tr", null, /* @__PURE__ */ React__default.createElement("th", null, /* @__PURE__ */ React__default.createElement(Trans, {
    i18nKey: "PrivacyRecordsPage.PrivacyRecords.document"
  }, "Document")), /* @__PURE__ */ React__default.createElement("th", null, /* @__PURE__ */ React__default.createElement(Trans, {
    i18nKey: "PrivacyRecordsPage.PrivacyRecords.version"
  }, "Version")), /* @__PURE__ */ React__default.createElement("th", null, /* @__PURE__ */ React__default.createElement(Trans, {
    i18nKey: "PrivacyRecordsPage.PrivacyRecords.date"
  }, "Date")))), /* @__PURE__ */ React__default.createElement("tbody", null, agreements.map((agreement) => /* @__PURE__ */ React__default.createElement(PrivacyRecordItem, {
    key: agreement.id,
    agreement
  }))));
};
const accountPrivacyRecordsPage = "accountPrivacyRecordsPage _accountPrivacyRecordsPage_5b97a";
const mainBody = "mainBody _mainBody_224f6";
var styles = {
  accountPrivacyRecordsPage,
  mainBody
};
class PrivacyRecordsPage extends React__default.Component {
  constructor(props) {
    super(props);
    this.logic = Ctx.getAppState().legalAppManager;
    this.logic.subscribe(() => this.setState({}));
  }
  componentDidMount() {
    this.logic.fetchAcceptedAgreement();
  }
  render() {
    const { isLoading, acceptedAgreements, error } = this.logic.state;
    return /* @__PURE__ */ React__default.createElement(AccountMainSection, {
      className: styles.accountPrivacyRecordsPage
    }, /* @__PURE__ */ React__default.createElement(AccountMainSectionHeader, null, /* @__PURE__ */ React__default.createElement(Trans, {
      i18nKey: "PrivacyRecordsPage.title"
    }, "Privacy Records")), /* @__PURE__ */ React__default.createElement(AccountMainSectionBody, {
      className: styles.mainBody
    }, !isLoading && error && /* @__PURE__ */ React__default.createElement(Alert, {
      type: AlertType.danger
    }, /* @__PURE__ */ React__default.createElement(CommonError, {
      error
    })), isLoading && /* @__PURE__ */ React__default.createElement(Loading, null), !isLoading && Array.isArray(acceptedAgreements) && /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, acceptedAgreements.length > 0 ? /* @__PURE__ */ React__default.createElement(PrivacyRecords, {
      agreements: acceptedAgreements
    }) : /* @__PURE__ */ React__default.createElement("p", null, /* @__PURE__ */ React__default.createElement(Trans, {
      i18nKey: "PrivacyRecordsPage.noRecord"
    }, "There is no record to show")))));
  }
}
export { PrivacyRecordsPage as default };
