Skip to content

Commit

Permalink
Merge pull request #336 from depromeet/fix/QA-19
Browse files Browse the repository at this point in the history
kakaoCategoryName이 아닌 categoryName을 참조하도록 수정
  • Loading branch information
YOOJS1205 authored May 7, 2024
2 parents dd12ffc + 21dc013 commit 952598f
Show file tree
Hide file tree
Showing 22 changed files with 134 additions and 98 deletions.
2 changes: 1 addition & 1 deletion src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default function Home() {
} as CoordinateWithIds,
storeName: searchParams.get('storeName') || '',
isBookmarked: Boolean(searchParams.get('isBookmarked')),
totalRevisitedCount: Number(searchParams.get('totalRevisitedCount')),
totalRevisitedCnt: Number(searchParams.get('totalRevisitedCnt')),
address: searchParams.get('address') || '',
categoryType: searchParams.get('categoryType') || '',
distance: Number(searchParams.get('distance')),
Expand Down
6 changes: 3 additions & 3 deletions src/components/common/Pin/PinBubble.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import { useSearchParams } from 'next/navigation';
import { bounceAnimationVariants } from '@constants/motions';

interface PinBubbleProps {
totalRevisitedCount: number;
totalRevisitedCnt: number;
}

export default function PinBubble({ totalRevisitedCount }: PinBubbleProps) {
export default function PinBubble({ totalRevisitedCnt }: PinBubbleProps) {
const searchParams = useSearchParams();
const storeId = searchParams.get('storeId');

Expand All @@ -29,7 +29,7 @@ export default function PinBubble({ totalRevisitedCount }: PinBubbleProps) {
{storeId && <PinVisitorIcon />}
<p className="body-14-extraBold text-white">
{storeId
? `${totalRevisitedCount}명이 재방문했어요!`
? `${totalRevisitedCnt}명이 재방문했어요!`
: '첫 방문 기록을 남겨주세요!'}
</p>
</div>
Expand Down
12 changes: 5 additions & 7 deletions src/components/common/Pin/PinIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import PinBowlSamllIcon from '/public/assets/icon30/pin_bowl_30.svg';

interface PinIconProps {
isBookmarked: boolean;
totalRevisitedCount: number;
totalRevisitedCnt: number;
mapLevel: number;
}

export const PinIcon = ({
isBookmarked,
totalRevisitedCount,
totalRevisitedCnt,
mapLevel,
}: PinIconProps) => {
if (isBookmarked) {
Expand All @@ -26,11 +26,9 @@ export const PinIcon = ({

return (
<>
{totalRevisitedCount >= 15 && <PinBowlThreeIcon />}
{totalRevisitedCount >= 5 && totalRevisitedCount < 15 && (
<PinBowlTwoIcon />
)}
{totalRevisitedCount < 5 && <PinBowlOneIcon />}
{totalRevisitedCnt >= 15 && <PinBowlThreeIcon />}
{totalRevisitedCnt >= 5 && totalRevisitedCnt < 15 && <PinBowlTwoIcon />}
{totalRevisitedCnt < 5 && <PinBowlOneIcon />}
</>
);
};
8 changes: 4 additions & 4 deletions src/components/common/Pin/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export interface PinProps {
isActive: boolean;
storeName: string;
isBookmarked: boolean;
totalRevisitedCount: number;
totalRevisitedCnt: number;
onClick?: (e: React.PointerEvent<HTMLButtonElement>) => void;
mapLevel: number;
}
Expand All @@ -16,14 +16,14 @@ export default function Pin({
isActive,
storeName,
isBookmarked,
totalRevisitedCount,
totalRevisitedCnt,
onClick,
mapLevel,
}: PinProps) {
return (
<div className="relative w-full flex flex-col justify-center items-center">
<AnimatePresence mode="wait">
{isActive && <PinBubble totalRevisitedCount={totalRevisitedCount} />}
{isActive && <PinBubble totalRevisitedCnt={totalRevisitedCnt} />}
</AnimatePresence>
<button
onClick={onClick}
Expand All @@ -32,7 +32,7 @@ export default function Pin({
<PinIcon
mapLevel={mapLevel}
isBookmarked={isBookmarked}
totalRevisitedCount={totalRevisitedCount}
totalRevisitedCnt={totalRevisitedCnt}
/>
{mapLevel < 5 && (
<p className="body-14-extraBold text-gray-900 text-shadow-stroke absolute top-[90%]">
Expand Down
4 changes: 2 additions & 2 deletions src/components/main/CustomOverlayPin/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function CustomOverlayPin({
storeName,
position,
isBookmarked,
totalRevisitedCount,
totalRevisitedCnt,
isActive,
onClick,
mapLevel,
Expand All @@ -27,7 +27,7 @@ function CustomOverlayPin({
isActive={isActive}
storeName={storeName}
isBookmarked={isBookmarked}
totalRevisitedCount={totalRevisitedCount}
totalRevisitedCnt={totalRevisitedCnt}
onClick={onClick}
/>
</CustomOverlayMap>
Expand Down
2 changes: 1 addition & 1 deletion src/components/main/LocationStorePinList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function LocationStorePinList({
position={{ lat: store.latitude, lng: store.longitude }}
storeName={store.storeName}
isBookmarked={store.isBookmarked}
totalRevisitedCount={store.totalRevisitedCount}
totalRevisitedCnt={store.totalFeedCnt}
onClick={handlePinClick({
storeName: store.storeName,
lat: store.latitude,
Expand Down
2 changes: 1 addition & 1 deletion src/components/main/StoreDetailSection/Report/ReVisit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default function ReVisit() {
return (
<ReportContainer>
<p className="caption-12-regular">재방문한 단골은</p>
<p className="header-20">{data?.totalRevisitedCount ?? 0}</p>
<p className="header-20">{data?.totalRevisitedCnt ?? 0}</p>
<DdobabReportTwoIcon />
</ReportContainer>
);
Expand Down
62 changes: 35 additions & 27 deletions src/components/main/StoreDetailSection/Reviews/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@ import { useState } from 'react';
import { useSearchParams } from 'next/navigation';

import SectionTitle from '../SectionTitle';
import StoreDetailLog from '../StoreDetailLog';

import cn from '@utils/cn';
import Tag from '@components/common/Tag';
import {
type GetReviewParams,
useInfiniteReview,
} from '@hooks/api/useInfiniteReview';
import useObserver from '@hooks/useObserver';
import { useDeleteLog } from '@hooks/api/useDeleteLog';
import { useGetStoreFeedList } from '@hooks/api/useGetFeedList';
import { Feed } from '@components/feed/Feed';

export default function Reviews() {
const [activeTag, setActiveTag] = useState<'REVISITED' | 'PHOTO' | null>(
Expand All @@ -20,17 +16,17 @@ export default function Reviews() {

const searchParams = useSearchParams();

const storeId = searchParams.get('storeId');
const storeId = Number(searchParams.get('storeId'));

const params: GetReviewParams = {
storeId: storeId ?? '',
type: activeTag,
const params = {
storeId: storeId ?? 0,
};

const { data, fetchNextPage, isLoading, hasNextPage } =
useInfiniteReview(params);
useGetStoreFeedList(params);
const { mutate: deleteLog } = useDeleteLog();

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const handleTagClick = (tag: 'REVISITED' | 'PHOTO' | null) => () => {
setActiveTag((prevTag) => (prevTag === tag ? null : tag));
};
Expand All @@ -44,10 +40,12 @@ export default function Reviews() {
threshold: 0.5,
});

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const handleDeleteLog = (id: number) => {
deleteLog(id);
};

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const formatTagClassName = (tag: 'REVISITED' | 'PHOTO') => {
return cn({
'bg-gray-500 text-white': activeTag === tag,
Expand All @@ -59,7 +57,7 @@ export default function Reviews() {
<div>
<div className="px-[16px] pb-[8px]">
<SectionTitle>방문기록</SectionTitle>
<div className="flex gap-[8px]">
{/* <div className="flex gap-[8px]">
<Tag
size="large"
className={formatTagClassName('REVISITED')}
Expand All @@ -74,27 +72,37 @@ export default function Reviews() {
>
사진 리뷰만
</Tag>
</div>
</div> */}
</div>

<div className="mx-[16px]">
{data && !data[0].data.empty ? (
data?.map((page) => {
return page.data.content.map((item) => {
return page.data.content.map((feed) => {
return (
<StoreDetailLog
key={item.reviewId}
date={item.visitedAt}
score={item.rating}
log={item.description}
storeImgUrl={item.imageUrl}
name={item.nickName}
visitNum={item.visitTimes}
hasDeleteOption={item.isMine}
hasReportOption={!item.isMine}
isLast={true}
onClick={() => handleDeleteLog(item.reviewId)}
/>
<Feed key={feed.feedId}>
<Feed.Date>{feed.createdAt}</Feed.Date>
<Feed.Profile
userId={feed.userId}
src={feed.profileImageUrl}
nickName={feed.nickname}
alt={`${feed.userId} 프로필 이미지`}
isMyFeed={feed.isMine}
isFollowed={feed.isFollowed}
/>
<Feed.Image
src={feed.feedImg}
alt={`${feed.feedStoreResponse.storeName} 이미지`}
storeName={feed.feedStoreResponse.storeName}
storeCategory={feed.feedStoreResponse.kakaoCategoryName}
storeLocation={feed.feedStoreResponse.address}
storeResponse={feed.feedStoreResponse}
/>
<Feed.Description
id={feed.feedId}
description={feed.description}
/>
</Feed>
);
});
})
Expand Down
12 changes: 5 additions & 7 deletions src/components/main/StoreDetailSection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { useBottomSheet } from '../BottomSheet/contexts/BottomSheetContext';
import StoreInformation from '../StoreInformation';
import { SearchedPinFromSearchParams } from '../StorePreviewSection';
import WriteLogButton from '../WriteLogButton';
import Report from './Report';
import Reviews from './Reviews';

import AnimatePortal from '@components/common/AnimatePortal';
Expand Down Expand Up @@ -83,8 +82,8 @@ export default function StoreDetailSection({
})}
/>
<StoreInformation
categoryName={
storeData?.categoryName ??
kakaoCategoryName={
storeData?.kakaoCategoryName ??
searchedPinFromSearchParams?.kakaoCategoryName ??
''
}
Expand All @@ -95,16 +94,16 @@ export default function StoreDetailSection({
storeData?.address ?? searchedPinFromSearchParams?.address ?? ''
}
totalRating={storeData?.totalRating ?? 0}
totalReviewCount={storeData?.totalReviewCount ?? 0}
myRevisitedCount={storeData?.myRevisitedCount ?? 0}
totalReviewCount={storeData?.totalFeedCnt ?? 0}
myRevisitedCount={storeData?.userFeedCnt ?? 0}
/>
<div className="flex gap-[8px] p-[16px]">
<WriteLogButton
storeName={
storeData?.storeName ?? searchedPinFromSearchParams?.storeName ?? ''
}
storeId={storeData?.storeId ?? null}
myRevisitedCount={storeData?.myRevisitedCount ?? 0}
myRevisitedCount={storeData?.userFeedCnt ?? 0}
searchedPinFromSearchParams={searchedPinFromSearchParams}
/>
{storeData && (
Expand All @@ -115,7 +114,6 @@ export default function StoreDetailSection({
)}
</div>
<div className="w-full h-[8px] bg-gray-100" />
<Report />
<Reviews />
</div>
);
Expand Down
6 changes: 3 additions & 3 deletions src/components/main/StoreInformation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Tag from '@components/common/Tag';
import switchUrl from '@utils/switchUrl';

interface StoreInformationProps {
categoryName: string;
kakaoCategoryName: string;
storeName: string;
address: string;
totalRating: number;
Expand All @@ -12,7 +12,7 @@ interface StoreInformationProps {
}

function StoreInformation({
categoryName,
kakaoCategoryName,
storeName,
address,
totalRating,
Expand All @@ -39,7 +39,7 @@ function StoreInformation({
내방문 {myRevisitedCount}
</Tag>
<Tag size="small" className=" bg-gray-50 text-gray-500">
{categoryName}
{kakaoCategoryName}
</Tag>
</div>
</div>
Expand Down
14 changes: 7 additions & 7 deletions src/components/main/StorePreviewSection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface SearchedPinFromSearchParams {
position: CoordinateWithIds;
storeName: string;
isBookmarked: boolean;
totalRevisitedCount: number;
totalRevisitedCnt: number;
address: string;
categoryType: string;
distance: number;
Expand Down Expand Up @@ -51,7 +51,7 @@ function StorePreviewSection({
url.searchParams.set('lng', String(lng));
url.searchParams.set(
'myRevisitedCount',
String(storeData?.myRevisitedCount ?? 0),
String(storeData?.userFeedCnt ?? 0),
);
switchUrl(url);

Expand All @@ -62,8 +62,8 @@ function StorePreviewSection({
<>
<div className="w-full h-fit pb-[12px]">
<StoreInformation
categoryName={
storeData?.categoryName ??
kakaoCategoryName={
storeData?.kakaoCategoryName ??
searchedPinFromSearchParams?.kakaoCategoryName ??
''
}
Expand All @@ -74,8 +74,8 @@ function StorePreviewSection({
storeData?.address ?? searchedPinFromSearchParams?.address ?? ''
}
totalRating={storeData?.totalRating ?? 0}
totalReviewCount={storeData?.totalReviewCount ?? 0}
myRevisitedCount={storeData?.myRevisitedCount ?? 0}
totalReviewCount={storeData?.totalFeedCnt ?? 0}
myRevisitedCount={storeData?.userFeedCnt ?? 0}
/>
{storeData && storeData.feedImageUrls.length > 0 && (
<StoreLogPhotoPreview feedImageUrls={storeData?.feedImageUrls} />
Expand All @@ -88,7 +88,7 @@ function StorePreviewSection({
''
}
storeId={storeData?.storeId ?? null}
myRevisitedCount={storeData?.myRevisitedCount ?? 0}
myRevisitedCount={storeData?.userFeedCnt ?? 0}
searchedPinFromSearchParams={searchedPinFromSearchParams}
/>
{storeData && (
Expand Down
2 changes: 1 addition & 1 deletion src/components/profile/BookMarkContent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export default function BookMarkContent() {
storeId={item.storeId}
location={item.address}
menuType={item.categoryName}
revisitNum={item.totalRevisitedCount}
revisitNum={item.totalRevisitedCnt}
storeName={item.storeName}
onClick={() => handleDeleteItem(item.storeId)}
/>
Expand Down
Loading

0 comments on commit 952598f

Please sign in to comment.