diff --git a/src/app/[lng]/search/Result.tsx b/src/app/[lng]/search/Result.tsx new file mode 100644 index 00000000..bab947b9 --- /dev/null +++ b/src/app/[lng]/search/Result.tsx @@ -0,0 +1,59 @@ +import { getAllNotices } from '@/api/notice/notice'; +import ResultZabo from '@/app/components/templates/ResultZabo/ResultZabo'; +import { createTranslation } from '@/app/i18next'; +import { Locale } from '@/app/i18next/settings'; + +import SearchNoResult from './assets/searchNoResult.svg'; + +const Result = async ({ + lng, + ...props +}: { + lng: Locale; + search: string; + tags: string[]; + offset: number; + limit: number; +}) => { + const { t } = await createTranslation(lng, 'translation'); + const data = await getAllNotices(props); + return ( + <> + {data?.list.length !== 0 && ( +
+

+ {t('searchPage.title')} +

+ +
+ + {data.list.map((notice) => ( + + ))} +
+ )} + + {props.search && data.list.length === 0 && ( +
+
+
+
+ + + +

+ {t('searchPage.noResult')} +

+
+
+ )} + + ); +}; + +export default Result; diff --git a/src/app/[lng]/search/page.tsx b/src/app/[lng]/search/page.tsx index 5fbdcb3d..7f4b0ac0 100644 --- a/src/app/[lng]/search/page.tsx +++ b/src/app/[lng]/search/page.tsx @@ -1,10 +1,11 @@ -import { getAllNotices } from '@/api/notice/notice'; +import { Suspense } from 'react'; + import LoadingCatAnimation from '@/app/components/templates/LoadingCatAnimation'; import SearchAnimation from '@/app/components/templates/SearchAnimation'; import { createTranslation } from '@/app/i18next'; import { Locale } from '@/app/i18next/settings'; -import SearchNoResult from './assets/searchNoResult.svg'; +import Result from './Result'; import SearchBar from './SearchBar'; import SearchTagSelect from './SearchTagSelect'; @@ -21,12 +22,6 @@ const SearchPage = async ({ const tags = rawTags?.split(',').filter(Boolean) ?? []; const { t } = await createTranslation(lng, 'translation'); - const data = await getAllNotices({ - search, - tags, - offset: 0, - limit: ITEMS_PER_CALL, - }); return (
@@ -37,27 +32,20 @@ const SearchPage = async ({
- {data?.list.length !== 0 && ( -
-

- {t('searchPage.title')} -

- -
- - {/* {data.list.map((notice) => ( - - ))} */} -
- )} - {/* 검색어를 입력하지 않았을 때만 */} - {!search && ( + {search ? ( + } + > + + + ) : (
@@ -68,23 +56,6 @@ const SearchPage = async ({
)} - {/* 검색어를 입력했을 때 로딩 */} - {search && } - - {search && data.list.length === 0 && ( -
-
-
-
- - - -

- {t('searchPage.noResult')} -

-
-
- )}
); diff --git a/src/app/components/templates/ResultZabo/ResultZabo.tsx b/src/app/components/templates/ResultZabo/ResultZabo.tsx index c26bb5e2..e7fc7eb5 100644 --- a/src/app/components/templates/ResultZabo/ResultZabo.tsx +++ b/src/app/components/templates/ResultZabo/ResultZabo.tsx @@ -1,5 +1,6 @@ +'use client'; + import { Notice } from '@/api/notice/notice'; -import { T } from '@/app/i18next'; import ResultImageZabo from './ResultImageZabo'; import ResultTextZabo from './ResultTextZabo'; @@ -7,7 +8,6 @@ import ResultTextZabo from './ResultTextZabo'; export type ResultZaboProps = Notice & { searchQuery: string; logName?: string; - t: T; }; export type ResultImageZaboProps = ResultZaboProps & {