From 5e8eb13bcff34f23385c27b451c8f46c79fc45ca Mon Sep 17 00:00:00 2001 From: CocoByte Date: Mon, 6 Jan 2025 18:15:05 -0700 Subject: [PATCH] Slight refactor to remove code duplication. --- .../assets/src/js/getgov/table-members.js | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/registrar/assets/src/js/getgov/table-members.js b/src/registrar/assets/src/js/getgov/table-members.js index 0b311751d..871006a48 100644 --- a/src/registrar/assets/src/js/getgov/table-members.js +++ b/src/registrar/assets/src/js/getgov/table-members.js @@ -417,24 +417,21 @@ export class MembersTable extends BaseTable { * @param {string} submit_delete_url - `${member_type}-${member_id}/delete` * @param {HTMLElement} wrapper_element - The element to which the modal is appended */ - static addMemberModal(num_domains, member_email, submit_delete_url, id, wrapper_element) { - let modalHeading = ''; - let modalDescription = ''; + static addMemberDeleteModal(num_domains, member_email, submit_delete_url, id, wrapper_element) { - if (num_domains == 0){ + let modalHeading = ``; + let modalDescription = ``; + + if (num_domains >= 0){ modalHeading = `Are you sure you want to delete ${member_email}?`; modalDescription = `They will no longer be able to access this organization. This action cannot be undone.`; - } else if (num_domains == 1) { - modalHeading = `Are you sure you want to delete ${member_email}?`; - modalDescription = `${member_email} currently manages ${num_domains} domain in the organization. - Removing them from the organization will remove all of their domains. They will no longer be able to - access this organization. This action cannot be undone.`; - } else if (num_domains > 1) { - modalHeading = `Are you sure you want to delete ${member_email}?`; - modalDescription = `${member_email} currently manages ${num_domains} domains in the organization. - Removing them from the organization will remove all of their domains. They will no longer be able to - access this organization. This action cannot be undone.`; + if (num_domains >= 1) + { + modalDescription = `${member_email} currently manages ${num_domains} domain${num_domains > 1 ? "s": ""} in the organization. + Removing them from the organization will remove all of their domains. They will no longer be able to + access this organization. This action cannot be undone.`; + } } const modalSubmit = `