|
|
@@ -6,42 +6,15 @@ Barre d'alerte qui s'affiche pour donner l'état de la cotisation
|
|
|
|
|
|
<template>
|
|
|
<main>
|
|
|
- <!-- TODO : fonctionnement à valider -->
|
|
|
- <UiSystemBar v-if="showCotisationAccess" background-color="ot-info">
|
|
|
- <template #bar.text>
|
|
|
- <a @click="goOn('AFFILIATION')" class="text-ot-white">
|
|
|
- <v-icon small>fas fa-info-circle</v-icon>
|
|
|
- {{$t('cotisation_access')}}
|
|
|
- </a>
|
|
|
- </template>
|
|
|
- </UiSystemBar>
|
|
|
-
|
|
|
- <UiSystemBar v-else-if="showUploadInvoice" background-color="ot-info">
|
|
|
- <template #bar.text>
|
|
|
- <a @click="goOn('INVOICE')" class="text-ot-white">
|
|
|
- <v-icon small>fas fa-info-circle</v-icon>
|
|
|
- {{$t('upload_cotisation_invoice')}}
|
|
|
- </a>
|
|
|
- </template>
|
|
|
- </UiSystemBar>
|
|
|
-
|
|
|
- <UiSystemBar v-else-if="showRenewInsurance" background-color="ot-info">
|
|
|
- <template #bar.text>
|
|
|
- <a @click="goOn('INSURANCE')" class="text-ot-white">
|
|
|
- <v-icon small>fas fa-info-circle</v-icon>
|
|
|
- {{$t('renew_insurance_cmf')}}
|
|
|
- </a>
|
|
|
- </template>
|
|
|
- </UiSystemBar>
|
|
|
-
|
|
|
- <UiSystemBar v-else-if="showInsuranceSubscription" background-color="ot-info">
|
|
|
- <template #bar.text>
|
|
|
- <a @click="goOn('ADVERTISINGINSURANCE')" class="text-ot-white">
|
|
|
- <v-icon small>fas fa-info-circle</v-icon>
|
|
|
- {{$t('insurance_cmf_subscription')}}
|
|
|
- </a>
|
|
|
- </template>
|
|
|
- </UiSystemBar>
|
|
|
+ <!-- TODO : vérifier le bon fonctionnement -->
|
|
|
+ <UiSystemBar
|
|
|
+ v-if="show"
|
|
|
+ :text="$t(alertTextKey)"
|
|
|
+ icon="fas fa-info-circle"
|
|
|
+ :on-click="alertOnClick"
|
|
|
+ background-color="ot-info"
|
|
|
+ text-color="ot-white"
|
|
|
+ />
|
|
|
</main>
|
|
|
</template>
|
|
|
|
|
|
@@ -50,105 +23,85 @@ import {useOrganizationProfileStore} from "~/stores/organizationProfile";
|
|
|
import {Ref} from "vue";
|
|
|
import UrlUtils from "~/services/utils/urlUtils";
|
|
|
import {ALERT_STATE_COTISATION} from "~/types/enum/enums";
|
|
|
-import {useAsyncData} from "#app";
|
|
|
import {useEntityFetch} from "~/composables/data/useEntityFetch";
|
|
|
import Cotisation from "~/models/Organization/Cotisation";
|
|
|
|
|
|
-const { fetch } = useEntityFetch()
|
|
|
-
|
|
|
const organizationProfile = useOrganizationProfileStore()
|
|
|
|
|
|
const runtimeConfig = useRuntimeConfig()
|
|
|
const baseLegacyUrl: string = runtimeConfig.baseUrlAdminLegacy
|
|
|
|
|
|
const cotisationYear: Ref<number | null> = ref(null)
|
|
|
-const showCotisationAccess: Ref<Boolean> = ref(false)
|
|
|
-const showUploadInvoice: Ref<Boolean> = ref(false)
|
|
|
-const showRenewInsurance: Ref<Boolean> = ref(false)
|
|
|
-const showInsuranceSubscription: Ref<Boolean> = ref(false)
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
- * On récupère l'état des cotisations via l'API
|
|
|
+ * Redirige l'utilisateur vers la page des cotisations
|
|
|
*/
|
|
|
-useAsyncData(async () => {
|
|
|
+const goToCotisation = () => {
|
|
|
if (!organizationProfile.id) {
|
|
|
throw new Error('missing organization id')
|
|
|
}
|
|
|
- const { data: cotisation } = await fetch(Cotisation, organizationProfile.id)
|
|
|
+ window.location.href = UrlUtils.join(baseLegacyUrl, '/cotisation/cotisation_steps', organizationProfile.id, 'steps/1')
|
|
|
+}
|
|
|
|
|
|
- if (cotisation.value !== null) {
|
|
|
- cotisationYear.value = cotisation.value.cotisationYear
|
|
|
- handleShow(cotisation.value.alertState)
|
|
|
+/**
|
|
|
+ * Ouvre la page facturation dans un nouvel onglet
|
|
|
+ */
|
|
|
+const openInvoiceWindow = () => {
|
|
|
+ if (!cotisationYear.value) {
|
|
|
+ throw new Error('no cotisation year defined')
|
|
|
}
|
|
|
-})
|
|
|
+ window.open(UrlUtils.join(baseLegacyUrl, 'cotisation/invoice', cotisationYear.value), '_blank')
|
|
|
+}
|
|
|
|
|
|
/**
|
|
|
- * Suivant l'état de l'alerte on affiche tel ou tel message
|
|
|
- * @param alertState
|
|
|
+ * Redirige l'utilisateur vers la page des assurances
|
|
|
*/
|
|
|
-const handleShow = (alertState: ALERT_STATE_COTISATION) =>{
|
|
|
- switch(alertState){
|
|
|
- case ALERT_STATE_COTISATION.AFFILIATION :
|
|
|
- showCotisationAccess.value = true
|
|
|
- break;
|
|
|
- case ALERT_STATE_COTISATION.INVOICE :
|
|
|
- showUploadInvoice.value = true
|
|
|
- break;
|
|
|
- case ALERT_STATE_COTISATION.INSURANCE :
|
|
|
- showRenewInsurance.value = true
|
|
|
- break;
|
|
|
- case ALERT_STATE_COTISATION.ADVERTISINGINSURANCE :
|
|
|
- showInsuranceSubscription.value = true
|
|
|
- break;
|
|
|
- }
|
|
|
+const goToInsurancePage = () => {
|
|
|
+ window.location.href = UrlUtils.join(baseLegacyUrl, 'cotisation/insuranceedit')
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Suivant le bandeau, une action différente est réalisée
|
|
|
- * @param type
|
|
|
+ * Redirige (dans un nouvel onglet) l'utilsateur vers le site web de la CMF
|
|
|
*/
|
|
|
-const goOn = (type: ALERT_STATE_COTISATION) => {
|
|
|
- switch(type){
|
|
|
+const openCmfSubscriptionPage = () => {
|
|
|
+ window.open('https://www.cmf-musique.org/services/assurances/assurance-de-groupe/', '_blank')
|
|
|
+}
|
|
|
+
|
|
|
+// On récupère l'état des cotisations via l'API
|
|
|
+if (!organizationProfile.id) {
|
|
|
+ throw new Error('missing organization id')
|
|
|
+}
|
|
|
+
|
|
|
+const { fetch } = useEntityFetch()
|
|
|
+const { data: cotisation } = await fetch(Cotisation, organizationProfile.id)
|
|
|
+
|
|
|
+const show: Ref<boolean> = ref(false)
|
|
|
+const alertTextKey: Ref<string> = ref('')
|
|
|
+const alertOnClick: Ref<() => void> = ref(() => {})
|
|
|
+
|
|
|
+if (cotisation.value !== null) {
|
|
|
+ cotisationYear.value = cotisation.value.cotisationYear
|
|
|
+ show.value = true
|
|
|
+
|
|
|
+ switch(cotisation.value.alertState) {
|
|
|
case ALERT_STATE_COTISATION.AFFILIATION :
|
|
|
- if (!organizationProfile.id) {
|
|
|
- throw new Error('missing organization id')
|
|
|
- }
|
|
|
- window.location.href = UrlUtils.join(baseLegacyUrl, '/cotisation/cotisation_steps', organizationProfile.id, 'steps/1')
|
|
|
+ alertTextKey.value = 'cotisation_access'
|
|
|
+ alertOnClick.value = goToCotisation
|
|
|
break;
|
|
|
case ALERT_STATE_COTISATION.INVOICE :
|
|
|
- if (!cotisationYear.value) {
|
|
|
- throw new Error('no cotisation year defined')
|
|
|
- }
|
|
|
- window.open(
|
|
|
- UrlUtils.join(baseLegacyUrl, 'cotisation/invoice', cotisationYear.value),
|
|
|
- '_blank'
|
|
|
- )
|
|
|
+ alertTextKey.value = 'upload_cotisation_invoice'
|
|
|
+ alertOnClick.value = openInvoiceWindow
|
|
|
break;
|
|
|
case ALERT_STATE_COTISATION.INSURANCE :
|
|
|
- window.location.href = UrlUtils.join(baseLegacyUrl, 'cotisation/insuranceedit')
|
|
|
+ alertTextKey.value = 'renew_insurance_cmf'
|
|
|
+ alertOnClick.value = goToInsurancePage
|
|
|
break;
|
|
|
case ALERT_STATE_COTISATION.ADVERTISINGINSURANCE :
|
|
|
- window.open(
|
|
|
- 'https://www.cmf-musique.org/services/assurances/assurance-de-groupe/',
|
|
|
- '_blank'
|
|
|
- )
|
|
|
+ alertTextKey.value = 'insurance_cmf_subscription'
|
|
|
+ alertOnClick.value = openCmfSubscriptionPage
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
-</script>
|
|
|
-
|
|
|
-<style scoped lang="scss">
|
|
|
-.v-system-bar {
|
|
|
- font-size: 14px;
|
|
|
-}
|
|
|
|
|
|
-.v-icon {
|
|
|
- height: 20px;
|
|
|
- margin: 0 6px;
|
|
|
-}
|
|
|
-
|
|
|
-a {
|
|
|
- // Je ne sais pas pourquoi il faut le préciser, mais sans ça le pointeur n'est pas bon
|
|
|
- cursor: pointer;
|
|
|
-}
|
|
|
-</style>
|
|
|
+</script>
|