'use strict';

var React = require('react');
var types = require('./types-91d0677b.js');
var notifications = require('./notifications-56c6fc94.js');
var Checkmark = require('./Checkmark-74444a78.js');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var React__default = /*#__PURE__*/_interopDefaultLegacy(React);

const Notification = ({
  title,
  issuerImage,
  issueDate,
  className,
  notificationType = notifications.NotificationTypeEnum.Achievement,
  handleViewOnClick = () => {
  },
  claimStatus = false,
  handleClaimOnClick = () => {
  },
  loadingState = false
}) => {
  const [isClaimed, setIsClaimed] = React.useState(claimStatus || false);
  const [isLoading, setIsLoading] = React.useState(loadingState || false);
  React.useEffect(() => {
    setIsClaimed(claimStatus);
  }, [claimStatus]);
  React.useEffect(() => {
    setIsLoading(loadingState);
  }, [loadingState]);
  const {
    IconComponent,
    iconCircleStyles,
    textStyles,
    viewButtonStyles,
    claimedButtonStyles,
    unclaimedButtonStyles,
    typeText
  } = types.NotificationTypeStyles[notificationType];
  const claimButtonStyles = isClaimed ? claimedButtonStyles : unclaimedButtonStyles;
  let buttonText = "";
  if (isClaimed) {
    buttonText = "Claimed";
  } else if (!isClaimed) {
    buttonText = "Claim";
  }
  return /* @__PURE__ */ React__default["default"].createElement(
    "div",
    {
      className: `flex justify-center items-center relative w-full rounded-3xl shadow-2xl py-3 bg-white ${className}`
    },
    /* @__PURE__ */ React__default["default"].createElement(
      "div",
      {
        className: `absolute flex items-center justify-center top-2 right-2 h-8 w-8 overflow-hidden rounded-full z-10 ${iconCircleStyles}`
      },
      /* @__PURE__ */ React__default["default"].createElement(IconComponent, { className: "h-4/5 text-white" })
    ),
    /* @__PURE__ */ React__default["default"].createElement("div", { className: "flex flex-col justify-center items-center relative w-11/12" }, /* @__PURE__ */ React__default["default"].createElement("div", { className: "flex flex-row items-center justify-start w-full" }, /* @__PURE__ */ React__default["default"].createElement(
      "div",
      {
        className: `h-12 w-12 max-h-12 max-w-[48px] min-h-[48px] min-w-[48px] overflow-hidden rounded-full ${iconCircleStyles}`
      },
      /* @__PURE__ */ React__default["default"].createElement(
        "img",
        {
          src: issuerImage,
          alt: "issuer image",
          className: "w-full h-full object-cover"
        }
      )
    ), /* @__PURE__ */ React__default["default"].createElement("div", { className: "text-left ml-3" }, /* @__PURE__ */ React__default["default"].createElement(
      "h4",
      {
        className: "font-bold tracking-wide line-clamp-1 text-black",
        "data-testid": "notification-title"
      },
      title
    ), /* @__PURE__ */ React__default["default"].createElement(
      "p",
      {
        className: `font-semibold p-0 m-0 leading-none tracking-wide line-clamp-1 ${textStyles}`,
        "data-testid": "notification-type"
      },
      typeText,
      " ",
      /* @__PURE__ */ React__default["default"].createElement(
        "span",
        {
          className: "text-grayscale-600 normal-case font-normal text-sm",
          "data-testid": "notification-cred-issue-date"
        },
        "\u2022 ",
        issueDate
      )
    ))), /* @__PURE__ */ React__default["default"].createElement("div", { className: "flex items-center justify-between w-full mt-3" }, /* @__PURE__ */ React__default["default"].createElement(
      "button",
      {
        onClick: handleViewOnClick,
        className: `flex-1 rounded-[24px] border-solid border-2 bg-white font-semibold mr-2 py-2 px-3 tracking-wide ${viewButtonStyles}`,
        role: "button",
        name: "notification-view-button"
      },
      "View"
    ), /* @__PURE__ */ React__default["default"].createElement(
      "button",
      {
        className: `flex items-center justify-center flex-1 rounded-[24px] border-2 border-solid font-semibold py-2 px-3 tracking-wide ${claimButtonStyles}`,
        onClick: handleClaimOnClick,
        role: "button",
        name: "notification-claim-button"
      },
      isClaimed && /* @__PURE__ */ React__default["default"].createElement(Checkmark.Checkmark, { className: "h-[24px] p-0 m-0" }),
      " ",
      isLoading ? "Loading..." : buttonText
    )))
  );
};

exports.Notification = Notification;
//# sourceMappingURL=Notification-24d4de25.js.map
