11import { useState , useEffect , useRef , ChangeEvent } from "react" ;
22import Image from "next/image" ;
3- import NoDashboardMessage from "./NoResultDashBoard" ;
3+ import NoResultDashBoard from "./NoResultDashBoard" ;
44import EmptyInvitations from "./EmptyInvitations" ;
55
66interface Invite {
77 title : string ;
88 nickname : string ;
99}
1010
11+ // api데이터로 추후 변경
1112const invitedData : Invite [ ] = [
1213 { title : "프로덕트 디자인" , nickname : "손동희" } ,
1314 { title : "새로운 기획 문서" , nickname : "안귀영" } ,
@@ -24,9 +25,9 @@ const invitedData: Invite[] = [
2425const ITEMS_PER_PAGE = 6 ; // 한 번에 보여줄 개수
2526
2627function InvitedList ( { searchTitle } : { searchTitle : string } ) {
27- const [ displayedData , setDisplayedData ] = useState < Invite [ ] > ( [ ] ) ; // 보여줄 데이터 상태
28- const [ page , setPage ] = useState ( 1 ) ; // 페이지 번호
29- const observerRef = useRef < HTMLDivElement | null > ( null ) ; // IntersectionObserver를 위한 ref
28+ const [ displayedData , setDisplayedData ] = useState < Invite [ ] > ( [ ] ) ;
29+ const [ page , setPage ] = useState ( 1 ) ;
30+ const observerRef = useRef < HTMLDivElement | null > ( null ) ;
3031
3132 const hasMore = displayedData . length < invitedData . length ;
3233
@@ -41,13 +42,10 @@ function InvitedList({ searchTitle }: { searchTitle: string }) {
4142 ( entries ) => {
4243 entries . forEach ( ( entry ) => {
4344 if ( entry . isIntersecting ) {
44- console . log ( "스크롤이 바닥에 도달했습니다." ) ;
4545 if ( hasMore ) {
4646 console . log ( "Scroll reached the end. Loading more data..." ) ;
4747 setPage ( ( prevPage ) => prevPage + 1 ) ;
4848 }
49- } else {
50- console . log ( "스크롤이 바닥에서 벗어났습니다." ) ;
5149 }
5250 } ) ;
5351 } ,
@@ -60,15 +58,15 @@ function InvitedList({ searchTitle }: { searchTitle: string }) {
6058
6159 return ( ) => {
6260 if ( observerRef . current ) {
63- observer . unobserve ( observerRef . current ) ; // cleanup
61+ observer . unobserve ( observerRef . current ) ;
6462 }
6563 } ;
6664 } , [ hasMore ] ) ;
6765
68- // 데이터를 로드하는 함수
66+ // 데이터를 로드 함수
6967 const loadMoreData = ( ) => {
70- const nextData = invitedData . slice ( 0 , page * ITEMS_PER_PAGE ) ; // 페이지에 맞는 데이터만 가져옴
71- setDisplayedData ( nextData ) ; // 데이터를 갱신
68+ const nextData = invitedData . slice ( 0 , page * ITEMS_PER_PAGE ) ;
69+ setDisplayedData ( nextData ) ;
7270 } ;
7371
7472 // 검색 기능
@@ -81,10 +79,10 @@ function InvitedList({ searchTitle }: { searchTitle: string }) {
8179 return (
8280 < div className = "relative bg-white w-[260px] sm:w-[504px] lg:w-[1022px] h-[770px] sm:h-[592px] lg:h-[620px] mx-auto mt-[40px]" >
8381 { filteredData . length > 0 && (
84- < div className = "p-6 flex w-full h-[26px] justify-start items-center pl-[43px] pr-[76px] md:gap-x-[130px] lg:gap-x-[280px]" >
82+ < div className = "hidden sm:flex p-6 w-full h-[26px] justify-start items-center pl-[43px] pr-[76px] md:gap-x-[130px] lg:gap-x-[280px]" >
8583 < p className = "lg:ml-10 font-normal text-[var(--color-gray2)]" > 이름</ p >
8684 < p className = "font-normal text-[var(--color-gray2)]" > 초대자</ p >
87- < p className = "lg:ml-6 font-normal text-[var(--color-gray2)]" >
85+ < p className = "lg:ml-13 font-normal text-[var(--color-gray2)]" >
8886 수락여부
8987 </ p >
9088 </ div >
@@ -94,15 +92,39 @@ function InvitedList({ searchTitle }: { searchTitle: string }) {
9492 ? filteredData . map ( ( invite , index ) => (
9593 < div
9694 key = { index }
97- className = "pb-5 mb-[20px] w-[260px] sm:w-[504px] lg:w-[1022px] h-[50px] sm:grid sm:grid-cols-[1fr_1fr_1fr] sm:items-center flex flex-col gap-2 border-b border-[var(--color-gray4)]"
95+ className = "pb-5 mb-[20px] w-[260px] sm:w-[504px] lg:w-[1022px] h-auto sm:h- [50px] sm:grid sm:grid-cols-[1fr_1fr_1fr] sm:items-center flex flex-col gap-10 border-b border-[var(--color-gray4)]"
9896 >
99- < p className = "lg:ml-21 ml-9 flex justify-left mt-1 w-full" >
97+ { /* 모바일 레이아웃 */ }
98+ < div className = "flex flex-col sm:hidden" >
99+ < p className = "ml-9 mt-1 w-full" >
100+ { " " }
101+ < span className = "mr-8 text-[var(--color-gray2)]" > 이름</ span >
102+ < span className = "text-[#333236]" > { invite . title } </ span >
103+ </ p >
104+ < p className = "ml-9 mt-1 w-full" >
105+ < span className = "mr-3.5 text-[var(--color-gray2)]" >
106+ 초대자
107+ </ span > { " " }
108+ < span className = "text-[#333236]" > { invite . nickname } </ span >
109+ </ p >
110+ < div className = "flex gap-2 mt-2 justify-center" >
111+ < button className = "cursor-pointer bg-[var(--primary)] text-white px-3 py-1 rounded-md w-[84px] h-[32px]" >
112+ 수락
113+ </ button >
114+ < button className = "cursor-pointer border px-3 py-1 rounded-md w-[84px] h-[32px] text-[var(--primary)] border-[var(--color-gray3)]" >
115+ 거절
116+ </ button >
117+ </ div >
118+ </ div >
119+
120+ { /* 웹, 태블릿 레이아웃 */ }
121+ < p className = "lg:ml-21 md:ml-11 ml-9 justify-left mt-1 w-full hidden sm:flex" >
100122 { invite . title }
101123 </ p >
102- < p className = "lg:ml-12 ml-9 justify-center mt-1" >
124+ < p className = "lg:mr-25 md:mr-10 ml-9 justify-left mt-1 hidden sm:flex " >
103125 { invite . nickname }
104126 </ p >
105- < div className = "lg:mr-2 flex gap-2 mt-1 justify-between sm:justify-start" >
127+ < div className = "lg:mr-5 gap-2 mt-1 mr-2 justify-between sm:justify-start hidden sm:flex " >
106128 < button className = "cursor-pointer bg-[var(--primary)] text-white px-3 py-1 rounded-md w-[84px] h-[32px]" >
107129 수락
108130 </ button >
@@ -112,16 +134,15 @@ function InvitedList({ searchTitle }: { searchTitle: string }) {
112134 </ div >
113135 </ div >
114136 ) )
115- : ! hasMore && < NoDashboardMessage searchTitle = { searchTitle } /> }
116-
137+ : ! hasMore && < NoResultDashBoard searchTitle = { searchTitle } /> } { " " }
138+ { /* 검색 내역이 없을 경우*/ }
117139 { filteredData . length > 0 && ! hasMore && (
118- < p className = "text-center text-gray-400 py-4" >
140+ < p className = "lg:mr-18 text-center text-gray-400 py-4" >
119141 더 이상 초대 목록이 없습니다.
120142 </ p >
121143 ) }
122-
123144 { hasMore && (
124- < div ref = { observerRef } className = "h-[50px] bg-transparent" > </ div > // 마지막 요소로 스크롤을 감지
145+ < div ref = { observerRef } className = "h-[50px] bg-transparent" > </ div > // 마지막 요소로 스크롤 감지
125146 ) }
126147 </ div >
127148 </ div >
@@ -135,19 +156,19 @@ export default function InvitedDashBoard() {
135156 setSearchTitle ( event . target . value ) ;
136157 } ;
137158
138- // invitedData가 비어 있으면 EmptyInvitations만 렌더링
159+ // invitedData가 비어 있으면 EmptyInvitations만 렌더링 > 초대내역이 아예 없을 경우
139160 if ( invitedData . length === 0 ) {
140161 return < EmptyInvitations /> ;
141162 }
142163
143164 return (
144165 < div >
145166 < div className = "relative bg-white rounded-lg shadow-md w-[260px] sm:w-[504px] lg:w-[1022px] h-[770px] sm:h-[592px] lg:h-[620px] max-w-none mx-auto" >
146- < div className = "p-6 relative w-[966px] h-[104px]" >
167+ < div className = "p-6 relative w-full h-[104px]" >
147168 < div className = "flex justify-between items-center mb-[32px]" >
148169 < p className = "text-xl sm:text-2xl font-bold" > 초대받은 대시보드</ p >
149170 </ div >
150- < div className = "relative w-[260px ] sm:w-[448px] lg:w-[966px]" >
171+ < div className = "relative w-[228px ] sm:w-[448px] lg:w-[966px]" >
151172 < input
152173 id = "title"
153174 placeholder = "검색"
0 commit comments