|
@@ -17,10 +17,9 @@ Barre d'alerte qui s'affiche pour donner l'état de la cotisation
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
|
-import type { Ref } from 'vue'
|
|
|
|
|
import { useOrganizationProfileStore } from '~/stores/organizationProfile'
|
|
import { useOrganizationProfileStore } from '~/stores/organizationProfile'
|
|
|
import UrlUtils from '~/services/utils/urlUtils'
|
|
import UrlUtils from '~/services/utils/urlUtils'
|
|
|
-import { ALERT_STATE_COTISATION } from '~/types/enum/enums'
|
|
|
|
|
|
|
+import type { ALERT_STATE_COTISATION } from '~/types/enum/enums'
|
|
|
import { useEntityFetch } from '~/composables/data/useEntityFetch'
|
|
import { useEntityFetch } from '~/composables/data/useEntityFetch'
|
|
|
import Cotisation from '~/models/Organization/Cotisation'
|
|
import Cotisation from '~/models/Organization/Cotisation'
|
|
|
|
|
|
|
@@ -29,7 +28,52 @@ const organizationProfile = useOrganizationProfileStore()
|
|
|
const runtimeConfig = useRuntimeConfig()
|
|
const runtimeConfig = useRuntimeConfig()
|
|
|
const baseLegacyUrl: string = runtimeConfig.baseUrlAdminLegacy
|
|
const baseLegacyUrl: string = runtimeConfig.baseUrlAdminLegacy
|
|
|
|
|
|
|
|
-const cotisationYear: Ref<number | null> = ref(null)
|
|
|
|
|
|
|
+// 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, pending } = await fetch(
|
|
|
|
|
+ Cotisation,
|
|
|
|
|
+ organizationProfile.id,
|
|
|
|
|
+)
|
|
|
|
|
+
|
|
|
|
|
+interface Alert {
|
|
|
|
|
+ text: string
|
|
|
|
|
+ callback: () => void
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+const cotisationYear: ComputedRef<number | null> = computed(() => {
|
|
|
|
|
+ if (pending.value || cotisation.value === null) {
|
|
|
|
|
+ return null
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return cotisation.value.cotisationYear
|
|
|
|
|
+})
|
|
|
|
|
+
|
|
|
|
|
+const alert: ComputedRef<Alert | null> = computed(() => {
|
|
|
|
|
+ if (pending.value || cotisation.value === null) {
|
|
|
|
|
+ return null
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ 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,
|
|
|
|
|
+ },
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!cotisation.value.alertState) {
|
|
|
|
|
+ return null
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return mapping[cotisation.value.alertState as ALERT_STATE_COTISATION]
|
|
|
|
|
+})
|
|
|
|
|
+
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Redirige l'utilisateur vers la page des cotisations
|
|
* Redirige l'utilisateur vers la page des cotisations
|
|
@@ -79,45 +123,6 @@ const openCmfSubscriptionPage = () => {
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// 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, pending } = await fetch(
|
|
|
|
|
- Cotisation,
|
|
|
|
|
- organizationProfile.id,
|
|
|
|
|
-)
|
|
|
|
|
-
|
|
|
|
|
-interface Alert {
|
|
|
|
|
- text: string
|
|
|
|
|
- callback: () => void
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-const alert: ComputedRef<Alert | null> = computed(() => {
|
|
|
|
|
- if (pending.value) {
|
|
|
|
|
- return null
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- cotisationYear.value = cotisation.value.cotisationYear
|
|
|
|
|
-
|
|
|
|
|
- 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,
|
|
|
|
|
- },
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (!cotisation.value.alertState) {
|
|
|
|
|
- return null
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return mapping[cotisation.value.alertState as ALERT_STATE_COTISATION]
|
|
|
|
|
-})
|
|
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
<style scoped lang="scss">
|