UNPKG

@mojito-inc/secondary-market

Version:

Mojito secondary market is the platform to purchase NFT.

2 lines (1 loc) 3.55 kB
import{jsx as e,jsxs as i,Fragment as t}from"react/jsx-runtime";import o from"@mui/material/Stack";import n from"@mui/material/Divider";import r from"@mui/material/Button";import l from"@mui/material/Typography";import d from"@mui/material/Box";import{useTheme as a}from"@mui/material/styles";import c from"moment";import{Currency as f}from"../interface/index.js";import s from"./Pagination.js";import{truncateAddress as p}from"../utils/truncateAddress.utils.js";const m=({data:m,walletAddress:u,offersOffset:x,totalOffers:h,selectedCurrency:v=f.USD,onClickAcceptOffer:g,onClickRejectOffer:C,onClickCancelOffer:S,onHandleOffersPagination:E})=>{const y=a();return e(d,{children:m.length>0?i(t,{children:[m.map(((t,a)=>{var f,s,x,h,E,w,O,D,j,k,R,W;return i(d,{children:[i(o,{direction:"row",sx:{justifyContent:"space-between",alignItems:"center",marginBottom:"16px"},children:[e(l,{sx:{fontSize:"12px",fontWeight:"500"},children:"OFFER PRICE:"}),i(o,{direction:"row",sx:{alignItems:"center"},children:[e(l,{sx:{fontSize:"16px",fontWeight:"400"},children:`${t.price[0].value} ${v}`}),e(l,{sx:{fontSize:"12px",fontWeight:"400",color:null===(s=null===(f=null==y?void 0:y.palette)||void 0===f?void 0:f.grey)||void 0===s?void 0:s[600],marginLeft:"5px"},children:`${t.price[1].value} ${t.price[1].unit}`})]})]}),i(o,{direction:"row",sx:{justifyContent:"space-between",alignItems:"center",marginBottom:"16px"},children:[e(l,{sx:{fontSize:"12px",fontWeight:"500"},children:"FROM:"}),e(l,{sx:{fontSize:"14px",fontWeight:"400"},children:p(t.buyerAddress)})]}),i(o,{direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:[e(l,{sx:{fontSize:"12px",fontWeight:"500"},children:"OFFER EXPIRES:"}),e(l,{sx:{fontSize:"14px",fontWeight:"400"},children:c(t.expiryDate).format("MMMM DD, YYYY hh:mm A")})]}),["CANCELLED","REJECTED","EXPIRED"].some((e=>{var i;return null===(i=null==t?void 0:t.offerStatus)||void 0===i?void 0:i.includes(e)}))&&i(o,{direction:"row",sx:{justifyContent:"space-between",alignItems:"center",marginTop:"16px"},children:[e(l,{sx:{fontSize:"12px",fontWeight:"500"},children:"OFFER STATUS:"}),e(l,{sx:{fontSize:"14px",fontWeight:"400"},children:null==t?void 0:t.offerStatus})]}),"PENDING"===t.offerStatus&&t.ownerWalletAddress===u?i(o,{direction:"row",spacing:2,sx:{marginTop:"24px"},children:[e(r,{"data-testid":"accept_offer",sx:{width:"100%"},onClick:()=>g(t),children:"Accept Offer"}),e(r,{"data-testid":"reject_offer",onClick:()=>C(t),sx:{color:null===(E=null===(h=null===(x=null==y?void 0:y.palette)||void 0===x?void 0:x.appDefaultColor)||void 0===h?void 0:h.secondary)||void 0===E?void 0:E.dark,background:null===(w=null==y?void 0:y.palette)||void 0===w?void 0:w.primary.main,width:"100%"},children:"Reject Offer"})]}):"PENDING"===t.offerStatus&&u?e(r,{"data-testid":"cancel_offer",onClick:()=>S(t.id),sx:{color:null===(j=null===(D=null===(O=null==y?void 0:y.palette)||void 0===O?void 0:O.appDefaultColor)||void 0===D?void 0:D.secondary)||void 0===j?void 0:j.dark,background:null===(k=null==y?void 0:y.palette)||void 0===k?void 0:k.primary.main,marginTop:"24px",width:"100%"},children:"Cancel Offer"}):e(d,{}),a!==m.length-1?e(n,{sx:{marginTop:"24px",marginBottom:"16px",borderColor:null===(W=null===(R=y.palette.appDefaultColor)||void 0===R?void 0:R.secondary)||void 0===W?void 0:W.light}}):null]},t.id)})),h>1&&e(d,{sx:{marginTop:"16px"},children:e(s,{total:h,offset:x+1,onHandlePagination:E})})]}):e(l,{sx:{fontSize:"12px",fontWeight:"500",textAlign:"center"},children:"NO OFFERS YET"})})};export{m as default};