-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #98 from boostcampwm2023/feat/ui-room-setting
Feat/UI room setting
- Loading branch information
Showing
8 changed files
with
119 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<ProblemType[]>([]); | ||
return ( | ||
<ul className='flex flex-col w-full'> | ||
{problemProps.map((problem) => ( | ||
<ProblemButton key={problem.boj_problem_id} {...problem} /> | ||
))} | ||
</ul> | ||
<> | ||
{isHost && problems.length === 0 && ( | ||
<div className="flex h-full w-full flex-col items-center justify-center"> | ||
<h1 className="text-2xl font-bold">문제를 추가해주세요!</h1> | ||
<button | ||
className="text-white bg-aod_pink mt-4 rounded-lg px-4 py-2" | ||
onClick={() => setProblems(mockData.problems)}> | ||
문제 추가 | ||
</button> | ||
</div> | ||
)} | ||
|
||
<ul className="flex w-full flex-col"> | ||
{problems.map((problem) => ( | ||
<ProblemButton key={problem.boj_problem_id} {...problem} /> | ||
))} | ||
</ul> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<div className="border-aod_gutter flex w-[322px] flex-col items-center justify-center gap-4 rounded-xl border-8 px-6 py-10"> | ||
<Link to="/room/1"> | ||
<RoomCreateButton /> | ||
</Link> | ||
<div className="flex w-[322px] flex-col items-center justify-center gap-4 rounded-xl border-8 border-aod_gutter px-6 py-10"> | ||
<RoomCreateButton /> | ||
<p className="text-aod_text">- or -</p> | ||
<form className="flex items-center justify-between gap-2"> | ||
<input | ||
className="bg-aod_white rounded-lg px-2 py-1" | ||
placeholder="Room code" | ||
/> | ||
<RoomJoinButton /> | ||
</form> | ||
<RoomJoinButton /> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import CopyIcon from '../icons/CopyIcon'; | ||
|
||
export default function RoomCode({ code }: { code: string }) { | ||
return ( | ||
<div className="text-md flex cursor-pointer flex-row items-center justify-center gap-1 rounded-lg bg-aod_text_alt bg-opacity-80 px-2 py-1 font-bold text-aod_text"> | ||
{code} | ||
<CopyIcon /> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,36 @@ | ||
import { useNavigate } from 'react-router-dom'; | ||
|
||
import { useState } from 'react'; | ||
|
||
export default function RoomJoinButton() { | ||
const [roomCode, setRoomCode] = useState<string>(''); | ||
const navigate = useNavigate(); | ||
|
||
const onClick = (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => { | ||
e.preventDefault(); | ||
|
||
if (roomCode === '') { | ||
alert('방 코드를 입력해주세요.'); | ||
return; | ||
} | ||
|
||
// TODO: 여기도 서버 로직 나오면 수정 | ||
navigate(`/room/${'q1w2e3'}`, { state: { isHost: false } }); | ||
}; | ||
|
||
return ( | ||
<button className="text-aod_white bg-aod_accent h-[33px] w-[60px] items-center justify-center rounded-lg font-medium hover:opacity-80"> | ||
Join | ||
</button> | ||
<form className="flex items-center justify-between gap-2"> | ||
<input | ||
className="rounded-lg bg-aod_white px-2 py-1" | ||
placeholder="Room code" | ||
value={roomCode} | ||
onChange={(e) => setRoomCode(e.target.value)} | ||
/> | ||
<button | ||
className="h-[33px] w-[60px] items-center justify-center rounded-lg bg-aod_accent font-medium text-aod_white hover:opacity-80" | ||
onClick={onClick}> | ||
Join | ||
</button> | ||
</form> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters