<script setup>
const props = defineProps({
  row: {
    type: Object,
    required: true,
    default: {}
  },
  inShow: {
    type: Boolean,
    default: false
  }
})

const value = computed(() => {
  const costcentre = props.row.parentCostcentre || props.row.costcentre || props.row.costCentre || null

  if (!costcentre) {
    return ""
  }

  return [costcentre.number, costcentre.name].filter(Boolean).join(" - ")
})
</script>

<template>
  <div v-if="props.row.parentCostcentre">
    <nuxt-link v-if="props.inShow" :to="`/standardEntity/costcentres/show/${props.row.parentCostcentre.id}`">
      {{ value }}
    </nuxt-link>
    <span v-else>{{ value }}</span>
  </div>
</template>
