You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
851 B
24 lines
851 B
import { debounce } from './helpers';
|
|
|
|
// Synchronizes the "Email" input value with "Email login credentials to" input value
|
|
// based on the "Send welcome email" checkbox state on Add User page
|
|
export default function handleSyncEmailValues() {
|
|
const emailInput = document.querySelector('.js-sync-email-input');
|
|
const sendWelcomeEmailCheckbox = document.querySelector('.js-sync-email-checkbox');
|
|
const emailCredentialsToInput = document.querySelector('.js-sync-email-output');
|
|
|
|
if (!emailInput || !sendWelcomeEmailCheckbox || !emailCredentialsToInput) {
|
|
return;
|
|
}
|
|
|
|
function syncEmailValues() {
|
|
emailCredentialsToInput.value = sendWelcomeEmailCheckbox.checked ? emailInput.value : '';
|
|
}
|
|
|
|
emailInput.addEventListener(
|
|
'input',
|
|
debounce(() => syncEmailValues())
|
|
);
|
|
sendWelcomeEmailCheckbox.addEventListener('change', syncEmailValues);
|
|
}
|