Skip to content

Commit

Permalink
๐Ÿ› Fix: ๊ธฐ๊ฐ„ ์ง์ ‘ ์„ค์ • ํ•€ ํ•„ํ„ฐ๋ง ๊ด€๋ จ ๋กœ์ง ์ˆ˜์ •
Browse files Browse the repository at this point in the history
  • Loading branch information
billy0904 committed Aug 21, 2024
1 parent 7d73781 commit 98d1335
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const defaultLevel = 3;

function App() {
const [allPins, setAllPins] = useState([]);
const [term, setTerm] = useState(null);
const [recentPins, setRecentPins] = useState([]);
const [isLoggedIn, setIsLoggedIn] = useState(false);
const [loginModal, setLoginModal] = useState(false);
Expand Down Expand Up @@ -120,6 +121,7 @@ function App() {
};
const data = await postAllMarkers(request);
setAllPins(data.mapPlaceSet || []);
setTerm("ALL");
} catch (error) {
console.error("Error fetching all pin data:", error);
}
Expand All @@ -145,6 +147,7 @@ function App() {
const data = await postAllMarkers(request);
setAllPins(data.mapPlaceSet || []);
setRecentPins([]);
setTerm("ALL");
} else if (term === "1week" || term === "1month" || term === "3months") {
const periodMap = {
"1week": "week",
Expand All @@ -167,6 +170,7 @@ function App() {
};
const data = await postRecentMarkers(request);
setRecentPins(data.mapPlaceSet || []);
setTerm("NOTALL");
}
};

Expand All @@ -187,6 +191,7 @@ function App() {
};
const data = await postCustomPeriodMarkers(request);
setRecentPins(data.mapPlaceSet || []);
setTerm("NOTALL");
};

return (
Expand All @@ -208,6 +213,7 @@ function App() {
<MapLayout
allPins={allPins}
recentPins={recentPins}
term={term}
handleFilterChange={handleFilterChange}
handleFilterChange2={handleFilterChange2}
isLoggedIn={isLoggedIn}
Expand Down Expand Up @@ -279,6 +285,7 @@ export default App;
function MapLayout({
allPins,
recentPins,
term,
handleFilterChange,
handleFilterChange2,
isLoggedIn,
Expand Down Expand Up @@ -328,8 +335,14 @@ function MapLayout({
const data = await getMyPins(memberId);
setPinsToDisplay(data.mapPlaceSet || []);
} else {
const pins = recentPins.length >= 0 ? recentPins : allPins;
setPinsToDisplay(pins);
if (term !== "ALL") {
const pins = recentPins.length > 0 ? recentPins : [];
setPinsToDisplay(pins);
}
else {
const pins = allPins;
setPinsToDisplay(pins);
}
}
setMapKey(Date.now()); // ํ•€์„ ๋ถˆ๋Ÿฌ์˜จ ํ›„ ๋งต ์ƒˆ๋กœ๊ณ ์นจ
} catch (error) {
Expand Down

0 comments on commit 98d1335

Please sign in to comment.