<script setup lang="ts">
const props = defineProps({
  data: Object
})

const activeName = ref('shipmentStatus')

const handleTabClick = (name: string) => {
  activeName.value = name
}
</script>

<template>
  <div class="transport-step">
    <div class="header">
      <div
        class="tab"
        :class="{
          'is-active':
            activeName === 'shipmentStatus' && props.data?.transportInfo?.mode !== 'Air Freight',
          'only-one-mode': props.data?.transportInfo?.mode === 'Air Freight'
        }"
        @click="handleTabClick('shipmentStatus')"
      >
        Shipment Status
      </div>
      <div
        v-if="props.data?.transportInfo?.mode !== 'Air Freight'"
        class="tab"
        :class="{ 'is-active': activeName === 'containerStatus' }"
        @click="handleTabClick('containerStatus')"
      >
        Container Status
      </div>
      <div v-else class="tab"></div>
    </div>
    <div class="content">
      <template v-if="activeName === 'shipmentStatus'">
        <ShipmentStatus :data="props.data?.simplexData" />
      </template>
      <template
        v-else-if="
          activeName === 'containerStatus' && props.data?.transportInfo?.mode !== 'Air Freight'
        "
      >
        <ContainerStatus :data="props.data?.containerStatusData" :website="props.data?.website" />
      </template>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.transport-step {
  width: 400px;
  background-color: var(--color-header-bg);
  height: 448px;
  border-radius: 3px;
  border: 1px solid var(--color-border);
  // box-shadow: -2px 2px 12px 0px var(--color-shipment-status-shadow);
  .header {
    display: flex;
    height: 48px;
    border-radius: 6px 6px 0 0;
    background-color: var(--color-shipment-status-header-bg);
    .tab {
      flex: 1;
      text-align: center;
      line-height: 52px;
      color: var(--color-neutral-3);
      font-size: 18px;
      font-weight: 700;
      cursor: pointer;
      &.is-active {
        border-bottom: 2px solid var(--color-theme);
        color: var(--color-neutral-1);
      }
      &.only-one-mode {
        color: var(--color-neutral-1);
      }
    }
  }
  .content {
    height: calc(100% - 48px);
    background-color: var(--color-mode);
  }
  :deep(.el-collapse-item__wrap) {
    border-bottom: none;
  }
}
</style>
