import ApiDetailHeader from "../../api/factory/detailHeader.js"; export default { name: 'DetailHeader', inject: { domain: { from: 'configDomain', default: 'technikum-wien.at' }, }, props: { headerData: { type: Object, required: false }, person_id: { type: Number, required: false }, typeHeader: { type: String, default: 'student', validator(value) { return [ 'student', 'mitarbeiter', ].includes(value) } } }, computed: { appRoot() { return FHC_JS_DATA_STORAGE_OBJECT.app_root; }, validatedHeaderData() { if (this.typeHeader === 'student') return this.headerData; if (this.typeHeader === 'mitarbeiter') return this.person_id; return null; } }, created(){ if(this.person_id) { this.getHeader(this.person_id); this.loadDepartmentData(this.mitarbeiter_uid) .then(() => { // Call getLeitungOrg only after departmentData is loaded this.getLeitungOrg(this.departmentData.oe_kurzbz); }) .catch((error) => { console.error("Error loading department data:", error); }); } }, watch: { person_id: { handler(newVal) { if (newVal) { this.getHeader(this.person_id); this.loadDepartmentData(this.person_id). then(() => { this.getLeitungOrg(this.departmentData.oe_kurzbz); }); } }, deep: true, }, }, data(){ return{ headerDataMa: {}, departmentData: {}, leitungData: {}, }; }, methods: { getHeader(person_id) { return this.$api .call(ApiDetailHeader.getHeader(person_id)) .then(result => { this.headerDataMa = result.data; }) .catch(this.$fhcAlert.handleSystemError); }, loadDepartmentData(mitarbeiter_uid) { return this.$api .call(ApiDetailHeader.getPersonAbteilung(mitarbeiter_uid)) .then(result => { this.departmentData = result.data; }) .catch(this.$fhcAlert.handleSystemError); }, getLeitungOrg(oekurzbz){ return this.$api .call(ApiDetailHeader.getLeitungOrg(oekurzbz)) .then(result => { this.leitungData = result.data; }) .catch(this.$fhcAlert.handleSystemError); }, redirectToLeitung(){ this.$emit('redirectToLeitung', { person_id: this.leitungData.person_id}); } }, template: `
Email {{headerDataMa.uid}}@{{domain}} {{headerDataMa.alias}}@{{domain}} | DW {{headerDataMa?.telefonklappe}}