templates/explorer/includes/asset-card.html.twig line 1

  1. <div class="grid-x nft-container glow-{{ nftMetadata.template.tier }}">
  2.     <div class="small-12 large-12 cell">
  3.         <div class="template-nft">
  4.             <a href="{{ path('explorer_asset_detail', { id: nftMetadata.nftHub.id }) }}">
  5.             <img src="{{ nftMetadata.imageUrl }}" />
  6.             </a>
  7.             <div class="mint-num">#{{ nftMetadata.mint }}</div>
  8. {#            <div style="display: block; background: #1d232d; padding: 7px; border-radius: 10px; font-size: 1em; margin: 5px;">#}
  9. {#                <span><span style="font-weight:bold; color: dodgerblue; margin-right: 2px;">L</span>{{ (nftMetadata.statStar is defined) ? nftMetadata.statStar : nftMetadata.luck }}</span>#}
  10. {#                <span><span style="font-weight:bold; color: dodgerblue; margin-right: 2px;">D</span>{{ (nftMetadata.statRectangle is defined) ? nftMetadata.statRectangle : nftMetadata.distance }}</span>#}
  11. {#                <span><span style="font-weight:bold; color: dodgerblue; margin-right: 2px;">T</span>{{ (nftMetadata.statCircle is defined) ? nftMetadata.statCircle : nftMetadata.tension }}</span>#}
  12. {#            </div>#}
  13.             <div style="display: block; margin: 7px 10px 10px 0;">
  14.                 {% if nftMetadata.template.genus.id != 3 %}
  15.                 <span style="font-weight: bold; font-size: 1em; float: right; margin-left: 5px; color: goldenrod"><em>{{ nftMetadata.score }}</em></span>
  16.                 <span style="font-weight: bold; font-size: 1em; float: right;">{{ nftMetadata.grade }}</span>
  17.                 <div style="height: 10px; width: 10px; border-radius: 8px; float: right; margin: 7px;" class="bg-tier-{{ (nftMetadata.template.tier is defined) ? nftMetadata.template.tier : nftMetadata.tier }}"></div>
  18.                 <img data-tooltip aria-haspopup="true" class="has-tip" title="{{ nftMetadata.schoolOfMagic.name }}" style="border-bottom: 0; height: 20px; width: 20px; float: right;" src="{{ asset('/build/images/web/icon-' ~ nftMetadata.schoolOfMagic.name|lower ~ '.png') }}" />
  19.                 {% endif %}
  20.                 <div style="float: left; padding: 3px 3px 3px 12px; font-size: .8em;">
  21.                     {% if nftMetadata.nftHub.activeMarketItem is not empty%}
  22.                         {# If Market Item exists, look for username attached to Market Item Seller #}
  23.                         {% if nftMetadata.nftHub.activeMarketItem|first.seller.user.username is defined and nftMetadata.nftHub.activeMarketItem|first.seller.user.username|length <= 10 %}
  24.                             {{ nftMetadata.nftHub.activeMarketItem|first.seller.user.username }}
  25.                         {% elseif nftMetadata.nftHub.activeMarketItem|first.seller.user.username is defined %}
  26.                             {{ nftMetadata.nftHub.activeMarketItem|first.seller.user.username|slice(0,10) ~ '...' }}
  27.                         {% endif %}
  28.                     {% else %}
  29.                         {# Otherwise look for username attached to NFT #}
  30.                         {% if nftMetadata.nftHub.thetaWallet.user.username is defined and nftMetadata.nftHub.thetaWallet.user.username| length <= 10 %}
  31.                             {{ nftMetadata.nftHub.thetaWallet.user.username }}
  32.                         {% elseif nftMetadata.nftHub.thetaWallet.user.username is defined %}
  33.                             {{ nftMetadata.nftHub.thetaWallet.user.username|slice(0,10) ~ '...' }}
  34.                         {% endif %}
  35.                     {% endif %}
  36.                 </div>
  37.                 <div style="clear: both;"></div>
  38.             </div>
  39.             <div style="display: block; padding: 0 12px 12px 12px; text-align: left;">
  40.                 <span style="font-size: .6em; text-align: left; display: block;">Series {{ nftMetadata.nftCollection.series }}</span>
  41.                 <span style="font-size: .8em; text-align: left; display: block; font-weight: bold;">{{ nftMetadata.nftCollection.name }}</span>
  42.                 <span style="text-align: left; font-size: 1em; font-weight: bold; display: block;">{{ nftMetadata.name|length > 18 ? nftMetadata.name|slice(0,18) ~ '...' : nftMetadata.name }}</span>
  43.                 <div style="font-weight: bold; text-align: left; display: block; min-height: 25px; vertical-align: center; margin-top: 10px;">
  44.                 {% if nftMetadata.nftHub.activeMarketItem is not empty %}
  45.                     <img height="20" width="20" src="{{ asset('build/images/web/tfuel-logo.svg') }}" style="vertical-align: top;" />
  46.                     <span class="market-price-{{ nftMetadata.nftHub.activeMarketItem|first.id }}" style="color: #ffa50d; font-size: .9em; vertical-align: top;">{{ nftMetadata.nftHub.activeMarketItem|first.price|number_format(2,'.',',')  }}</span> <span style="color: #ffa50d; font-size: .9em; vertical-align: top;">TFUEL</span>
  47.                 {% endif %}
  48.                 </div>
  49.             </div>
  50.             <div style="padding: 3px;">
  51.                 {# MARKET OFFER LOGIC ------------------------------------------------------------------------------- #}
  52.                 {% if nftMetadata.nftHub.thetaWallet.address != '0x000000000000000000000000000000000000dEaD' %} {# already opened #}
  53.                     {% if nftMetadata.nftHub.isMinted is same as(true) %}
  54.                         {% if app.user %} {# If not logged in, show Market Offer button that links to app_login #}
  55.                             {% if app.user.activeWallet is defined %} {# If wallet is not defined they cannot interact with the market #}
  56.                                 {% if (app.user.activeWallet != nftMetadata.nftHub.thetaWallet) and
  57.                                     ((nftMetadata.nftHub.activeMarketItem is empty) or (nftMetadata.nftHub.activeMarketItem is not empty and nftMetadata.nftHub.activeMarketItem|first.seller != app.user.activeWallet)) %}
  58.                                     {# Two possibilities:
  59.                                         1) Item is listed for sale, so the owning wallet is the market address,
  60.                                         2) item is not listed and does not belong to the user #}
  61.                                     {# Scenario 1: Item is listed on Market and current user does not own item / is not the seller #}
  62.                                     {# See if current user has an existing offer #}
  63.                                     {% set activeOffer = null %}
  64.                                     {% for offer in nftMetadata.nftHub.activeMarketOffers %}
  65.                                         {% if offer.bidder == app.user.activeWallet %}
  66.                                             {% set activeOffer = offer %}
  67.                                         {% endif %}
  68.                                     {% endfor %}
  69.                                     {% if activeOffer is not null %}
  70.                                         {# If current user has an existing offer, show Update and Cancel buttons #}
  71.                                         <button class="double-button-left button orange-button initiateUpdateMarketOffer {{ app.user.walletExtension == 1 ? 'ext-theta' : 'ext-meta' }}" data-open="updateMarketOffer-{{ nftMetadata.nftHub.id }}" style="width: 50%; display: block; float: left; font-size: .8em; font-weight: bold;">Update Offer</button>
  72.                                         {% include 'marketplace/modals/updateMarketOffer.html.twig' with {'marketOffer' : activeOffer, 'assetMetadata' : nftMetadata, 'app': app } %}
  73.                                         <button class="double-button-right button orange-button initiateCancelMarketOffer {{ app.user.walletExtension == 1 ? 'ext-theta' : 'ext-meta' }}" data-open="cancelMarketOffer-{{ nftMetadata.nftHub.id }}" style="width: 50%; display: block; float: left; font-size: .8em; font-weight: bold;">Cancel Offer</button>
  74.                                         {% include 'marketplace/modals/cancelMarketOffer.html.twig' with {'marketOffer' : activeOffer, 'assetMetadata' : nftMetadata, 'app': app } %}
  75.                                         <div style="clear: both;"></div>
  76.                                     {% elseif not app.user.activeWallet %}
  77.                                         <button class="button orange-button initiateCreateMarketOffer connect-wallet" data-open="connect-wallet-modal" style="width: 100%; font-size: .8em; font-weight: bold;">Make Offer</button>
  78.                                         <button class="button orange-button initiateCreateMarketOffer" data-open="createMarketOffer-{{ nftMetadata.nftHub.id }}" style="width: 100%; font-size: .8em; font-weight: bold; display: none;">Make Offer</button>
  79.                                     {% else %}
  80.                                         {# If current user does not have an existing offer, show Make Offer button #}
  81.                                         <button class="button orange-button initiateCreateMarketOffer {{ app.user.walletExtension == 1 ? 'ext-theta' : 'ext-meta' }}" data-open="createMarketOffer-{{ nftMetadata.nftHub.id }}" style="width: 100%; font-size: .8em; font-weight: bold;">MAKE OFFER</button>
  82.                                     {% endif %}
  83.                                     {% include 'marketplace/modals/createMarketOffer.html.twig' with {'assetMetadata' : nftMetadata, 'app': app } %}
  84.                                 {% else %} {# User owns this item, so show View Offers button #}
  85.                                     <button onclick="window.location.href='{{ url('explorer_asset_detail', { id: nftMetadata.nftHub.id }) }}#asset-offers';" class="button view-offers orange-button" style="width: 100%; font-size: .8em; font-weight: bold;" {{ nftMetadata.nftHub.activeMarketOffers|length == 0 ? 'disabled' : '' }}>View Offers ({{ nftMetadata.nftHub.activeMarketOffers|length }})</button>
  86.                                 {% endif %}
  87.                             {% else %} {# No wallet connected #}
  88.                                 Button to connect wallet
  89.                             {% endif %}
  90.                         {% else %} {# Not logged in #}
  91.                             <a class="button orange-button initiateCreateMarketOffer"  style="width: 100%; font-size: .8em; font-weight: bold;" href="{{ path('app_login') }}" />MAKE OFFER</a>
  92.                         {% endif %}
  93.                     {% else %} {# NFT not minted #}
  94.                         <button class="button orange-button" data-open="createMarketOffer-{{ nftMetadata.nftHub.id }}" style="width: 100%; font-size: .8em; font-weight: bold; background-color: #333" disabled>View Offers (0)</button>
  95.                     {% endif %}
  96.                 {% else %}
  97.                     <button class="button orange-button" data-open="createMarketOffer-{{ nftMetadata.nftHub.id }}" style="width: 100%; font-size: .8em; font-weight: bold; background-color: #333" disabled>MAKE OFFER</button>
  98.                 {% endif %}
  99.                 {# MARKET ITEM LOGIC -------------------------------------------------------------------------------- #}
  100.                 {% if app.user %} {# If not logged in, show BUY NOW button that links to app_login #}
  101.                     {% if app.user.activeWallet is defined %} {# If wallet is not defined they cannot interact with the market #}
  102.                         {% if nftMetadata.nftHub.activeMarketItem is not empty %} {# Item is listed for sale in Market #}
  103.                             {# If user is the owner/seller of the item so buttons specific to Market Contract version #}
  104.                             {% if app.user.activeWallet == nftMetadata.nftHub.activeMarketItem|first.seller %}
  105.                                 {# Check which Market Contract item is listed on and show appropriate buttons #}
  106.                                 {% if nftMetadata.nftHub.activeMarketItem|first.marketContract.id == 3 %}
  107.                                     <button class="double-button-left-w-curve button initiateUpdateMarketItem {{ app.user.walletExtension == 1 ? 'ext-theta' : 'ext-meta' }}" data-open="updateMarketItem-{{ nftMetadata.nftHub.activeMarketItem|first.id }}" style="width: 50%; float: left; font-size: .8em; font-weight: bold;">Update</button>
  108.                                     <button class="double-button-right-w-curve button initiateCancelMarketItem {{ app.user.walletExtension == 1 ? 'ext-theta' : 'ext-meta' }}" data-open="cancelMarketItem-{{ nftMetadata.nftHub.activeMarketItem|first.id }}" style="width: 50%; float: left; font-size: .8em; font-weight: bold;">Cancel</button>
  109.                                 {% else %}
  110.                                     <a class="button orange-button initiateCancelMarketItem {{ app.user.walletExtension == 1 ? 'ext-theta' : 'ext-meta' }}" data-open="cancelMarketItem-{{ nftMetadata.nftHub.activeMarketItem|first.id }}" style="width: 100%; font-size: .8em; font-weight: bold;">Cancel</a>
  111.                                 {% endif %}
  112.                                 {% include 'marketplace/modals/createMarketCancel.html.twig' with {'marketItem': nftMetadata.nftHub.activeMarketItem|first, 'app': app } %}
  113.                                 {% include 'marketplace/modals/updateMarketItem.html.twig' with {'assetMetadata' : nftMetadata, 'marketItem' : nftMetadata.nftHub.activeMarketItem|first, 'app' : app } %}
  114.                             {# If user does not have an active wallet change button to open Connect Wallet Modal #}
  115.                             {% elseif not app.user.activeWallet %}
  116.                                 <button class="button orange-button initiateTransactMarketItem connect-wallet" data-open="connect-wallet-modal" style="width: 100%; font-size: .8em; font-weight: bold;">BUY NOW</button>
  117.                                 <button class="button orange-button initiateTransactMarketItem {{ app.user.walletExtension == 1 ? 'ext-theta' : 'ext-meta' }}"
  118.                                         data-open="transactMarketItem-{{ nftMetadata.nftHub.activeMarketItem|first.id }}"
  119.                                         style="width: 100%; font-size: .8em; font-weight: bold; display: none;">BUY NOW
  120.                                 </button>
  121.                             {# If user is not the owner/seller show BUY NOW button #}
  122.                             {% else %}
  123.                                 {# If user has an existing offer on this item they must cancel that offer before Buying #}
  124.                                 {# We already looped through this above, so we can just reuse activeOffer here #}
  125.                                 {% if activeOffer is defined and activeOffer is not null %}
  126.                                     <button class="button orange-button initiateTransactMarketItem"
  127.                                             data-open="conflict-cancelMarketOffer-{{ nftMetadata.nftHub.activeMarketItem|first.id }}"
  128.                                             style="width: 100%; font-size: .8em; font-weight: bold;">BUY NOW
  129.                                     </button>
  130.                                     <div class="reveal" id="conflict-cancelMarketOffer-{{ nftMetadata.nftHub.activeMarketItem|first.id }}" data-reveal
  131.                                          style="text-align: center; background: #1f1f29; border-radius: 15px; border: none;">
  132.                                         <h1>Active Offer Exists</h1>
  133.                                         <img height="100" width="100" src="{{ asset('build/images/web/warning.svg') }}" />
  134.                                         <p>You must cancel your offer for this item before you can purchase from the Market.</p>
  135.                                         <button class="close-button" data-close aria-label="Close modal" type="button">
  136.                                             <span aria-hidden="true">&times;</span>
  137.                                         </button>
  138.                                     </div>
  139.                                 {% else %}
  140.                                     <button class="button orange-button initiateTransactMarketItem {{ app.user.walletExtension == 1 ? 'ext-theta' : 'ext-meta' }}"
  141.                                             data-open="transactMarketItem-{{ nftMetadata.nftHub.activeMarketItem|first.id }}"
  142.                                             style="width: 100%; font-size: .8em; font-weight: bold;">BUY NOW
  143.                                     </button>
  144.                                 {% endif %}
  145.                             {% endif %}
  146.                             {% include 'marketplace/modals/transactMarketItem.html.twig' with {'marketItem': nftMetadata.nftHub.activeMarketItem|first, 'app': app } %}
  147.                         {% else %} {# Item not for sale #}
  148.                             {# If current user is the owner show Sell button #}
  149.                             {% if app.user.activeWallet == nftMetadata.nftHub.thetaWallet %}
  150.                                 {% if nftMetadata.nftHub.isMinted is same as(true) %}
  151.                                     {# If the NFT is a crate #}
  152.                                     {% if nftMetadata.template.genus.name == 'crate' %}
  153.                                         {% if nftMetadata.nftHub.crateActionLog.isOpened is same as(null) %}
  154.                                             {% if app.user.activeWallet.isApprovedForAllMarketCrate is same as(true) %}
  155.                                                 <button class="button orange-button initiateCreateMarketItem {{ app.user.walletExtension == 1 ? 'ext-theta' : 'ext-meta' }}" style="width: 100%; font-weight: bold; font-size: .8em; color: #fff;" data-open="createMarketItem-{{ nftMetadata.nftHub.id }}">Sell</button>
  156.                                                 {% include 'marketplace/modals/createMarketItem.html.twig' with {'assetMetadata': nftMetadata, 'app': app } %}
  157.                                             {% else %}
  158.                                                 <button class="button orange-button initiateCreateMarketItem" style="width: 100%; font-weight: bold; font-size: .8em; display: none; color: #fff;" data-open="createMarketItem-{{ nftMetadata.nftHub.id }}">Sell</button>
  159.                                                 {% include 'marketplace/modals/setApprovalForAll.html.twig' with {'assetMetadata': nftMetadata, 'app': app, 'buttonText': 'Sell'} %}
  160.                                                 {% include 'marketplace/modals/createMarketItem.html.twig' with {'assetMetadata': nftMetadata, 'app': app, 'hideSellButton': true } %}
  161.                                             {% endif %}
  162.                                         {% else %}
  163.                                             <button class="button orange-button initiateCreateMarketItem inactive" style="width: 100%; font-weight: bold; font-size: .8em; color: #fff;" data-open="createMarketItem-{{ nftMetadata.nftHub.id }}" disabled>Sell</button>
  164.                                         {% endif %}
  165.                                     {% endif %}
  166.                                     {# If the NFT is not a crate #}
  167.                                     {% if nftMetadata.template.genus.name != 'crate' %}
  168.                                         {# If the wallet has approved the Market Contract then show Sell button #}
  169.                                         {% if app.user.activeWallet.isApprovedForAllMarket2 is same as(true) %}
  170.                                             <button class="button orange-button initiateCreateMarketItem {{ app.user.walletExtension == 1 ? 'ext-theta' : 'ext-meta' }}" style="width: 100%; font-weight: bold; font-size: .8em; color: #fff;" data-open="createMarketItem-{{ nftMetadata.nftHub.id }}">Sell</button>
  171.                                             {% include 'marketplace/modals/createMarketItem.html.twig' with {'assetMetadata': nftMetadata, 'app': app } %}
  172.                                         {# If the wallet has not approved Market contract, show sell button but open Permission Modal (this fades to Sell button after success) #}
  173.                                         {% else %}
  174.                                             <button class="button orange-button initiateCreateMarketItem" style="width: 100%; font-weight: bold; font-size: .8em; display: none; color: #fff;" data-open="createMarketItem-{{ nftMetadata.nftHub.id }}">Sell</button>
  175.                                             {% include 'marketplace/modals/setApprovalForAll.html.twig' with {'assetMetadata': nftMetadata, 'app': app, 'buttonText': 'Sell'} %}
  176.                                             {% include 'marketplace/modals/createMarketItem.html.twig' with {'assetMetadata': nftMetadata, 'app': app, 'hideSellButton': true } %}
  177.                                         {% endif %}
  178.                                     {% endif %}
  179.                                 {% else %} {# Item not minted yet (drop from crate) #}
  180.                                     <button class="button orange-button initiateCreateMarketItem inactive" style="width: 100%; font-weight: bold; font-size: .8em; color: #fff;" data-open="createMarketItem-{{ nftMetadata.nftHub.id }}" disabled>Sell</button>
  181.                                 {% endif %}
  182.                             {# If current user is not owner and item is not listed for sale #}
  183.                             {% else %}
  184.                                 <button class="button orange-button"
  185.                                         style="width: 100%; font-size: .8em; font-weight: bold; color: #666; background-color: #333;" disabled>Not for Sale
  186.                                 </button>
  187.                             {% endif %}
  188.                         {% endif %}
  189.                     {% else %} {# No wallet connected #}
  190.                         Button to connect wallet
  191.                     {% endif %}
  192.                 {% else %} {# Not logged in #}
  193.                     {% if nftMetadata.nftHub.activeMarketItem is not empty %}
  194.                         <a class="button orange-button initiatetransactMarketItem"  style="width: 100%; font-size: .8em; font-weight: bold;" href="{{ path('app_login') }}" />BUY NOW</a>
  195.                     {% else %}
  196.                         <button class="button orange-button"  style="width: 100%; font-size: .8em; font-weight: bold; background: #333;" disabled />BUY NOW</a>
  197.                     {% endif %}
  198.                 {% endif %}
  199.                 {% if marketItem is defined and marketItem is not same as(null) and marketItem.isSold is same as(true) %}
  200.                     <span style="font-size: .8em; padding: 5px; display: block; font-weight: bold; margin: 10px; border-radius: 5px;"><em>{{ marketItem.updatedAt|date }}</em></span>
  201.                 {% endif %}
  202.             </div>
  203.         </div>
  204.     </div>
  205. </div>