From 96c77cd476586655b57cbdc833ae1faa3330a75c Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Fri, 18 Oct 2024 13:09:18 -0400 Subject: [PATCH] commented js --- src/registrar/assets/js/get-gov.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/registrar/assets/js/get-gov.js b/src/registrar/assets/js/get-gov.js index 5899328ec..f70c2f240 100644 --- a/src/registrar/assets/js/get-gov.js +++ b/src/registrar/assets/js/get-gov.js @@ -1910,22 +1910,22 @@ class MembersTable extends LoadTableBase { /** * Helper function which takes last_active and returns display value and sort value - * @param {*} last_active + * @param {*} last_active - UTC date, or strings "Invited" or "Invalid date" * @returns */ handleLastActive(last_active) { let last_active_display = ''; - let last_active_sort_value = -1; + let last_active_sort_value = -1; // sort by default as numeric value to sort with dates - const invited = 'Invited'; // Assuming "invited" is a constant string - const invalid_date = 'Invalid date'; // Assuming "invalid_date" is a constant string + const invited = 'Invited'; + const invalid_date = 'Invalid date'; const options = { year: 'numeric', month: 'long', day: 'numeric' }; // Format options for date - // Check if last_active is valid before proceeding + // Check if last_active is not null if (last_active) { if (last_active === invited) { last_active_display = invited; - last_active_sort_value = 0; + last_active_sort_value = 0; // sort as numeric value } else if (last_active === invalid_date) { last_active_display = invalid_date; } else { @@ -1934,11 +1934,11 @@ class MembersTable extends LoadTableBase { try { if (!isNaN(parsedDate.getTime())) { // Check if the date is valid last_active_display = parsedDate.toLocaleDateString('en-US', options); - last_active_sort_value = parsedDate.getTime(); // For sorting purposes + last_active_sort_value = parsedDate.getTime(); // sort as numeric value, seconds since 1970 } else { throw new Error(invalid_date); // Throw an error to catch in catch block } - } catch (e) { + } catch (e) { // catch invalid values and treat as 'Invalid date' console.error(`Error parsing date: ${last_active}. Error: ${e}`); last_active_display = invalid_date; }