Vincent 10 ヶ月 前
コミット
d14cefea7a

+ 17 - 5
components/Layout/MainMenu.vue

@@ -11,11 +11,15 @@ Prend en paramètre une liste de ItemMenu et les met en forme
     class="theme-secondary main-menu"
   >
     <div
-      v-if="organizationProfile.isArtist && (accessProfile.isCaMember || accessProfile.isAdmin)"
+      v-if="(organizationProfile.isArtistProduct || organizationProfile.isTrialActive) && (accessProfile.isCaMember || accessProfile.isAdmin)"
       class="btn_trial"
       :class="{['btn_mini'] : isRail}"
       @click="trialAction()"
-    ><v-icon icon="fa fa-ticket" /> <span v-if="!isRail">{{btnLabel}}</span></div>
+    >
+      <v-icon icon="fa fa-ticket" />
+      <span v-if="organizationProfile.isTrialActive && !isRail"><strong>J-{{organizationProfile.trialCountDown}}</strong><br/></span>
+      <span v-if="!isRail">{{btnLabel}}</span>
+    </div>
 
     <template #prepend>
       <slot name="title"></slot>
@@ -120,6 +124,9 @@ const isRail = computed(() => {
 })
 
 const btnLabel = computed(() => {
+  if(organizationProfile.isTrialActive){
+    return i18n.t('trial_started')
+  }
   return organizationProfile.principalType === 'ARTISTIC_PRACTICE_ONLY' ? i18n.t('try_premium') : i18n.t('discover_offer')
 })
 
@@ -138,14 +145,18 @@ onUnmounted(() => {
  * Lorsque l'on appuie sur le bouton pour démarrer l'essai / découvrir les offres
  */
 const trialAction = async () => {
-  if(organizationProfile.principalType === 'ARTISTIC_PRACTICE_ONLY'){
+  const v1BaseURL = runtimeConfig.baseUrlAdminLegacy || runtimeConfig.public.baseUrlAdminLegacy
+
+  if(organizationProfile.isTrialActive){
+    await navigateTo(UrlUtils.join(v1BaseURL, '#', 'trial/subscribe'), {
+      external: true
+    })
+  }else if(organizationProfile.principalType === 'ARTISTIC_PRACTICE_ONLY'){
     try{
       const apiV1BaseURL = runtimeConfig.baseUrlLegacy || runtimeConfig.public.baseUrlLegacy
       await apiRequestService.get(
         UrlUtils.join(apiV1BaseURL,  '/api/trial/is_available')
       )
-
-      const v1BaseURL = runtimeConfig.baseUrlAdminLegacy || runtimeConfig.public.baseUrlAdminLegacy
       await navigateTo(UrlUtils.join(v1BaseURL, '#', 'trial'), {
         external: true
       })
@@ -254,6 +265,7 @@ function getItems(menu: MenuGroup|MenuItem|null) : Array<MenuGroup | MenuItem>{
   padding-left: 10px;
   padding-right: 10px;
   cursor: pointer;
+  white-space: pre-line;
   .v-icon{
     font-size: 15px;
     color:#000;

+ 2 - 1
lang/fr.json

@@ -1,4 +1,5 @@
 {
+  "trial_started": "Sur votre période d'essai.\nSouscrire à l'offre Premium.",
   "important": "Important",
   "trial_all_ready_did": "Vous avez déjà bénéficié d’un essai gratuit !",
   "opentalent_contact": "Contacter Opentalent",
@@ -537,7 +538,7 @@
   "informations": "Informations",
   "more_features": "Plus de fonctionnalités",
   "client_id": "Numéro de client",
-  "version": "Version",
+  "version": "Version logiciel",
   "services": "Services",
   "bills": "Factures",
   "paid": "Payée",

+ 2 - 1
pages/subscription.vue

@@ -11,6 +11,7 @@ Page 'Mon abonnement'
             <v-row>
               <v-col cols="12" lg="6" sm="12">
                 {{ $t('version') }} : <strong>{{ dolibarrAccount ? $t(dolibarrAccount.product) : '-' }}</strong>
+                <span v-if="organizationProfile.isTrialActive"> - En cours d'essai: <strong>{{$t('PRODUCT_ARTIST_PREMIUM')}} - J-{{organizationProfile.trialCountDown}}</strong></span>
               </v-col>
               <v-col cols="12" lg="6" sm="12">
                 {{ $t('client_id') }} : {{ dolibarrAccount ? dolibarrAccount.clientNumber : '-' }}
@@ -150,7 +151,7 @@ Page 'Mon abonnement'
                           Essayer la version premium <i class="fa-solid fa-greater-than small"></i>
                         </v-btn>
                       </v-col>
-                      <v-col cols="12" v-if="!organizationProfile.isArtistPremiumProduct && (accessProfileStore.isAdmin || accessProfileStore.isCaMember)">
+                      <v-col cols="12" v-if="(!organizationProfile.isArtistPremiumProduct || organizationProfile.isTrialActive) && (accessProfileStore.isAdmin || accessProfileStore.isCaMember)">
                         <v-btn
                           class="theme-artist btn"
                           @click="subscription"

+ 6 - 0
stores/organizationProfile.ts

@@ -28,6 +28,8 @@ export const useOrganizationProfileStore = defineStore(
     const networks: Ref<Array<string>> = ref([])
     const website: Ref<string | null> = ref(null)
     const parents: Ref<Array<BaseOrganizationProfile>> = ref([])
+    const isTrialActive: Ref<boolean> = ref(false)
+    const trialCountDown: Ref<number> = ref(0)
 
     // Getters
     /**
@@ -181,6 +183,8 @@ export const useOrganizationProfileStore = defineStore(
       legalStatus.value = profile.legalStatus
       principalType.value = profile.principalType
       showAdherentList.value = profile.showAdherentList
+      isTrialActive.value = profile.trialActive
+      trialCountDown.value = profile.trialCountDown
       networks.value = Array.from(profile.networks)
 
       _.each(profile.parents, (parent) => {
@@ -226,6 +230,8 @@ export const useOrganizationProfileStore = defineStore(
       isManagerProduct,
       isShowAdherentList,
       isAssociation,
+      isTrialActive,
+      trialCountDown,
       getWebsite,
       hasModule,
       setProfile,

+ 2 - 0
types/interfaces.d.ts

@@ -132,6 +132,8 @@ interface organizationState extends BaseOrganizationProfile {
   principalType?: string | null
   networks: Array<string>
   parents: Array<BaseOrganizationProfile>
+  isTrialActive: boolean
+  trialCountDown: number
 
   hasModule(module: string): boolean
 }