Skip to content

Commit

Permalink
fix:드로우 모달 수정 (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
yelynnn authored Feb 20, 2025
1 parent 7c90f04 commit c302aaf
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/pages/raffleDetail/components/modal/RandomModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,38 @@ export default function RandomModal({
const [isRolling, setIsRolling] = useState(false);
const { openModal } = useModalContext();

const handleAddName = () => {
setItems((prevItems) => {
const newItems = [...prevItems];
newItems.splice(1, 0, '닉네임');
return newItems;
});
};

useEffect(() => {
console.log('nicknameSet:', nicknameSet);
console.log('winner:', winner);
setItems(nicknameSet);
handleAddName();
setWinner(winnerNickname);
}, [nicknameSet, deliveryId]);
}, [deliveryId]);

console.log('참여자 목록', items);

const handleClick = () => {
if (!isRolling && winner && sliderRef.current) {
setIsRolling(true);
sliderRef.current.slickPlay();

setTimeout(() => {
//const winnerIndex = items.findIndex((item) => item.name === winner) - 1;
const winnerIndex = items.length - 1;
const winnerIndex = items.length - 2;
if (winnerIndex !== -1) {
sliderRef.current?.slickGoTo(winnerIndex);
setTimeout(() => sliderRef.current?.slickPause(), 500);
}
setIsRolling(false);
}, 500);

setTimeout(() => {
openModal(({ onClose }) => (
<RandomOkModal
onClose={onClose}
Expand All @@ -63,11 +74,7 @@ export default function RandomModal({
image={image}
/>
));

console.log('새로운 모달 열기');
onClose();
console.log('기존 모달 닫기');
}, 500); //슬라이더 속도 조정하기
}, 1500);
}
};

Expand Down

0 comments on commit c302aaf

Please sign in to comment.