<script lang='ts' setup>
import type { RwaData } from "@/api/types";

const props = defineProps<{
  data: RwaData | null;
}>();

const { t } = useI18n();
</script>

<template>
  <div class="mt-2">
    <!-- Rwa about -->
    <div>
      <div class="font-semibold">
        {{ t('market.tradeRwa.about') }}
      </div>
      <div class="text-xs mt-2">
        {{ data?.product.description || t('market.tradeRwa.noDescription') }}
      </div>
    </div>

    <!-- Rwa fields -->
    <ion-grid class="mt-5 text-sm space-y-5">
      <ion-row>
        <ion-col>
          <div class="label">
            {{ t('market.tradeRwa.fields.productCode') }}
          </div>
          <div>{{ data?.product.code }}</div>
        </ion-col>
        <ion-col>
          <div class="label">
            {{ t('market.tradeRwa.fields.valuation') }}
          </div>
          <div>${{ formatAmountWithUnit(data?.product.estimatedValue) }}</div>
        </ion-col>
      </ion-row>
      <ion-row>
        <ion-col>
          <div class="label">
            {{ t('market.tradeRwa.fields.unitPrice') }}
          </div>
          <div>${{ formatAmountWithUnit(data?.unitPrice) }}</div>
        </ion-col>
        <ion-col>
          <div class="label">
            {{ t('market.tradeRwa.fields.totalSupply') }}
          </div>
          <div>{{ Number(data?.totalSupply) }}{{ t('market.tradeRwa.units.shares') }}</div>
        </ion-col>
      </ion-row>
      <ion-row>
        <ion-col>
          <div class="label">
            {{ t('market.tradeRwa.fields.perUserLimit') }}
          </div>
          <div>{{ Number(data?.perUserLimit) }}{{ t('market.tradeRwa.units.shares') }}</div>
        </ion-col>
        <ion-col>
          <div class="label">
            {{ t('market.tradeRwa.fields.launchDate') }}
          </div>
          <div>{{ useDateFormat(data?.launchDate || '', 'YYYY/MM/DD HH:mm') }}</div>
        </ion-col>
      </ion-row>
      <ion-row>
        <ion-col>
          <div class="label">
            {{ t('market.tradeRwa.fields.subscriptionStartDate') }}
          </div>
          <div>{{ useDateFormat(data?.subscriptionStartDate || '', 'YYYY/MM/DD HH:mm') }}</div>
        </ion-col>
        <ion-col>
          <div class="label">
            {{ t('market.tradeRwa.fields.subscriptionEndDate') }}
          </div>
          <div>{{ useDateFormat(data?.subscriptionEndDate || '', 'YYYY/MM/DD HH:mm') }}</div>
        </ion-col>
      </ion-row>
    </ion-grid>

    <!-- Rwa status -->
    <div class="mt-5">
      <div class="font-semibold">
        资产状态
      </div>
      <div class="text-xs mt-2">
        {{ data?.status }}
      </div>
    </div>
  </div>
</template>

<style lang='css' scoped></style>
