index.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <template>
  2. <LayoutContainer>
  3. <v-card>
  4. <v-row>
  5. <v-col cols="12" md="4" class="d-flex justify-center">
  6. <v-img src="/images/logos/Logo-HelloAsso.svg" class="logo" />
  7. </v-col>
  8. <v-col cols="12" md="8" class="presentation">
  9. {{ $t('helloasso_presentation') }}
  10. </v-col>
  11. </v-row>
  12. <v-row>
  13. <v-col cols="12" class="d-flex justify-center align-center w-100 mt-6">
  14. <UiButtonHelloAssoConnect
  15. v-if="!alreadyConnected"
  16. @click="onHelloAssoConnectClicked"
  17. />
  18. <div v-else>
  19. <v-icon icon="fas fa-check" color="success" />
  20. {{ $t('your_helloasso_account_is_linked') }}
  21. </div>
  22. </v-col>
  23. </v-row>
  24. </v-card>
  25. <!-- <v-dialog-->
  26. <!-- v-model="showDialog"-->
  27. <!-- :width="900"-->
  28. <!-- class="authDialog"-->
  29. <!-- >-->
  30. <!-- <v-card>-->
  31. <!-- <iframe-->
  32. <!-- :src="authUrl!.authUrl"-->
  33. <!-- height="600"-->
  34. <!-- frameborder="0"-->
  35. <!-- />-->
  36. <!-- </v-card>-->
  37. <!-- </v-dialog>-->
  38. </LayoutContainer>
  39. </template>
  40. <script setup lang="ts">
  41. import AuthUrl from '~/models/ApiResources/HelloAsso/AuthUrl'
  42. import { useHelloAssoStore } from '~/stores/helloasso'
  43. import { useEntityManager } from '~/composables/data/useEntityManager'
  44. import { FETCHING_STATUS } from '~/types/enum/data'
  45. const helloassoStore = useHelloAssoStore()
  46. const { em } = useEntityManager()
  47. const onHelloAssoConnectClicked = async () => {
  48. // Important de régénérer une URL avec un nouveau challenge à chaque
  49. // essai (entre autres pour supporter le HMR pendant les tests en local,
  50. // ou en cas d'erreur et de ré-essai)
  51. const authUrl = await em.fetch(AuthUrl)
  52. navigateTo(authUrl.authUrl, {
  53. external: true,
  54. open: {
  55. target: '_blank',
  56. windowFeatures: {
  57. popup: true,
  58. width: 900,
  59. height: 600,
  60. },
  61. },
  62. })
  63. }
  64. const alreadyConnected = computed(() => helloassoStore.authorizationCode)
  65. onMounted(() => {
  66. window.addEventListener('message', (event) => {
  67. if (event.origin !== window.location.origin) {
  68. return
  69. }
  70. if (!event.data || !event.data.code) {
  71. return
  72. }
  73. onHelloAssoConnected()
  74. })
  75. })
  76. const helloAssoToken: Ref<string | null> = ref(null)
  77. const onHelloAssoConnected = async () => {
  78. // const { data: helloAsso, status: helloAssoStatus } = fetch(HelloAsso)
  79. console.log('helloasso connected')
  80. // const helloAsso = await em.fetch(HelloAsso)
  81. //
  82. // helloAssoToken.value = helloAsso.token
  83. }
  84. </script>
  85. <style scoped lang="scss">
  86. .v-card {
  87. padding: 48px;
  88. max-width: 70%;
  89. margin: 36px auto;
  90. @media (max-width: 600px) {
  91. max-width: 90%;
  92. }
  93. }
  94. .logo {
  95. max-width: 80%;
  96. }
  97. .presentation {
  98. border-left: 3px solid rgb(var(--v-theme-info));
  99. padding: 0 24px;
  100. color: rgb(var(--v-theme-on-neutral));
  101. }
  102. .authDialog {
  103. max-width: 90%;
  104. }
  105. </style>