-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] - 마이페이지 좋아요 탭 및 검색 창 국가 탭 기능 구현 (#556)
* refactor(MyPage): 프로필 이미지 수정 모달 text 변경 * feat(TravelogueList): 여행기 검색 나라 탭 추가 * refactor(Tab): 스타일링 수정 * refactor(MyTravelogue): 불필요한 스타일 제거 및 일관성을 위하여 게시일 텍스트 제거 * feat(useInfiniteMyLikes): 훅 기능 구현 * feat(MyLikes): 좋아요 탭 UI 구현 * refactor: 좋아요 버튼 클릭시 마이페이지 좋아요 무효화 하도록 수정 * refactor(MyLikes): 마이페이지텝 컴포넌트 좋아요 탭에서도 재사용하도록 수정
- Loading branch information
Showing
18 changed files
with
268 additions
and
24 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
45 changes: 45 additions & 0 deletions
45
frontend/src/components/pages/my/MyLikes/MyLikes.styled.ts
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,45 @@ | ||
import styled from "@emotion/styled"; | ||
|
||
export const Layout = styled.div` | ||
display: flex; | ||
width: 100%; | ||
height: 100%; | ||
gap: ${(props) => props.theme.spacing.m}; | ||
`; | ||
|
||
export const List = styled.ul` | ||
display: flex; | ||
flex-direction: column; | ||
gap: ${(props) => props.theme.spacing.m}; | ||
width: 100%; | ||
padding: 0 ${(props) => props.theme.spacing.l}; | ||
`; | ||
|
||
export const Container = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: flex-start; | ||
gap: ${(props) => props.theme.spacing.s}; | ||
`; | ||
|
||
export const DetailContainer = styled.div` | ||
display: flex; | ||
align-items: center; | ||
gap: ${(props) => props.theme.spacing.m}; | ||
width: 100%; | ||
`; | ||
|
||
export const BoxButton = styled.button` | ||
display: flex; | ||
gap: ${(props) => props.theme.spacing.m}; | ||
justify-content: flex-start; | ||
align-items: center; | ||
width: 100%; | ||
padding: ${(props) => props.theme.spacing.m}; | ||
border: 1px solid ${(props) => props.theme.colors.border}; | ||
border-radius: 10px; | ||
`; |
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,102 @@ | ||
import { useEffect } from "react"; | ||
import { useNavigate } from "react-router-dom"; | ||
|
||
import { css } from "@emotion/react"; | ||
|
||
import type { UserResponse } from "@type/domain/user"; | ||
|
||
import useInfiniteMyLikes from "@queries/useInfiniteMyLikes"; | ||
|
||
import { AvatarCircle, Text } from "@components/common"; | ||
import MyPageTabContentSkeleton from "@components/pages/my/MyPageTabContentSkeleton/MyPageTabContentSkeleton"; | ||
|
||
import useIntersectionObserver from "@hooks/useIntersectionObserver"; | ||
|
||
import { ERROR_MESSAGE_MAP } from "@constants/errorMessage"; | ||
import { ROUTE_PATHS_MAP } from "@constants/route"; | ||
|
||
import theme from "@styles/theme"; | ||
|
||
import MyPageTabContent from "../MyPageTabContent/MyPageTabContent"; | ||
import * as S from "./MyLikes.styled"; | ||
|
||
interface MyLikesProps { | ||
userData: UserResponse; | ||
} | ||
|
||
const MyLikes = ({ userData }: MyLikesProps) => { | ||
const { myLikes, fetchNextPage, status, isPaused, error } = useInfiniteMyLikes(userData); | ||
const { lastElementRef } = useIntersectionObserver(fetchNextPage); | ||
|
||
const navigate = useNavigate(); | ||
|
||
const handleClickTravelogue = (id: string) => { | ||
navigate(ROUTE_PATHS_MAP.travelogue(Number(id))); | ||
}; | ||
|
||
const handleClickIconButton = () => { | ||
navigate(ROUTE_PATHS_MAP.root); | ||
}; | ||
|
||
useEffect(() => { | ||
if (isPaused) alert(ERROR_MESSAGE_MAP.network); | ||
}, [isPaused]); | ||
|
||
if (status === "pending") return <MyPageTabContentSkeleton />; | ||
|
||
if (error) alert(error.message); | ||
|
||
return ( | ||
<> | ||
<MyPageTabContent | ||
iconButtonType="search-icon" | ||
iconButtonLabel="다른 여행기 구경하기" | ||
onClickIconButton={handleClickIconButton} | ||
contentDetail={myLikes} | ||
renderItem={({ id, title, createdAt, thumbnailUrl, authorName }) => ( | ||
<S.Layout onClick={() => handleClickTravelogue(id)}> | ||
<AvatarCircle size="medium" profileImageUrl={thumbnailUrl} /> | ||
|
||
<S.Container> | ||
<Text | ||
textType="body" | ||
css={css` | ||
font-weight: 500; | ||
`} | ||
> | ||
{title} | ||
</Text> | ||
<S.DetailContainer> | ||
<Text | ||
textType="detail" | ||
css={css` | ||
color: ${theme.colors.text.secondary}; | ||
`} | ||
> | ||
{authorName} | ||
</Text> | ||
<Text | ||
textType="detail" | ||
css={css` | ||
color: ${theme.colors.text.secondary}; | ||
`} | ||
> | ||
{createdAt} | ||
</Text> | ||
</S.DetailContainer> | ||
</S.Container> | ||
</S.Layout> | ||
)} | ||
/> | ||
|
||
<div | ||
ref={lastElementRef} | ||
css={css` | ||
height: 1px; | ||
`} | ||
/> | ||
</> | ||
); | ||
}; | ||
|
||
export default MyLikes; |
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
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 |
---|---|---|
@@ -1,11 +1,13 @@ | ||
import { ERROR_MESSAGE_MAP } from "@constants/errorMessage"; | ||
|
||
import MyLikes from "./MyLikes/MyLikes"; | ||
import MyTravelPlans from "./MyTravelPlans/MyTravelPlans"; | ||
import MyTravelogues from "./MyTravelogues/MyTravelogues"; | ||
|
||
export const TAB_CONTENT = [ | ||
{ label: "✈️ 내 여행 계획", component: MyTravelPlans }, | ||
{ label: "📝 내 여행기", component: MyTravelogues }, | ||
{ label: "❤️ 좋아요", component: MyLikes }, | ||
] as const; | ||
|
||
export const IGNORED_ERROR_MESSAGES = [ERROR_MESSAGE_MAP.api.login, "Network Error"]; |
22 changes: 22 additions & 0 deletions
22
frontend/src/components/pages/search/TravelogueList/EmptySearchResult.tsx
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,22 @@ | ||
import { SearchFallback, Text } from "@components/common"; | ||
|
||
import * as S from "./TravelogueList.styled"; | ||
|
||
interface EmptySearchResultProps { | ||
keyword: string | undefined; | ||
} | ||
|
||
const EmptySearchResult = ({ keyword }: EmptySearchResultProps) => { | ||
return ( | ||
<S.Layout> | ||
{keyword && ( | ||
<Text css={S.searchResultTextStyle} textType="title">{`"${keyword}" 검색 결과`}</Text> | ||
)} | ||
<S.SearchFallbackWrapper> | ||
<SearchFallback title="휑" text="검색 결과가 없어요." /> | ||
</S.SearchFallbackWrapper> | ||
</S.Layout> | ||
); | ||
}; | ||
|
||
export default EmptySearchResult; |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export const TAB_CONTENT = [ | ||
{ label: "제목", searchType: "TITLE" }, | ||
{ label: "작성자", searchType: "AUTHOR" }, | ||
{ label: "나라", searchType: "COUNTRY" }, | ||
] as const; |
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.