Browse Source

Merge branch 'develop' into 'feature/post-oneToM'

# Conflicts:
#   pages/subscription.vue
Guffon 3 years ago
parent
commit
b49e85be38

+ 46 - 0
components/Ui/Display/MobytStatus.vue

@@ -0,0 +1,46 @@
+<!--
+Texte descriptif du statut Mobyt de la structure
+
+@see https://vuetifyjs.com/en/components/text-fields/
+-->
+
+<template>
+  <span v-if="mobytStatus && !mobytStatusFetch.pending">
+    {{ mobytStatus.money.toLocaleString($i18n.locale, { style: 'currency', currency: 'EUR' }) }}
+    ({{ mobytStatus.amount }} SMS)
+  </span>
+</template>
+
+<script lang="ts">
+
+import { defineComponent, ref, Ref, useContext, useFetch } from '@nuxtjs/composition-api'
+import { ApiResponse, MobytUserStatus } from '~/types/interfaces'
+import { QUERY_TYPE } from '~/types/enums'
+
+export default defineComponent({
+  setup () {
+    const { store, $dataProvider } = useContext()
+    const id: number = store.state.profile.organization.id
+    const mobytStatus: Ref<MobytUserStatus | null> = ref(null)
+
+    // fetch the mobyt status
+    const { fetchState } = useFetch(async () => {
+      try {
+        const response:ApiResponse = await $dataProvider.invoke({
+          type: QUERY_TYPE.DEFAULT,
+          url: '/api/mobyt/status/' + id
+        })
+        mobytStatus.value = response.data as MobytUserStatus
+      } catch (Error) {
+        // eslint-disable-next-line no-console
+        console.error('Error: Mobyt status not found')
+      }
+    })
+
+    return {
+      mobytStatus,
+      mobytStatusFetch: fetchState
+    }
+  }
+})
+</script>

+ 42 - 0
lang/content/subscription/fr-FR.js

@@ -0,0 +1,42 @@
+/**
+ * Specific translations for the /subscription page
+ *
+ * @param context
+ * @param locale
+ * @returns {{get_more_functionalities_with_version: string, only_for_cmf_members: string, contact_us_at: string, contact_us_for_show_and_demo: string, starting_from_x_eur_ttc_per_month: string, download_order_form: string, for_x_sms: string, for_only_x_eur_ttc_by_month: string, example: string, domain_name: string, and_benefit: string, public_price_x_ttc_a_year: string, product_sheet: string, get_your_own_domain_and_up_to_five_emails_for_only_x_eur_ttc_per_month: string, dummy_domain_name: string, website: string, version_x_up_to_x_students: string, download_cmf_order_form: string, send_sms_from_app_to_your_members: string, freely_try_our_software: string, starting_from_x_eur_ttc_per_ssm: string, yearly_paid_giving_x_eur_ttc_per_year: string, excluding_license_and_training_fees: string, a_suitable_solution_for_your_artistic_school: string, dummy_email_address: string, associated_mail_address: string, switch_to_version: string, or_by_mail_at: string, of_accounts_for_teachers_and_students: string, of_a_complete_website: string}}
+ */
+export default (context, locale) => {
+  return ({
+    get_more_functionalities_with_version: 'Bénéficiez de plus de fonctionnalités avec la version',
+    for_only_x_eur_ttc_by_month: 'Pour seulement {price} TTC par mois',
+    yearly_paid_giving_x_eur_ttc_per_year: 'Payable annuellement, soit {price} TTC / an',
+    only_for_cmf_members: 'Offre réservée aux adhérents CMF',
+    public_price_x_ttc_a_year: 'Prix public: {price} TTC/an',
+    product_sheet: 'Fiche produit',
+    download_order_form: 'Télécharger le bon de commande',
+    download_cmf_order_form: 'Télécharger le bon de commande CMF',
+    a_suitable_solution_for_your_artistic_school: 'Une solution économique adaptée à votre établissement d\'enseignement artistique',
+    starting_from_x_eur_ttc_per_month: 'A partir de {price} TTC par mois',
+    version_x_up_to_x_students: 'Version {product} jusqu\'à {max_students} étudiants',
+    excluding_license_and_training_fees: 'Hors frais de licence d\'utilisation et de formation',
+    freely_try_our_software: 'Essayez notre logiciel en toute liberté',
+    contact_us_for_show_and_demo: 'Contactez-nous sans plus tarder pour obtenir une présentation ainsi qu\'un accès de démonstration',
+    contact_us_at: 'Contactez-nous au',
+    or_by_mail_at: 'ou par mail à l\'adresse',
+    switch_to_version: 'Passez à la version',
+    and_benefit: 'et bénéficiez',
+    of_accounts_for_teachers_and_students: 'de comptes pour vos professeurs et élèves',
+    of_a_complete_website: 'd\'un site internet complet',
+    send_sms: 'Envoyez des SMS',
+    to_your_members_from_app: 'à vos membres / élèves depuis votre logiciel',
+    starting_from_x_eur_ttc_per_sms: 'A partir de {price} TTC / sms',
+    for_x_sms: 'pour {amount} SMS',
+    get_your_own_domain_and_up_to_five_emails_for_only_x_eur_ttc_per_month: 'Bénéficiez de votre propre nom de domaine et 5 adresses email pour seulement {price} TTC / mois',
+    example: 'Exemple',
+    domain_name: 'Nom de domaine',
+    dummy_domain_name: 'ma-structure.fr',
+    associated_mail_address: 'Adresse email associée',
+    dummy_email_address: 'contact@ma-structure.fr',
+    sms: 'SMS'
+  })
+}

+ 3 - 1
lang/fr-FR.js

@@ -5,6 +5,7 @@ import rulesAndErrors from '@/lang/rulesAndErrors/fr-FR'
 import form from '@/lang/form/fr-FR'
 import breadcrumbs from '@/lang/breadcrumbs/fr-FR'
 import menuKey from '@/lang/menuKey/fr-FR'
+import contentSubscription from '@/lang/content/subscription/fr-FR'
 
 export default (context, locale) => {
   return {
@@ -14,6 +15,7 @@ export default (context, locale) => {
     ...rulesAndErrors(context, locale),
     ...form(context, locale),
     ...breadcrumbs(context, locale),
-    ...menuKey(context, locale)
+    ...menuKey(context, locale),
+    ...contentSubscription(context, locale)
   }
 }

+ 83 - 158
pages/subscription.vue

@@ -8,7 +8,7 @@ Page 'Mon abonnement'
     <v-col cols="12" sm="12" md="12">
       <h3 class="mb-5">{{ $t('my_subscription') }}</h3>
 
-      <v-expansion-panels focusable multiple :value="[0,1]">
+      <v-expansion-panels focusable multiple :value="[0,1,2]">
         <UiExpansionPanel id="informations" icon="fa-info">
           <v-container fluid class="container">
             <v-row>
@@ -34,18 +34,15 @@ Page 'Mon abonnement'
                       </div>
                     </td>
                   </tr>
-                  <tr v-if="mobytStatus && mobytStatus.active">
+                  <tr>
                     <td>{{ $t('remaining_sms_credit') }}</td>
                     <td>
-                      {{ mobytStatus.money.toLocaleString($i18n.locale, { style: 'currency', currency: 'EUR' }) }}
-                      ({{ mobytStatus.amount }} SMS)
+                      <UiDisplayMobytStatus />
                     </td>
                   </tr>
                   <tr v-if="organizationProfile.isCmf && organizationProfile.isArtistProduct">
                     <td>{{ $t('paying_structure') }}</td>
-                    <td>
-                      CMF
-                    </td>
+                    <td>CMF</td>
                   </tr>
                 </tbody>
               </v-simple-table>
@@ -56,7 +53,7 @@ Page 'Mon abonnement'
         <UiExpansionPanel id="bills" icon="fa-file">
           <v-container fluid class="container">
             <v-row>
-              <v-simple-table v-if="!dolibarAccountFetch.pending && dolibarrAccount.bills.length > 0">
+              <v-simple-table v-if="!dolibarrAccountFetch.pending && dolibarrAccount && dolibarrAccount.bills">
                 <thead>
                   <tr>
                     <th>{{ $t('reference') }}</th>
@@ -92,19 +89,16 @@ Page 'Mon abonnement'
                   <thead>
                     <tr>
                       <th v-if="organizationProfile.isArtistProduct">
-                        Opentalent Artist Premium
+                        {{ $t('PRODUCT_ARTIST_PREMIUM') }}
                       </th>
                       <th v-if="organizationProfile.isArtist">
-                        Opentalent School
-                      </th>
-                      <th v-if="organizationProfile.isSchoolProduct">
-                        Opentalent School Premium
+                        {{ $t('PRODUCT_SCHOOL') }}
                       </th>
                       <th>
-                        Sms
+                        {{ $t('sms') }}
                       </th>
                       <th>
-                        Site internet
+                        {{ $t('website') }}
                       </th>
                     </tr>
                   </thead>
@@ -116,9 +110,6 @@ Page 'Mon abonnement'
                       <td v-if="organizationProfile.isArtist">
                         <nuxt-img src="/images/School-Square.jpg" />
                       </td>
-                      <td v-if="organizationProfile.isSchoolProduct">
-                        <nuxt-img src="/images/School-Square.jpg" />
-                      </td>
                       <td>
                         <nuxt-img src="/images/sms_big.png" />
                       </td>
@@ -130,168 +121,112 @@ Page 'Mon abonnement'
                       <!-- Opentalent Artist Premium -->
                       <td v-if="organizationProfile.isArtistProduct">
                         <p>
-                          Bénéficiez de plus de fonctionnalités avec la version
-                          <b>Opentalent Artist Premium</b>
+                          {{ $t('get_more_functionalities_with_version') }} <b>{{ $t('PRODUCT_ARTIST_PREMIUM') }}</b>
                         </p>
 
                         <!-- Cmf member -->
                         <div v-if="organizationProfile.isCmf">
                           <p>
-                            Pour seulement 6,33 €.TTC par mois *
-                          </p>
-                          <p>
-                            <i>
-                              * Payable annuellement, soit 76 €.TTC / an.
-                              Offre réservée aux adhérents CMF (Prix public: 168€.TTC/an)
-                            </i>
+                            <b>{{ $t('for_only_x_eur_ttc_by_month', { price: formatCurrency(7.25, 'EUR') }) }} *</b>
                           </p>
+                          <div><i>* {{ $t('yearly_paid_giving_x_eur_ttc_per_year', { price: formatCurrency(87.00, 'EUR') }) }}</i></div>
+                          <div><i>{{ $t('only_for_cmf_members') }} ({{ $t('public_price_x_ttc_a_year', { price: formatCurrency(168.00, 'EUR') }) }})</i></div>
                         </div>
 
-                        <!-- Not cmf member -->
+                        <!-- Not a cmf member -->
                         <div v-else>
                           <p>
-                            Pour seulement 14 € TTC par mois *
+                            <b>{{ $t('for_only_x_eur_ttc_by_month', { price: formatCurrency(14.00, 'EUR') }) }} *</b>
                           </p>
                           <p>
                             <i>
-                              * Payable annuellement soit 168 €.TTC/an
+                              * {{ $t('yearly_paid_giving_x_eur_ttc_per_year', { price: formatCurrency(168.00, 'EUR') }) }}
                             </i>
                           </p>
                         </div>
 
-                        <p>
-                          <a href="https://www.opentalent.fr/uploads/opentalent/ficheproduit_Opentalentartist.pdf">
-                            Fiche produit Opentalent Artist Premium
+                        <p class="mt-3">
+                          <a href="https://www.opentalent.fr/uploads/opentalent/ficheproduit_Opentalentartist.pdf" target="_blank">
+                            {{ $t('product_sheet') }} {{ $t('PRODUCT_ARTIST_PREMIUM') }}
                           </a>
                         </p>
 
-                        <p v-if="organizationProfile.isCmf">
+                        <p v-if="organizationProfile.isCmf" class="mt-3">
                           <a href="">
-                            Télécharger le bon de commande CMF
+                            <b>{{ $t('download_cmf_order_form') }}</b>
                           </a>
                         </p>
-                        <p v-else>
+                        <p v-else class="mt-3">
                           <a href="">
-                            Télécharger le bon de commande
+                            <b>{{ $t('download_order_form') }}</b>
                           </a>
                         </p>
                       </td>
 
-                      <!-- Opentalent School -->
-                      <td v-if="organizationProfile.isArtist">
-                        <p>
-                          Une solution économique adaptée à votre établissement d'enseignement
-                          artistique
-                        </p>
-
-                        <!-- Cmf member -->
-                        <div v-if="organizationProfile.isCmf">
-                          <p>A partir de 16.45€ TTC par mois *</p>
-                          <p>
-                            <i>
-                              * Payable annuellement, soit 198€ TTC par an
-                              Version <b>Opentalent School Standard</b> jusqu'à 69 élèves.
-                              Hors frais de licence d'utilisation et de formation.
-                              Offre réservée aux adhérents CMF (prix public: 358.80€ TTC par an)
-                            </i>
-                          </p>
-                        </div>
-                        <!-- Not cmf member -->
-                        <div v-else>
-                          <p>A partir de 29.90€ TTC par mois *</p>
-                          <p>
-                            <i>
-                              * Payable annuellement, soit 358 € TTC par an
-                              Version <b>Opentalent School Standard</b> jusqu'à 69 élèves.
-                              Hors frais de licence d'utilisation et de formation.
-                            </i>
-                          </p>
-                        </div>
-
-                        <p>
-                          <a href="https://www.opentalent.fr/uploads/opentalent/ficheproduit_Opentalentschool">
-                            Fiche produit Opentalent School
-                          </a>
-                        </p>
-
-                        <p>
-                          Essayez notre logiciel en toute liberté ! Contactez-nous sans plus tarder pour obtenir
-                          une présentation ainsi qu'un accès de démonstration.
-                        </p>
-                        <p>
-                          Contactez-nous au <a href="tel:+33972126017">0 972 126 017</a>, ou par mail à l'adresse
-                          <a href="mailto:contact@opentalent.fr">contact@opentalent.fr</a>
-                        </p>
-                      </td>
-
                       <!-- Opentalent School Premium -->
-                      <td v-if="organizationProfile.isSchoolProduct">
+                      <td v-if="organizationProfile.isArtist">
                         <p>
-                          Passez à la version <b>Opentalent School Premium</b> et bénéficiez:
+                          {{ $t('switch_to_version') }} <b>{{ $t('PRODUCT_SCHOOL_PREMIUM') }}</b> {{ $t('and_benefit') }} :
                         </p>
 
-                        <ul>
-                          <li>de comptes pour vos professeurs et élèves</li>
-                          <li>d'un site internet complet</li>
+                        <ul class="mb-2">
+                          <li>{{ $t('of_accounts_for_teachers_and_students') }}</li>
+                          <li>{{ $t('of_a_complete_website') }}</li>
                         </ul>
 
                         <!-- Cmf member -->
                         <div v-if="organizationProfile.isCmf">
-                          <p>A partir de 22.30€ TTC par mois *</p>
-                          <p>
-                            <i>* Payable annuellement, soit 267.60€ TTC par an
-                              Version <b>Opentalent School Premium</b> jusqu'à 69 élèves.
-                              Hors frais de licence d'utilisation et de formation.
-                              Offre réservée aux adhérents CMF (prix public: 438€ TTC/an)</i>
-                          </p>
+                          <p><b>{{ $t('starting_from_x_eur_ttc_per_month', { price: formatCurrency(26.50, 'EUR') }) }} *</b></p>
+                          <div><i>* {{ $t('yearly_paid_giving_x_eur_ttc_per_year', { price: formatCurrency(318.00, 'EUR') }) }}</i></div>
+                          <div><i>{{ $t('version_x_up_to_x_students', { product: $t('PRODUCT_SCHOOL_PREMIUM'), max_students: '69' }) }}</i></div>
+                          <div><i>{{ $t('excluding_license_and_training_fees') }}.</i></div>
+                          <div><i>{{ $t('only_for_cmf_members') }} ({{ $t('public_price_x_ttc_a_year', { price: formatCurrency(529.20, 'EUR') }) }})</i></div>
                         </div>
                         <!-- Not cmf member -->
                         <div v-else>
-                          <p>A partir de 36.50€ TTC par mois *</p>
-                          <p>
-                            <i>
-                              * Payable annuellement, soit 438€ TTC par an
-                              Version <b>Opentalent School Premium</b> jusqu'à 69 élèves.
-                              Hors frais de licence d'utilisation et de formation.
-                            </i>
-                          </p>
+                          <p>{{ $t('starting_from_x_eur_ttc_per_month', { price: formatCurrency(44.10, 'EUR') }) }} *</p>
+                          <div><i>* {{ $t('yearly_paid_giving_x_eur_ttc_per_year', { price: formatCurrency(529.20, 'EUR') }) }}</i></div>
+                          <div><i>{{ $t('version_x_up_to_x_students', { product: $t('PRODUCT_SCHOOL_PREMIUM'), max_students: '69' }) }}</i></div>
+                          <div><i>{{ $t('excluding_license_and_training_fees') }}.</i></div>
                         </div>
 
-                        <p>
-                          <a href="https://www.opentalent.fr/uploads/opentalent/ficheproduit_Opentalentschool">
-                            Fiche produit Opentalent School
+                        <p class="mt-4">
+                          <a href="https://www.opentalent.fr/uploads/opentalent/ficheproduit_Opentalentschool" target="_blank">
+                            {{ $t('product_sheet') }} {{ $t('PRODUCT_SCHOOL') }}
                           </a>
                         </p>
 
                         <p>
-                          Contactez-nous au <a href="tel:+33972126017">0-972 126 017</a>, ou par mail à l'adresse
+                          {{ $t('contact_us_at') }} <a href="tel:+33972126017">0 972 126 017</a>, {{ $t('or_by_mail_at') }}
                           <a href="mailto:contact@opentalent.fr">contact@opentalent.fr</a>
                         </p>
                       </td>
 
                       <!-- SMS -->
                       <td>
-                        <p>Envoyez des <b>SMS</b> directement depuis votre logiciel à vos membres / élèves</p>
+                        <p><b>{{ $t('send_sms') }} {{ $t('to_your_members_from_app') }}</b></p>
 
                         <!-- Cmf member -->
                         <div v-if="organizationProfile.isCmf">
-                          <p>A partir de 0.10 €.TTC/sms *</p>
-                          <p><i>* pour 5000 SMS</i></p>
+                          <p><b>{{ $t('starting_from_x_eur_ttc_per_sms', { price: formatCurrency(0.10, 'EUR') }) }} *</b></p>
+                          <p><i>* {{ $t('for_x_sms', { amount: '5000' }) }}</i></p>
 
                           <p>
-                            <a href="https://www.opentalent.fr/uploads/opentalent/Bon_commande_SMS_ouverture-CMF.pdf">
-                              Télécharger le bon de commande CMF
-                            </a>
+                            <b>
+                              <a href="https://www.opentalent.fr/uploads/opentalent/Bon_commande_SMS_ouverture-CMF.pdf" target="_blank">
+                                {{ $t('download_cmf_order_form') }}
+                              </a>
+                            </b>
                           </p>
                         </div>
                         <!-- Not cmf member -->
                         <div v-else>
-                          <p>A partir de 0.12 €.TTC/sms *</p>
-                          <p><i>* pour 5000 SMS</i></p>
+                          <p><b>{{ $t('starting_from_x_eur_ttc_per_sms', { price: formatCurrency(0.12, 'EUR') }) }} *</b></p>
+                          <p><i>* {{ $t('for_x_sms', { amount: '5000' }) }}</i></p>
 
                           <p>
-                            <a href="https://www.opentalent.fr/uploads/opentalent/Bon_commande_SMS_ouverture-public.pdf">
-                              Télécharger le bon de commande
+                            <a href="https://www.opentalent.fr/uploads/opentalent/Bon_commande_SMS_ouverture-public.pdf" target="_blank">
+                              <b>{{ $t('download_order_form') }}</b>
                             </a>
                           </p>
                         </div>
@@ -300,26 +235,27 @@ Page 'Mon abonnement'
                       <!-- Custom domain -->
                       <td>
                         <p>
-                          Bénéficiez de votre <b>propre nom de domaine</b> et 5 adresses email
-                          pour seulement 34.80 €.TTC / mois
+                          <b>{{ $t('get_your_own_domain_and_up_to_five_emails_for_only_x_eur_ttc_per_month', { price: formatCurrency(34.80, 'EUR') }) }}</b>
                         </p>
 
-                        <p>Exemple:</p>
+                        <p>{{ $t('example') }} :</p>
                         <table>
-                          <tr>
-                            <td style="width: 200px;">
-                              Nom de domaine:
-                            </td>
-                            <td>
-                              <i>ma-structure.fr</i>
-                            </td>
-                          </tr>
-                          <tr>
-                            <td>Adresse email associée: </td>
-                            <td>
-                              <i>contact@NomDeMaStructure.fr</i>
-                            </td>
-                          </tr>
+                          <tbody>
+                            <tr>
+                              <td style="width: 150px;">
+                                {{ $t('domain_name') }} :
+                              </td>
+                              <td>
+                                <i>{{ $t('dummy_domain_name') }}</i>
+                              </td>
+                            </tr>
+                            <tr>
+                              <td>{{ $t('associated_mail_address') }} : </td>
+                              <td>
+                                <i>{{ $t('dummy_email_address') }}</i>
+                              </td>
+                            </tr>
+                          </tbody>
                         </table>
                       </td>
                     </tr>
@@ -338,50 +274,40 @@ Page 'Mon abonnement'
 import { defineComponent, useFetch, useContext, ref, Ref } from '@nuxtjs/composition-api'
 import { $organizationProfile } from '~/services/profile/organizationProfile'
 import { QUERY_TYPE } from '~/types/enums'
-import {ApiResponse, DolibarrAccount, MobytUserStatus} from '~/types/interfaces'
+import { ApiResponse, DolibarrAccount } from '~/types/interfaces'
+import {trimEnd} from "lodash";
 
 export default defineComponent({
   name: 'Subscription',
   setup () {
     const { store, $dataProvider } = useContext()
-    const organizationProfile = $organizationProfile(store)
+    const organizationProfile = ref($organizationProfile(store))
     const id: number = store.state.profile.organization.id
     const dolibarrAccount: Ref<DolibarrAccount | null> = ref(null)
-    const mobytStatus: Ref<MobytUserStatus | null> = ref(null)
 
     // fetch the dolibarr account's data
-    const {fetchState} = useFetch(async () => {
+    const { fetchState } = useFetch(async () => {
       try {
-        const reponse:ApiResponse = await $dataProvider.invoke({
+        const response: ApiResponse = await $dataProvider.invoke({
           type: QUERY_TYPE.DEFAULT,
           url: '/api/dolibarr/account/' + id
         })
-        dolibarrAccount.value = reponse.data as DolibarrAccount
+        dolibarrAccount.value = response.data as DolibarrAccount
       } catch (Error) {
         // eslint-disable-next-line no-console
         console.error('Error: Dolibarr account not found')
       }
     })
 
-    // fetch the mobyt status
-    useFetch(async () => {
-      try {
-        const reponse:ApiResponse = await $dataProvider.invoke({
-          type: QUERY_TYPE.DEFAULT,
-          url: '/api/mobyt/status/' + id
-        })
-        mobytStatus.value = reponse.data as MobytUserStatus
-      } catch (Error) {
-        // eslint-disable-next-line no-console
-        console.error('Error: Mobyt status not found')
-      }
-    })
-
     return {
       organizationProfile,
       dolibarrAccount,
-      mobytStatus,
-      dolibarAccountFetch : fetchState
+      dolibarrAccountFetch: fetchState
+    }
+  },
+  methods: {
+    formatCurrency(value: Number, currency: string): string {
+      return value.toLocaleString(this.$i18n.locale, { style: 'currency', currency: currency })
     }
   }
 })
@@ -406,5 +332,4 @@ export default defineComponent({
     padding: 12px 18px;
     vertical-align: top;
   }
-
 </style>

+ 1 - 1
services/data/baseDataManager.ts

@@ -44,7 +44,7 @@ abstract class BaseDataManager extends Hookable implements DataManager {
     await this.triggerHooks(queryArguments)
 
     try {
-      return this._invoke(queryArguments)
+      return await this._invoke(queryArguments)
     } catch (error) {
       throw new ApiError(error.response.status, error.response.data.detail)
     }