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

fix: 상세 모달에서 네이버 블로그 결과가 안나오는 이슈 수정 #214

Merged
merged 1 commit into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 21 additions & 25 deletions src/components/detail/PlaceDetailWindow/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@

const googleReviewCount = checkNumber(placeDetail?.reviews?.length);
const koreanReviewCount = checkEmpty(placeDetail?.reviews).filter(({ language }) => language === 'ko').length;
const blogCount = placeDetail?.searchBlogPost?.status === 'fulfilled' ? checkNumber(
placeDetail?.searchBlogPost?.value.total_count,
) : 0;
const blogCount = checkNumber(placeDetail?.searchBlogPost?.total_count);

const onClickShare = useCallback(async () => {
try {
Expand All @@ -78,7 +76,7 @@
} catch (error) {
renderToast('URL 복사에 실패했습니다.', { type: 'error' });
}
}, [placeDetail?.place_id, placeDetail?.name]);

Check warning on line 79 in src/components/detail/PlaceDetailWindow/index.tsx

View workflow job for this annotation

GitHub Actions / check unit test & lint

React Hook useCallback has missing dependencies: 'params' and 'renderToast'. Either include them or remove the dependency array

const displayDetailInfoText = useCallback(() => {
if (googleReviewCount < 3) {
Expand Down Expand Up @@ -197,28 +195,26 @@
))}
</div>
</Accordion>
{placeDetail?.searchBlogPost?.status === 'fulfilled' && (
<Accordion
title="네이버 검색결과"
counterColor={blogCount ? 'danger' : 'positive'}
counter={checkNumber(placeDetail?.searchBlogPost.value?.total_count)}
wrapperClassName={styles.reviewAccordionWrapper}
>
<div className={styles.resultWrapper}>
{checkEmpty(placeDetail?.searchBlogPost?.value?.posts).map(({
title, description, link, thumbnail,
}) => (
<ResultCard
key={title}
title={title}
description={description}
url={link}
thumbnail={thumbnail}
/>
))}
</div>
</Accordion>
)}
<Accordion
title="네이버 검색결과"
counterColor={blogCount ? 'danger' : 'positive'}
counter={checkNumber(placeDetail?.searchBlogPost?.total_count)}
wrapperClassName={styles.reviewAccordionWrapper}
>
<div className={styles.resultWrapper}>
{checkEmpty(placeDetail?.searchBlogPost?.posts).map(({
title, description, link, thumbnail,
}) => (
<ResultCard
key={title}
title={title}
description={description}
url={link}
thumbnail={thumbnail}
/>
))}
</div>
</Accordion>
</>
)}
</div>
Expand Down
3 changes: 2 additions & 1 deletion src/lib/types/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export type SelectedPlace = {
};

export interface PlacesWithSearchResult<T = false> extends PlaceResult {
searchBlogPost: PromiseSettledResult<NaverSearchBlog<T>> | null;
searchBlogPost: T extends true ? NaverSearchBlog<T> | null
: PromiseSettledResult<NaverSearchBlog<T>> | null;
}

export interface SearchPlaces extends TextSearchResponseData {
Expand Down
Loading