Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default function FilterPanel({ value, onChange }: FilterPanelProps) {
$selected={value === 'most-liked'}
onClick={handleClick}
>
최다 찬성
찬반순
</S.Btn>
<S.Btn
type="button"
Expand Down
16 changes: 12 additions & 4 deletions src/app/(with-sidebar)/issue/hooks/use-highlighted-ideas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ export const useIdeaHighlight = (issueId: string, initialIdeas: IdeaWithPosition
sorted.sort((a, b) => {
const aV = getVoteCounts(a);
const bV = getVoteCounts(b);
if (bV.agree !== aV.agree) return bV.agree - aV.agree;
return bV.total - aV.total;
const aDiff = aV.agree - aV.disagree;
const bDiff = bV.agree - bV.disagree;
if (aDiff === bDiff) return bV.agree - aV.agree;
return bDiff - aDiff;
});
} else if (activeFilter === 'need-discussion') {
// 찬반 비율 20% 이내 후보군 필터링 후 찬성순 정렬
Expand All @@ -44,8 +46,14 @@ export const useIdeaHighlight = (issueId: string, initialIdeas: IdeaWithPosition

const result = sorted.filter((idea, index) => {
if (index < 3) return true;
// 3등과 찬성 수가 같다면 무제한 포함
return getVoteCounts(idea).agree === thirdAgree;
const ideaV = getVoteCounts(idea);
if (ideaV.total===0) return false;
if (activeFilter === 'need-discussion') {
return getVoteCounts(idea).agree === thirdAgree;
}
const ideaDiff = ideaV.agree - ideaV.disagree;
const thirdDiff = thirdStandard ? getVoteCounts(thirdStandard).agree - getVoteCounts(thirdStandard).disagree : 0;
return (ideaV.agree === thirdAgree) && (ideaDiff > thirdDiff);
});

return new Set(result.map((i) => i.id));
Expand Down