Skip to content

Commit

Permalink
fix: 상세 모달에서 네이버 블로그 결과가 안나오는 이슈 수정 (#214)
Browse files Browse the repository at this point in the history
  • Loading branch information
saseungmin authored Oct 24, 2023
1 parent 309cea0 commit cfaccf0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 26 deletions.
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 @@ function PlaceDetailWindow({

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 Down Expand Up @@ -197,28 +195,26 @@ function PlaceDetailWindow({
))}
</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

1 comment on commit cfaccf0

@vercel
Copy link

@vercel vercel bot commented on cfaccf0 Oct 24, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.