Skip to content

Commit

Permalink
투표 현황이 잘 보이지 않는 이슈를 해결한다. (SWYP-team-2th#194)
Browse files Browse the repository at this point in the history
  • Loading branch information
YOOJS1205 committed Mar 3, 2025
1 parent dc83dfa commit bfbf657
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/components/vote-detail/Vote/VoteResult/VoteResultList.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useParams } from 'react-router-dom';
import useGetMyInfo from '@/api/useGetMyInfo';
import BlurImage from '@/assets/images/vote-detail/voteBlur.png';
import { getRole } from '@/components/login/Auth/token';
import useVoteStatus from '@/components/vote-detail/Vote/VoteResult/hooks';
import VoteResultItem from '@/components/vote-detail/Vote/VoteResult/VoteResultItem';

Expand All @@ -12,21 +13,15 @@ export default function VoteResultList() {
});
const { data: myInfo } = useGetMyInfo();

// 유저가 해당 게시글에 투표 했는지에 대한 유무

// 전체 투표 수 계산
const totalVoted = voteStatus?.reduce(
(sum, status) => sum + status.voteCount,
0,
);

// 가장 높은 투표 수 계산
const highestVoted = Math.max(
...(voteStatus?.map((status) => status.voteCount) ?? []),
);

//

return (
<div className="px-1">
{!userHasVoted && (
Expand All @@ -39,7 +34,7 @@ export default function VoteResultList() {
<p>투표하고, 뽀또들과 함께 결과를 실시간으로 확인해보세요! 🎉</p>
</div>
)}
{userHasVoted && !myInfo && (
{userHasVoted && myInfo && getRole() === 'GUEST' && (
<div
className="flex items-center justify-center w-full h-18 text-body-1-normal "
style={{
Expand All @@ -51,6 +46,7 @@ export default function VoteResultList() {
)}
{userHasVoted &&
myInfo &&
getRole() === 'USER' &&
voteStatus?.map((status, index) => {
const calculatedVoteRatio = totalVoted
? ((status.voteCount / totalVoted) * 100).toFixed(1)
Expand Down

0 comments on commit bfbf657

Please sign in to comment.