Skip to content

Commit

Permalink
Styling fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jrmhaig committed Jul 28, 2023
1 parent a31fd59 commit fdcc302
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions app/webpack/javascripts/modules/determination.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion app/webpack/javascripts/modules/determination_spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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(`
<table id="determinations" data-module="govuk-determination" data-apply-vat="true" data-vat-url="/vat.json" data-submitted-date="2023-07-18" data-scheme="agfs">
</table>
Expand Down

0 comments on commit fdcc302

Please sign in to comment.