diff --git a/client/.prettierrc b/client/.prettierrc index fa3e9bb..ca2463a 100644 --- a/client/.prettierrc +++ b/client/.prettierrc @@ -9,5 +9,7 @@ "arrowParens": "always", "endOfLine": "auto", "bracketSameLine": true, - "plugins": ["prettier-plugin-tailwindcss"] -} + "plugins": [ + "prettier-plugin-tailwindcss" + ] +} \ No newline at end of file diff --git a/client/src/components/Problems.tsx b/client/src/components/Problems.tsx index 51c5735..0842fa7 100644 --- a/client/src/components/Problems.tsx +++ b/client/src/components/Problems.tsx @@ -1,16 +1,29 @@ import { ProblemType } from '../types/ProblemType'; import { ProblemButton } from './buttons/ProblemButton'; +import mockData from '../../public/mocks/UpdateRoom.json'; +import { useState } from 'react'; -type ProblemProps = { - problems: ProblemType[]; -}; - -export default function Problems({ problems: problemProps }: ProblemProps) { +export default function Problems({ isHost }: { isHost: boolean }) { + // TODO: socket연결 후 수정 + const [problems, setProblems] = useState([]); return ( - + <> + {isHost && problems.length === 0 && ( +
+

문제를 추가해주세요!

+ +
+ )} + + + ); } diff --git a/client/src/components/RoomAccessPanel.tsx b/client/src/components/RoomAccessPanel.tsx index 2b314bd..81106b5 100644 --- a/client/src/components/RoomAccessPanel.tsx +++ b/client/src/components/RoomAccessPanel.tsx @@ -1,22 +1,12 @@ -import { Link } from 'react-router-dom'; - import RoomCreateButton from './buttons/RoomCreateButton'; import RoomJoinButton from './buttons/RoomJoinButton'; export default function RoomAccessPanel() { return ( -
- - - +
+

- or -

-
- - - +
); } diff --git a/client/src/components/RoomCode.tsx b/client/src/components/RoomCode.tsx new file mode 100644 index 0000000..a93836d --- /dev/null +++ b/client/src/components/RoomCode.tsx @@ -0,0 +1,10 @@ +import CopyIcon from '../icons/CopyIcon'; + +export default function RoomCode({ code }: { code: string }) { + return ( +
+ {code} + +
+ ); +} diff --git a/client/src/components/RoomSettingModal/RoomSettingModal.tsx b/client/src/components/RoomSettingModal/RoomSettingModal.tsx index 14d9216..8eaf74d 100644 --- a/client/src/components/RoomSettingModal/RoomSettingModal.tsx +++ b/client/src/components/RoomSettingModal/RoomSettingModal.tsx @@ -13,6 +13,10 @@ interface RoomSettingModalProps { modalOutsideClick: (arg: React.MouseEvent) => void; } +const iconStyle = { + fontSize: '1.5rem', +}; + export default function RoomSettingModal({ modalOverlayRef, closeModal, @@ -28,30 +32,27 @@ export default function RoomSettingModal({ return (
-
- -
- {isRandom ? ( -
-

랜덤으로 출제

- -
- ) : ( -
-

번호로 출제

- -
- )} +
+
+ {isRandom ?

랜덤으로 출제

:

번호로 출제

} +
+ + +
+ {isRandom ? ( ) : ( diff --git a/client/src/components/buttons/RoomCreateButton.tsx b/client/src/components/buttons/RoomCreateButton.tsx index 7de4c07..02e62ae 100644 --- a/client/src/components/buttons/RoomCreateButton.tsx +++ b/client/src/components/buttons/RoomCreateButton.tsx @@ -1,6 +1,22 @@ +import { useNavigate } from 'react-router-dom'; + export default function RoomCreateButton() { + // TODO: 방 생성 api가 개발되면 그때 navigate로직을 변경 + + const getNewRoomId = async () => { + return 'q1w2e3'; + }; + + const navigate = useNavigate(); + const onClick = async () => { + const roomId = await getNewRoomId(); + navigate(`/room/${roomId}`, { state: { isHost: true } }); + }; + return ( - ); diff --git a/client/src/components/buttons/RoomJoinButton.tsx b/client/src/components/buttons/RoomJoinButton.tsx index 9ecd37c..542628a 100644 --- a/client/src/components/buttons/RoomJoinButton.tsx +++ b/client/src/components/buttons/RoomJoinButton.tsx @@ -1,7 +1,36 @@ +import { useNavigate } from 'react-router-dom'; + +import { useState } from 'react'; + export default function RoomJoinButton() { + const [roomCode, setRoomCode] = useState(''); + const navigate = useNavigate(); + + const onClick = (e: React.MouseEvent) => { + e.preventDefault(); + + if (roomCode === '') { + alert('방 코드를 입력해주세요.'); + return; + } + + // TODO: 여기도 서버 로직 나오면 수정 + navigate(`/room/${'q1w2e3'}`, { state: { isHost: false } }); + }; + return ( - +
+ setRoomCode(e.target.value)} + /> + +
); } diff --git a/client/src/pages/Room.tsx b/client/src/pages/Room.tsx index f896b30..c960fb6 100644 --- a/client/src/pages/Room.tsx +++ b/client/src/pages/Room.tsx @@ -1,4 +1,5 @@ -import problems from '../../public/mocks/UpdateRoom.json'; +import { useLocation } from 'react-router-dom'; + import Problems from '../components/Problems'; import ScoreboardButton from '../components/buttons/ScoreBoardButton'; import Chat from '../components/Chat'; @@ -6,11 +7,14 @@ import StartButton from '../components/buttons/StartButton'; import RoomInfo from '../components/RoomInfo'; export default function Room() { + const location = useLocation(); + const isHost = location.state?.isHost; + return ( -
-
+
+
- +