-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[FE] ์ฝ๋๋ก ์ ์ฅํ๊ธฐ ๊ตฌํ
- Loading branch information
Showing
23 changed files
with
647 additions
and
124 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
58 changes: 58 additions & 0 deletions
58
chatty-fe/src/app/(game)/main-lobby/_components/CodeInput/CodeInput.tsx
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,58 @@ | ||
'use client'; | ||
|
||
import { useState } from 'react'; | ||
import TextInputField from '@/app/_components/TextInputField'; | ||
import SolidButton from '@/app/_components/SolidButton'; | ||
import Image from 'next/image'; | ||
import { useRouter } from 'next/navigation'; | ||
import { findByCode } from '@/app/_api/quiz'; | ||
import useAuthStore from '@/app/_store/useAuthStore'; | ||
|
||
const CodeInput = () => { | ||
const [code, setCode] = useState(''); | ||
const router = useRouter(); | ||
const { accessToken } = useAuthStore(); | ||
|
||
const enterRoomWithCode = async (e: React.FormEvent<HTMLFormElement>) => { | ||
e.preventDefault(); | ||
if (!code) return alert('์ฝ๋๋ฅผ ์ ๋ ฅํด์ฃผ์ธ์'); | ||
|
||
console.log('code', code); | ||
if (code || accessToken) { | ||
try { | ||
const res = (await findByCode(code, accessToken)) as any; | ||
router.push(`/enter-room/${res.roomId}`); | ||
} catch (error: any) { | ||
alert(error.message); | ||
} | ||
} | ||
}; | ||
|
||
return ( | ||
<> | ||
<form onSubmit={enterRoomWithCode}> | ||
<TextInputField | ||
value={code} | ||
placeholder="์ฝ๋๋ก ์ ์ฅํ๊ธฐ" | ||
borderRadius={12} | ||
onChange={(e) => { | ||
setCode(e.target.value); | ||
}} | ||
inputmode="numeric" | ||
endAdornment={ | ||
<SolidButton shadowExist={false} type="submit"> | ||
<Image | ||
src="/images/log-in.svg" | ||
alt="enter-room" | ||
width={24} | ||
height={24} | ||
/> | ||
</SolidButton> | ||
} | ||
/> | ||
</form> | ||
</> | ||
); | ||
}; | ||
|
||
export default CodeInput; |
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
Oops, something went wrong.