UpgradePremiumButton.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <div v-if="show">
  3. <div
  4. class="btn_trial"
  5. :class="{['btn_mini'] : minimized}"
  6. @click="trialAction()"
  7. >
  8. <v-icon icon="fa fa-ticket" />
  9. <span v-if="organizationProfile.isTrialActive && !minimized">
  10. <strong>J-{{organizationProfile.trialCountDown}}</strong>
  11. <br/>
  12. </span>
  13. <span v-if="!minimized">{{ btnLabel }}</span>
  14. </div>
  15. <LayoutDialogTrialAlreadyDid
  16. :show="showDialog"
  17. @closeDialog = "showDialog = false"
  18. />
  19. </div>
  20. </template>
  21. <script setup lang="ts">
  22. import UrlUtils from "~/services/utils/urlUtils";
  23. import {useApiLegacyRequestService} from '~/composables/data/useApiLegacyRequestService';
  24. import {computed} from '@vue/reactivity';
  25. const runtimeConfig = useRuntimeConfig()
  26. const accessProfile = useAccessProfileStore()
  27. const organizationProfile = useOrganizationProfileStore()
  28. const { apiRequestService } = useApiLegacyRequestService()
  29. const i18n = useI18n()
  30. const props = defineProps({
  31. show: {
  32. type: Boolean,
  33. required: false,
  34. default: false
  35. },
  36. minimized: {
  37. type: Boolean,
  38. required: false,
  39. default: false
  40. }
  41. })
  42. const showDialog: Ref<boolean> = ref(false)
  43. const btnLabel = computed(() => {
  44. if(organizationProfile.isTrialActive){
  45. return i18n.t('trial_started')
  46. }
  47. return organizationProfile.principalType === 'ARTISTIC_PRACTICE_ONLY' ? i18n.t('try_premium') : i18n.t('discover_offer')
  48. })
  49. /**
  50. * Lorsque l'on appuie sur le bouton pour démarrer l'essai / découvrir les offres
  51. */
  52. const trialAction = async () => {
  53. const v1BaseURL = runtimeConfig.baseUrlAdminLegacy || runtimeConfig.public.baseUrlAdminLegacy
  54. if(organizationProfile.isTrialActive){
  55. await navigateTo(UrlUtils.join(v1BaseURL, '#', 'subscribe'), {
  56. external: true
  57. })
  58. }else if(organizationProfile.principalType === 'ARTISTIC_PRACTICE_ONLY'){
  59. try{
  60. await apiRequestService.get('/trial/is_available')
  61. await navigateTo(UrlUtils.join(v1BaseURL, '#', 'trial'), {
  62. external: true
  63. })
  64. }catch(error){
  65. showDialog.value = true
  66. }
  67. }else{
  68. await navigateTo('/subscription')
  69. }
  70. }
  71. </script>
  72. <style scoped lang="scss">
  73. .btn_trial {
  74. background-color: rgb(var(--v-theme-x-create-btn));
  75. border-radius: 5px;
  76. border: 1px solid #fff;
  77. margin-left: 15px;
  78. margin-right: 15px;
  79. text-align: center;
  80. color:#000;
  81. margin-top: 5px;
  82. padding: 5px 10px;
  83. cursor: pointer;
  84. white-space: pre-line;
  85. font-size: 13px;
  86. .v-icon {
  87. font-size: 16px;
  88. color:#000;
  89. padding-right: 5px;
  90. margin: 0 5px 4px 0;
  91. }
  92. }
  93. .btn_mini {
  94. font-size: 17px;
  95. margin-left: 7px;
  96. margin-right: 7px;
  97. padding: 0;
  98. .v-icon {
  99. padding-right: 0;
  100. margin: 0 0 3px 0;
  101. }
  102. }
  103. </style>