Browse Source

Adds HelloAsso integration scaffolding

Adds necessary models and a basic page layout for HelloAsso integration.

This commit introduces:
- Models for HelloAsso authentication (AuthUrl, ConnectionRequest, HelloAsso).
- A HelloAsso page with a connect button.
- Translation keys.

The integration is still in progress, the button is currently disabled until the auth service gives an authURL.
Olivier Massot 11 tháng trước cách đây
mục cha
commit
596a65660a

+ 1 - 0
i18n/lang/fr/general.json

@@ -14,6 +14,7 @@
   "edit_organization": "Modifier la structure",
   "dashboard_breadcrumbs": "Tableau de bord",
   "freemium_breadcrumbs": "Freemium",
+  "helloasso_breadcrumbs": "Helloasso",
   "i_understand": "Je comprends",
   "place_change_everywhere": "Les changements apportés seront appliqués aux autres événements",
   "event_categories_choices": "Choisissez à quelles catégories appartient votre événement",

+ 20 - 0
models/Custom/HelloAsso/AuthUrl.ts

@@ -0,0 +1,20 @@
+import { Uid, Str } from 'pinia-orm/dist/decorators'
+import ApiModel from '~/models/ApiModel'
+
+/**
+ * AP2i Model : AuthUrl
+ *
+ * @see https://gitlab.2iopenservice.com/opentalent/ap2i/-/blob/develop/src/ApiResource/HelloAsso/AuthUrl.php
+ */
+export default class AuthUrl extends ApiModel {
+  static override entity = 'helloasso/auth-url'
+
+  @Uid()
+  declare id: number | string
+
+  @Str('')
+  declare authUrl: string
+
+  @Str('')
+  declare challengeVerifier: string
+}

+ 23 - 0
models/Custom/HelloAsso/ConnectionRequest.ts

@@ -0,0 +1,23 @@
+import { Uid, Str } from 'pinia-orm/dist/decorators'
+import ApiModel from '~/models/ApiModel'
+import { IdField } from '~/models/decorators'
+import { Num } from 'pinia-orm/decorators'
+
+/**
+ * AP2i Model : ConnectionRequest
+ *
+ * @see https://gitlab.2iopenservice.com/opentalent/ap2i/-/blob/develop/src/ApiResource/HelloAsso/ConnectionRequest.php
+ */
+export default class ConnectionRequest extends ApiModel {
+  static override entity = 'helloasso/connect'
+
+  @Uid()
+  declare id: number | string
+
+  @IdField()
+  @Num(0, { notNullable: true })
+  declare organizationId: number
+
+  @Str('')
+  declare authorizationCode: string
+}

+ 29 - 0
models/Organization/HelloAsso.ts

@@ -0,0 +1,29 @@
+import { Bool, Num, Uid } from 'pinia-orm/dist/decorators'
+import ApiResource from '~/models/ApiResource'
+import { IdField } from '~/models/decorators'
+import { Str } from 'pinia-orm/decorators'
+
+/**
+ * The Mobyt user status of an organization
+ *
+ * @see https://gitlab.2iopenservice.com/opentalent/ap2i/-/blob/develop/src/ApiResources/Mobyt/MobytUserStatus.php
+ */
+export default class MobytUserStatus extends ApiResource {
+  static override entity = 'helloasso'
+
+  @Uid()
+  declare id: number | string | null
+
+  @IdField()
+  @Num(0, { notNullable: true })
+  declare organizationId: number
+
+  @Str(null)
+  declare token: boolean
+
+  @Str(null)
+  declare refreshToken: number
+
+  @Str(null)
+  declare organizationSlug: number
+}

+ 55 - 15
pages/helloasso.vue

@@ -6,40 +6,80 @@
           <v-img src="/images/logos/Logo-HelloAsso.svg" class="logo" />
         </v-col>
 
-        <v-col cols="12" md="8">
+        <v-col cols="12" md="8" class="presentation">
           {{ $t('helloasso_presentation') }}
         </v-col>
       </v-row>
 
       <v-row>
         <v-col cols="12" class="d-flex justify-center align-center w-100 mt-6">
-          <UiButtonHelloAssoConnect @click="onHelloAssoConnectClicked"/>
+          <UiButtonHelloAssoConnect
+            :disabled="status !== 'success'"
+            @click="onHelloAssoConnectClicked"
+          />
         </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 { useEntityFetch } from '~/composables/data/useEntityFetch'
+import AuthUrl from '~/models/Custom/HelloAsso/AuthUrl'
+
+const { fetch } = useEntityFetch()
+
+const { data: authUrl, status } = fetch(AuthUrl)
+
+const showDialog: Ref<boolean> = ref(true)
 
 const onHelloAssoConnectClicked = () => {
-  console.log('helloasso connect clicked')
+  if (status.value !== 'success') {
+    console.log('still pending')
+  } else {
+    console.log(authUrl)
+    showDialog.value = true
+    navigateTo(authUrl.value!.authUrl, { external: true })
+  }
 }
-
 </script>
 
 <style scoped lang="scss">
-  .v-card {
-    padding: 48px;
-    max-width: 70%;
-    margin: 36px auto;
-
-    @media (max-width: 600px) {
-      max-width: 90%;
-    }
-  }
+.v-card {
+  padding: 48px;
+  max-width: 70%;
+  margin: 36px auto;
 
-  .logo {
-    max-width: 80%;
+  @media (max-width: 600px) {
+    max-width: 90%;
   }
+}
+
+.logo {
+  max-width: 80%;
+}
+
+.presentation {
+  border-left: 3px solid rgb(var(--v-theme-info));
+  padding: 0 24px;
+  color: rgb(var(--v-theme-on-neutral));
+}
+
+.authDialog {
+  max-width: 90%;
+}
 </style>