Skip to content

Commit

Permalink
add view
Browse files Browse the repository at this point in the history
  • Loading branch information
Tatyana-js committed Oct 31, 2024
1 parent f9d46c3 commit 04d8409
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions src/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,22 @@ export default (elements, i18n, state) => {
modalLink.url = url;
};

const renderFinishedProcess = () => {
const { staticEl, input, errorElement } = elements;
staticEl.button.disabled = false;
input.classList.remove('is-invalid');
errorElement.classList.remove('text-danger');
errorElement.classList.add('text-success');
errorElement.textContent = t('feedback');
};

const renderInvalidRSS = () => {
const { errorElement } = elements;
errorElement.classList.remove('text-success');
errorElement.classList.add('text-danger');
errorElement.textContent = t('errors.invalidRSS');
};

const watchedState = onChange(state, (path, value, previousValue) => {
const {
errorElement, input, form, staticEl,
Expand All @@ -115,11 +131,7 @@ export default (elements, i18n, state) => {
staticEl.button.disabled = true;
errorElement.textContent = '';
} else if (value === 'finished') {
staticEl.button.disabled = false;
input.classList.remove('is-invalid');
errorElement.classList.remove('text-danger');
errorElement.classList.add('text-success');
errorElement.textContent = t('feedback');
renderFinishedProcess();
form.reset();
input.focus();
renderFeeds();
Expand All @@ -132,9 +144,7 @@ export default (elements, i18n, state) => {
errorElement.textContent = t('errors.networkError');
}
if (value === 'invalidRSS') {
errorElement.classList.remove('text-success');
errorElement.classList.add('text-danger');
errorElement.textContent = t('errors.invalidRSS');
renderInvalidRSS();
}
break;
case 'posts':
Expand Down

0 comments on commit 04d8409

Please sign in to comment.