Skip to content

Commit ea62288

Browse files
Merge pull request #35 from 기능 구현 완료
Feat/schedule invitation 기능 구현 완료
2 parents 47718b7 + 8d68bc6 commit ea62288

File tree

5 files changed

+91
-20
lines changed

5 files changed

+91
-20
lines changed

src/components/mypage/ InvitationCard.jsx

+42-12
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,59 @@
11
import React from "react";
2-
import { useSelector } from "react-redux";
2+
import { useDispatch } from "react-redux";
3+
import {
4+
refuseInvitation,
5+
acceptInvitation,
6+
} from "../../redux/modules/InvitationSlice";
37

48
const InvitationCard = ({ invit }) => {
59
console.log("뭘까요?", invit);
10+
console.log("뭘까요?2", invit.invitees[0].username);
11+
12+
const dispatch = useDispatch();
13+
14+
const onRefuseHanddler = (e) => {
15+
e.stopPropagation();
16+
const result = window.confirm("거절?");
17+
if (result) {
18+
return dispatch(refuseInvitation(invit.eventId));
19+
}
20+
};
21+
22+
const onAcceptHanddler = (e) => {
23+
e.stopPropagation();
24+
const result = window.confirm("수락?");
25+
if (result) {
26+
return dispatch(acceptInvitation(invit.eventId));
27+
}
28+
};
629

730
return (
831
<div>
9-
<div className="rounded-[10px] mx-[20px] w-[335px] h-[184px] bg-gray-500">
10-
<div className="flex gap-[50px] relative top-[16px] ">
11-
<div className="flex ml-[23px] gap-[20px]">
32+
<div className="rounded-[10px] my-[10px] mx-[20px] w-[335px] h-[184px] bg-gray-500">
33+
<div className="flex gap-[50px] relative top-[16px]">
34+
<div className="flex ml-[23px] gap-[20px]">
1235
<span className="text-sm">{invit.date}</span>
1336
<span className="text-sm">{invit.time}</span>
1437
</div>
15-
<span className="text-sm">from.{invit.invitees.username}</span>
38+
{invit.invitees.map((invitees) => {
39+
console.log("이름 맵", invitees);
40+
return <span className="text-sm">from.{invitees.username}</span>;
41+
})}
1642
</div>
17-
<div className="ml-[23px] relative top-[20px]">
18-
<div className="p-2 text-md">
19-
일이삼사오육칠팔구십일이삼사오육칠팔구십
20-
</div>
43+
<div className="mx-[23px] relative top-[20px]">
44+
<div className="h-[58px] truncate text-md">{invit.subject}</div>
2145
</div>
22-
<div className="flex relative top-[44px] h-[57px] text-center items-center border-t-[1px] border-[#BBD7FF] border-solid">
23-
<div className="flex items-center justify-center flex-1 h-full text-center text-md">
46+
<div className="flex relative top-[50px] h-[57px] text-center items-center border-t-[1px] border-[#BBD7FF] border-solid">
47+
<div
48+
onClick={onRefuseHanddler}
49+
className="flex items-center justify-center flex-1 h-full text-center text-md"
50+
>
2451
거절
2552
</div>
26-
<div className="flex text-center justify-center items-center flex-1 border-l-[1px] h-full border-[#BBD7FF] border-solid text-md">
53+
<div
54+
onClick={onAcceptHanddler}
55+
className="flex text-center justify-center items-center flex-1 border-l-[1px] h-full border-[#BBD7FF] border-solid text-md"
56+
>
2757
수락
2858
</div>
2959
</div>

src/components/mypage/Profile.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const Profile = () => {
2525
<div>
2626
<div className="flex p-5 gap-[30px] justify-items-center">
2727
<div className="p-2 w-[86px] h-[86px]">
28-
<img className="rounded-full" src={basicImg} />
28+
<img className="rounded-full" src={profileImage} alr="이미지" />
2929
</div>
3030
<div className="inline-block pt-2">
3131
<div className="text-lg font-semibold leading-[21px]">

src/components/mypage/ScheduleInvitation.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import { __getInvitation } from "../../redux/modules/InvitationSlice";
55
import InvitationCard from "./ InvitationCard";
66

77
const ScheduleInvitation = () => {
8-
localStorage.setItem("nickname", "동퐈");
98
const nickname = localStorage.getItem("nickname");
109

1110
const dispatch = useDispatch();
1211
const { isLoading, error, data } = useSelector(
1312
(state) => state.InvitationSlice
1413
);
14+
console.log("무슨 스테이트?", data);
1515

1616
useEffect(() => {
1717
dispatch(__getInvitation());

src/components/signup/SetProfileImg.jsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { SignupApi } from "../../api/Signup";
55
import IsModal from "../modal/Modal";
66
import axios from "axios";
77
import { useNavigate } from "react-router";
8+
import { instance } from "../../shared/AxiosInstance";
89

910
const SetProfileImg = () => {
1011
const navigate = useNavigate();
@@ -44,7 +45,7 @@ const SetProfileImg = () => {
4445
}
4546

4647
if (singup === "emailLogin") {
47-
const url = "http://hayangaeul.shop/auth/signup";
48+
const url = "https://eb.jxxhxxx.shop/auth/signup";
4849
const data = {
4950
username: userInfo.username,
5051
nickname: userInfo.nickname,
@@ -53,7 +54,7 @@ const SetProfileImg = () => {
5354
};
5455
sginupAxios({ data, formData, url });
5556
} else {
56-
const url = "http://hayangaeul.shop/social/signup";
57+
const url = "https://eb.jxxhxxx.shop/social/signup";
5758
const data = {
5859
username: NameNickName.nickname,
5960
nickname: NameNickName.username,
@@ -125,7 +126,7 @@ const SetProfileImg = () => {
125126
<label htmlFor="profileImg">
126127
<div className=" h-[86px] w-[86px] justify-center mx-auto">
127128
<img
128-
className="rounded-full h-full w-full"
129+
className="w-full h-full rounded-full"
129130
src={image}
130131
alt="프로필이미지"
131132
/>

src/redux/modules/InvitationSlice.jsx

+43-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const initialState = {
2222
isLoading: false,
2323
error: null,
2424
};
25-
25+
//초대 스케줄 가져오기
2626
export const __getInvitation = createAsyncThunk(
2727
"getInvitation",
2828
async (payload, thunkAPI) => {
@@ -37,18 +37,58 @@ export const __getInvitation = createAsyncThunk(
3737
}
3838
}
3939
);
40+
//초대 스케줄 거절
41+
export const refuseInvitation = (payload) => {
42+
return async function (dispatch) {
43+
await instance
44+
.post(`/events/${payload}/rejection`)
45+
.then((res) => {
46+
console.log("거절후", res);
47+
dispatch(__getInvitation());
48+
})
49+
.catch((error) => {
50+
console.log(error);
51+
});
52+
};
53+
};
54+
//초대 스케줄 수락
55+
export const acceptInvitation = (payload) => {
56+
return async function (dispatch) {
57+
await instance
58+
.post(`/events/${payload}/acceptance`)
59+
.then((res) => {
60+
console.log("수락후", res);
61+
dispatch(__getInvitation());
62+
})
63+
.catch((error) => {
64+
console.log(error);
65+
});
66+
};
67+
};
4068

4169
export const invitationSlice = createSlice({
4270
name: "invitation",
4371
initialState,
44-
reducers: {},
72+
reducers: {
73+
// isLogin: (state, action) => {
74+
// console.log(action.payload);
75+
// state.isLogin = action.payload;
76+
// },
77+
// infoList: (state, action) => {
78+
// state.infoList = action.payload;
79+
// },
80+
// gethistorys: (state, action) => {
81+
// state.historyList = action.payload;
82+
// },
83+
},
4584
extraReducers: {
4685
[__getInvitation.pending]: (state) => {
4786
state.isLoading = true;
4887
},
4988
[__getInvitation.fulfilled]: (state, action) => {
5089
state.isLoading = false;
51-
state.todos = action.payload;
90+
state.data = action.payload.data;
91+
console.log(state.datas);
5292
},
5393
[__getInvitation.rejected]: (state, action) => {
5494
state.isLoading = false;

0 commit comments

Comments
 (0)