<script setup lang="ts">
import { ActionEvents, type ListItemDto } from '~/components/pub/my-ui/data/types';

const props = defineProps<{
  url: string
  btnTxt?: string
  rec: ListItemDto
}>()

const recId = inject<Ref<number>>('rec_id')!
const recAction = inject<Ref<string>>('rec_action')!
const recItem = inject<Ref<any>>('rec_item')!
const timestamp = inject<Ref<any>>('timestamp')!

function handlePrint() {
  recId.value = props.rec.id || 0
  recAction.value = ActionEvents.showPrint
  recItem.value = props.rec
  timestamp.value = new Date().toISOString()
}
</script>

<template>
  <Button 
    class="gap-3 items-center border-orange-400 text-orange-400"
    variant="outline" @click="handlePrint">
    <Icon name="i-lucide-printer" class="h-4 w-4" />
    {{ props.btnTxt || 'Preview' }}
  </Button>
</template>