Cotisation.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <!--
  2. Cotisation bar : Barre qui s'affiche pour donner l'état de la cotisation
  3. -->
  4. <template>
  5. <main>
  6. <UiSystemBar color="ot_info" v-if="show_cotisation_access">
  7. <template #bar.text>
  8. <a @click="goOn('AFFILIATION')" class="ot_white--text">
  9. <v-icon small>fas fa-exclamation-triangle</v-icon> {{$t('cotisation_access')}}
  10. </a>
  11. </template>
  12. </UiSystemBar>
  13. <UiSystemBar color="ot_info" v-else-if="show_upload_invoice">
  14. <template #bar.text>
  15. <a @click="goOn('INVOICE')" class="ot_white--text">
  16. <v-icon small>fas fa-exclamation-triangle</v-icon> {{$t('upload_cotisation_invoice')}}
  17. </a>
  18. </template>
  19. </UiSystemBar>
  20. <UiSystemBar color="ot_info" v-else-if="show_renew_insurance">
  21. <template #bar.text>
  22. <a @click="goOn('INSURANCE')" class="ot_white--text">
  23. <v-icon small>fas fa-exclamation-triangle</v-icon> {{$t('renew_insurance_cmf')}}
  24. </a>
  25. </template>
  26. </UiSystemBar>
  27. <UiSystemBar color="ot_info" v-else-if="show_insurance_subscription">
  28. <template #bar.text>
  29. <a @click="goOn('ADVERTISINGINSURANCE')" class="ot_white--text">
  30. <v-icon small>fas fa-exclamation-triangle</v-icon> {{$t('insurance_cmf_subscription')}}
  31. </a>
  32. </template>
  33. </UiSystemBar>
  34. </main>
  35. </template>
  36. <script lang="ts">
  37. import { defineComponent, useFetch, useContext, Ref, ref} from '@nuxtjs/composition-api'
  38. import {ALERT_STATE_COTISATION, QUERY_TYPE} from "~/types/enums";
  39. import {organizationState} from "~/types/interfaces";
  40. export default defineComponent({
  41. setup () {
  42. const {$dataProvider, store, $config} = useContext()
  43. const profileOrganization:organizationState = store.state.profile.organization
  44. const baseLegacyUrl:string = $config.baseURL_adminLegacy
  45. const show_cotisation_access: Ref<Boolean> = ref(false)
  46. const show_upload_invoice: Ref<Boolean> = ref(false)
  47. const show_renew_insurance: Ref<Boolean> = ref(false)
  48. const show_insurance_subscription: Ref<Boolean> = ref(false)
  49. const cotisation_year: Ref<Number> = ref(0)
  50. /**
  51. * On récupère l'état des cotisations via l'API
  52. */
  53. useFetch(async () => {
  54. const response = await $dataProvider.invoke({
  55. type: QUERY_TYPE.DEFAULT,
  56. id: profileOrganization.id,
  57. url: 'cotisations'
  58. })
  59. cotisation_year.value = response.data.cotisationYear
  60. handleShow(response.data.alertState)
  61. })
  62. /**
  63. * Suivant l'état de l'alerte on affiche tel ou tel message
  64. * @param alertState
  65. */
  66. const handleShow = (alertState: ALERT_STATE_COTISATION) =>{
  67. switch(alertState){
  68. case ALERT_STATE_COTISATION.AFFILIATION :
  69. show_cotisation_access.value = true
  70. break;
  71. case ALERT_STATE_COTISATION.INVOICE :
  72. show_upload_invoice.value = true
  73. break;
  74. case ALERT_STATE_COTISATION.INSURANCE :
  75. show_renew_insurance.value = true
  76. break;
  77. case ALERT_STATE_COTISATION.ADVERTISINGINSURANCE :
  78. show_insurance_subscription.value = true
  79. break;
  80. }
  81. }
  82. /**
  83. * Suivant le bandeau, une action différente est réalisée
  84. * @param type
  85. */
  86. const goOn = (type: ALERT_STATE_COTISATION) => {
  87. switch(type){
  88. case ALERT_STATE_COTISATION.AFFILIATION :
  89. window.location.href = `${baseLegacyUrl}/cotisation/cotisation_steps/${profileOrganization.id}/steps/1`
  90. break;
  91. case ALERT_STATE_COTISATION.INVOICE :
  92. window.open(`${baseLegacyUrl}/cotisation/invoice/${cotisation_year.value}`, '_blank')
  93. break;
  94. case ALERT_STATE_COTISATION.INSURANCE :
  95. window.location.href = `${baseLegacyUrl}/cotisation/insuranceedit`
  96. break;
  97. case ALERT_STATE_COTISATION.ADVERTISINGINSURANCE :
  98. window.open('https://www.cmf-musique.org/services/assurances/assurance-de-groupe/', '_blank')
  99. break;
  100. }
  101. }
  102. return{
  103. show_cotisation_access,
  104. show_upload_invoice,
  105. show_renew_insurance,
  106. show_insurance_subscription,
  107. goOn
  108. }
  109. }
  110. })
  111. </script>