Files
ihrm/base/static/base/date_settings.js
Ashwanth Balakrishnan 58be33a8d7 Added Pre-Commit Hooks (#175)
* Added pre commit hook

* Run pre commit hook on all files

---------

Co-authored-by: Horilla <131998600+horilla-opensource@users.noreply.github.com>
2024-05-07 12:23:36 +05:30

28 lines
807 B
JavaScript

function saveDateFormat() {
var dateFormatSelector = document.getElementById('dateFormat');
const selectedFormat = dateFormatSelector.value;
// Set the selected date format in the utility
dateFormatter.setDateFormat(selectedFormat);
// Save the date format to the backend
saveDateFormatToBackend(selectedFormat);
}
function saveDateFormatToBackend(selectedFormat) {
$.ajax({
url: '/settings/save-date/',
method: 'POST',
data: { selected_format: selectedFormat, csrfmiddlewaretoken:getCookie('csrftoken') },
success: function(response) {
window.location.reload();
},
error: function (xhr, textStatus, errorThrown) {
// Handle the error here
console.error('Error:', errorThrown);
window.location.reload();
},
});
}