From 9f5df91be459e0a79ef4092561d969988289cf93 Mon Sep 17 00:00:00 2001 From: carlosjr Date: Wed, 30 Jun 2021 14:05:16 +0200 Subject: [PATCH] workers without active contract no longer set calendar and timeControl at fault --- modules/worker/front/calendar/index.js | 6 ++++-- modules/worker/front/time-control/index.js | 7 ++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/modules/worker/front/calendar/index.js b/modules/worker/front/calendar/index.js index d60fa0647..014a35b63 100644 --- a/modules/worker/front/calendar/index.js +++ b/modules/worker/front/calendar/index.js @@ -91,8 +91,10 @@ class Controller extends Section { } getActiveContract() { - this.$http.get(`Workers/${this.worker.id}/activeContract`) - .then(res => this.businessId = res.data.businessFk); + this.$http.get(`Workers/${this.worker.id}/activeContract`).then(res => { + if (res.data) + this.businessId = res.data.businessFk; + }); } getContractHolidays() { diff --git a/modules/worker/front/time-control/index.js b/modules/worker/front/time-control/index.js index b980243c9..2631c82d2 100644 --- a/modules/worker/front/time-control/index.js +++ b/modules/worker/front/time-control/index.js @@ -90,7 +90,10 @@ class Controller extends Section { getActiveContract() { return this.$http.get(`Workers/${this.worker.id}/activeContract`) - .then(res => this.businessId = res.data.businessFk); + .then(res => { + if (res.data) + this.businessId = res.data.businessFk; + }); } fetchHours() { @@ -111,6 +114,8 @@ class Controller extends Section { } getAbsences() { + if (!this.businessId) return; + const fullYear = this.started.getFullYear(); let params = { businessFk: this.businessId,