Skip to content

Commit

Permalink
Merge pull request #213 from boostcampwm-2024/feature/#207
Browse files Browse the repository at this point in the history
[Feat] κ²Œμž„νŽ˜μ΄μ§€μ—μ„œ λ‚˜κ°€κΈ° λ²„νŠΌ 클릭 μ‹œ κ²½κ³  νŒμ—… λ„μš°λ„λ‘ μˆ˜μ •
  • Loading branch information
today-is-first authored Dec 2, 2024
2 parents 261717f + 57e1bdc commit 925029c
Show file tree
Hide file tree
Showing 30 changed files with 100 additions and 57 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useState, useEffect } from 'react';
import { useRoomStore } from '@/states/store/roomStore';
import { useRoomStore } from '@/store/roomStore';
import StartButton from './GameButtons/StartButton';
import ReadyButton from './GameButtons/ReadyButton';
import { GAME_PHASE, GamePhase } from '@/constants';
Expand All @@ -9,15 +9,15 @@ import { useGameSocket } from '@/hooks/useGameSocket';
import useGuessing from '@/hooks/useGuessing';
import useEnding from '@/hooks/useEnding';
import useVoteResult from '@/hooks/useVoteResult';
import { useAuthStore } from '@/states/store/authStore';
import { useAuthStore } from '@/store/authStore';
import Countdown from './Countdown';
import WordDisplay from './WordDisplay';
import Voting from './GamePhases/Voting';
import VoteResult from './GamePhases/VoteResult';
import EndingResult from './GamePhases/EndingResult';
import { usePeerConnectionStore } from '@/states/store/peerConnectionStore';
import { usePeerConnectionStore } from '@/store/peerConnectionStore';
import VideoStream from '@/components/gamePage/stream/VideoStream';
import { useLocalStreamStore } from '@/states/store/localStreamStore';
import { useLocalStreamStore } from '@/store/localStreamStore';
import { useSpeakingControl } from '@/hooks/useSpeakingControl';

export default function MainDisplay() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useRef, useEffect } from 'react';
import VideoStream from '@/components/gamePage/stream/VideoStream';
import { useAuthStore } from '@/states/store/authStore';
import { useLocalStreamStore } from '@/states/store/localStreamStore';
import { usePeerConnectionStore } from '@/states/store/peerConnectionStore';
import { useAuthStore } from '@/store/authStore';
import { useLocalStreamStore } from '@/store/localStreamStore';
import { usePeerConnectionStore } from '@/store/peerConnectionStore';
import { useReadyStatus } from '@/hooks/useReadyStatus';

export default function VideoFeed() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { useState, useEffect, useRef } from 'react';
import { useParams } from 'react-router-dom';
import { useChatSocket } from '@/hooks/useChatSocket';
import { useAuthStore } from '@/states/store/authStore';
import { useChatStore } from '@/states/store/chatStore';
import { useAuthStore } from '@/store/authStore';
import { useChatStore } from '@/store/chatStore';
import { ChatType } from '@/constants/chatState';
import ArrowDownIcon from '@/assets/images/ArrowDownIcon.svg?react';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import Leave from '@/assets/images/Leave.svg?react';
import { useNavigate } from 'react-router-dom';
import { useSocketStore } from '@/states/store/socketStore';
import { useChatStore } from '@/states/store/chatStore';
import { useRoomStore } from '@/states/store/roomStore';
import { useSignalingSocketStore } from '@/states/store/signalingSocketStore';
import { useSocketStore } from '@/store/socketStore';
import { useChatStore } from '@/store/chatStore';
import { useRoomStore } from '@/store/roomStore';
import { useSignalingSocketStore } from '@/store/signalingSocketStore';
import { useState } from 'react';
import LeaveConfirmModal from './LeaveConfirmModal';

export default function LeaveButton() {
const [showModal, setShowModal] = useState(false);
const navigate = useNavigate();
const socket = useSocketStore((state) => state.socket);
const setChatHistory = useChatStore((state) => state.setChatHistory);
const setRoomData = useRoomStore((state) => state.setRoomData);
const signalingSocket = useSignalingSocketStore((state) => state.signalingSocket);

function handleLeave() {
if (!socket || !signalingSocket) return;
socket.emit('leave_room');
Expand All @@ -19,13 +23,20 @@ export default function LeaveButton() {
setRoomData(null, false, false);
navigate('/lobby');
}

return (
<button
className="w-[120px] px-4 py-4 bg-transparent rounded-lg flex flex-col items-center justify-center gap-2"
onClick={handleLeave}
>
<Leave className="text-white-default pr-2" />
<p className="text-white-default text-lg">λ°© λ‚˜κ°€κΈ°</p>
</button>
<>
<button
className="w-[120px] px-4 py-4 bg-transparent rounded-lg flex flex-col items-center justify-center gap-2"
onClick={() => setShowModal(true)}
>
<Leave className="pr-2 text-white-default" />
<p className="text-lg text-white-default">λ°© λ‚˜κ°€κΈ°</p>
</button>

{showModal && (
<LeaveConfirmModal onConfirm={handleLeave} onClose={() => setShowModal(false)} />
)}
</>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import ReactDOM from 'react-dom';

interface ILeaveConfirmModalProps {
onConfirm: () => void;
onClose: () => void;
}

export default function LeaveConfirmModal({ onConfirm, onClose }: ILeaveConfirmModalProps) {
const modalContent = (
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50">
<div className="max-w-lg p-8 bg-white shadow-lg rounded-2xl w-96">
<h2 className="mb-4 text-xl font-semibold text-center text-gray-900">
κ²Œμž„μ„ λ‚˜κ°€μ‹œκ² μŠ΅λ‹ˆκΉŒ?
</h2>
<div className="flex justify-center gap-4 mt-4">
<button
onClick={onClose}
className="w-32 py-2 text-black border border-black rounded-lg hover:bg-gray-100"
>
μ·¨μ†Œ
</button>
<button
onClick={onConfirm}
className="w-32 py-2 bg-black rounded-lg text-white-default hover:bg-gray-800"
>
확인
</button>
</div>
</div>
</div>
);

return ReactDOM.createPortal(modalContent, document.getElementById('portal-root') as HTMLElement);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useState, useEffect } from 'react';
import CameraOn from '@/assets/images/CameraOn.svg?react';
import CameraOff from '@/assets/images/CameraOff.svg?react';
import { useLocalStreamStore } from '@/states/store/localStreamStore';
import { useLocalStreamStore } from '@/store/localStreamStore';

export default function CameraSettingButton({ iconColor }: { iconColor: string }) {
const { localStream } = useLocalStreamStore();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useState, useEffect } from 'react';
import MikeOn from '@/assets/images/MikeOn.svg?react';
import MikeOff from '@/assets/images/MikeOff.svg?react';
import { useLocalStreamStore } from '@/states/store/localStreamStore';
import { useLocalStreamStore } from '@/store/localStreamStore';

export default function MikeSettingButton({ iconColor }: { iconColor: string }) {
const { localStream } = useLocalStreamStore();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import Button from '@/components/common/Button';
import NicknameModal from './NicknameModal';
import { useNavigate } from 'react-router-dom';
import { getGuestLogin } from '@/apis/login';
import { useAuthStore } from '@/states/store/authStore';
import { useSocketStore } from '@/states/store/socketStore';
import { useSignalingSocketStore } from '@/states/store/signalingSocketStore';
import { useAuthStore } from '@/store/authStore';
import { useSocketStore } from '@/store/socketStore';
import { useSignalingSocketStore } from '@/store/signalingSocketStore';

export default function GuestLoginButton() {
const navigate = useNavigate();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import VideoStream from '@/components/gamePage/stream/VideoStream';
import { useLocalStreamStore } from '@/states/store/localStreamStore';
import { useLocalStreamStore } from '@/store/localStreamStore';
import CameraSettingButton from '@/components/gamePage/stream/CameraSettingButton';
import MikeSettingButton from '@/components/gamePage/stream/MikeSettingButton';

Expand Down
8 changes: 4 additions & 4 deletions packages/frontend/src/hooks/useChatSocket.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { useEffect } from 'react';
import { useChatStore } from '@/states/store/chatStore';
import { useSocketStore } from '@/states/store/socketStore';
import { useRoomStore } from '@/states/store/roomStore';
import { useChatStore } from '@/store/chatStore';
import { useSocketStore } from '@/store/socketStore';
import { useRoomStore } from '@/store/roomStore';
import { ChatType } from '@/constants/chatState';
import { useAuthStore } from '@/states/store/authStore';
import { useAuthStore } from '@/store/authStore';

interface IChatEntry {
userId: string;
Expand Down
8 changes: 4 additions & 4 deletions packages/frontend/src/hooks/useCreateRoom.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useNavigate } from 'react-router-dom';
import { useAuthStore } from '@/states/store/authStore';
import { useRoomStore } from '@/states/store/roomStore';
import { useSocketStore } from '@/states/store/socketStore';
import { useSignalingSocketStore } from '@/states/store/signalingSocketStore';
import { useAuthStore } from '@/store/authStore';
import { useRoomStore } from '@/store/roomStore';
import { useSocketStore } from '@/store/socketStore';
import { useSignalingSocketStore } from '@/store/signalingSocketStore';

export default function useCreateRoom() {
const navigate = useNavigate();
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/hooks/useEnding.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect, useState } from 'react';
import { useSocketStore } from '@/states/store/socketStore';
import { useSocketStore } from '@/store/socketStore';
import { GAME_PHASE, GamePhase } from '@/constants';

interface IEndingResult {
Expand Down
4 changes: 2 additions & 2 deletions packages/frontend/src/hooks/useGameSocket.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect, useState } from 'react';
import { useSocketStore } from '@/states/store/socketStore';
import { useRoomStore } from '@/states/store/roomStore';
import { useSocketStore } from '@/store/socketStore';
import { useRoomStore } from '@/store/roomStore';
import { GAME_PHASE, GamePhase } from '@/constants';

interface IReadyUsers {
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/hooks/useGuessing.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect } from 'react';
import { useSocketStore } from '@/states/store/socketStore';
import { useSocketStore } from '@/store/socketStore';
import { GAME_PHASE, GamePhase } from '@/constants';

export default function useGuessing(isPinoco: boolean, setGamePhase: (phase: GamePhase) => void) {
Expand Down
8 changes: 4 additions & 4 deletions packages/frontend/src/hooks/useJoinRoom.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useNavigate } from 'react-router-dom';
import { useAuthStore } from '@/states/store/authStore';
import { useRoomStore } from '@/states/store/roomStore';
import { useSocketStore } from '@/states/store/socketStore';
import { useSignalingSocketStore } from '@/states/store/signalingSocketStore';
import { useAuthStore } from '@/store/authStore';
import { useRoomStore } from '@/store/roomStore';
import { useSocketStore } from '@/store/socketStore';
import { useSignalingSocketStore } from '@/store/signalingSocketStore';

export default function useJoinRoom() {
const navigate = useNavigate();
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/hooks/useSpeakingControl.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect } from 'react';
import { useSocketStore } from '@/states/store/socketStore';
import { useSocketStore } from '@/store/socketStore';

export const useSpeakingControl = (currentSpeaker: string | null, userId: string | null) => {
const socket = useSocketStore((state) => state.socket);
Expand Down
4 changes: 2 additions & 2 deletions packages/frontend/src/hooks/useVoteResult.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useEffect, useState } from 'react';
import { useSocketStore } from '@/states/store/socketStore';
import { useSocketStore } from '@/store/socketStore';
import { GAME_PHASE, GamePhase } from '@/constants';
import { useRoomStore } from '@/states/store/roomStore';
import { useRoomStore } from '@/store/roomStore';

interface IVoteResult {
voteResult: Record<string, number>;
Expand Down
4 changes: 2 additions & 2 deletions packages/frontend/src/pages/gamePage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import LeftGameSection from '@/components/gamePage/leftSection/LeftGameSection';
import RightGameSection from '@/components/gamePage/rightSection/RightGameSection';
import Header from '@/components/layout/Header';
import GameManual from '@/components/gamePage/GameManual';
import { useSocketStore } from '@/states/store/socketStore';
import { useRoomStore } from '@/states/store/roomStore';
import { useSocketStore } from '@/store/socketStore';
import { useRoomStore } from '@/store/roomStore';

export default function GamePage() {
const { socket } = useSocketStore();
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/pages/landingPage/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import GuestLoginButton from '@/components/landingPage/GuestLoginButton';
import BackgroundImage from '@/components/layout/BackgroundImage';
import MainLogo from '@/assets/images/MainLogo.svg?react';
import { useSocketStore } from '@/states/store/socketStore';
import { useSocketStore } from '@/store/socketStore';

export default function LandingPage() {
const { socket } = useSocketStore();
Expand Down
8 changes: 4 additions & 4 deletions packages/frontend/src/pages/lobbyPage/index.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { useEffect } from 'react';
import { useSocketStore } from '@/states/store/socketStore';
import { useSocketStore } from '@/store/socketStore';
import BackgroundImage from '@/components/layout/BackgroundImage';
import MainLogo from '@/assets/images/MainLogo.svg?react';
import RoomCreationButton from '@/components/lobbyPage/RoomCreationButton';
import RoomJoinButton from '@/components/lobbyPage/RoomJoinButton';
import VideoAudioTestButton from '@/components/lobbyPage/VideoAudioTestButton';
import Header from '@/components/layout/Header';
import { useRoomStore } from '@/states/store/roomStore';
import { useChatStore } from '@/states/store/chatStore';
import { useLocalStreamStore } from '@/states/store/localStreamStore';
import { useRoomStore } from '@/store/roomStore';
import { useChatStore } from '@/store/chatStore';
import { useLocalStreamStore } from '@/store/localStreamStore';
import { getVideoStream } from '@/utils/videoStreamUtils';

export default function LobbyPage() {
Expand Down
1 change: 0 additions & 1 deletion packages/frontend/src/states/mutations/index.tsx

This file was deleted.

1 change: 0 additions & 1 deletion packages/frontend/src/states/queries/index.tsx

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { create } from 'zustand';
import { Socket, io } from 'socket.io-client';
import { useLocalStreamStore } from '@/states/store/localStreamStore';
import { usePeerConnectionStore } from '@/states/store/peerConnectionStore';
import { useLocalStreamStore } from '@/store/localStreamStore';
import { usePeerConnectionStore } from '@/store/peerConnectionStore';
import { getVideoStream } from '@/utils/videoStreamUtils';

interface ISignalingSocketStore {
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/utils/videoStreamUtils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useLocalStreamStore } from '@/states/store/localStreamStore';
import { useLocalStreamStore } from '@/store/localStreamStore';

export async function getVideoStream() {
const videoConfig = {
Expand Down

0 comments on commit 925029c

Please sign in to comment.