<template>
  <div class="ops-card q-mb-md">
    <div class="row items-center q-col-gutter-md">
      <div class="col-auto">
        <q-btn flat dense round icon="arrow_back" @click="$router.back()" />
      </div>
      <div class="col">
        <div class="text-h5 text-weight-bold">{{ customer.customer_name }}</div>
        <div class="text-caption text-grey-6 row items-center no-wrap q-gutter-x-xs">
          <span>{{ customer.name }}</span>
          <template v-if="customer.legacy_customer_id"><span>&middot; Legacy: {{ customer.legacy_customer_id }}</span></template>
          <span>&middot;</span>
          <q-select v-model="customer.customer_type" dense borderless
            :options="['Individual', 'Company']" emit-value map-options
            input-class="editable-input text-caption" style="min-width:80px;max-width:110px"
            @update:model-value="$emit('save', 'customer_type')" />
          <span>&middot;</span>
          <q-select v-model="customer.customer_group" dense borderless
            :options="customerGroups" emit-value map-options
            input-class="editable-input text-caption" style="min-width:90px;max-width:130px"
            @update:model-value="$emit('save', 'customer_group')" />
          <template v-if="customer.language">
            <span>&middot;</span>
            <q-select v-model="customer.language" dense borderless
              :options="[{label:'Français',value:'fr'},{label:'English',value:'en'}]" emit-value map-options
              input-class="editable-input text-caption" style="min-width:70px;max-width:100px"
              @update:model-value="$emit('save', 'language')" />
          </template>
        </div>
      </div>
      <div class="col-auto text-right">
        <span class="ops-badge q-mb-xs" :class="customer.disabled ? 'inactive' : 'active'" style="font-size:0.85rem">
          {{ customer.disabled ? 'Inactif' : 'Actif' }}
        </span>
      </div>
    </div>
  </div>
</template>

<script setup>
defineProps({
  customer: { type: Object, required: true },
  customerGroups: { type: Array, default: () => ['Commercial', 'Individual', 'Government', 'Non Profit'] },
})
defineEmits(['save'])
</script>
