From de3098d4826679ec097bfe0bd89dfe84d6762311 Mon Sep 17 00:00:00 2001 From: kanghaeun Date: Tue, 23 Jul 2024 19:27:15 +0900 Subject: [PATCH 1/5] =?UTF-8?q?feat:=20=EC=82=AD=EC=A0=9C,=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20=ED=97=A4=EB=8D=94=EC=97=90=20=ED=86=A0=ED=81=B0=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/DeleteEvent.jsx | 8 +++++++- FE/error/src/components/EconoCalendar.jsx | 2 -- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/FE/error/src/components/DeleteEvent.jsx b/FE/error/src/components/DeleteEvent.jsx index b69a7826..3a6e16c4 100644 --- a/FE/error/src/components/DeleteEvent.jsx +++ b/FE/error/src/components/DeleteEvent.jsx @@ -7,9 +7,15 @@ const DeleteEvent = ({ onRequestClose, handleUpdateDeleteData, }) => { + const storedToken = localStorage.getItem("slackToken"); + const calendarDelete = () => { axios - .delete("/api/calendar/" + selectID) + .delete(`/api/calendar/${selectID}`, { + headers: { + Authorization: `Bearer ${storedToken}`, + }, + }) .then(() => { handleUpdateDeleteData(selectID); handleDelete(); diff --git a/FE/error/src/components/EconoCalendar.jsx b/FE/error/src/components/EconoCalendar.jsx index 6d5b4bbf..2ef9ff58 100644 --- a/FE/error/src/components/EconoCalendar.jsx +++ b/FE/error/src/components/EconoCalendar.jsx @@ -14,11 +14,9 @@ const EconoCalendar = ({ isLoggedIn, setIsLoggedIn }) => { const [checkModalIsOpen, setCheckModalIsOpen] = useState(false); const [createModalIsOpen, setCreateModalIsOpen] = useState(false); const [selectedDate, setSelectedDate] = useState(""); - const [token, setToken] = useState(null); useEffect(() => { const storedToken = localStorage.getItem("slackToken"); - setToken(storedToken); const isUserLoggedIn = !!storedToken; setIsLoggedIn(isUserLoggedIn); From d02765c034bc21f97a0dd3b03eabba305fc986b9 Mon Sep 17 00:00:00 2001 From: kanghaeun Date: Tue, 23 Jul 2024 20:30:36 +0900 Subject: [PATCH 2/5] =?UTF-8?q?feat:=20=ED=95=84=ED=84=B0=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C,=EC=83=9D=EC=84=B1=20=ED=97=A4=EB=8D=94=EC=97=90=20?= =?UTF-8?q?=ED=86=A0=ED=81=B0=20=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 | 16 ++++++++-------- FE/error/src/pages/MainPage.jsx | 7 +++++-- .../utils/filterUtils/FilterCreateModal.jsx | 19 ++++++++++++------- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/FE/error/src/components/EconoCalendar.jsx b/FE/error/src/components/EconoCalendar.jsx index 2ef9ff58..910d93c8 100644 --- a/FE/error/src/components/EconoCalendar.jsx +++ b/FE/error/src/components/EconoCalendar.jsx @@ -87,16 +87,16 @@ const EconoCalendar = ({ isLoggedIn, setIsLoggedIn }) => { 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 { - 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 ( diff --git a/FE/error/src/pages/MainPage.jsx b/FE/error/src/pages/MainPage.jsx index 2e487908..a3f49eb9 100644 --- a/FE/error/src/pages/MainPage.jsx +++ b/FE/error/src/pages/MainPage.jsx @@ -11,7 +11,6 @@ const MainPage = () => { const [filterIndividualLists, setFilterIndividualLists] = useState([]); const [filterGroupLists, setFilterGroupLists] = useState([]); const [isLoggedIn, setIsLoggedIn] = useState(false); - useEffect(() => { const token = localStorage.getItem("slackToken"); setIsLoggedIn(!!token); @@ -29,11 +28,15 @@ const MainPage = () => { filterIndividualLists.filter((filter) => filter.filterId !== newFilter) ); }; + const storedToken = localStorage.getItem("slackToken"); useEffect(() => { axios - .get("/api/calendar/filter/all") + .get("/api/filter", { + headers: { Authorization: `Bearer ${storedToken}` }, + }) .then((res) => { + console.log(res); const fetchedFilter = res.data.data.map((filter) => ({ filterId: filter.filterId, filterName: filter.filterName, diff --git a/FE/error/src/utils/filterUtils/FilterCreateModal.jsx b/FE/error/src/utils/filterUtils/FilterCreateModal.jsx index c1c16f49..e7f21efe 100644 --- a/FE/error/src/utils/filterUtils/FilterCreateModal.jsx +++ b/FE/error/src/utils/filterUtils/FilterCreateModal.jsx @@ -15,7 +15,7 @@ const FilterCreateModal = ({ }) => { const [filterTitle, setFilterTitle] = useState(""); const [filterColor, setFilterColor] = useState(""); - + const storedToken = localStorage.getItem("slackToken"); const handleTitleChange = (event) => { setFilterTitle(event.target.value); }; @@ -24,12 +24,17 @@ const FilterCreateModal = ({ filterName: filterTitle, filterColor: filterColor, }; - //axios.post("/api/filter", newFilter).then((res) => { - addNewFilter(newFilter); - setFilterTitle(""); - setFilterColor(""); - onRequestClose(); - //}); + axios + .post("/api/filter", newFilter, { + headers: { Authorization: `Bearer ${storedToken}` }, + }) + .then((res) => { + console.log(res); + addNewFilter(newFilter); + setFilterTitle(""); + setFilterColor(""); + onRequestClose(); + }); }; return ( From fc596b2f735b20187e91240fd9ba5f9f5e73488a Mon Sep 17 00:00:00 2001 From: kanghaeun Date: Tue, 23 Jul 2024 20:32:19 +0900 Subject: [PATCH 3/5] =?UTF-8?q?feat:=20=ED=95=84=ED=84=B0=EC=88=98?= =?UTF-8?q?=EC=A0=95=20=ED=97=A4=EB=8D=94=20=ED=86=A0=ED=81=B0=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FE/error/src/utils/filterUtils/FilterModify.jsx | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/FE/error/src/utils/filterUtils/FilterModify.jsx b/FE/error/src/utils/filterUtils/FilterModify.jsx index d329b815..df6a961b 100644 --- a/FE/error/src/utils/filterUtils/FilterModify.jsx +++ b/FE/error/src/utils/filterUtils/FilterModify.jsx @@ -16,6 +16,7 @@ const FilterModify = ({ filterName, filterID }) => { setClickPosition({ x: rect.left, y: rect.top }); setShowModal(true); }; + const storedToken = localStorage.getItem("slackToken"); const handleTitleChange = (event) => { setFilterTitle(event.target.value); @@ -26,10 +27,18 @@ const FilterModify = ({ filterName, filterID }) => { filterName: filterTitle, filterColor: filterColor, }; - axios.post("/api/calendar/filter/" + filterID, modifyFilter).then((res) => { - setShowModal(false); - window.location.reload(); - }); + axios + .post( + "/api/calendar/filter/" + filterID, + { + headers: { Authorization: `Bearer ${storedToken}` }, + }, + modifyFilter + ) + .then((res) => { + setShowModal(false); + window.location.reload(); + }); }; const customStyles = { From 98b55fb71ca26b2aab0d34f0f8fd1c6d508ee73b Mon Sep 17 00:00:00 2001 From: kanghaeun Date: Tue, 23 Jul 2024 20:33:12 +0900 Subject: [PATCH 4/5] =?UTF-8?q?feat:=20=ED=95=84=ED=84=B0=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C=20=ED=97=A4=EB=8D=94=20=ED=86=A0=ED=81=B0=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FE/error/src/utils/filterUtils/FilterDelete.jsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/FE/error/src/utils/filterUtils/FilterDelete.jsx b/FE/error/src/utils/filterUtils/FilterDelete.jsx index ba23192e..ead17085 100644 --- a/FE/error/src/utils/filterUtils/FilterDelete.jsx +++ b/FE/error/src/utils/filterUtils/FilterDelete.jsx @@ -3,10 +3,16 @@ import styled from "styled-components"; import axios from "axios"; const FilterDelete = ({ filterID, updateDeleteFilter }) => { + const storedToken = localStorage.getItem("slackToken"); + const handleDelete = () => { - axios.delete("/api/filter/" + filterID).then(() => { - updateDeleteFilter(filterID); - }); + axios + .delete("/api/filter/" + filterID, { + headers: { Authorization: `Bearer ${storedToken}` }, + }) + .then(() => { + updateDeleteFilter(filterID); + }); }; return ( <> From 03b4f5cfe2bbafca13b5d44140c53b0c04cdf18e Mon Sep 17 00:00:00 2001 From: kanghaeun Date: Tue, 23 Jul 2024 20:37:58 +0900 Subject: [PATCH 5/5] =?UTF-8?q?feat:=20=ED=97=A4=EB=8D=94=EC=97=90=20?= =?UTF-8?q?=ED=86=A0=ED=81=B0=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scheduleCheck/CheckCalendar.jsx | 27 +++++++++++-------- .../components/scheduleCreate/CreateModal.jsx | 27 ++++++++++++------- FE/error/src/pages/CalendarModify.jsx | 9 ++++++- FE/error/src/pages/ProfilePage.jsx | 5 +++- 4 files changed, 46 insertions(+), 22 deletions(-) diff --git a/FE/error/src/components/scheduleCheck/CheckCalendar.jsx b/FE/error/src/components/scheduleCheck/CheckCalendar.jsx index 8fe3df22..2424f0b8 100644 --- a/FE/error/src/components/scheduleCheck/CheckCalendar.jsx +++ b/FE/error/src/components/scheduleCheck/CheckCalendar.jsx @@ -21,6 +21,7 @@ const CheckCalendar = ({ handleUpdateDeleteData, }) => { const [event, setEvent] = useState({}); + const storedToken = localStorage.getItem("slackToken"); function createDate(title, startDate, endDate, place, info, type, color) { const specificEvent = { @@ -42,17 +43,21 @@ const CheckCalendar = ({ return; } - axios.get("/api/calendar/" + selectID).then((res) => { - createDate( - res.data.data.eventName, - res.data.data.eventStartDate, - res.data.data.eventEndDate, - res.data.data.eventPlace, - res.data.data.eventInfo, - res.data.data.eventType, - res.data.data.filterColor - ); - }); + axios + .get("/api/calendar/" + selectID, { + headers: { Authorization: `Bearer ${storedToken}` }, + }) + .then((res) => { + createDate( + res.data.data.eventName, + res.data.data.eventStartDate, + res.data.data.eventEndDate, + res.data.data.eventPlace, + res.data.data.eventInfo, + res.data.data.eventType, + res.data.data.filterColor + ); + }); }, [selectID]); function date(startDate, endDate) { diff --git a/FE/error/src/components/scheduleCreate/CreateModal.jsx b/FE/error/src/components/scheduleCreate/CreateModal.jsx index ae74644c..e1c5103e 100644 --- a/FE/error/src/components/scheduleCreate/CreateModal.jsx +++ b/FE/error/src/components/scheduleCreate/CreateModal.jsx @@ -29,6 +29,7 @@ const CreateModal = ({ const [eventEndTime, setEventEndTime] = useState("00:00"); const [selectedFilter, setSelectedFilter] = useState(null); const [activeDropdown, setActiveDropdown] = useState(null); + const storedToken = localStorage.getItem("slackToken"); useEffect(() => { if (isOpen && selectedDate) { @@ -160,15 +161,23 @@ const CreateModal = ({ }, }; - axios.post("/api/calendar", data).then((res) => { - createDate( - eventName, - res.data.data.eventId, - eventStartDate, - eventEndDate - ); - onRequestClose(); - }); + axios + .post( + "/api/calendar", + { + headers: { Authorization: `Bearer ${storedToken}` }, + }, + data + ) + .then((res) => { + createDate( + eventName, + res.data.data.eventId, + eventStartDate, + eventEndDate + ); + onRequestClose(); + }); }; return ( diff --git a/FE/error/src/pages/CalendarModify.jsx b/FE/error/src/pages/CalendarModify.jsx index 614361f6..58c92628 100644 --- a/FE/error/src/pages/CalendarModify.jsx +++ b/FE/error/src/pages/CalendarModify.jsx @@ -10,6 +10,7 @@ const CalendarModify = () => { const navigate = useNavigate(); const location = useLocation(); const selectID = location.state.selectID; + const storedToken = localStorage.getItem("slackToken"); const [modifyName, setModifyName] = useState(""); const [modifyStartDate, setModifyStartDate] = useState(""); @@ -75,7 +76,13 @@ const CalendarModify = () => { eventPlace: modifyPlace, }; axios - .put("/api/calendar/" + selectID, eventData) + .put( + "/api/calendar/" + selectID, + { + headers: { Authorization: `Bearer ${storedToken}` }, + }, + eventData + ) .then((res) => { goBack(); }) diff --git a/FE/error/src/pages/ProfilePage.jsx b/FE/error/src/pages/ProfilePage.jsx index 64f7b319..d1f72533 100644 --- a/FE/error/src/pages/ProfilePage.jsx +++ b/FE/error/src/pages/ProfilePage.jsx @@ -7,11 +7,14 @@ const ProfilePage = () => { const [selectedImage, setSelectedImage] = useState(null); const [images, setImages] = useState([]); const [isLoading, setIsLoading] = useState(true); + const storedToken = localStorage.getItem("slackToken"); useEffect(() => { const fetchImages = async () => { try { - const response = await axios.get("http://localhost:8080/api/images"); + const response = await axios.get("http://localhost:8080/api/images", { + headers: { Authorization: `Bearer ${storedToken}` }, + }); setImages(response.data); setIsLoading(false); } catch (error) {