Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fixes #37

Merged
merged 2 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions build/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"files": {
"main.css": "/static/css/main.93bbd3db.css",
"main.js": "/static/js/main.f6a172e9.js",
"main.js": "/static/js/main.bbddd460.js",
"static/js/787.b7a83069.chunk.js": "/static/js/787.b7a83069.chunk.js",
"static/media/map1.svg": "/static/media/map1.d959b0bd3dc709373454e7ffa70c98c5.svg",
"static/media/map4.svg": "/static/media/map4.b30cff7757376c8f288d0d15a6e9dc4c.svg",
"index.html": "/index.html",
"static/media/map2.svg": "/static/media/map2.868b139b87ec38365817bd132e0b3f5f.svg",
"main.93bbd3db.css.map": "/static/css/main.93bbd3db.css.map",
"main.f6a172e9.js.map": "/static/js/main.f6a172e9.js.map",
"main.bbddd460.js.map": "/static/js/main.bbddd460.js.map",
"787.b7a83069.chunk.js.map": "/static/js/787.b7a83069.chunk.js.map"
},
"entrypoints": [
"static/css/main.93bbd3db.css",
"static/js/main.f6a172e9.js"
"static/js/main.bbddd460.js"
]
}
2 changes: 1 addition & 1 deletion build/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>Air Quality</title><script defer="defer" src="/static/js/main.f6a172e9.js"></script><link href="/static/css/main.93bbd3db.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>Air Quality</title><script defer="defer" src="/static/js/main.bbddd460.js"></script><link href="/static/css/main.93bbd3db.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions build/static/js/main.bbddd460.js.map

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion build/static/js/main.f6a172e9.js.map

This file was deleted.

9 changes: 6 additions & 3 deletions src/components/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const StyledHome = styled.div`
`;

const Home = () => {
const airQualityParameters = ['pm25'];
const airQualityParameters = ['pm25', 'pm10'];
const dispatch = useDispatch();
const data = useSelector((state) => state.home.home);
const isLoading = useSelector((state) => state.home.isLoading);
Expand All @@ -34,6 +34,7 @@ const Home = () => {
const [searchKeyword, setSearchKeyword] = useState('');
const filteredData = data.filter(({ measurements }) => measurements.some(({ parameter }) => airQualityParameters.includes(parameter)));
const filteredLocations = filteredData.filter((location) => location.location.toLowerCase().includes(searchKeyword.toLowerCase()));
const isDataFetched = useSelector((state) => state.home.isDataFetched);

const toggleSearch = () => {
setIsSearchVisible(!isSearchVisible);
Expand All @@ -54,8 +55,10 @@ const Home = () => {
}, [dispatch]);

useEffect(() => {
dispatch(fetchData());
}, [dispatch]);
if (!isDataFetched) {
dispatch(fetchData());
}
}, [dispatch, isDataFetched]);

useEffect(() => {
}, [data]);
Expand Down
2 changes: 2 additions & 0 deletions src/redux/home/homeSlice.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const initialState = {
home: [],
isLoading: false,
error: undefined,
isDataFetched: false,
};

const homeSlice = createSlice({
Expand Down Expand Up @@ -43,6 +44,7 @@ const homeSlice = createSlice({
.addCase(fetchData.fulfilled, (state, action) => {
state.isLoading = false;
state.home = action.payload.results;
state.isDataFetched = true;
})
.addCase(fetchData.rejected, (state, action) => {
state.isLoading = false;
Expand Down