Untitled

 avatar
unknown
plain_text
2 years ago
1.1 kB
6
Indexable
<template>
  <tr>
    <td>
      <p v-if="title">
        {{ title }}
        <sup v-for="id in price.footnotes" :key="id">{{ id }})</sup>
      </p>
    </td>
    <td class="text--right">
      <p v-if="price">
        <span v-if="isDecimal">{{ formatPriceValue(price[clientPriceType]) }}</span>
        <span v-else>{{ Math.ceil(price[clientPriceType]) }}</span>
        {{ price.currency }}
      </p>
    </td>
  </tr>
</template>

<script>
import formatPrice from '../filters/formatPrice';

export default {
  props: {
    price: {
      type: Object,
      default: () => ({ value: 0, currency: '', footnotes: [] })
    },
    title: {
      type: String,
      default: ''
    },
    isDecimal: {
      type: Boolean,
      default: false
    },
    clientPriceType: {
      type: String,
      default: 'brutto'
    }
  },
  setup() {
    // Since filters are removed in Vue 3, use a method instead
    const formatPriceValue = (value) => {
      return formatPrice(value);
    };

    return {
      formatPriceValue
    };
  }
};
</script>
Editor is loading...