<script setup>
import { date } from 'alga-js'
const router = useRouter()
const quickView = useQuickView()
const quickViewParam = useQuickViewParam()

const props = defineProps({
  modelName: String 
})

const showQuickViewContent = ref(false)
const handleQuickViewContent = () => {
  if(quickView.value === 'receipt') {
    setTimeout(() => {
      showQuickViewContent.value = true
    }, 400)
  }
}
onMounted(handleQuickViewContent)
watch(quickView, handleQuickViewContent)

const viewHandler = () => {
  router.push(`/procurements/receipts/${quickViewParam.value.id}/view`)
  setTimeout(() => {
    quickView.value = ''
    quickViewParam.value = {}
  }, 400)
}
const closeQuickView = () => {
  showQuickViewContent.value = false
  setTimeout(() => {
    quickView.value = ''
    quickViewParam.value = {}
  }, 400)
}
</script>

<template>
  <div class="offCanvas right" :class="{'active': quickView === 'receipt'}" :style="{display: quickView === 'receipt' ? 'block' : 'none'}">
    <div class="offCanvasBackdrop" @click.self="closeQuickView"></div>
    <Transition name="slideRight">
    <div v-if="showQuickViewContent" class="offCanvasContent">
      <div class="offCanvasHeader">
        <h3 class="offCanvasTitle">Shipment Details</h3>
        <div class="cursor-pointer" @click="closeQuickView">
          <span class="tf-icon ti ti-x ti-sm me-1"></span>
        </div>
      </div>
      <div class="offCanvasBody">
        <div class="mb-2 d-flex justify-between gap-10px">
          <strong>Tenant</strong>
          <div class="textAlign-right">{{ quickViewParam.client }}</div>
        </div>
        <div class="mb-2 d-flex justify-between gap-10px">
          <strong>Organization</strong>
          <div class="textAlign-right">{{ quickViewParam.organization }}</div>
        </div>
        <div class="mb-2 d-flex justify-between gap-10px">
          <strong>Document Number</strong>
          <div class="textAlign-right">{{ quickViewParam.documentNo }}</div>
        </div>
        <div class="mb-2 d-flex justify-between gap-10px">
          <strong>Order Reference</strong>
          <div class="textAlign-right">{{ quickViewParam.poReference }}</div>
        </div>
        <div class="mb-2 d-flex justify-between gap-10px">
          <strong>Movement Date</strong>
          <div class="textAlign-right">{{ quickViewParam.dateOrdered }}</div>
        </div>
        <div class="mb-2 d-flex justify-between gap-10px">
          <strong>Date Accounted</strong>
          <div class="textAlign-right">{{ quickViewParam.dateAcct }}</div>
        </div>
        <div class="mb-2 d-flex justify-between gap-10px">
          <strong>Business Partner</strong>
          <div class="textAlign-right">{{ quickViewParam.partner }}</div>
        </div>
        <div class="mb-2 d-flex justify-between gap-10px">
          <strong>Document Type</strong>
          <div class="textAlign-right">{{ quickViewParam.docType }}</div>
        </div>
        <div class="mb-2 d-flex justify-between gap-10px">
          <strong>Partner Location</strong>
          <div class="textAlign-right">{{ quickViewParam.partnerLocation }}</div>
        </div>
        <div class="mb-2 d-flex justify-between gap-10px">
          <strong>User/Contact</strong>
          <div class="textAlign-right">{{ quickViewParam.user }}</div>
        </div>
        <div class="mb-2 d-flex justify-between gap-10px">
          <strong>Warehouse</strong>
          <div class="textAlign-right">{{ quickViewParam.warehouse }}</div>
        </div>
        <div class="mb-2 d-flex justify-between gap-10px">
          <strong>Delivery Rule</strong>
          <div class="textAlign-right">{{ quickViewParam.deliveryRule }}</div>
        </div>
        <div class="mb-2 d-flex justify-between gap-10px">
          <strong>Sales Rep</strong>
          <div class="textAlign-right">{{ quickViewParam.procurementsRep }}</div>
        </div>
        <div class="mb-2 d-flex justify-between gap-10px">
          <strong>Priority</strong>
          <div class="textAlign-right">{{ quickViewParam.priorityRule }}</div>
        </div>
        <div class="mb-2 d-flex justify-between gap-10px">
          <strong>Freight Cost Rule</strong>
          <div class="textAlign-right">{{ quickViewParam.freightCostRule }}</div>
        </div>
        <div class="mb-2 d-flex justify-between gap-10px">
          <strong>Delivery Via</strong>
          <div class="textAlign-right">{{ quickViewParam.deliveryViaRule }}</div>
        </div>
        <div class="mb-2 d-flex justify-between gap-10px">
          <strong>Movement Type</strong>
          <div class="textAlign-right">{{ quickViewParam.movementType }}</div>
        </div>
        <div class="d-flex justify-between gap-10px">
          <strong>Document Type</strong>
          <div class="textAlign-right">{{ quickViewParam.docType }}</div>
        </div>
        <div class="mb-2 d-flex justify-between gap-10px">
          <strong>Document Status</strong>
          <div class="textAlign-right">{{ quickViewParam.docStatus }}</div>
        </div>
        <div class="mb-2 d-flex justify-between gap-10px">
          <strong>Description</strong>
          <div class="textAlign-right">{{ quickViewParam.description }}</div>
        </div>
      </div>
      <div class="offCanvasFooter">
        <div></div>
        <div class="d-flex justify-flexEnd gap-5px">
          <button type="button" class="button" @click="viewHandler">View More Details</button>
          <button type="button" class="button" @click="closeQuickView">Close</button>
        </div>
      </div>
    </div>
    </Transition>
  </div>
</template>

<style scoped>

</style>