浏览代码

divers fix

Vincent 8 月之前
父节点
当前提交
b4842f88ed
共有 2 个文件被更改,包括 22 次插入17 次删除
  1. 4 14
      components/Dialog/Trial/StopConfirmation.vue
  2. 18 3
      pages/subscription.vue

+ 4 - 14
components/Dialog/Trial/StopConfirmation.vue

@@ -18,7 +18,7 @@
       <v-btn class="mr-4 submitBtn theme-neutral-strong" @click="closeDialog">
         {{ $t('cancel') }}
       </v-btn>
-      <v-btn class="mr-4 submitBtn theme-danger" @click="contactOpentalent">
+      <v-btn class="mr-4 submitBtn theme-danger" @click="stopTrial">
         Arrêter l'essai
       </v-btn>
     </template>
@@ -27,9 +27,6 @@
 
 <script setup lang="ts">
 
-import UrlUtils from "~/services/utils/urlUtils";
-import {useApiLegacyRequestService} from "~/composables/data/useApiLegacyRequestService";
-
 const props = defineProps({
   show: {
     type: Boolean,
@@ -37,21 +34,14 @@ const props = defineProps({
     default: false,
   },
 })
-const runtimeConfig = useRuntimeConfig()
-const { apiRequestService } = useApiLegacyRequestService()
 
-const emit = defineEmits(['closeDialog'])
+const emit = defineEmits(['closeDialog', 'stopTrial'])
 
 const closeDialog = () => {
   emit('closeDialog')
 }
-
-const contactOpentalent = async () => {
-  await apiRequestService.post('/trial/stop')
-  const v1BaseURL = runtimeConfig.baseUrlAdminLegacy || runtimeConfig.public.baseUrlAdminLegacy
-  await navigateTo(UrlUtils.join(v1BaseURL, '#', 'dashboard'), {
-    external: true
-  })
+const stopTrial = () => {
+  emit('stopTrial')
 }
 </script>
 

+ 18 - 3
pages/subscription.vue

@@ -178,7 +178,7 @@ Page 'Mon abonnement'
                       <v-col cols="12" v-if="organizationProfile.isTrialActive && (accessProfileStore.isAdmin || accessProfileStore.isCaMember)">
                         <v-btn
                           class="stop_btn"
-                          @click="stopTrial"
+                          @click="showStopTrialDialog"
                         >
                           Arrêter l'essai
                         </v-btn>
@@ -294,6 +294,7 @@ Page 'Mon abonnement'
   <DialogTrialStopConfirmation
     :show="showDialogTrialStopConfirmation"
     @closeDialog = "showDialogTrialStopConfirmation = false"
+    @stopTrial = "stopTrial"
   />
 </template>
 
@@ -309,6 +310,7 @@ import MobytUserStatus from '~/models/Organization/MobytUserStatus'
 import UrlUtils from '~/services/utils/urlUtils';
 import {useDownloadFromRoute} from '~/composables/utils/useDownloadFromRoute';
 import {useApiLegacyRequestService} from "~/composables/data/useApiLegacyRequestService";
+import {usePageStore} from "~/stores/page";
 
 //meta
 definePageMeta({
@@ -452,12 +454,25 @@ async function subscription(){
 }
 
 /**
- * Action lorsque l'on souhaite stopper l'essai
+ * Action lorsque l'on souhaite afficher la modal de confirmation pour stopper
  */
-function stopTrial(){
+function showStopTrialDialog(){
   showDialogTrialStopConfirmation.value = true
 }
 
+/**
+ * Action lorsque l'on souhaite stopper l'essai
+ */
+async function stopTrial() {
+  usePageStore().loading = true
+  await apiRequestService.post('/trial/stop')
+  const v1BaseURL = runtimeConfig.baseUrlAdminLegacy || runtimeConfig.public.baseUrlAdminLegacy
+  await navigateTo(UrlUtils.join(v1BaseURL, '#', 'dashboard'), {
+    external: true
+  })
+}
+
+
 const downloadDolibarrBill = (ref: string): void => {
   const route = UrlUtils.join('api/dolibarr/download/invoice', ref)