Skip to content

Commit 49aa76d

Browse files
author
Ju
committed
Feat/main gnims-project#31. 1차 - main페이지, main detail연결, 백이랑 확인
1 parent d089c14 commit 49aa76d

15 files changed

+352
-151
lines changed

src/api/ScheduleApi.jsx

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { instance } from "../shared/AxiosInstance";
2+
3+
export const ScheduleApi = {
4+
getSccheduleApi: (payload) => {
5+
console.log(payload);
6+
const data = instance.get(`/users/${payload}/events`);
7+
return data;
8+
},
9+
postScheduleApi: (payload) => {
10+
const data = instance.post("/events", payload);
11+
return data;
12+
},
13+
};

src/components/Schedule/ScheduleAdd.jsx

+9-16
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, { useEffect, useState } from "react";
22
import DatePicker from "react-datepicker";
33
import "react-datepicker/dist/react-datepicker.css";
44
import { useDispatch } from "react-redux";
5+
import { useNavigate } from "react-router-dom";
56
import { __postSchedule } from "../../redux/modules/ScheduleSlice";
67
import TopNavBar from "../layout/TopNavBar";
78
import ScheduleModal from "../modal/ScheduleModal";
@@ -12,7 +13,7 @@ import ScheduleModal from "../modal/ScheduleModal";
1213
const ScheduleAdd = () => {
1314
//필요한 변수들
1415
const [selectedDate, setSelectedDate] = useState();
15-
const [selectedColor, setColorSelected] = useState("");
16+
const [selectedColor, setColorSelected] = useState("sora");
1617
const [bgColor, setBgColor] = useState("bg-sora");
1718
const [subject, setSubject] = useState("");
1819
const [content, setContent] = useState("");
@@ -21,36 +22,27 @@ const ScheduleAdd = () => {
2122
const [borderNam, setBorderNam] = useState("border-none");
2223
const [borderParang, setBorderParang] = useState("border-none");
2324
const [modalOpen, setModalOpen] = useState(false);
24-
25-
// const [schedules, setSchedules] = useState({
26-
// id: 0,
27-
// cardColor: "",
28-
// date: "",
29-
// time: "",
30-
// subject: "",
31-
// content: "",
32-
// participantsId: "",
33-
// });
25+
const navigate = useNavigate();
3426
const dispatch = useDispatch();
3527
const today = new Date().toISOString().slice(0, 10);
3628

3729
//색상지정시 카드의 백그라운드컬러가 바뀌면서 selectedColor에 값이 입혀진다.
3830
const eventHandlerSora = () => {
39-
setColorSelected("SORA");
31+
setColorSelected("sora");
4032
setBgColor("bg-sora");
4133
setBorderSora("border-white");
4234
setBorderNam("border-none");
4335
setBorderParang("border-none");
4436
};
4537
const eventHandlerNam = () => {
46-
setColorSelected("NAM");
38+
setColorSelected("nam");
4739
setBgColor("bg-nam");
4840
setBorderSora("border-none");
4941
setBorderNam("border-white");
5042
setBorderParang("border-none");
5143
};
5244
const eventHandlerParang = () => {
53-
setColorSelected("PARNG");
45+
setColorSelected("parang");
5446
setBgColor("bg-parang");
5547
setBorderSora("border-none");
5648
setBorderNam("border-none");
@@ -87,7 +79,7 @@ const ScheduleAdd = () => {
8779
time: time,
8880
subject: subject,
8981
content: content,
90-
participantsId: participantss,
82+
participantsId: [3],
9183
};
9284
await dispatch(__postSchedule(newSchedule));
9385
setSubject("");
@@ -97,6 +89,7 @@ const ScheduleAdd = () => {
9789
setBgColor("bg-sora");
9890
alert("등록이 완료되었습니다!");
9991
console.log(newSchedule);
92+
navigate("/main");
10093
} else {
10194
setModalOpen(true);
10295
}
@@ -158,7 +151,7 @@ const ScheduleAdd = () => {
158151
참여자 (우선 Id로 받습니다)
159152
<input
160153
value={participants}
161-
onChange={onParticipantsChangeHandler}
154+
onChange={() => onParticipantsChangeHandler}
162155
placeholder="함께할 친구들을 선택해주세요. (최대 4명)"
163156
className="mt-4 shadow
164157
hover:bg-sky-100
+47-18
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,88 @@
1-
import React, { useRef, useState } from "react";
1+
import axios from "axios";
2+
import React, { memo, useEffect, useState } from "react";
3+
import { useParams } from "react-router-dom";
24
import kebab from "../../img/kebab.png";
5+
import BottomNavi from "../layout/BottomNavi";
6+
import TopNavBar from "../layout/TopNavBar";
37
import KebabModal from "../modal/KebabButtonModal";
8+
import ScheduleDetailParticipants from "./ScheduleDetailParticipants";
49

510
const ScheduleDetail = () => {
11+
const pram = useParams();
612
// 모달 노출시키는 여부
713
const [modalOpen, setModalOpen] = useState(false);
814
const showModalHandler = () => {
915
setModalOpen(true);
1016
};
17+
//id구하기
18+
const { id } = useParams();
19+
20+
//데이터베이스를 담을 schedule변수.
21+
const [schedule, setSchedule] = useState([]);
22+
const fetchTodos = async () => {
23+
await axios
24+
//.get`https://eb.jxxhxxx.shop/v2/events/5`, {
25+
.get(`https://eb.jxxhxxx.shop/v2/events/${id}`, {
26+
// .get("http://localhost:3001/todos", {
27+
headers: {
28+
Authorization: localStorage.getItem("Authorization"),
29+
},
30+
})
31+
.then((appData) => {
32+
setSchedule(appData.data.data);
33+
}, []);
34+
};
35+
// const subject = schedule.data.subject;
36+
// const [index, setIndex] = useState("0");
37+
// setIndex(id);
38+
useEffect(() => {
39+
fetchTodos();
40+
}, [id]);
41+
console.log(schedule);
42+
const time = schedule.time?.split(":", 2).join(":");
1143

1244
return (
1345
<div className="bg-[#EDF7FF] h-[734px] width-[375px]">
14-
<div className="h-[48px]">네비바상단영역</div>
46+
<TopNavBar />
1547
<div>
1648
{modalOpen && <KebabModal setModalOpen={setModalOpen} />}
1749
{/* bg는 유저가 등록시에 선택한 cardColor로 */}
18-
<div className="h-[202px] bg-[#538EDF] pl-[18px] pt-[23px] pr-[21px] text-white">
50+
<div
51+
// bg-${schedule.data.cardColor}
52+
className={`h-[250px] bg-${schedule.cardColor} pl-[18px] pt-[71px] pr-[21px] text-white`}
53+
>
1954
<div className="flex flex-row-reverse">
2055
<img
21-
className="h-[20px] w-[20px] flex "
56+
className="h-[20px] flex "
2257
src={kebab}
2358
alt="케밥메뉴"
2459
onClick={showModalHandler}
2560
/>
2661
</div>
2762
<div className="flex space-x-3 text-[18px] mt-[-18px] font-light ">
28-
<div>23.02.06</div> <div> 오후 6:00</div>{" "}
63+
<div>{schedule.date}</div> <div> {time}</div>{" "}
2964
</div>
3065
<div className="mt-[28px] font-semibold text-[24px]">
31-
선희랑 마라탕 먹으러 가기
66+
{schedule.subject}
3267
</div>{" "}
3368
<div className="place-content-end font-light flex text-[18px] mt-[70px]">
34-
D-Day
69+
d-
70+
{schedule.dday === 0 ? <div>day</div> : <div>{schedule.dday}</div>}
3571
</div>
3672
</div>
3773
<div className="text-[#12396F]">
38-
<div className="mt-[30px] h-[98px] ml-[20px]">
39-
참여자{" "}
40-
<div className="bg-[#CEE4F8] h-[50px] w-[335px] mt-[20px] p-[15px] shadow flex rounded-lg">
41-
본인 포함 4명, 참여자 없으면 아예 뜨지 않습니다
42-
</div>
43-
</div>
74+
<ScheduleDetailParticipants />
4475
<div className="h-[234px] mt-[30px] mb-[8px] ml-[20px]">
4576
일정내용{" "}
4677
<div className="bg-[#CEE4F8] shadow h-[186px] w-[335px] mt-[20px] p-[15px] flex rounded-lg">
47-
여기에 내용이 들어갑니다
78+
{schedule.content}
4879
</div>
4980
</div>
5081
</div>{" "}
5182
</div>
52-
<div className="h-[50px] bg-white inset-x-0 bottom-0 flex absolute">
53-
네비바하단영역
54-
</div>
83+
{modalOpen ? false : <BottomNavi />}
5584
</div>
5685
);
5786
};
5887

59-
export default ScheduleDetail;
88+
export default memo(ScheduleDetail);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import axios from "axios";
2+
import React, { memo, useCallback, useEffect, useState } from "react";
3+
4+
const ScheduleDetailParticipants = () => {
5+
const [schedule, setSchedule] = useState([]);
6+
7+
const fetchTodos = async () => {
8+
await axios
9+
.get(`https://eb.jxxhxxx.shop/v2/events/5`, {
10+
// .get(`https://eb.jxxhxxx.shop/events/${id}`, {
11+
// .get("http://localhost:3001/todos", {
12+
headers: {
13+
Authorization: localStorage.getItem("Authorization"),
14+
},
15+
})
16+
.then((appData) => {
17+
setSchedule(appData.data.data);
18+
console.log(schedule);
19+
}, []);
20+
};
21+
// const a = schedule.invitees.length;
22+
// const [index, setIndex] = useState("0");
23+
// setIndex(id);
24+
useEffect(() => {
25+
fetchTodos();
26+
}, []);
27+
// console.log(schedule);
28+
// console.log(schedule.invitees.length);
29+
// console.log(schedule.invitees);
30+
// console.log(a.length);
31+
const invitees = schedule.invitees;
32+
console.log(schedule);
33+
console.log(invitees);
34+
return (
35+
<div>
36+
{schedule.invitees.length !== 1 ? (
37+
<div className="mt-[30px] h-[98px] ml-[20px]">
38+
참여자{" "}
39+
<div className="bg-[#CEE4F8] h-[50px] w-[335px] mt-[20px] p-[15px] shadow flex rounded-lg">
40+
{/* {schedule.invitees} */}
41+
</div>
42+
</div>
43+
) : (
44+
<div />
45+
)}
46+
</div>
47+
);
48+
};
49+
export default ScheduleDetailParticipants;

src/components/layout/Layout.jsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ const Container = styled.div`
1818
top: "calc(50% - 167px/2)";
1919
-ms-overflow-style: none;
2020
background-color: #edf7ff;
21-
2221
font-family: Pretendard-Regular;
22+
2323
//스크롤창 숨기기
2424
overflow-y: scroll;
2525
/* IE and Edge */
@@ -28,6 +28,7 @@ const Container = styled.div`
2828
scrollbar-width: none;
2929
&::-webkit-scrollbar {
3030
display: none;
31+
3132
}
3233
@media screen and (max-width: 768px) {
3334
width: 375px;

src/components/layout/TopNavBar.jsx

+34-30
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,41 @@ import { useNavigate } from "react-router-dom";
66
const TopNavBar = () => {
77
const navigate = useNavigate();
88
return (
9-
<div className="h-[48px] w-screen absolute bg-white opacity-80 flex ">
10-
<div className="h-[48px] w-[217px] bg-slate-600">GNIMS로고들어갈자리</div>
11-
<img
12-
className="h-[24px] w-[24px] flex absolute left-[255px] mt-[13px]"
13-
src={searchIcon}
14-
alt="검색버튼"
15-
//navigate 경로는 검색페이지루트가 정해지면 변경하면됩니다
16-
onClick={() => {
17-
navigate("/login");
18-
console.log("검색페이지로이동");
19-
}}
20-
/>
21-
<img
22-
className="h-[24px] w-[24px] flex absolute left-[293px] mt-[13px]"
23-
src={plusIcon}
24-
alt="추가버튼"
25-
onClick={() => {
26-
console.log("스케쥴추가페이지로이동!");
27-
navigate("/schedule");
28-
}}
29-
/>
30-
<img
31-
className="h-[24px] w-[24px] flex absolute left-[331px] mt-[13px]
9+
<div className="fixed">
10+
<div className="h-[48px] w-screen absolute bg-white opacity-80 flex ">
11+
<div className="h-[48px] w-[217px] bg-slate-600">
12+
GNIMS로고들어갈자리
13+
</div>
14+
<img
15+
className="h-[24px] w-[24px] flex absolute left-[255px] mt-[13px]"
16+
src={searchIcon}
17+
alt="검색버튼"
18+
//navigate 경로는 검색페이지루트가 정해지면 변경하면됩니다
19+
onClick={() => {
20+
navigate("/login");
21+
console.log("검색페이지로이동");
22+
}}
23+
/>
24+
<img
25+
className="h-[24px] w-[24px] flex absolute left-[293px] mt-[13px]"
26+
src={plusIcon}
27+
alt="추가버튼"
28+
onClick={() => {
29+
console.log("스케쥴추가페이지로이동!");
30+
navigate("/schedule");
31+
}}
32+
/>
33+
<img
34+
className="h-[24px] w-[24px] flex absolute left-[331px] mt-[13px]
3235
"
33-
src={notifyIcon}
34-
alt="알림버튼"
35-
onClick={() => {
36-
console.log("알림페이지로 이동");
37-
navigate("/notification");
38-
}}
39-
/>
36+
src={notifyIcon}
37+
alt="알림버튼"
38+
onClick={() => {
39+
console.log("알림페이지로 이동");
40+
navigate("/notification");
41+
}}
42+
/>
43+
</div>
4044
</div>
4145
);
4246
};

0 commit comments

Comments
 (0)