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

Feat/#301 best piickle API #304

Merged
merged 15 commits into from
Jul 16, 2023
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,24 @@ interface RankItemProps {
cardId: string;
content: string;
rank: number;
isBookmark: boolean;
}

export default function RankItem(props: RankItemProps) {
const { cardId, content, rank } = props;
const { cardId, content, rank, isBookmark } = props;

const navigateRankCollection = useNavigateCardCollection(LocationType.BEST) as NavigateCardCollectionBookMarkType;

const [isBookmarked, setIsBookmarked] = useState<boolean>(true);
const [isBookmarked, setIsBookmarked] = useState<boolean>(isBookmark);
const toggleBookmark = () => {
setIsBookmarked((prev) => !prev);
//cardCollectionApi.addNDeleteBookmark(cardId);
cardCollectionApi.addNDeleteBookmark(cardId);
};

return (
<St.RankItemContainer>
<St.RankItemContent>
<St.RankItemNumber idx={rank}>{rank}</St.RankItemNumber>
<St.RankItemNumber idx={rank}>{rank + 1}</St.RankItemNumber>
<St.RankItemText>{content}</St.RankItemText>
</St.RankItemContent>
<St.BookmarkWrapper onClick={toggleBookmark}>
Expand Down
24 changes: 15 additions & 9 deletions src/@components/BestPiicklePage/BestPiickleRank/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { LocationType } from "../../../types/cardCollection";
import { HeadingTitle } from "../../../util/main/headingTitles";
import HeadingTitleContainer from "../../@common/HeadingTitleContainer";
import useNavigateCardCollection, {
NavigateCardCollectionBookMarkType,
} from "../../@common/hooks/useNavigateCardCollection";
import { useBestPiickle } from "../../MainPage/hooks/useBestPiickle";
import RankItem from "./RankItem";
import * as St from "./style";

Expand All @@ -9,20 +14,21 @@ const rankTitles: HeadingTitle = {
};

export default function BestPiickleRank() {
const { bestPiickle } = useBestPiickle();

const navigateRankCollection = useNavigateCardCollection(LocationType.BEST) as NavigateCardCollectionBookMarkType;
return (
<St.RankContainer>
{/* todo : rankitem id 수정*/}
<HeadingTitleContainer headingTitles={rankTitles} paddingVerticalValue={1.6} />
<RankItem cardId="1" content="상대방의첫인상을기억하나요저는몰라요그냥해그냥해그냥해" rank={1} />
<RankItem cardId="1" content="상대방의 첫인상을 기억하나요?" rank={2} />
<RankItem cardId="1" content="상대방의 첫인상을 기억하나요?" rank={3} />
<RankItem cardId="1" content="상대방의 첫인상을 기억하나요?" rank={4} />
<RankItem cardId="1" content="상대방의 첫인상을 기억하나요?" rank={5} />
<RankItem cardId="1" content="상대방의 첫인상을 기억하나요?" rank={6} />
<RankItem cardId="1" content="상대방의 첫인상을 기억하나요?" rank={7} />
<RankItem cardId="1" content="상대방의 첫인상을 기억하나요?" rank={8} />
{bestPiickle &&
[...bestPiickle.data]
.slice(0, 8)
Copy link
Member

Choose a reason for hiding this comment

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

8이라는 숫자에 대해서 const BEST_PIICKLE_TOTAL_COUNT = ~ 처럼 정의해두면 읽기 좀 더 편하지 않을까 해요!

Copy link
Member Author

Choose a reason for hiding this comment

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

좋은 의견이에요! 다른 브랜치에서 반영해보겠습니다:)

.map(({ _id, content, isBookmark }, idx) => (
<RankItem key={_id} cardId={_id} content={content} rank={idx} isBookmark={isBookmark} />
))}
<St.ButtonWrapper>
<St.ContinueButton>이어서 베스트 피클 카드 보기</St.ContinueButton>
<St.ContinueButton onClick={() => navigateRankCollection(8)}>이어서 베스트 피클 카드 보기</St.ContinueButton>
Copy link
Contributor

Choose a reason for hiding this comment

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

이거 왜 8인지 몰라서 기능명세서 보고 왔쟈나~ 똑순이!👑👍

Copy link
Member Author

Choose a reason for hiding this comment

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

나도 처음에 이해안돼서 승헌오빠한테 물어봤어 ㅎㅎ

</St.ButtonWrapper>
</St.RankContainer>
);
Expand Down