Replace var with const/let in customers module

This commit is contained in:
Alex Tselegidis 2022-01-07 09:02:30 +01:00
parent 62357dfc36
commit bd3b55c2f9
1 changed files with 12 additions and 11 deletions

View File

@ -47,8 +47,8 @@ App.Pages.Customers = (function () {
return; // Do nothing when user edits a customer record. return; // Do nothing when user edits a customer record.
} }
var customerId = $(this).attr('data-id'); const customerId = $(this).attr('data-id');
var customer = filterResults.find(function (filterResult) { const customer = filterResults.find(function (filterResult) {
return Number(filterResult.id) === Number(customerId); return Number(filterResult.id) === Number(customerId);
}); });
@ -85,7 +85,7 @@ App.Pages.Customers = (function () {
* Event: Cancel Customer Add/Edit Operation Button "Click" * Event: Cancel Customer Add/Edit Operation Button "Click"
*/ */
$customers.on('click', '#cancel-customer', function () { $customers.on('click', '#cancel-customer', function () {
var id = $('#customer-id').val(); const id = $('#customer-id').val();
resetForm(); resetForm();
if (id) { if (id) {
select(id, true); select(id, true);
@ -96,7 +96,7 @@ App.Pages.Customers = (function () {
* Event: Save Add/Edit Customer Operation "Click" * Event: Save Add/Edit Customer Operation "Click"
*/ */
$customers.on('click', '#save-customer', function () { $customers.on('click', '#save-customer', function () {
var customer = { const customer = {
first_name: $('#first-name').val(), first_name: $('#first-name').val(),
last_name: $('#last-name').val(), last_name: $('#last-name').val(),
email: $('#email').val(), email: $('#email').val(),
@ -124,8 +124,8 @@ App.Pages.Customers = (function () {
* Event: Delete Customer Button "Click" * Event: Delete Customer Button "Click"
*/ */
$customers.on('click', '#delete-customer', function () { $customers.on('click', '#delete-customer', function () {
var customerId = $('#customer-id').val(); const customerId = $('#customer-id').val();
var buttons = [ const buttons = [
{ {
text: App.Lang.cancel, text: App.Lang.cancel,
click: function () { click: function () {
@ -181,7 +181,7 @@ App.Pages.Customers = (function () {
try { try {
// Validate required fields. // Validate required fields.
var missingRequired = false; let missingRequired = false;
$('.required').each(function (index, requiredField) { $('.required').each(function (index, requiredField) {
if ($(requiredField).val() === '') { if ($(requiredField).val() === '') {
@ -270,13 +270,14 @@ App.Pages.Customers = (function () {
return; return;
} }
var start = App.Utils.Date.format( const start = App.Utils.Date.format(
moment(appointment.start_datetime).toDate(), moment(appointment.start_datetime).toDate(),
App.Vars.date_format, App.Vars.date_format,
App.Vars.time_format, App.Vars.time_format,
true true
); );
var end = App.Utils.Date.format(
const end = App.Utils.Date.format(
moment(appointment.end_datetime).toDate(), moment(appointment.end_datetime).toDate(),
App.Vars.date_format, App.Vars.date_format,
App.Vars.time_format, App.Vars.time_format,
@ -383,9 +384,9 @@ App.Pages.Customers = (function () {
* @return {String} Returns the record HTML code. * @return {String} Returns the record HTML code.
*/ */
function getFilterHtml(customer) { function getFilterHtml(customer) {
var name = customer.first_name + ' ' + customer.last_name; const name = customer.first_name + ' ' + customer.last_name;
var info = customer.email; let info = customer.email;
info = customer.phone_number ? info + ', ' + customer.phone_number : info; info = customer.phone_number ? info + ', ' + customer.phone_number : info;