export const loaderHandler = (action: string) => { if (!action) { throw Error('"setDisabledButton function - "You didn\'t add required parameters'); } const loader = document.querySelector('.js-accessible-docs-admin-loader') as HTMLElement | null; if (loader) { loader.classList[action]('active'); } }; export const setDisabledButton = (selector: string, disabled: boolean) => { if (!selector) { throw Error('"setDisabledButton function - "You didn\'t add required parameters'); } const button = document.querySelector(selector); if (button) { button.disabled = disabled; } }; export const returnCheckedDocumentsIds = () => { const checkboxes = document.querySelectorAll('.js-accessible-docs-id'); if (checkboxes.length > 0) { const checkedValues = Array.from(checkboxes) .filter(checkbox => checkbox.checked) .map(checkbox => checkbox.value); return checkedValues.length ? checkedValues : false; } return false; }; /** * Displays an error alert and hides the loader loader if present. * * @param {string} errorText - The error message to be displayed. */ export const showErrorAlert = (errorText: string) => { loaderHandler('remove'); if (errorText) { alert(errorText); } }