|
@@ -27,7 +27,6 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
|
-
|
|
|
|
|
import {useEntityManager} from "~/composables/data/useEntityManager";
|
|
import {useEntityManager} from "~/composables/data/useEntityManager";
|
|
|
import {useFormStore} from "~/stores/form";
|
|
import {useFormStore} from "~/stores/form";
|
|
|
import {useOrganizationProfileStore} from "~/stores/organizationProfile";
|
|
import {useOrganizationProfileStore} from "~/stores/organizationProfile";
|
|
@@ -35,22 +34,27 @@ import {useAccessProfileStore} from "~/stores/accessProfile";
|
|
|
import Access from "~/models/Access/Access";
|
|
import Access from "~/models/Access/Access";
|
|
|
import {Ref, ref} from "@vue/reactivity";
|
|
import {Ref, ref} from "@vue/reactivity";
|
|
|
import {useDisplay} from "vuetify";
|
|
import {useDisplay} from "vuetify";
|
|
|
|
|
+import {usePageStore} from "~/stores/page";
|
|
|
|
|
+import MyProfile from "~/models/Access/MyProfile";
|
|
|
|
|
|
|
|
const { em } = useEntityManager()
|
|
const { em } = useEntityManager()
|
|
|
const accessProfileStore = useAccessProfileStore()
|
|
const accessProfileStore = useAccessProfileStore()
|
|
|
const organizationProfileStore = useOrganizationProfileStore()
|
|
const organizationProfileStore = useOrganizationProfileStore()
|
|
|
const formStore = useFormStore()
|
|
const formStore = useFormStore()
|
|
|
|
|
+const pageStore = usePageStore()
|
|
|
const { mdAndUp } = useDisplay()
|
|
const { mdAndUp } = useDisplay()
|
|
|
|
|
|
|
|
-const currentActivityYear: Ref<number | undefined> = ref(accessProfileStore.activityYear ?? undefined)
|
|
|
|
|
|
|
+const currentActivityYear: ComputedRef<number | undefined> = computed(() => accessProfileStore.activityYear ?? undefined)
|
|
|
const yearPlusOne: boolean = !organizationProfileStore.isManagerProduct
|
|
const yearPlusOne: boolean = !organizationProfileStore.isManagerProduct
|
|
|
const label: string = organizationProfileStore.isSchool ? 'schooling_year' : organizationProfileStore.isArtist ? 'season_year' : 'cotisation_year'
|
|
const label: string = organizationProfileStore.isSchool ? 'schooling_year' : organizationProfileStore.isArtist ? 'season_year' : 'cotisation_year'
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Persist a new activityYear
|
|
* Persist a new activityYear
|
|
|
- * @param activityYear
|
|
|
|
|
|
|
+ * @param event
|
|
|
*/
|
|
*/
|
|
|
-const setActivityYear = async (activityYear: number) => {
|
|
|
|
|
|
|
+const setActivityYear = async (event: string) => {
|
|
|
|
|
+ const activityYear = parseInt(event)
|
|
|
|
|
+
|
|
|
if (!(1900 < activityYear) || !(activityYear <= 2100)) {
|
|
if (!(1900 < activityYear) || !(activityYear <= 2100)) {
|
|
|
throw new Error("Error: 'year' shall be a valid year")
|
|
throw new Error("Error: 'year' shall be a valid year")
|
|
|
}
|
|
}
|
|
@@ -59,17 +63,12 @@ const setActivityYear = async (activityYear: number) => {
|
|
|
}
|
|
}
|
|
|
formStore.setDirty(false)
|
|
formStore.setDirty(false)
|
|
|
|
|
|
|
|
- const access = await em.fetch(Access, accessProfileStore.id)
|
|
|
|
|
- access.activityYear = activityYear
|
|
|
|
|
- await em.persist(Access, access)
|
|
|
|
|
-
|
|
|
|
|
- // Update the store
|
|
|
|
|
- // TODO: voir si mieux d'automatiser ces maj du profil, ou de les faire à la main au cas par cas?
|
|
|
|
|
- accessProfileStore.$patch({ activityYear: activityYear })
|
|
|
|
|
|
|
+ pageStore.loading = true
|
|
|
|
|
+ await em.patch(Access, accessProfileStore.currentAccessId, { activityYear: activityYear })
|
|
|
|
|
+ await em.refreshProfile()
|
|
|
|
|
|
|
|
window.location.reload()
|
|
window.location.reload()
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
<style lang="scss">
|