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

const emailInvoice = useEmailInvoice()
const emailInvoiceParam = useEmailInvoiceParam()

const openEmailModal = () => {
  const data = props.params?.data
  if (!data) return

  emailInvoiceParam.value = {
    id: data.id,
    documentNo: data.documentNo,
    partnerId: data.partnerId,
    partner: data.partner,
    docBaseType: data.docBaseTypeId || data.docBaseType || ''
  }
  emailInvoice.value = true
}
</script>

<template>
  <div v-if="params?.data" class="d-inlineFlex items-center justify-center">
    <span
      class="tf-icon ti ti-send ti-sm fg-primary cursor-pointer send-email-btn"
      @click="openEmailModal"
      title="Send Invoice Email"
    ></span>
  </div>
</template>

<style scoped>
.send-email-btn:hover {
  opacity: 0.7;
}

.fg-primary {
  color: #0d6efd;
}

.cursor-pointer {
  cursor: pointer;
}
</style>
