Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] - 마이페이지 좋아요 탭 및 검색 창 국가 탭 기능 구현 #556

Merged
merged 8 commits into from
Oct 22, 2024
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

분리 좋네요! 👍

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;
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import type { SearchType } from "@type/domain/travelogue";

import useInfiniteSearchTravelogues from "@queries/useInfiniteSearchTravelogues";

import { SearchFallback, Text } from "@components/common";
import { Text } from "@components/common";
import TravelogueCard from "@components/pages/main/TravelogueCard/TravelogueCard";
import TravelogueCardSkeleton from "@components/pages/main/TravelogueCard/skeleton/TravelogueCardSkeleton";

import useIntersectionObserver from "@hooks/useIntersectionObserver";

import { ERROR_MESSAGE_MAP } from "@constants/errorMessage";

import EmptySearchResult from "./EmptySearchResult";
import * as S from "./TravelogueList.styled";

const SKELETON_COUNT = 5;
Expand All @@ -29,22 +30,13 @@ const TravelogueList = ({ keyword, searchType }: TravelogueListProps) => {
const { lastElementRef } = useIntersectionObserver(fetchNextPage);

if (travelogues.length === 0 && status === "success") {
return (
<S.Layout>
{keyword && (
<Text css={S.searchResultTextStyle} textType="title">{`"${keyword}" 검색 결과`}</Text>
)}
<S.SearchFallbackWrapper>
<SearchFallback title="휑" text="검색 결과가 없어요." />
</S.SearchFallbackWrapper>
</S.Layout>
);
return <EmptySearchResult keyword={keyword} />;
}

if (status === "error") {
error && alert(error.message);

return <SearchFallback title="휑" text="검색 결과가 없어요." />;
return <EmptySearchResult keyword={keyword} />;
}

if (isPaused) alert(ERROR_MESSAGE_MAP.network);
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/pages/search/constants.ts
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;