Skip to content

Commit

Permalink
Merge pull request #727 from woowacourse-teams/feature/#725
Browse files Browse the repository at this point in the history
룰렛 수정
  • Loading branch information
ss0526100 authored Oct 23, 2024
2 parents f4c0ea1 + 252c835 commit ca576be
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 6 deletions.
1 change: 1 addition & 0 deletions frontend/src/components/UserPreview/UserPreview.style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const preview = ({
height: ${size || '3.5rem'};
background: url(${imageUrl}), url(${defaultProfile});
background-color: white;
background-repeat: no-repeat;
background-position: center center;
background-size: 100% 100%;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const Container = ({ theme }: { theme: Theme }) => css`
display: flex;
flex-direction: column;
gap: 2rem;
align-items: center;
align-items: flex-start;
justify-content: flex-start;
width: 100%;
Expand Down
15 changes: 14 additions & 1 deletion frontend/src/pages/Bet/BetDetailPage/BetDetailPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,19 @@ const getIsButtonDisabled = (bet?: BetDetail) => {

const bitbit = 'bitbit';

const getPercentString = (bet: BetDetail) => {
const prefix =
bet.myRole === 'NON_MOIMEE' ? '지금 오면 당첨 확률' : '지금 당첨 확률은';
const motherNumber =
bet.participants.length + (bet.myRole === 'NON_MOIMEE' ? 1 : 0);
const percentNumber = (1 / motherNumber) * 100;
const percentString =
percentNumber % 1 === 0
? percentNumber.toString()
: percentNumber.toFixed(1);
return `${prefix} *${percentString}*%`;
};

export default function BetDetailPage() {
const navigate = useNavigate();
const params = useParams();
Expand Down Expand Up @@ -113,7 +126,7 @@ export default function BetDetailPage() {
{
<RouletteWrapper
title={bet?.title || ''}
description={`지금 당첨될 확률은 *${((1 / (bet?.participants.length || 1)) * 100).toFixed(1)}*%!`}
description={bet ? getPercentString(bet) : '지금 오면 %'}
mainDescription={mainDescription}
>
{nameList && (
Expand Down
14 changes: 13 additions & 1 deletion frontend/src/pages/Bet/BetResultPage/BetResultPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useMemo, useState } from 'react';
import { useNavigate, useParams } from 'react-router-dom';

import BackArrowButton from '@_components/Button/BackArrowButton/BackArrowButton';
import { BetDetail } from '@_types/index';
import Button from '@_components/Button/Button';
import GET_ROUTES from '@_common/getRoutes';
import Roulette from '../components/Roulette/Roulette';
Expand All @@ -18,6 +19,17 @@ import useBetResult from '@_hooks/queries/useBetResult';
// import StarThreeIcon from '@_components/Icons/StarIcons/StarThreeIcon';
// import StarTwoIcon from '@_components/Icons/StarIcons/StarTwoIcon';
const bitbit = 'bitbit';

const getPercentString = (bet: BetDetail) => {
const motherNumber = bet.participants.length;
const percentNumber = (1 / motherNumber) * 100;
const percentString =
percentNumber % 1 === 0
? percentNumber.toString()
: percentNumber.toFixed(1);
return `지금 당첨 확률은 *${percentString}*%`;
};

export default function BetResultPage() {
const navigate = useNavigate();

Expand Down Expand Up @@ -83,7 +95,7 @@ export default function BetResultPage() {
<div css={S.containerStyle}>
<RouletteWrapper
title={bet?.title || ''}
description={`지금 당첨될 확률은 *${((1 / (bet?.participants.length || 1)) * 100).toFixed(1)}*%!`}
description={bet ? getPercentString(bet) : '지금 당첨 확률은 %'}
mainDescription={isRouletteEnd ? betResult + ' 당첨!!' : ''}
>
{nameList && (
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/pages/Bet/components/Roulette/DrawRoulette.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@ export default function drawRoulette(props: drawRouletteProps) {
const ctx = canvas.getContext('2d');
if (!ctx) return { clearCanvas: () => {} };

canvas.width = widthPx || canvas.width;
canvas.height = heightPx || canvas.height;
const { gpw, gph } = getCanvasUtil(canvas, widthPx, heightPx);

const FRAME_SECOND = 20;
Expand Down
4 changes: 1 addition & 3 deletions frontend/src/pages/Chatting/ChatPage/ChatPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default function ChatPage() {
</h2>
</ChattingPreviewLayout.Header.Left>
</ChattingPreviewLayout.Header>
<ChattingPreviewLayout.HeaderBottom>
<ChattingPreviewLayout.ContentContainer>
<ChatFilterTagList>
<ChatFilterTag
value={'모임'}
Expand All @@ -48,8 +48,6 @@ export default function ChatPage() {
onClick={() => setNowChatRoomType('BET')}
/>
</ChatFilterTagList>
</ChattingPreviewLayout.HeaderBottom>
<ChattingPreviewLayout.ContentContainer>
{isLoading ? (
<ChatCardListSkeleton />
) : chatPreviews && chatPreviews.length > 0 ? (
Expand Down

0 comments on commit ca576be

Please sign in to comment.