@@ -3,27 +3,39 @@ import HamburgerButton from '@/components/common/SideBar/HamburgerButton';
3
3
import Calendar from '@/components/common/Calendar' ;
4
4
import CreateEventDialog from '@/components/MyCalendar/CreateEventButton' ;
5
5
import { useParams } from 'react-router-dom' ;
6
- import { useGetOneGroupSchedule } from '@/react-queries/useGetOneGroupSchedule' ;
7
6
import { Loading } from '.' ;
8
7
import { DB_Events } from '@/utils' ;
8
+ import { useGetOneGroup } from '@/react-queries/useGetOneGroup.ts' ;
9
+ import { useGetAllMemberSchedule } from '@/react-queries/useGetAllMemberSchedule.ts' ;
9
10
10
11
const GroupSchedulePage = ( ) => {
11
12
// TODO: 캘린더 수정해서 이벤트 리스트를 외부에서 받을 수 있도록 해야함.
12
13
// TODO: 그룹 스케줄을 받아오는게 아닌 그룹 정보를 받아와 이름을 표현해줘야 한다.
13
14
const params = useParams < { groupId : string } > ( ) ;
14
15
const groupId = params . groupId ! ;
15
16
16
- const { data, isLoading, isError } = useGetOneGroupSchedule ( groupId ) ;
17
+ const { data, isLoading, isError } = useGetOneGroup ( groupId ) ;
18
+ const {
19
+ data : memberScheduleList ,
20
+ isLoading : memberScheduleListLoading ,
21
+ isError : memberScheduleListError ,
22
+ } = useGetAllMemberSchedule ( groupId ) ;
17
23
18
- if ( isError ) {
24
+ if ( isError || memberScheduleListError ) {
19
25
return < div > 에러가 발생했습니다.</ div > ;
20
26
}
21
27
22
28
console . log ( data ) ;
23
29
24
30
const db_events : DB_Events [ ] = [ ] ;
25
- if ( data ) {
26
- db_events . push ( { ...data , start_date : data . start_date , end_date : data . end_date , title : data . title , id : data . id } ) ;
31
+ if ( memberScheduleList ) {
32
+ const eventList : DB_Events [ ] = memberScheduleList . map ( ( item ) => ( {
33
+ start_date : item . start_date ,
34
+ end_date : item . end_date ,
35
+ title : item . title ,
36
+ id : item . id ,
37
+ } ) ) ;
38
+ db_events . push ( ...eventList ) ;
27
39
}
28
40
29
41
const onDelete = ( id : number ) => {
@@ -33,8 +45,8 @@ const GroupSchedulePage = () => {
33
45
34
46
return (
35
47
< div className = "lg:ml-80" >
36
- { isLoading && < Loading size = "lg" display = "spinner" color = "primary" /> }
37
- < AppBar backButton = { false } IconButton = { < HamburgerButton /> } calendarName = { data ?. title ?? '' } />
48
+ { ( isLoading || memberScheduleListLoading ) && < Loading size = "lg" display = "spinner" color = "primary" /> }
49
+ < AppBar backButton = { false } IconButton = { < HamburgerButton /> } calendarName = { data ?. name ?? '' } />
38
50
< main className = "z-1 relative flex-grow" >
39
51
< div className = "mx-auto max-w-7xl px-4 sm:px-6 lg:px-8" >
40
52
< div className = "rounded bg-white p-6 px-4 sm:px-0" >
0 commit comments