@@ -2,6 +2,7 @@ import { useNavigate } from 'react-router-dom';
22
33import { Authenticated , Registration } from '@/type/models' ;
44
5+ import { CrewItem } from '@components/CrewItem' ;
56import { Header } from '@components/Header' ;
67import { MatchItem } from '@components/MatchItem' ;
78import { Button } from '@components/shared/Button' ;
@@ -12,6 +13,7 @@ import { theme } from '@styles/theme';
1213import { PATH_NAME } from '@consts/pathName' ;
1314
1415import { MainPageContainer , MainPageSubContainer } from './MainPage.style' ;
16+ import { useMainPageNearCrewListQuery } from './useMainPageNearCrewListQuery' ;
1517import { useMainPageNearGamesQuery } from './useMainPageNearGamesQuery' ;
1618
1719export const MainPage = ( ) => {
@@ -36,14 +38,18 @@ export const MainPage = () => {
3638 } ;
3739
3840 const { addressDepth1, addressDepth2 } = loginInfo ;
39- const { data } = useMainPageNearGamesQuery ( {
41+ const { data : gameData } = useMainPageNearGamesQuery ( {
4042 category : 'location' ,
4143 value :
4244 addressDepth1 === null ? '서울시+강남구' : addressDepth2 + addressDepth2 ,
4345 } ) ;
44- console . log ( data ) ;
4546
46- const filteredData = data . map (
47+ const { data : crewData } = useMainPageNearCrewListQuery ( {
48+ addressDepth1 : addressDepth1 === null ? '서울시' : addressDepth1 ,
49+ addressDepth2 : addressDepth2 === null ? '영등포구' : addressDepth2 ,
50+ } ) ;
51+
52+ const filteredGameData = gameData . map (
4753 ( {
4854 id,
4955 //playStartTime,
@@ -68,12 +74,40 @@ export const MainPage = () => {
6874 )
6975 ) ;
7076
77+ console . log ( crewData ) ;
78+
79+ const filteredCrewData = crewData . map (
80+ ( {
81+ id,
82+ name,
83+ addressDepth1,
84+ addressDepth2,
85+ profileImageUrl,
86+ members,
87+ memberCount,
88+ maxMemberCount,
89+ } ) => (
90+ < CrewItem
91+ key = { id . toString ( ) }
92+ name = { name }
93+ address = { `${ addressDepth1 } ${ addressDepth2 } ` }
94+ imgSrc = { profileImageUrl }
95+ membersProfileImageUrls = { members . map (
96+ ( { profileImageUrl } ) => profileImageUrl
97+ ) }
98+ memberCount = { memberCount }
99+ maxMemberCount = { maxMemberCount }
100+ onClick = { ( ) => navigate ( PATH_NAME . GET_CREWS_PATH ( id . toString ( ) ) ) }
101+ />
102+ )
103+ ) ;
104+
71105 return (
72106 < MainPageContainer >
73107 < Header isLogo = { true } />
74108 < MainPageSubContainer >
75109 < Text children = { '내 근처의 경기' } weight = { 700 } size = { '1.25rem' } />
76- { filteredData }
110+ { filteredGameData }
77111 < Button
78112 { ...MAIN_PAGE_BUTTON_PROP }
79113 onClick = { ( ) => navigate ( PATH_NAME . GAMES_NEAR ) }
@@ -83,8 +117,11 @@ export const MainPage = () => {
83117 </ MainPageSubContainer >
84118 < MainPageSubContainer >
85119 < Text children = { '추천 크루' } weight = { 700 } size = { '1.25rem' } />
86- { filteredData }
87- < Button { ...MAIN_PAGE_BUTTON_PROP } onClick = { ( ) => console . log ( 'hi' ) } >
120+ { filteredCrewData }
121+ < Button
122+ { ...MAIN_PAGE_BUTTON_PROP }
123+ onClick = { ( ) => navigate ( PATH_NAME . CREWS_RECOMMEND ) }
124+ >
88125 더보기
89126 </ Button >
90127 </ MainPageSubContainer >
0 commit comments