Skip to content

Conversation

@emilyluskin
Copy link

No description provided.

Copy link

@yuvalbenshitrit yuvalbenshitrit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code structure is clear, and you've followed good practices

const loader = document.querySelector('.loader');
loader.style.display = 'none';

detailsContainer.innerHTML = `

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure the use of backticks (``) for the innerHTML content

fetchCountryData(countryName);
}
else {
console.error('Country name not found');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Provide feedback to user if country name is not found

const displayCountryDetails = (country) => {
const detailsContainer = document.querySelector('.country-details');
const loader = document.querySelector('.loader');
loader.style.display = 'none';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hide loader after data is fetched

const dropdownWrapper = document.querySelector('.dropdown-wrapper');

if (dropdownWrapper.classList.contains('open')) {
dropdownWrapper.classList.remove('open');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Close dropdown after selection

});

const fetchCountryData = (countryName) => {
fetch('./CountriesData.json')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid calling fetch repeatedly for the same data (e.g., when filtering regions). Cache the data once:

dropdownWrapper.classList.remove('open');
}

const filterByRegion = (region) => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider displaying a loader while filtering data by region. This ensures the user is aware that a background process is ongoing.

}
});

const fetchCountryData = (countryName) => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Display a loader before fetching country data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants