-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #153 from FinalDoubleTen/FE-83--feat/myTrip
Feat: 나의 여정 마크업 및 API 연동 완료
- Loading branch information
Showing
13 changed files
with
344 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const CreateMyTripButton = () => { | ||
return ( | ||
<div className="sticky bottom-20 z-[100] ml-auto mr-2 flex h-12 w-[119px] items-center justify-center gap-2 rounded-[30px] bg-[#28d8ff] p-2 shadow-[2px_2px_5px_0_rgba(0,0,0,0.2)]"> | ||
<button className="headline1 pt-[2px] text-white">여행 계획하기</button> | ||
</div> | ||
); | ||
}; | ||
|
||
export default CreateMyTripButton; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { useInfiniteQuery } from '@tanstack/react-query'; | ||
import MyTripList from './MyTripList'; | ||
import NoDataMessage from '@components/common/noData/NoDataMessage'; | ||
import { getMemberTrips } from '@api/member'; | ||
import { PenIcon } from '@components/common/icons/Icons'; | ||
|
||
const MyTrip = () => { | ||
const { fetchNextPage, hasNextPage, data, isLoading, error } = | ||
useInfiniteQuery({ | ||
queryKey: ['wishList'], | ||
queryFn: ({ pageParam = 0 }) => getMemberTrips(pageParam, 10), | ||
initialPageParam: 0, | ||
getNextPageParam: (lastPage) => { | ||
if ( | ||
lastPage && | ||
lastPage.data && | ||
lastPage.data && | ||
lastPage.data.pageable | ||
) { | ||
const currentPage = lastPage.data.pageable.pageNumber; | ||
const totalPages = lastPage.data.totalPages; | ||
|
||
if (currentPage < totalPages - 1) { | ||
return currentPage + 1; | ||
} | ||
} | ||
return undefined; | ||
}, | ||
}); | ||
|
||
if (error) { | ||
return <div>데이터를 불러오는 중 오류가 발생했습니다.</div>; | ||
} | ||
|
||
return ( | ||
<div className="mt-3 min-h-[100vh] "> | ||
<div className=" sticky top-0 z-[105] bg-white py-[15px]"> | ||
<h1 className="title2">나의 여정</h1> | ||
</div> | ||
|
||
{data?.pages[0].data.content.length > 0 ? ( | ||
<MyTripList | ||
myTripsData={data || { pages: [] }} | ||
fetchNextPage={fetchNextPage} | ||
hasNextPage={hasNextPage} | ||
isLoading={isLoading} | ||
/> | ||
) : ( | ||
<NoDataMessage | ||
message1="저장된 관심 여행지가 없습니다." | ||
message2="가고 싶은 장소를 저장해보세요!" | ||
icon={<PenIcon size={44} fill="#EDEDED" color="#EDEDED" />} | ||
/> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default MyTrip; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { MoreIcon } from '@components/common/icons/Icons'; | ||
|
||
interface MyTripItemProps { | ||
myTripList: MyTripType; | ||
} | ||
|
||
const MyTripItem: React.FC<MyTripItemProps> = ({ myTripList }) => { | ||
const { | ||
tripName, | ||
startDate, | ||
endDate, | ||
numberOfTripMembers, | ||
tripStatus, | ||
tripThumbnailUrl, | ||
} = myTripList; | ||
|
||
const ACTIVE_TRIP = '여행 중'; | ||
const COMPLETED_TRIP = '여행 후'; | ||
|
||
return ( | ||
<div className="relative cursor-pointer pb-4"> | ||
<div className="flex min-h-[96px]"> | ||
<div> | ||
<img | ||
className="rounded-1 h-[96px] min-h-[96px] w-[96px] rounded-[16px] object-cover" | ||
src={tripThumbnailUrl} | ||
alt="여행지 이미지" | ||
/> | ||
<div className="absolute right-[0px] top-[0px] z-10 w-[24px]"> | ||
<MoreIcon size={20} fill="gray3" color="gray3" /> | ||
</div> | ||
</div> | ||
<div className="ml-[10px] flex flex-col items-start justify-between gap-[15px]"> | ||
<div className="max-w-[300px]"> | ||
<div | ||
className={`inline-flex ${ | ||
tripStatus === ACTIVE_TRIP | ||
? 'border-cyan-400 bg-cyan-400 ' | ||
: tripStatus === COMPLETED_TRIP | ||
? 'border-none bg-gray-200' | ||
: 'border-cyan-400 border-cyan-400 ' | ||
} h-[22px] items-center justify-center gap-[8px] rounded-2xl border border-solid px-[8px] py-[10px] pt-[11px]`}> | ||
<span | ||
className={`text-xs font-semibold ${ | ||
tripStatus === ACTIVE_TRIP | ||
? 'text-white' | ||
: tripStatus === COMPLETED_TRIP | ||
? 'text-gray4' | ||
: 'text-cyan-400' | ||
}`}> | ||
{tripStatus} | ||
</span> | ||
</div> | ||
<div className="mt-[7.5px] w-56 truncate text-base font-bold text-black"> | ||
{tripName} | ||
</div> | ||
<div className="h-4 w-56 font-['Pretendard'] text-sm font-medium tracking-tight text-zinc-500"> | ||
{startDate} ~ {endDate} | ||
</div> | ||
<div className="mt-[7.5px] inline-flex h-4 w-56 items-start justify-start gap-2"> | ||
<div className=" text-xs font-normal text-zinc-500"> | ||
{numberOfTripMembers}명과 공유중 | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default MyTripItem; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import React from 'react'; | ||
import InfiniteScroll from 'react-infinite-scroller'; | ||
import { v4 as uuidv4 } from 'uuid'; | ||
import ToursItemSkeleton from '@components/Tours/ToursItemSkeleton'; | ||
import MyTripItem from './MyTripItem'; | ||
|
||
interface MyTripListProps { | ||
myTripsData: { pages: Array<{ data: { content: MyTripType[] } }> }; | ||
fetchNextPage: () => void; | ||
hasNextPage: boolean; | ||
isLoading: boolean; | ||
} | ||
|
||
const MyTripList: React.FC<MyTripListProps> = ({ | ||
myTripsData, | ||
fetchNextPage, | ||
hasNextPage, | ||
isLoading, | ||
}) => { | ||
if (!myTripsData || myTripsData.pages.length === 0) { | ||
return <div>데이터를 불러오는 중 오류가 발생했습니다.</div>; | ||
} | ||
|
||
return ( | ||
<InfiniteScroll | ||
pageStart={0} | ||
loadMore={() => fetchNextPage()} | ||
hasMore={hasNextPage} | ||
loader={ | ||
<div key={uuidv4()} className="flex justify-center"> | ||
<div | ||
className="z-[100] mx-auto h-8 w-8 animate-spin rounded-full border-[3px] border-solid border-current border-t-transparent pt-10 text-[blue-600] dark:text-[#28d8ff]" | ||
role="status" | ||
aria-label="loading"> | ||
<div className="sr-only">Loading...</div> | ||
</div> | ||
</div> | ||
}> | ||
<div className="no-scrollbar grid grid-cols-1 gap-[5px] overflow-y-scroll"> | ||
{isLoading | ||
? Array.from({ length: 10 }, (_, index) => ( | ||
<ToursItemSkeleton key={index} /> | ||
)) | ||
: myTripsData.pages.map((group) => ( | ||
<React.Fragment key={uuidv4()}> | ||
{group?.data.content.map((myTripList: MyTripType) => ( | ||
<MyTripItem key={uuidv4()} myTripList={myTripList} /> | ||
))} | ||
</React.Fragment> | ||
))} | ||
</div> | ||
</InfiniteScroll> | ||
); | ||
}; | ||
|
||
export default MyTripList; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.