Skip to content

Commit

Permalink
Merge pull request #147 from JNU-econovation/FE
Browse files Browse the repository at this point in the history
Fe
  • Loading branch information
capDoYeonLee authored Jul 23, 2024
2 parents 9b4966b + bf6afd4 commit 2dc2907
Show file tree
Hide file tree
Showing 17 changed files with 491 additions and 204 deletions.
Binary file added FE/error/public/Profile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added FE/error/public/seed0838.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
74 changes: 0 additions & 74 deletions FE/error/src/axiosConfig.js
Original file line number Diff line number Diff line change
@@ -1,80 +1,6 @@
import axios from "axios";
import { useNavigate } from "react-router-dom";

// Axios 기본 설정
axios.defaults.baseURL = import.meta.env.VITE_ERROR_API;
axios.defaults.headers.common["Content-Type"] = "application/json";
axios.defaults.withCredentials = true;

let isRefreshing = false;
let refreshSubscribers = [];

const onRefreshed = (token) => {
refreshSubscribers.map((cb) => cb(token));
};

const addRefreshSubscriber = (cb) => {
refreshSubscribers.push(cb);
};

axios.interceptors.request.use(
(config) => {
const token = localStorage.getItem("slackToken");
if (token) {
config.headers["Authorization"] = `Bearer ${token}`;
}
return config;
},
(error) => {
return Promise.reject(error);
}
);

axios.interceptors.response.use(
(response) => {
return response;
},
async (error) => {
const originalRequest = error.config;
if (error.response.status === 401 && !originalRequest._retry) {
if (isRefreshing) {
return new Promise((resolve) => {
addRefreshSubscriber((token) => {
originalRequest.headers["Authorization"] = "Bearer " + token;
resolve(axios(originalRequest));
});
});
}

originalRequest._retry = true;
isRefreshing = true;

const refreshToken = localStorage.getItem("refreshToken");

return new Promise((resolve, reject) => {
axios
.post("/auth/reissue", { refreshToken: refreshToken })
.then(({ data }) => {
const newToken = data.data.accessToken;
localStorage.setItem("slackToken", newToken);
axios.defaults.headers.common["Authorization"] =
"Bearer " + newToken;
originalRequest.headers["Authorization"] = "Bearer " + newToken;
onRefreshed(newToken);
resolve(axios(originalRequest));
})
.catch((err) => {
reject(err);
useNavigate().push("/login");
})
.finally(() => {
isRefreshing = false;
refreshSubscribers = [];
});
});
}
return Promise.reject(error);
}
);

export default axios;
8 changes: 7 additions & 1 deletion FE/error/src/components/DeleteEvent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
12 changes: 6 additions & 6 deletions FE/error/src/components/EconoCalendar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,10 @@ const EconoCalendar = ({ isLoggedIn, setIsLoggedIn }) => {

const uri = isUserLoggedIn
? "/api/calendar/all"
: "/api/calendar/public/all";
const config = isUserLoggedIn
? { headers: { Authorization: `Bearer ${storedToken}` } }
: {};
: "/api/calendar/all/public";

axios
.get(uri, config)
.get(uri, { headers: { Authorization: `Bearer ${storedToken}` } })
.then((res) => {
const fetchedEvents = res.data.data.map((event) => ({
title: event.eventName,
Expand Down Expand Up @@ -292,7 +289,7 @@ const CalendarContainer = styled.div`
background-color: #fff;
border-color: #cbcbcb;
color: #595959;
margin-right: 0.7rem;
margin-right: 1rem;
}
.fc-event-title-container {
height: 1.3rem;
Expand All @@ -301,4 +298,7 @@ const CalendarContainer = styled.div`
font-size: 0.95rem;
margin-left: 0.3rem;
}
.fc-direction-ltr .fc-toolbar > * > :not(:first-child) {
margin-left: 0.5rem;
}
`;
60 changes: 57 additions & 3 deletions FE/error/src/components/SideBar/ProfileBar.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,66 @@
import styled from "styled-components";
import { useState } from "react";
import { HiPencil } from "react-icons/hi2";
import { useNavigate } from "react-router-dom";

const ProfileBar = () => {
return <StyledProfileFrame></StyledProfileFrame>;
const [isHovered, setIsHovered] = useState(false);
const navigate = useNavigate();

const handleProfileClick = () => {
navigate("/profile");
};

return (
<StyledProfileFrame>
<ProfileImageContainer
onMouseEnter={() => setIsHovered(true)}
onMouseLeave={() => setIsHovered(false)}
onClick={handleProfileClick}
>
<ProfileImage src="seed0838.png" alt="Profile" />
{isHovered && (
<EditIconOverlay>
<HiPencil />
</EditIconOverlay>
)}
</ProfileImageContainer>
</StyledProfileFrame>
);
};

export default ProfileBar;

const StyledProfileFrame = styled.div`
width: 20rem;
height: 18.4375rem;
width: 15.625rem;
height: 15rem;
align-items: center;
display: flex;
flex-direction: column;
margin-bottom: 0.6rem;
`;

const ProfileImageContainer = styled.div`
position: relative;
cursor: pointer;
`;

const ProfileImage = styled.img`
margin-top: 1.25rem;
width: 13rem;
`;

const EditIconOverlay = styled.div`
position: absolute;
top: 1rem;
left: 0;
right: 0;
bottom: 0;
border-radius: 50%;
background-color: rgba(0, 0, 0, 0.5);
display: flex;
justify-content: center;
align-items: center;
color: white;
font-size: 2rem;
`;
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import styled from "styled-components";
import FilterCreateModal from "../../../utils/filterUtils/FilterCreateModal";
import FilterList from "../../../utils/filterUtils/FilterList";

const IndividualFilter = ({ filterLists, addNewFilter }) => {
const IndividualFilter = ({
filterLists,
addNewFilter,
updateDeleteFilter,
}) => {
const [individualFilterIsOpen, setindividualFilterIsOpen] = useState(false);
const [filterListsIsOpen, setFilterListsIsOpen] = useState(true);
const createIndividualFilter = () => {
Expand All @@ -16,6 +20,7 @@ const IndividualFilter = ({ filterLists, addNewFilter }) => {
const handleArrowDown = () => {
setFilterListsIsOpen(!filterListsIsOpen);
};

return (
<>
<StyledIndividualFilterFrame>
Expand Down Expand Up @@ -60,7 +65,12 @@ const IndividualFilter = ({ filterLists, addNewFilter }) => {
/>
</StyledDetailIcon>
</StyledIndividualFilterFrame>
{filterListsIsOpen && <FilterList filterLists={filterLists} />}
{filterListsIsOpen && (
<FilterList
filterLists={filterLists}
updateDeleteFilter={updateDeleteFilter}
/>
)}
</>
);
};
Expand Down
27 changes: 16 additions & 11 deletions FE/error/src/components/scheduleCheck/CheckCalendar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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) {
Expand Down
Loading

0 comments on commit 2dc2907

Please sign in to comment.