<template>
  <div class="mkt-header">
    <div class="assets-user">
      <div class="assets-user-img" :style="{background: bgCor[bgCorFloor]}">
        <img v-if="localWalletStore.showAddress" :src="imageUrl" alt="Dynamic Image">
        <img v-else src="@/assets/img/marketplace/avatar/0000.png" alt="Dynamic Image">
      </div>
      <div class="assets-user-name">{{ localWalletStore.showAddress ? localWalletStore.showAddress : 'User Address' }}</div>
      <div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, computed } from "vue"
import {walletStore} from "@/store/wallet";

const localWalletStore = walletStore()

const bgCor = ref(['#5bbbff', '#ffc35b', '#bb7fff', '#ff6600'])

const bgCorFloor = computed(() => {
  return parseInt(localWalletStore.showAddress.substring(0,6))%4
})
const imageUrl = computed(() => {
  let str = parseInt(localWalletStore.showAddress.substring(0,6))%34
  if (str < 10) {
    str = '0' + str
  }
  let imgUrl = `https://res.counterfire.games/headimg/00${str}.png`
  return new URL(imgUrl, import.meta.url).href;
});

</script>

<style lang="scss" scoped>
.mkt-header {
  width: 100%;
  .assets-user {
    display: flex;
    // margin: 168px 0 45px 77px;
    padding: 168px 0 45px 77px;
    .assets-user-img {
      width: 173.8px;
      height: 173.8px;
      margin-right: 25px;
      border-radius: 16px;
      img {
        width: 100%;
        height: 100%;
      }
    }
    .assets-user-name {
      font-family: 'Poppins';
      font-weight: bold;
      font-size: 30px;
      color: #FFFFFF;
    }
  }
}
</style>