|
|
@@ -8,10 +8,10 @@ Barre d'alerte qui s'affiche pour donner l'état de la cotisation
|
|
|
<main>
|
|
|
<!-- TODO : vérifier le bon fonctionnement -->
|
|
|
<UiSystemBar
|
|
|
- v-if="show"
|
|
|
- :text="$t(alertTextKey)"
|
|
|
+ v-if="alert !== null"
|
|
|
+ :text="$t(alert.text)"
|
|
|
icon="fas fa-info-circle"
|
|
|
- :on-click="alertOnClick"
|
|
|
+ :on-click="alert.callback"
|
|
|
background-color="ot-info"
|
|
|
text-color="ot-white"
|
|
|
/>
|
|
|
@@ -76,32 +76,24 @@ if (!organizationProfile.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(() => {})
|
|
|
+interface Alert {
|
|
|
+ text: string
|
|
|
+ callback: () => void
|
|
|
+}
|
|
|
+
|
|
|
+const alert: Ref<Alert | null> = ref(null)
|
|
|
|
|
|
if (cotisation.value !== null) {
|
|
|
cotisationYear.value = cotisation.value.cotisationYear
|
|
|
- show.value = true
|
|
|
-
|
|
|
- switch(cotisation.value.alertState) {
|
|
|
- case ALERT_STATE_COTISATION.AFFILIATION :
|
|
|
- alertTextKey.value = 'cotisation_access'
|
|
|
- alertOnClick.value = goToCotisation
|
|
|
- break;
|
|
|
- case ALERT_STATE_COTISATION.INVOICE :
|
|
|
- alertTextKey.value = 'upload_cotisation_invoice'
|
|
|
- alertOnClick.value = openInvoiceWindow
|
|
|
- break;
|
|
|
- case ALERT_STATE_COTISATION.INSURANCE :
|
|
|
- alertTextKey.value = 'renew_insurance_cmf'
|
|
|
- alertOnClick.value = goToInsurancePage
|
|
|
- break;
|
|
|
- case ALERT_STATE_COTISATION.ADVERTISINGINSURANCE :
|
|
|
- alertTextKey.value = 'insurance_cmf_subscription'
|
|
|
- alertOnClick.value = openCmfSubscriptionPage
|
|
|
- break;
|
|
|
+
|
|
|
+ const mapping: Record<ALERT_STATE_COTISATION, Alert> = {
|
|
|
+ 'AFFILIATION': { text: 'cotisation_access', callback: goToCotisation },
|
|
|
+ 'INVOICE': { text: 'upload_cotisation_invoice', callback: openInvoiceWindow },
|
|
|
+ 'INSURANCE': { text: 'renew_insurance_cmf', callback: goToInsurancePage },
|
|
|
+ 'ADVERTISINGINSURANCE': { text: 'insurance_cmf_subscription', callback: openCmfSubscriptionPage },
|
|
|
}
|
|
|
+
|
|
|
+ alert.value = mapping[cotisation.value.alertState as ALERT_STATE_COTISATION]
|
|
|
}
|
|
|
|
|
|
</script>
|