import { CheckCircleOutlined } from "@ant-design/icons";
import { Modal } from "antd";

function ModalCompleted({ nftToBuy, onCancel, onOk }) {
  return (
    <Modal visible={true} onCancel={onCancel} onOk={onOk} width={600}>
      <div
        style={{
          display: "flex",
          alignItems: "center",
          flexDirection: "column",
        }}
      >
        <div
          style={{
            textAlign: "center",
            fontWeight: 600,
            borderBottom: "1px solid black",
            paddingBottom: 8,
            marginBottom: 16,
            width: "100%",
          }}
        >
          Your purchase has processed!
        </div>

        <div
          style={{
            display: "flex",
            justifyContent: "center",
            flexDirection: "column",
            alignItems: "center",
            gap: 10,
          }}
        >
          <div>
            Woot! You just purchased {`${nftToBuy.name} ${nftToBuy.token_id}.`}
            It's been confirmed on the blockchain!
          </div>
          <img style={{ maxHeight: 200 }} src={nftToBuy.image} alt="" />
          <div
            style={{
              width: 300,
              display: "flex",
              flexDirection: "column",
              // justifyContent: "space-around",
              border: "1px solid rgba(0,0,0,0.5)",
              borderRadius: 6,
            }}
          >
            <div
              style={{
                display: "flex",
                width: "100%",
                borderBottom: "1px solid rgba(0,0,0,0.5)",
                padding: "8px 8px 8px 12px",
              }}
            >
              <div style={{ flex: 1 }}>Status</div>
              <div style={{ flex: 1 }}>TransactionHash</div>
            </div>
            <div
              style={{
                display: "flex",
                width: "100%",
                padding: 16,
              }}
            >
              <div style={{ flex: 1 }}>
                <CheckCircleOutlined
                  style={{
                    color: "green",
                    transform: "scale(2)",
                    marginRight: 12,
                  }}
                />
                Complete
              </div>
              <div style={{ flex: 1, color: "blue" }}>
                {splitHash("0x3cb478657856324234804e")}
              </div>
            </div>
          </div>
          Congratulation on your first purchased! Lets create your own
          storefront
        </div>
      </div>
    </Modal>
  );
}

export default ModalCompleted;

function splitHash(string) {
  const beginHash = string.slice(0, 5);
  const last4Hash = string.slice(-4);
  return beginHash + "..." + last4Hash;
}
