@@ -4,38 +4,45 @@ import frends from "../../img/Friends.png";
4
4
import Vector from "../../img/Vector.png" ;
5
5
import { useEffect } from "react" ;
6
6
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" ;
7
10
8
11
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 ) ;
11
16
const [ nickName , setNickname ] = useState ( "" ) ;
12
17
const [ email , setEmail ] = useState ( "" ) ;
13
18
14
19
useEffect ( ( ) => {
15
20
const getnickName = window . localStorage . getItem ( "nickname" ) ;
16
21
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 ) ;
20
26
setEmail ( ( ) => getEmail ) ;
21
- if ( getprofilImg === undefined ) {
22
- setProfileImg ( profileImg ) ;
27
+ if ( getprofilImg ) {
28
+ setProfileImg ( getprofilImg ) ;
23
29
}
30
+ dispatch ( __getSchedule ( userId ) ) ;
24
31
} else {
25
- navigate ( " /login" ) ;
32
+ navigate ( ` /login` ) ;
26
33
}
34
+ } , [ dispatch , navigate , email ] ) ;
27
35
28
- console . log ( getprofilImg ) ;
29
- } , [ ] ) ;
30
-
36
+ console . log ( schedules ) ;
37
+
31
38
return (
32
- < div className = "container md " >
39
+ < div className = "container md" >
33
40
< div className = "grid grid-flow-row ml-[20px] mr-[20px]" >
34
41
< div className = "mt-[78px] w-full h-[80px] bg-[#FFFFFF]" >
35
42
< div className = "flex flex-row gap-[10px]" >
36
43
< div className = "p-[10px]" >
37
44
< img
38
- className = "h-[60px] w-[60px]"
45
+ className = "h-[60px] w-[60px] rounded-full "
39
46
src = { profileImg }
40
47
alt = "프로필이미지"
41
48
/>
@@ -47,50 +54,16 @@ const Main = () => {
47
54
</ div >
48
55
</ div >
49
56
</ 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
+ } ) }
94
67
</ div >
95
68
</ div >
96
69
</ div >
0 commit comments