{"version":3,"file":"ContractPreviewModal-CC3KTcFM.mjs","names":[],"sources":["../src/components/misc/modal/ContractPreviewModal.vue","../src/components/misc/modal/ContractPreviewModal.vue"],"sourcesContent":["<template>\n  <ClassicModal\n    id-modal=\"checking-modal\"\n    :title-modal=\"t('Contract preview')\"\n    @close=\"closePopup\"\n  >\n    <template #body>\n      <h2 class=\"mb-3\">{{ selectedContract?.name }}</h2>\n      <div v-for=\"page in thisPages\" :key=\"page\">\n        <VuePDF :pdf=\"thisPdf\" :page=\"page\" />\n      </div>\n    </template>\n    <template #footer>\n      <div class=\"d-flex justify-content-end\">\n        <button class=\"btn btn-primary m-1\" @click=\"onDownloadContract()\">\n          {{ t(\"Download\") }}\n        </button>\n        <button class=\"btn m-1 btn-primary\" @click=\"closePopup\">\n          {{ t(\"Close\") }}\n        </button>\n      </div>\n    </template>\n  </ClassicModal>\n</template>\n\n<script setup lang=\"ts\">\nimport { useApiStore } from \"../../../stores/ApiStore\";\nimport { useAuthStore } from \"../../../stores/AuthStore\";\nimport { Contract } from \"../../../stores/class/contract/contract\";\n// @ts-expect-error Problème de bibliothèque\nimport { usePDF, VuePDF, PDFDocumentLoadingTask } from \"@tato30/vue-pdf\";\nimport { defineAsyncComponent, ShallowRef, ref, Ref, computed, watch, onMounted } from \"vue\";\nimport { useI18n } from \"vue-i18n\";\nconst ClassicModal = defineAsyncComponent(() => import(\"./ClassicModal.vue\"));\n\n\n//Props \nconst props = defineProps({\n  selectedContract: { default: undefined, type: Object as () => Contract },\n})\n\n//Emits\nconst emit = defineEmits([\"download\", \"close\"]);\n\n\n//Data \nconst pdfSource = ref(\"\");\nconst thisPdf: Ref<PDFDocumentLoadingTask> = ref(undefined);\nconst thisPages: Ref< number | ShallowRef<number>> = ref(0);\n\n//Composables\nconst { t } = useI18n();\nconst authStore = useAuthStore();\nconst apiStore = useApiStore();\n\n//Computed\nconst pdfToDisplay = computed(() => {\n  if (\"\" !== pdfSource.value) {\n    return pdfSource.value;\n  }\n  return undefined;\n});\n\n//Watch\nwatch(pdfToDisplay, async () => {\n  if (undefined === pdfToDisplay.value) {\n    return;\n  }\n  const { pdf, pages } = usePDF(pdfToDisplay.value);\n  thisPdf.value = pdf;\n  thisPages.value = pages;\n});\n\nonMounted(()=>initSrcContract())\n\n\n//Methods\nfunction closePopup(): void {\n  emit(\"close\");\n}\nfunction initSrcContract(): void {\n  let source = \"\";\n  if (props.selectedContract) {\n    source = apiStore.keycloakUrl + \"contract/\" + props.selectedContract.id;\n  }\n  pdfSource.value = source + \"?access_token=\" + authStore.authParam.accessToken;\n}\nfunction onDownloadContract(): void {\n  emit(\"download\", props.selectedContract);\n}\n</script>\n","<template>\n  <ClassicModal\n    id-modal=\"checking-modal\"\n    :title-modal=\"t('Contract preview')\"\n    @close=\"closePopup\"\n  >\n    <template #body>\n      <h2 class=\"mb-3\">{{ selectedContract?.name }}</h2>\n      <div v-for=\"page in thisPages\" :key=\"page\">\n        <VuePDF :pdf=\"thisPdf\" :page=\"page\" />\n      </div>\n    </template>\n    <template #footer>\n      <div class=\"d-flex justify-content-end\">\n        <button class=\"btn btn-primary m-1\" @click=\"onDownloadContract()\">\n          {{ t(\"Download\") }}\n        </button>\n        <button class=\"btn m-1 btn-primary\" @click=\"closePopup\">\n          {{ t(\"Close\") }}\n        </button>\n      </div>\n    </template>\n  </ClassicModal>\n</template>\n\n<script setup lang=\"ts\">\nimport { useApiStore } from \"../../../stores/ApiStore\";\nimport { useAuthStore } from \"../../../stores/AuthStore\";\nimport { Contract } from \"../../../stores/class/contract/contract\";\n// @ts-expect-error Problème de bibliothèque\nimport { usePDF, VuePDF, PDFDocumentLoadingTask } from \"@tato30/vue-pdf\";\nimport { defineAsyncComponent, ShallowRef, ref, Ref, computed, watch, onMounted } from \"vue\";\nimport { useI18n } from \"vue-i18n\";\nconst ClassicModal = defineAsyncComponent(() => import(\"./ClassicModal.vue\"));\n\n\n//Props \nconst props = defineProps({\n  selectedContract: { default: undefined, type: Object as () => Contract },\n})\n\n//Emits\nconst emit = defineEmits([\"download\", \"close\"]);\n\n\n//Data \nconst pdfSource = ref(\"\");\nconst thisPdf: Ref<PDFDocumentLoadingTask> = ref(undefined);\nconst thisPages: Ref< number | ShallowRef<number>> = ref(0);\n\n//Composables\nconst { t } = useI18n();\nconst authStore = useAuthStore();\nconst apiStore = useApiStore();\n\n//Computed\nconst pdfToDisplay = computed(() => {\n  if (\"\" !== pdfSource.value) {\n    return pdfSource.value;\n  }\n  return undefined;\n});\n\n//Watch\nwatch(pdfToDisplay, async () => {\n  if (undefined === pdfToDisplay.value) {\n    return;\n  }\n  const { pdf, pages } = usePDF(pdfToDisplay.value);\n  thisPdf.value = pdf;\n  thisPages.value = pages;\n});\n\nonMounted(()=>initSrcContract())\n\n\n//Methods\nfunction closePopup(): void {\n  emit(\"close\");\n}\nfunction initSrcContract(): void {\n  let source = \"\";\n  if (props.selectedContract) {\n    source = apiStore.keycloakUrl + \"contract/\" + props.selectedContract.id;\n  }\n  pdfSource.value = source + \"?access_token=\" + authStore.authParam.accessToken;\n}\nfunction onDownloadContract(): void {\n  emit(\"download\", props.selectedContract);\n}\n</script>\n"],"mappings":";;;;;;;;;;;;;;;EAiCA,MAAM,eAAe,2BAA2B,OAAO,+BAAA,MAAA,MAAA,EAAA,CAAA,CAAqB;EAI5E,MAAM,QAAQ;EAKd,MAAM,OAAO;EAIb,MAAM,YAAY,IAAI,EAAE;EACxB,MAAM,UAAuC,IAAI,KAAA,CAAS;EAC1D,MAAM,YAA+C,IAAI,CAAC;EAG1D,MAAM,EAAE,MAAM,QAAQ;EACtB,MAAM,YAAY,aAAa;EAC/B,MAAM,WAAW,YAAY;EAG7B,MAAM,eAAe,eAAe;GAClC,IAAI,OAAO,UAAU,OACnB,OAAO,UAAU;EAGrB,CAAC;EAGD,MAAM,cAAc,YAAY;GAC9B,IAAI,KAAA,MAAc,aAAa,OAC7B;GAEF,MAAM,EAAE,KAAK,UAAU,OAAO,aAAa,KAAK;GAChD,QAAQ,QAAQ;GA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