To keep the code DRY I would have made the functions being used in the files below reusable
- UserDashboardContainer.js,
- PinnedCitiesContainer.js
- CitySearchResultContainer.js
const deleteNotification = () => {
notification.open({
message: 'City Removed',
description: `${cityAndState.city}, ${cityAndState.state}
has been has been removed from Pinned Cities.`,
});
};
const handleRemoveCity = id => {
unpinCity(localStorage.getItem('token'), id);
deleteNotification();
fetchSavedCity(localStorage.getItem('token'));
window.location.reload();
};
const handleOnCityClick = cityAndState => {
localStorage.setItem('cityAndState', JSON.stringify(cityAndState));
setCityAndState(localStorage.getItem('cityAndState'));
push(`/pinned/${cityAndState.state}/${cityAndState.city}`);
};
Right now you have to enter specifically city, state initials ex. New York, NY (any rendition lowercase, capitalize or uppercase) in the search bar.
- If you entered the state spelled out (ex. Miami)
- If the user search for a city that does not exists
- If there is a typo
When the user pins a city or clicks on the view city from the dashboard of pinned cities they are only supposed to see the pinned city that was pinned/clicked but right now it shows a list of all the cities pinned.
The user should only be able to pin a city to their pinned cities once.