<script setup lang="ts">
import FilePreview from '@af-mobile-client-vue3/components/data/FilePreview/index.vue'
import { computed, onMounted, ref } from 'vue'
import { useRoute } from 'vue-router'

const route = useRoute()
const previewPath = computed(() => route.query.previewPath?.toString() || '')
const filePreviewRef = ref()

onMounted(() => {
  const path = previewPath.value
  filePreviewRef.value.init({ path })
})
</script>

<template>
  <FilePreview
    ref="filePreviewRef"
    :key="`pdf-${previewPath}`"
    style="height: 80vh"
  />
</template>
