Skip to content

Commit

Permalink
fix yarn lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
aisayo committed Oct 16, 2023
1 parent 6f9139d commit 27a4d4b
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions app/javascript/src/all_casa_admin/feature_flags.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
$(function() {
let checkboxes = $('.form-check-input.toggle-switch');
$(function () {
const checkboxes = $('.form-check-input.toggle-switch')

checkboxes.on('change', function(e) {
e.preventDefault();
let featureFlagId = $(this).data('feature-flag-id');
let uniqueCheckbox = $('#feature-checkbox-' + featureFlagId);
const csrfToken = $('meta[name=csrf-token]').attr('content');
const isChecked = this.checked;
toggleSwitch(uniqueCheckbox, csrfToken, featureFlagId, isChecked);
});
checkboxes.on('change', function (e) {
e.preventDefault()
const featureFlagId = $(this).data('feature-flag-id')
const uniqueCheckbox = $('#feature-checkbox-' + featureFlagId)
const csrfToken = $('meta[name=csrf-token]').attr('content')
const isChecked = this.checked
toggleSwitch(uniqueCheckbox, csrfToken, featureFlagId, isChecked)
})

function toggleSwitch(uniqueCheckbox, csrfToken, featureFlagId, checked) {
$.ajax({
url: `/all_casa_admins/feature_flags/${featureFlagId}`,
method: 'PATCH',
contentType: 'application/json',
headers: {
'X-CSRF-Token': csrfToken
},
success: function() {
if (checked) {
uniqueCheckbox.prop('checked', true);
} else {
uniqueCheckbox.prop('checked', false);
}
function toggleSwitch (uniqueCheckbox, csrfToken, featureFlagId, checked) {
$.ajax({
url: `/all_casa_admins/feature_flags/${featureFlagId}`,
method: 'PATCH',
contentType: 'application/json',
headers: {
'X-CSRF-Token': csrfToken
},
success: function () {
if (checked) {
uniqueCheckbox.prop('checked', true)
} else {
uniqueCheckbox.prop('checked', false)
}
});
}
});
}
})
}
})

0 comments on commit 27a4d4b

Please sign in to comment.