Browse Source

complete previous commit

Olivier Massot 2 tháng trước cách đây
mục cha
commit
32a17db88a
1 tập tin đã thay đổi với 15 bổ sung32 xóa
  1. 15 32
      pages/helloasso/index.vue

+ 15 - 32
pages/helloasso/index.vue

@@ -14,41 +14,30 @@
       <v-row>
         <v-col cols="12" class="d-flex justify-center align-center w-100 mt-6">
           <UiButtonHelloAssoConnect
-            v-if="!alreadyConnected"
+            v-if="!helloAssoProfile || !helloAssoProfile.token"
             @click="onHelloAssoConnectClicked"
           />
 
           <div v-else>
-            <v-icon icon="fas fa-check" color="success" />
-            {{ $t('your_helloasso_account_is_linked') }}
+            <v-row>
+              <v-icon icon="fas fa-check" color="success" class="mr-3" />
+              {{ $t('your_helloasso_account_is_linked') }}
+            </v-row>
+            <v-row>
+              Token : {{ helloAssoProfile.token.slice(0, 30) }}...
+            </v-row>
           </div>
         </v-col>
       </v-row>
     </v-card>
-
-    <!--    <v-dialog-->
-    <!--      v-model="showDialog"-->
-    <!--      :width="900"-->
-    <!--      class="authDialog"-->
-    <!--    >-->
-    <!--      <v-card>-->
-    <!--        <iframe-->
-    <!--          :src="authUrl!.authUrl"-->
-    <!--          height="600"-->
-    <!--          frameborder="0"-->
-    <!--        />-->
-    <!--      </v-card>-->
-    <!--    </v-dialog>-->
   </LayoutContainer>
 </template>
 
 <script setup lang="ts">
 import AuthUrl from '~/models/ApiResources/HelloAsso/AuthUrl'
-import { useHelloAssoStore } from '~/stores/helloasso'
+import HelloAssoProfile from '~/models/ApiResources/HelloAsso/HelloAssoProfile'
 import { useEntityManager } from '~/composables/data/useEntityManager'
-import { FETCHING_STATUS } from '~/types/enum/data'
-
-const helloassoStore = useHelloAssoStore()
+import { useEntityFetch } from '~/composables/data/useEntityFetch'
 
 const { em } = useEntityManager()
 
@@ -71,8 +60,6 @@ const onHelloAssoConnectClicked = async () => {
   })
 }
 
-const alreadyConnected = computed(() => helloassoStore.authorizationCode)
-
 onMounted(() => {
   window.addEventListener('message', (event) => {
     if (event.origin !== window.location.origin) {
@@ -85,19 +72,15 @@ onMounted(() => {
   })
 })
 
-const helloAssoToken: Ref<string | null> = ref(null)
+const { fetch } = useEntityFetch()
 
-const onHelloAssoConnected = async () => {
-  // const { data: helloAsso, status: helloAssoStatus } = fetch(HelloAsso)
+const { data: helloAssoProfile, refresh: refreshHelloAsso } = await fetch(HelloAssoProfile)
 
-  console.log('helloasso connected')
-
-  // const helloAsso = await em.fetch(HelloAsso)
-  //
-  // helloAssoToken.value = helloAsso.token
+const onHelloAssoConnected = async () => {
+  console.log('Helloasso connected')
+  await refreshHelloAsso()
 }
 
-
 </script>
 
 <style scoped lang="scss">