From fdcc3023f598ab86c33b11c89f5ae58c06057fe8 Mon Sep 17 00:00:00 2001 From: Joe Haig Date: Fri, 28 Jul 2023 16:16:46 +0100 Subject: [PATCH] Styling fixes --- .../javascripts/modules/determination.mjs | 18 +++++++++--------- .../javascripts/modules/determination_spec.mjs | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/webpack/javascripts/modules/determination.mjs b/app/webpack/javascripts/modules/determination.mjs index 90bb3ae8b0..44028c7c73 100644 --- a/app/webpack/javascripts/modules/determination.mjs +++ b/app/webpack/javascripts/modules/determination.mjs @@ -6,12 +6,10 @@ export class Determination { * @param {Element} $module - HTML element to use for component */ constructor ($module) { - if (!($module instanceof HTMLElement) || !document.body.classList.contains('govuk-frontend-supported')) { - return this + if (($module instanceof window.HTMLElement) && document.body.classList.contains('govuk-frontend-supported')) { + this.$module = $module } - this.$module = $module - // Code goes here } @@ -46,12 +44,14 @@ export class Determination { this.fields.forEach(element => element.addEventListener('change', () => this.calculateTotalRows())) } - async calculateTotalRows () { + calculateTotalRows () { const total = this.fields.reduce((n, field) => n + this.parsedValue(field), 0).toFixed(2) - const data = await this.applyVat(total) - this.$totalExclVat.innerHTML = data.net_amount - if (this.$totalVat) { this.$totalVat.innerHTML = data.vat_amount } - this.$totalInclVat.innerHTML = data.total_inc_vat + + this.applyVat(total).then(data => { + this.$totalExclVat.innerHTML = data.net_amount + if (this.$totalVat) { this.$totalVat.innerHTML = data.vat_amount } + this.$totalInclVat.innerHTML = data.total_inc_vat + }) } parsedValue (field) { diff --git a/app/webpack/javascripts/modules/determination_spec.mjs b/app/webpack/javascripts/modules/determination_spec.mjs index 9df444dfb9..480857689f 100644 --- a/app/webpack/javascripts/modules/determination_spec.mjs +++ b/app/webpack/javascripts/modules/determination_spec.mjs @@ -4,7 +4,7 @@ describe('Determination', () => { let determination = null beforeEach(() => { - document.body.classList.add("govuk-frontend-supported") + document.body.classList.add('govuk-frontend-supported') document.body.append(`