DownloadPdfBtn.client.vue 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <template>
  2. <div class="btn-wrapper">
  3. <v-btn variant="outlined" @click="onClick">
  4. {{ $t('download_pdf') }}
  5. </v-btn>
  6. <AltchaValidation
  7. v-if="showCaptcha"
  8. @verified="onVerified"
  9. />
  10. </div>
  11. </template>
  12. <script setup lang="ts">
  13. import type { Ref } from '@vue/reactivity'
  14. import type { ComputedRef } from 'vue'
  15. const appStore = useAppStore()
  16. const downloadRequested: Ref<boolean> = ref(false)
  17. const showCaptcha: ComputedRef<boolean> = computed(() => {
  18. return downloadRequested.value && !appStore.altchaPayload
  19. })
  20. const onClick = () => {
  21. if (appStore.altchaPayload) {
  22. submit()
  23. } else {
  24. downloadRequested.value = true
  25. }
  26. }
  27. const onVerified = () => {
  28. if (!downloadRequested.value) {
  29. return
  30. }
  31. downloadRequested.value = false
  32. setTimeout(() => {
  33. submit()
  34. }, 100)
  35. }
  36. const submit = async () => {
  37. const url = 'https://api.ogene.fr/api/download-cv?payload=' + (appStore.altchaPayload ?? '');
  38. window.open(url, '_blank');
  39. }
  40. </script>
  41. <style scoped lang="scss">
  42. .btn-wrapper {
  43. position: relative;
  44. margin: 0 !important;
  45. }
  46. altcha-widget {
  47. position: absolute;
  48. top: 50px; /* Ajustez cette valeur en fonction de la hauteur de votre bouton */
  49. left: 0;
  50. background: rgb(var(--v-theme-surface));
  51. border-radius: 4px;
  52. z-index: 10;
  53. }
  54. </style>