<script setup>
const props = defineProps({
  params: Object
})

const shipment = ref({})
const getShipment = async () => {
  if(props.params.data.id) {
    const res = await $fetch(`/api/inouts/${props.params.data.id}/order`)
    if(res) {
      shipment.value = res
    }
  }
}
onMounted(getShipment)
watch(() => props.params, getShipment)
</script>

<template>
  <div class="d-inlineFlex items-center gap-5px">
    <div class="tags">
      <a v-if="shipment?.TrackingNo && props.params.data.shipper === 'DHL'" target="_blank" :href="'https://www.dhl.de/de/privatkunden/pakete-empfangen/verfolgen.html?idc='+shipment?.TrackingNo">{{shipment?.TrackingNo}}</a>
      <span v-else>{{shipment?.TrackingNo}}</span>
    </div>
  </div>
</template>

<style scoped>
.tag {
  width: 40px;
  height: 20px;
}
.greenbt {
  color: white;
  background-color: #00a500;
  border: 1px solid #00a500;
}

.greybt {
  color: grey;
  border: 1px solid grey;
}

.icons {
  color: white;
}

span[class^='i-mdi'] {
  font-size: 19px;
  margin-top: 4px;
}
</style>