Skip to content

Commit

Permalink
Javascript linting
Browse files Browse the repository at this point in the history
  • Loading branch information
jrmhaig committed Jul 4, 2023
1 parent 1fe96af commit 064ce8d
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions app/webpack/javascripts/modules/Modules.UnclaimedFees.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ moj.Modules.UnclaimedFees = {
this.checkListWrapper = document.getElementById('mod-unclaimed-fees')
if (this.checkListWrapper) {
this.button = document.getElementById('add-unclaimed-fees')
const form = this.button.closest("form")
this.url = form.getAttribute("action")
this.token = Array.from(form.getElementsByTagName("input")).filter(i => i.getAttribute("name") === "authenticity_token")[0].value
const form = this.button.closest('form')
this.url = form.getAttribute('action')
this.token = Array.from(form.getElementsByTagName('input')).filter(i => i.getAttribute('name') === 'authenticity_token')[0].value
this.checkBoxes = Array.from(this.checkListWrapper.getElementsByClassName('govuk-checkboxes__input'))
this.checkBoxes.forEach(box => box.onchange = () => this.setSubmitButton())
this.checkBoxes.forEach(box => { box.onchange = () => this.setSubmitButton() })
this.setSubmitButton()
this.button.addEventListener('click', (event) => this.submit(event))
}
Expand All @@ -24,20 +24,20 @@ moj.Modules.UnclaimedFees = {

const feesToAdd = this.checkBoxes.filter(box => box.checked)

const response = await fetch(this.url, {
method: "POST",
headers: { "Content-Type": "application/json" },
await fetch(this.url, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
authenticity_token: this.token,
fees: feesToAdd.map(fee => fee.value)
})
}).then(response => {
if (response.ok) {
feesToAdd.forEach(box => box.disabled = true)
feesToAdd.forEach(box => { box.disabled = true })
this.setSubmitButton()
} else {
console.log('There was a problem')
}
})
}
}
}

0 comments on commit 064ce8d

Please sign in to comment.