From 10dbc65d202b7c8d42abad2e5e57d407e463feae Mon Sep 17 00:00:00 2001 From: mlnwns Date: Mon, 22 Jul 2024 20:21:56 +0900 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20=EB=A1=9C=EC=BB=AC=20=EC=9E=84?= =?UTF-8?q?=EC=9D=98=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FE/error/src/components/EconoCalendar.jsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/FE/error/src/components/EconoCalendar.jsx b/FE/error/src/components/EconoCalendar.jsx index bc7e0e4d..fc33e75d 100644 --- a/FE/error/src/components/EconoCalendar.jsx +++ b/FE/error/src/components/EconoCalendar.jsx @@ -89,8 +89,15 @@ const EconoCalendar = () => { setIsLoggedIn(false); setToken(null); } else { - window.location.href = "/login"; + const newToken = "dummyToken" + Math.random().toString(36).substr(2, 9); // 임의의 토큰 생성 + localStorage.setItem("slackToken", newToken); + setToken(newToken); + setIsLoggedIn(true); } + //TODO: 추후 아래 코드로 변경 + // } else { + // window.location.href = "/login"; + // } }; return ( From 16b1488baa2e19ae13982e069ad7f37c90f3a0bd Mon Sep 17 00:00:00 2001 From: mlnwns Date: Mon, 22 Jul 2024 20:53:32 +0900 Subject: [PATCH 2/3] =?UTF-8?q?feat:=20=EB=A1=9C=EA=B7=B8=EC=95=84?= =?UTF-8?q?=EC=9B=83=20=EC=8B=9C=20=ED=95=84=ED=84=B0=20=EC=98=81=EC=97=AD?= =?UTF-8?q?=20=EB=A0=8C=EB=8D=94=EB=A7=81=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FE/error/src/components/EconoCalendar.jsx | 20 +++++++++----------- FE/error/src/pages/MainPage.jsx | 3 ++- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/FE/error/src/components/EconoCalendar.jsx b/FE/error/src/components/EconoCalendar.jsx index fc33e75d..4ad12ca7 100644 --- a/FE/error/src/components/EconoCalendar.jsx +++ b/FE/error/src/components/EconoCalendar.jsx @@ -8,19 +8,17 @@ import axios from "axios"; import CreateModal from "./scheduleCreate/CreateModal"; import CheckCalendar from "./scheduleCheck/CheckCalendar"; -const EconoCalendar = () => { +const EconoCalendar = ({ isLoggedIn, setIsLoggedIn }) => { const [events, setEvents] = useState([]); const [selectID, setSelectID] = useState(""); const [checkModalIsOpen, setCheckModalIsOpen] = useState(false); const [createModalIsOpen, setCreateModalIsOpen] = useState(false); const [selectedDate, setSelectedDate] = useState(""); - const [isLoggedIn, setIsLoggedIn] = useState(false); const [token, setToken] = useState(null); useEffect(() => { const storedToken = localStorage.getItem("slackToken"); setToken(storedToken); - setIsLoggedIn(!!storedToken); }, []); useEffect(() => { @@ -88,16 +86,16 @@ const EconoCalendar = () => { localStorage.removeItem("slackToken"); setIsLoggedIn(false); setToken(null); + // } else { + // const newToken = "dummyToken" + Math.random().toString(36).substr(2, 9); // 임의의 토큰 생성 + // localStorage.setItem("slackToken", newToken); + // setToken(newToken); + // setIsLoggedIn(true); + // } + //TODO: 추후 아래 코드로 변경 } else { - const newToken = "dummyToken" + Math.random().toString(36).substr(2, 9); // 임의의 토큰 생성 - localStorage.setItem("slackToken", newToken); - setToken(newToken); - setIsLoggedIn(true); + window.location.href = "/login"; } - //TODO: 추후 아래 코드로 변경 - // } else { - // window.location.href = "/login"; - // } }; return ( diff --git a/FE/error/src/pages/MainPage.jsx b/FE/error/src/pages/MainPage.jsx index c8c88b41..c0d9dd7a 100644 --- a/FE/error/src/pages/MainPage.jsx +++ b/FE/error/src/pages/MainPage.jsx @@ -19,6 +19,7 @@ const MainPage = () => { const addNewIndividualFilter = (newIndividualFilter) => { setFilterIndividualLists([...filterIndividualLists, newIndividualFilter]); }; + const addNewGroupFilter = (newGroupFilter) => { setFilterGroupLists([...filterGroupLists, newGroupFilter]); }; @@ -46,7 +47,7 @@ const MainPage = () => { )} - + ); From d86de50a888484aec71e50241aed86ed1987c594 Mon Sep 17 00:00:00 2001 From: mlnwns Date: Mon, 22 Jul 2024 21:13:42 +0900 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20useEffect=20=ED=95=A8=EC=88=98=20?= =?UTF-8?q?=ED=95=98=EB=82=98=EB=A1=9C=20=ED=86=B5=ED=95=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FE/error/src/components/EconoCalendar.jsx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/FE/error/src/components/EconoCalendar.jsx b/FE/error/src/components/EconoCalendar.jsx index 4ad12ca7..814eae47 100644 --- a/FE/error/src/components/EconoCalendar.jsx +++ b/FE/error/src/components/EconoCalendar.jsx @@ -19,12 +19,15 @@ const EconoCalendar = ({ isLoggedIn, setIsLoggedIn }) => { useEffect(() => { const storedToken = localStorage.getItem("slackToken"); setToken(storedToken); - }, []); - useEffect(() => { - const uri = isLoggedIn ? "/api/calendar/all" : "/api/calendar/public/all"; - const config = isLoggedIn - ? { headers: { Authorization: `Bearer ${token}` } } + const isUserLoggedIn = !!storedToken; + setIsLoggedIn(isUserLoggedIn); + + const uri = isUserLoggedIn + ? "/api/calendar/all" + : "/api/calendar/public/all"; + const config = isUserLoggedIn + ? { headers: { Authorization: `Bearer ${storedToken}` } } : {}; axios @@ -42,7 +45,7 @@ const EconoCalendar = ({ isLoggedIn, setIsLoggedIn }) => { .catch((error) => { console.error("Error fetching events:", error); }); - }, [isLoggedIn, token]); + }, []); const handleDelete = () => { toast("일정이 삭제되었습니다", {