Skip to content

Commit 59b0d8e

Browse files
Merge pull request #194 from gnims-project/dev
Upload/Main Merge #100
2 parents 3056cbf + 51c4750 commit 59b0d8e

30 files changed

+335
-418
lines changed

src/api/ScheduleApi.jsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ export const ScheduleApi = {
44
//스케줄 전체 조회
55
getSccheduleApi: (payload) => {
66
//const data = instance.get(`/v2-dto/users/${payload}/events`);
7-
const data = instance.get(`/users/${payload}/events`);
7+
const data = instance.get(
8+
`/v2/users/${payload.userId}/events?sortedBy=${payload.sortedBy}`
9+
);
810
return data;
911
},
1012

1113
getInfiniteScrollPage: (payload) => {
1214
const data = instance.get(
13-
`/v2-page/users/${payload.userId}/events?page=${payload.page}&size=${3}`
15+
`/v2/users/${payload.userId}/events?page=${payload.page}&size=${3}`
1416
);
1517
return data;
1618
},

src/components/follow/FollowerCard.jsx

+10-4
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,18 @@ const FollowerCard = ({ follower }) => {
5050
</div>
5151
</div>
5252
{isFollowed ? (
53-
<div className="flex items-center w-[62px] h-[39px] justify-center text-sm rounded-[4px] text-white bg-[#002C51]">
54-
<span onClick={handleClick}>팔로우</span>
53+
<div
54+
onClick={handleClick}
55+
className="flex items-center w-[62px] h-[39px] cursor-pointer justify-center text-sm rounded-[4px] text-white bg-[#002C51]"
56+
>
57+
팔로우
5558
</div>
5659
) : (
57-
<div className="flex items-center w-[62px] h-[39px] justify-center text-sm rounded-[4px] text-white bg-[#A31414]">
58-
<span onClick={handleClick}>삭제</span>
60+
<div
61+
onClick={handleClick}
62+
className="flex items-center w-[62px] h-[39px] cursor-pointer justify-center text-sm rounded-[4px] text-white bg-[#A31414]"
63+
>
64+
삭제
5965
</div>
6066
)}
6167
</div>

src/components/follow/FollowingCard.jsx

+10-4
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,18 @@ const FollowingCard = ({ following }) => {
5050
</div>
5151
</div>
5252
{isFollowed ? (
53-
<div className="flex items-center w-[62px] h-[39px] justify-center text-sm rounded-[4px] text-white bg-[#A31414] cursor-pointer">
54-
<span onClick={handleClick}>삭제</span>
53+
<div
54+
onClick={handleClick}
55+
className="flex items-center w-[62px] h-[39px] justify-center text-sm rounded-[4px] text-white bg-[#A31414] cursor-pointer"
56+
>
57+
삭제
5558
</div>
5659
) : (
57-
<div className="flex items-center w-[62px] h-[39px] justify-center text-sm rounded-[4px] text-white bg-[#002C51] cursor-pointer">
58-
<span onClick={handleClick}>팔로우</span>
60+
<div
61+
onClick={handleClick}
62+
className="flex items-center w-[62px] h-[39px] justify-center text-sm rounded-[4px] text-white bg-[#002C51] cursor-pointer"
63+
>
64+
팔로우
5965
</div>
6066
)}
6167
</div>

src/components/follow/UserSearch.jsx

+2-6
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const UserSearch = () => {
2525
setUser(() => userInfo);
2626
setLoading(false);
2727
} catch (e) {
28-
console.log("api 호출 실패");
28+
// console.log("api 호출 실패");
2929
}
3030
}, time);
3131

@@ -51,11 +51,7 @@ const UserSearch = () => {
5151
handleSearch(userSearchName.current.value);
5252
}}
5353
>
54-
<img
55-
className="absolute top-[15px] right-[15px]"
56-
src={searchIcon}
57-
alt="돋보기 아이콘"
58-
/>
54+
<img className="absolute top-[15px] right-[15px]" src={searchIcon} alt="돋보기 아이콘" />
5955
</div>
6056
</div>
6157
<div className="px-[20px]">

src/components/layout/TopNavBar.jsx

+8-16
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,10 @@ import { instance } from "../../shared/AxiosInstance";
88
import Point from "../../img/point.png";
99
import { EventSourcePolyfill } from "event-source-polyfill";
1010
import NotificationModal from "../modal/NotificationModal";
11-
import { useDispatch } from "react-redux";
1211

1312
const TopNavBar = () => {
1413
const navigate = useNavigate();
15-
const dispatch = useDispatch();
1614
const [content, setContent] = useState("");
17-
1815
const [open, setOpen] = useState(false);
1916
const [allchecked, setAllChecked] = useState("");
2017

@@ -36,36 +33,32 @@ const TopNavBar = () => {
3633
headers: {
3734
Authorization: sessionStorage.getItem("accessToken"),
3835
},
39-
// withCredentials: true,
4036
});
41-
// SSE 연결 성공 시 호출되는 이벤트 핸들러
42-
eventSource.onopen = () => {
43-
// console.log("SSE 연결완료");
44-
};
37+
38+
eventSource.onopen = () => {};
4539
eventSource.onmessage = async function (event) {
4640
const data = JSON.parse(event.data);
4741
const message = data.message;
4842
setContent(message);
4943
setOpen(true);
50-
// handleModalOpen(message);
51-
await setAllChecked("");
5244
};
5345
eventSource.addEventListener("follow", async (e) => {
5446
const data = JSON.parse(e.data);
5547
const message = data.message;
5648
setContent(message);
5749
setOpen(true);
58-
// handleModalOpen(message);
59-
60-
await setAllChecked("");
6150
});
6251
eventSource.addEventListener("invite", async (e) => {
6352
const data = JSON.parse(e.data);
6453
const message = data.message;
6554
setContent(message);
66-
// handleModalOpen(message);
6755
setOpen(true);
68-
await setAllChecked("");
56+
});
57+
eventSource.addEventListener("invite_response", async (e) => {
58+
const data = JSON.parse(e.data);
59+
const message = data.message;
60+
setContent(message);
61+
setOpen(true);
6962
});
7063
} catch (error) {
7164
if (eventSource) eventSource.close();
@@ -77,7 +70,6 @@ const TopNavBar = () => {
7770
//컴포넌트가 언마운트될 때 eventSource를 닫음
7871
return () => {
7972
eventSource && eventSource.close();
80-
// console.log("event source closed.");
8173
};
8274
}, []);
8375

src/components/login/EmailLogin.jsx

+6-3
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const EmailLogin = () => {
3838
//이메일, 비밀번호 정규 표현식
3939
const emailRegulationExp =
4040
/^[a-zA-Z0-9+-\_.]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$/;
41-
const passwordRegulationExp = /^(?=.*[a-zA-Z])(?=.*\d)[a-zA-Z\d]{8,16}$/;
41+
const passwordRegulationExp = /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,16}$/;
4242

4343
//유효성검사
4444
const onValidity = (event) => {
@@ -80,6 +80,9 @@ const EmailLogin = () => {
8080

8181
const onMoalClose = () => {
8282
dispatch(__closeModal());
83+
if (sessionStorage.getItem("userId")) {
84+
navigate("/main");
85+
}
8386
};
8487

8588
//서버에 전달
@@ -120,7 +123,6 @@ const EmailLogin = () => {
120123
setModalStr,
121124
})
122125
);
123-
onSubmit();
124126
};
125127

126128
//카카오 로그인
@@ -176,14 +178,15 @@ const EmailLogin = () => {
176178
placeholder="비밀번호 입력"
177179
shadow={style.shadowPassword}
178180
bgColor={style.bgColorPassword}
181+
maxLength={16}
179182
/>
180183
</div>
181184
<div className="flex items-center ">
182185
<p
183186
className="h-[40px] w-full font-[500] text-[16px] text-[#DE0D0D] flex items-center"
184187
hidden={regulation.regulationPassword}
185188
>
186-
8글자이상 입력 해주세요.
189+
8글자이상 영문숫자 조합으로 입려해주세요.
187190
</p>
188191
</div>
189192
</div>

src/components/login/InputEmail.jsx

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
import {
1414
__openModal,
1515
__closeModal,
16-
openModal,
1716
} from "../../redux/modules/SingupSlice";
1817
import { useEffect } from "react";
1918

src/components/login/KakaoLoginLoding.jsx

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
11
import React, { useEffect, useRef, useState } from "react";
22
import { useDispatch } from "react-redux";
3-
import { useNavigate } from "react-router-dom";
43
import LoadingPage from "../../page/LoadingPage";
54
import { __kakaologin } from "../../redux/modules/LoginSlice";
5+
import WelcomeModal from "../modal/WelcomeModal";
66

77
//인가코드를 백으로 전달하기 위한 페이지
88
const KakaoLoginLoding = () => {
9+
const [isModalOpen, setIsModalOpen] = useState(false);
10+
const [message, setMessage] = useState("");
11+
const [path, setPath] = useState("");
912
const dispatch = useDispatch();
1013

1114
// new URL 객체에서 searchParams객체의 get메소드를 사용하여 'code'키의 값을 추출
1215
const code = new URL(window.location.href).searchParams.get("code");
1316

1417
// 페이지가 로딩됨과 동시에 디스패치로 code 전달
1518
useEffect(() => {
16-
dispatch(__kakaologin(code));
17-
});
19+
dispatch(__kakaologin({ code, setMessage, setPath, setIsModalOpen }));
20+
}, []);
1821
return (
1922
<div>
23+
{isModalOpen && <WelcomeModal message={message} path={path} />}
2024
<LoadingPage />
2125
</div>
2226
);

src/components/main/FriendsMain.jsx

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ const FriendsMain = () => {
2626
} catch (e) {
2727
if (e.response.status === 403) {
2828
setStatus(403);
29-
console.log(status);
3029
}
3130
}
3231
};

src/components/main/Main.jsx

+20-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import React, { useState, useEffect } from "react";
22
import { useDispatch, useSelector } from "react-redux";
3-
import { __getSchedule } from "../../redux/modules/ScheduleSlice";
3+
import {
4+
mainScheduleReset,
5+
__getSchedule,
6+
} from "../../redux/modules/ScheduleSlice";
47
import MainScheduleCards from "./MainScheduleCards";
58
import BottomNavi from "../layout/BottomNavi";
69
import desc from "../../img/desc.png";
@@ -10,8 +13,7 @@ const Main = () => {
1013
const dispatch = useDispatch();
1114
const nickName = sessionStorage.getItem("nickname");
1215
const getRandom = Math.floor(Math.random() * (3 + 0) + 0);
13-
const { schedules } = useSelector((state) => state.ScheduleSlice);
14-
const [sortList, setSortList] = useState("D-Day");
16+
const { schedules, sortList } = useSelector((state) => state.ScheduleSlice);
1517
const [modalOpen, setModalOpen] = useState(false);
1618
const welcomText = ["환영합니다.", "좋은하루 되세요!", "안녕하세요."];
1719

@@ -21,8 +23,16 @@ const Main = () => {
2123

2224
useEffect(() => {
2325
const userId = sessionStorage.getItem("userId");
24-
dispatch(__getSchedule(userId));
25-
}, [dispatch]);
26+
27+
if (sortList === "D-Day") {
28+
dispatch(__getSchedule({ userId: userId, sortedBy: "event.dDay" }));
29+
} else {
30+
dispatch(__getSchedule({ userId: userId, sortedBy: "event.createAt" }));
31+
}
32+
return () => {
33+
dispatch(mainScheduleReset());
34+
};
35+
}, [sortList]);
2636

2737
return (
2838
<>
@@ -61,9 +71,11 @@ const Main = () => {
6171
</div>
6272
</div>
6373
<div className="fixed bottom-0">
64-
{/* {modalOpen ? false : <BottomNavi />} */}
65-
<BottomNavi />
66-
{/* {modalOpen && (<SelectorSort setModalOpen={setModalOpen} setSortList={setSortList} /> )} */}
74+
{modalOpen ? false : <BottomNavi />}
75+
{/* <BottomNavi /> */}
76+
{modalOpen && (
77+
<SelectorSort setModalOpen={setModalOpen} sortList={sortList} />
78+
)}
6779
</div>
6880
</>
6981
);

src/components/main/MainScheduleCards.jsx

+17-8
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ const MainScheduleCards = ({ schedules }) => {
2828
if (invitees.length > 1) {
2929
setInviteesList(() => ({
3030
hidden: false,
31-
inviteesList: `${schedules.invitees[0].username}${invitees.length - 1} 명`,
31+
inviteesList: `${schedules.invitees[0].username}${
32+
invitees.length - 1
33+
}명`,
3234
}));
3335
}
3436
}, [invitees, schedules.invitees]);
@@ -40,9 +42,11 @@ const MainScheduleCards = ({ schedules }) => {
4042
return (
4143
<div
4244
onClick={onDetail}
43-
className={`w-[335px] h-[180px] bg-white rounded-[10px] border border-solid border-[#E8E8E8] shadow-md`}
45+
className={`w-[335px] h-[180px] bg-white rounded-[10px] border border-solid border-[#E8E8E8] shadow-md cursor-pointer`}
4446
>
45-
<div className={`flex items-center h-[14px] ${bgColor} rounded-t-[10px] `}>
47+
<div
48+
className={`flex items-center h-[14px] ${bgColor} rounded-t-[10px] `}
49+
>
4650
<ul className="ml-[9px] flex flex-row gap-[4px]">
4751
{[0, 1, 2].map((list) => (
4852
<li key={list} className="bg-white h-[4px] w-[4px] rounded-full" />
@@ -77,11 +81,14 @@ const MainScheduleCards = ({ schedules }) => {
7781
</div>
7882

7983
<div className="h-[40px]">
80-
<div hidden={inviteesList.hidden} className="flex space-x-32">
81-
<div className="flex -space-x-5 overflow-hidden ">
82-
{invitees.map((list, index) => {
84+
<div hidden={inviteesList.hidden} className="flex space-x-32 ">
85+
<div className="flex -space-x-8 overflow-hidden ">
86+
{invitees?.map((list, index) => {
8387
return (
84-
<div key={index} className="flex border-2 border-white rounded-full">
88+
<div
89+
key={index}
90+
className="flex border-2 border-white rounded-full"
91+
>
8592
<img
8693
className="inline-block h-[40px] w-[40px] rounded-full"
8794
src={list.profile}
@@ -91,7 +98,9 @@ const MainScheduleCards = ({ schedules }) => {
9198
);
9299
})}
93100
</div>
94-
<div className="flex items-center text-[#6F6F6F]">{inviteesList.inviteesList}</div>
101+
<div className="flex items-center text-[#6F6F6F]">
102+
{inviteesList.inviteesList}
103+
</div>
95104
</div>
96105
</div>
97106
</div>
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import React from "react";
2+
import { useDispatch } from "react-redux";
3+
import { useNavigate } from "react-router-dom";
4+
import { refuseInvitation, acceptInvitation } from "../../redux/modules/InvitationSlice";
5+
6+
const InvitaionResponse = ({ message, setOpen, invit }) => {
7+
const dispatch = useDispatch();
8+
9+
const approveHandler = () => dispatch(acceptInvitation(invit.eventId));
10+
const rejectHandler = () => dispatch(refuseInvitation(invit.eventId));
11+
return (
12+
<div>
13+
<div className="h-full w-[375px] bg-black bg-opacity-50 justify-center fixed bottom-0 z-10 flex">
14+
<div className="text-black pt-8 items-center w-[300px] h-[167px] text-center rounded-[16px] fixed top-[38%] bg-white">
15+
<div className="text-[18px] font-bold flex flex-col ">{message}</div>
16+
<button
17+
className="bg-[#002C51] rounded-[4px] h-[40px] w-[127px] text-white mt-[38px]"
18+
onClick={message === "초대를 수락하시겠습니까?" ? approveHandler : rejectHandler}
19+
>
20+
확인
21+
</button>
22+
<button
23+
className="ml-[14px] h-[40px] rounded-[4px] border-solid border-black border-[1px] w-[127px] text-black mt-[18px]"
24+
onClick={() => {
25+
setOpen(false);
26+
}}
27+
>
28+
닫기
29+
</button>
30+
</div>
31+
</div>
32+
</div>
33+
);
34+
};
35+
36+
export default InvitaionResponse;

0 commit comments

Comments
 (0)