diff --git a/assets/js/components/TargetCharge.vue b/assets/js/components/TargetCharge.vue index ad8170c01..e67e151a3 100644 --- a/assets/js/components/TargetCharge.vue +++ b/assets/js/components/TargetCharge.vue @@ -128,7 +128,7 @@ export default { timeTooFarInTheFuture: function () { if (this.tariff?.rates) { const lastRate = this.tariff.rates[this.tariff.rates.length - 1]; - if (lastRate.end) { + if (lastRate?.end) { const end = new Date(lastRate.end); return this.selectedTargetTime >= end; } @@ -201,13 +201,18 @@ export default { !isNaN(this.selectedTargetTime) ) { try { - const opts = { - params: { targetTime: this.selectedTargetTime }, - }; this.plan = ( - await api.get(`loadpoints/${this.id}/target/plan`, opts) + await api.get(`loadpoints/${this.id}/target/plan`, { + params: { targetTime: this.selectedTargetTime }, + }) ).data.result; - this.tariff = (await api.get(`tariff/planner`)).data.result; + + const tariffRes = await api.get(`tariff/planner`, { + validateStatus: function (status) { + return status >= 200 && status < 500; + }, + }); + this.tariff = tariffRes.status === 404 ? { rates: [] } : tariffRes.data.result; } catch (e) { console.error(e); } diff --git a/assets/js/components/TargetChargePlan.vue b/assets/js/components/TargetChargePlan.vue index 52573c6a9..0279f2965 100644 --- a/assets/js/components/TargetChargePlan.vue +++ b/assets/js/components/TargetChargePlan.vue @@ -5,7 +5,7 @@