Skip to content

Commit f290ac9

Browse files
Merge pull request #36 from haruharuganda/dev
Feat/main #31
2 parents ea62288 + 20b5e97 commit f290ac9

15 files changed

+276
-111
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

+11-9
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@ import React, { memo, useCallback, useEffect, useMemo, 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 { __AddSchedule } from "../../redux/modules/ScheduleSlice";
6-
import { instance } from "../../shared/AxiosInstance";
7-
import BottomNavi from "../layout/BottomNavi";
5+
import { useNavigate } from "react-router-dom";
6+
import { __postSchedule } from "../../redux/modules/ScheduleSlice";
87
import TopNavBar from "../layout/TopNavBar";
98
import ScheduleModal from "../modal/ScheduleModal";
9+
import BottomNavi from "../layout/BottomNavi";
1010
//네비바테스트 후 TopNavBar지워야합니다
1111
// CSS Modules, react-datepicker-cssmodules.css
1212
// import 'react-datepicker/dist/react-datepicker-cssmodules.css';
1313

1414
const ScheduleAdd = () => {
1515
//필요한 변수들
1616
const [selectedDate, setSelectedDate] = useState();
17-
const [selectedColor, setColorSelected] = useState("SORA");
17+
const [selectedColor, setColorSelected] = useState("sora");
1818
const [bgColor, setBgColor] = useState("bg-sora");
1919
const [subject, setSubject] = useState("");
2020
const [content, setContent] = useState("");
@@ -24,26 +24,27 @@ const ScheduleAdd = () => {
2424
const [borderParang, setBorderParang] = useState("border-none");
2525
const [modalOpen, setModalOpen] = useState(false);
2626

27+
const navigate = useNavigate();
2728
const dispatch = useDispatch();
2829
const today = new Date().toISOString().slice(0, 10);
2930

3031
//색상지정시 카드의 백그라운드컬러가 바뀌면서 selectedColor에 값이 입혀진다.
3132
const eventHandlerSora = () => {
32-
setColorSelected("SORA");
33+
setColorSelected("sora");
3334
setBgColor("bg-sora");
3435
setBorderSora("border-white");
3536
setBorderNam("border-none");
3637
setBorderParang("border-none");
3738
};
3839
const eventHandlerNam = () => {
39-
setColorSelected("NAM");
40+
setColorSelected("nam");
4041
setBgColor("bg-nam");
4142
setBorderSora("border-none");
4243
setBorderNam("border-white");
4344
setBorderParang("border-none");
4445
};
4546
const eventHandlerParang = () => {
46-
setColorSelected("PARANG");
47+
setColorSelected("parang");
4748
setBgColor("bg-parang");
4849
setBorderSora("border-none");
4950
setBorderNam("border-none");
@@ -82,16 +83,17 @@ const ScheduleAdd = () => {
8283
time: time,
8384
subject: subject,
8485
content: content,
85-
participantsId: participantss,
86+
participantsId: [3],
8687
};
87-
await dispatch(__AddSchedule(newSchedule));
88+
await dispatch(__postSchedule(newSchedule));
8889
setSubject("");
8990
setContent("");
9091
setParticipants("");
9192
setSelectedDate("");
9293
setBgColor("bg-sora");
9394
alert("등록이 완료되었습니다!");
9495
console.log(newSchedule);
96+
navigate("/main");
9597
} else {
9698
setModalOpen(true);
9799
}

src/components/Schedule/ScheduleDetail.jsx

+17-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import axios from "axios";
2-
import React, { memo, useEffect, useRef, useState } from "react";
2+
import React, { memo, useEffect, useState } from "react";
33
import { useParams } from "react-router-dom";
44
import kebab from "../../img/kebab.png";
55
import BottomNavi from "../layout/BottomNavi";
@@ -8,6 +8,7 @@ import KebabModal from "../modal/KebabButtonModal";
88
import ScheduleDetailParticipants from "./ScheduleDetailParticipants";
99

1010
const ScheduleDetail = () => {
11+
const pram = useParams();
1112
// 모달 노출시키는 여부
1213
const [modalOpen, setModalOpen] = useState(false);
1314
const showModalHandler = () => {
@@ -20,24 +21,29 @@ const ScheduleDetail = () => {
2021
const [schedule, setSchedule] = useState([]);
2122
const fetchTodos = async () => {
2223
await axios
23-
// .get(`https://eb.jxxhxxx.shop/events-${id}`, {
24-
.get("http://localhost:3001/todos", {
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+
2528
headers: {
2629
Authorization: localStorage.getItem("Authorization"),
2730
},
2831
})
2932
.then((appData) => {
30-
//useparam으로 id찾는게 가능해지면 data[index]로 처리.
31-
setSchedule(appData.data[1]);
33+
34+
setSchedule(appData.data.data);
3235
}, []);
3336
};
37+
// const subject = schedule.data.subject;
3438

3539
// const [index, setIndex] = useState("0");
3640
// setIndex(id);
3741
useEffect(() => {
3842
fetchTodos();
3943
}, [id]);
4044
console.log(schedule);
45+
const time = schedule.time?.split(":", 2).join(":");
46+
4147

4248
return (
4349
<div className="bg-[#EDF7FF] h-[734px] width-[375px]">
@@ -46,7 +52,7 @@ const ScheduleDetail = () => {
4652
{modalOpen && <KebabModal setModalOpen={setModalOpen} />}
4753
{/* bg는 유저가 등록시에 선택한 cardColor로 */}
4854
<div
49-
// ${schedule[0].cardColor}
55+
// bg-${schedule.data.cardColor}
5056
className={`h-[250px] bg-${schedule.cardColor} pl-[18px] pt-[71px] pr-[21px] text-white`}
5157
>
5258
<div className="flex flex-row-reverse">
@@ -58,13 +64,15 @@ const ScheduleDetail = () => {
5864
/>
5965
</div>
6066
<div className="flex space-x-3 text-[18px] mt-[-18px] font-light ">
61-
<div>{schedule.date}</div> <div> {schedule.time}</div>{" "}
67+
<div>{schedule.date}</div> <div> {time}</div>{" "}
68+
6269
</div>
6370
<div className="mt-[28px] font-semibold text-[24px]">
6471
{schedule.subject}
6572
</div>{" "}
6673
<div className="place-content-end font-light flex text-[18px] mt-[70px]">
67-
D-{schedule.dday}
74+
d-
75+
{schedule.dday === 0 ? <div>day</div> : <div>{schedule.dday}</div>}
6876
</div>
6977
</div>
7078
<div className="text-[#12396F]">
@@ -77,7 +85,7 @@ const ScheduleDetail = () => {
7785
</div>
7886
</div>{" "}
7987
</div>
80-
<BottomNavi />
88+
{modalOpen ? false : <BottomNavi />}
8189
</div>
8290
);
8391
};

src/components/Schedule/ScheduleDetailParticipants.jsx

+23-10
Original file line numberDiff line numberDiff line change
@@ -6,38 +6,51 @@ const ScheduleDetailParticipants = () => {
66

77
const fetchTodos = async () => {
88
await axios
9-
// .get(`https://eb.jxxhxxx.shop/events-${id}`, {
10-
.get("http://localhost:3001/todos", {
9+
10+
.get(`https://eb.jxxhxxx.shop/v2/events/5`, {
11+
// .get(`https://eb.jxxhxxx.shop/events/${id}`, {
12+
// .get("http://localhost:3001/todos", {
13+
1114
headers: {
1215
Authorization: localStorage.getItem("Authorization"),
1316
},
1417
})
1518
.then((appData) => {
16-
//useparam으로 id찾는게 가능해지면 data[index]로 처리.
17-
setSchedule(appData.data[1]);
19+
20+
setSchedule(appData.data.data);
21+
console.log(schedule);
1822
}, []);
1923
};
24+
// const a = schedule.invitees.length;
2025

2126
// const [index, setIndex] = useState("0");
2227
// setIndex(id);
2328
useEffect(() => {
2429
fetchTodos();
25-
// console.log(schedule.joiner.split(","));
26-
// console.log(joiners);
2730
}, []);
31+
// console.log(schedule);
32+
// console.log(schedule.invitees.length);
33+
// console.log(schedule.invitees);
34+
// console.log(a.length);
35+
const invitees = schedule.invitees;
36+
console.log(schedule);
37+
console.log(invitees);
2838
return (
2939
<div>
30-
{schedule.joiner !== "" ? (
40+
{schedule.invitees.length !== 1 ? (
3141
<div className="mt-[30px] h-[98px] ml-[20px]">
3242
참여자{" "}
3343
<div className="bg-[#CEE4F8] h-[50px] w-[335px] mt-[20px] p-[15px] shadow flex rounded-lg">
34-
{schedule.joiner}
44+
{/* {schedule.invitees} */}
3545
</div>
3646
</div>
3747
) : (
38-
false
48+
<div />
49+
3950
)}
4051
</div>
4152
);
4253
};
43-
export default memo(ScheduleDetailParticipants);
54+
55+
export default ScheduleDetailParticipants;
56+

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

+5-4
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ import searchIcon from "../../img/searchIcon.png";
33
import plusIcon from "../../img/plusIcon.png";
44
import notifyIcon from "../../img/notifyIcon.png";
55
import { useNavigate } from "react-router-dom";
6+
67
const TopNavBar = () => {
78
const navigate = useNavigate();
89
return (
9-
<div className="relative">
10-
<div className="h-[48px] w-screen top-0 fixed bg-white opacity-80 flex ">
11-
<div className="h-[48px] w-[217px] text-white bg-textNavy text-[40px] pl-4">
12-
GNIMS
10+
<div className="fixed">
11+
<div className="h-[48px] w-screen absolute bg-white opacity-80 flex ">
12+
<div className="h-[48px] w-[217px] bg-slate-600">
13+
GNIMS로고들어갈자리
1314
</div>
1415
<img
1516
className="h-[24px] w-[24px] flex absolute left-[255px] mt-[13px]"

src/components/main/Main.jsx

+30-57
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,45 @@ import frends from "../../img/Friends.png";
44
import Vector from "../../img/Vector.png";
55
import { useEffect } from "react";
66
import { useNavigate } from "react-router-dom";
7+
import { useDispatch, useSelector } from "react-redux";
8+
import { __getSchedule } from "../../redux/modules/ScheduleSlice";
9+
import MainScheduleCards from "./MainScheduleCards";
710

811
const Main = () => {
9-
const navigate = useNavigate;
10-
const [profileImg, setProfileImg] = useState("");
12+
const dispatch = useDispatch();
13+
const navigate = useNavigate();
14+
const { schedules } = useSelector((state) => state.ScheduleSlice);
15+
const [profileImg, setProfileImg] = useState(defaultprofileImg);
1116
const [nickName, setNickname] = useState("");
1217
const [email, setEmail] = useState("");
1318

1419
useEffect(() => {
1520
const getnickName = window.localStorage.getItem("nickname");
1621
const getprofilImg = window.localStorage.getItem("profileImage");
17-
const getEmail = window.localStorage.getItem("nickname");
18-
19-
if (nickName && getEmail) {
22+
const getEmail = window.localStorage.getItem("email");
23+
const userId = window.localStorage.getItem("userId");
24+
if (getnickName && getEmail) {
25+
setNickname(() => getnickName);
2026
setEmail(() => getEmail);
21-
if (getprofilImg === undefined) {
22-
setProfileImg(profileImg);
27+
if (getprofilImg) {
28+
setProfileImg(getprofilImg);
2329
}
30+
dispatch(__getSchedule(userId));
2431
} else {
25-
navigate("/login");
32+
navigate(`/login`);
2633
}
34+
}, [dispatch, navigate, email]);
2735

28-
console.log(getprofilImg);
29-
}, []);
30-
36+
console.log(schedules);
37+
3138
return (
32-
<div className="container md ">
39+
<div className="container md">
3340
<div className="grid grid-flow-row ml-[20px] mr-[20px]">
3441
<div className="mt-[78px] w-full h-[80px] bg-[#FFFFFF]">
3542
<div className="flex flex-row gap-[10px]">
3643
<div className="p-[10px]">
3744
<img
38-
className="h-[60px] w-[60px]"
45+
className="h-[60px] w-[60px] rounded-full"
3946
src={profileImg}
4047
alt="프로필이미지"
4148
/>
@@ -47,50 +54,16 @@ const Main = () => {
4754
</div>
4855
</div>
4956
</div>
50-
<div className="mt-[28px] rounded-[10px]">
51-
<div className=" w-[335px] h-[180px] bg-[#538EDF] rounded-[10px] pt-[20px] pl-[22px] ">
52-
<div className=" text-[#ffff]">
53-
<div className="grid grid-flow-row gap-[19px]">
54-
<div className="flex flex-row h-[21px] gap-[22px] text-[18px] font-[400]">
55-
<div>23.02.06</div>
56-
<div>오후 6:00</div>
57-
</div>
58-
<div className="grid grid-flow-row gap-[17px]">
59-
<div className="text-[18px] font-[700]">
60-
<div>선희랑 마라탕 먹으러가기</div>
61-
</div>
62-
<div className="flex flex-row gap-[20px]">
63-
<div className="flex -space-x-5 overflow-hidden">
64-
<div className="flex rounded-full border-white border-2">
65-
<img
66-
className="inline-block h-[40px] w-[40px] rounded-full ring-2 "
67-
src={profileImg}
68-
alt="프로필이미지"
69-
></img>
70-
</div>
71-
<div className="flex rounded-full border-white border-2">
72-
<img
73-
className="h-[40px] w-[40px] inline-block rounded-full ring-2"
74-
src={profileImg}
75-
alt="프로필이미지"
76-
></img>
77-
</div>
78-
<div className="flex rounded-full border-white border-2">
79-
<img
80-
className="h-[40px] w-[40px] inline-block rounded-full ring-2"
81-
src={profileImg}
82-
alt="프로필이미지"
83-
></img>
84-
</div>
85-
</div>
86-
<div className="flex items-center">이재헌님 외 2명</div>
87-
</div>
88-
</div>
89-
</div>
90-
</div>
91-
<div className="flex items-center h-[40px] w-full rigth-0 ">
92-
<div className="text-[#FFFFFF] font-[400] text-[18px]">D-DAY</div>
93-
</div>
57+
<div>
58+
<div className="flex flex-col gap-[30px] mt-[28px] rounded-[10px]">
59+
{schedules.map((list) => {
60+
return (
61+
<MainScheduleCards
62+
key={list.eventId}
63+
schedules={list}
64+
/>
65+
);
66+
})}
9467
</div>
9568
</div>
9669
</div>

0 commit comments

Comments
 (0)