diff --git a/src/components/job/PoliceNight.tsx b/src/components/job/PoliceNight.tsx index 8f235d6..bc9ecb5 100644 --- a/src/components/job/PoliceNight.tsx +++ b/src/components/job/PoliceNight.tsx @@ -6,7 +6,6 @@ import { middle } from '../../pages/Night'; import { VariablesCSS } from '../../styles/VariablesCSS'; import { Player } from '../../type'; import InvestResult from '../modal/InvestResult'; -import ModalContainer from '../modal/ModalContainer'; import PlayerGrid from '../player/PlayerGrid'; import PlayerNight from '../player/PlayerNight'; @@ -48,9 +47,7 @@ export const PoliceNight = (props: PropsType) => { {/* 경찰: 조사하기 */} - - - + {openModal && } ); }; diff --git a/src/components/modal/InvestResult.tsx b/src/components/modal/InvestResult.tsx index a6fdee4..86ce34d 100644 --- a/src/components/modal/InvestResult.tsx +++ b/src/components/modal/InvestResult.tsx @@ -1,33 +1,49 @@ /** @jsxImportSource @emotion/react */ import { css } from '@emotion/react'; import { useEffect, useState } from 'react'; +import { Toaster } from 'react-hot-toast'; import { postSkill } from '../../axios/http'; import { VariablesCSS } from '../../styles/VariablesCSS'; import { Job, SkillResponse } from '../../type'; import PlayerInvest from '../player/PlayerInvest'; +import { notifyUseToast } from '../toast/NotifyToast'; +import ModalContainer from './ModalContainer'; interface PropsType { target: string; + isOpen: boolean; } -export default function InvestResult(props: PropsType) { - const { target } = props; +export default function InvestResult({ target, isOpen }: PropsType) { + const [jobResult, setJobResult] = useState(null); - const [jobResult, setJobResult] = useState('CITIZEN'); useEffect(() => { (async () => { - const skillResponse: SkillResponse = await postSkill({ target: target }); - setJobResult(skillResponse.result); + try { + const skillResponse: SkillResponse = await postSkill({ target: target }); + setJobResult(skillResponse.result); + } catch (error: any) { + console.log(jobResult); + + notifyUseToast(error.response.data.message, 'LOBBY'); + } })(); }, [target]); return ( -
- -

- {jobResult === 'MAFIA' ? '마피아가 맞습니다' : '마피아가 아닙니다'} -

-
+ <> + {jobResult && ( + +
+ +

+ {jobResult === 'MAFIA' ? '마피아가 맞습니다' : '마피아가 아닙니다'} +

+
+
+ )} + + ); } diff --git a/src/pages/Game.tsx b/src/pages/Game.tsx index 5e1b882..dd49769 100644 --- a/src/pages/Game.tsx +++ b/src/pages/Game.tsx @@ -185,6 +185,10 @@ export default function Game() { // 방 정보 저장 (방 상태가 바뀔때만 작동?) useEffect(() => { (async () => { + if (gamesStatus.statusType == 'WAIT') { + setMyJobRecoilState(null); + } + // 방 정보 불러오기 const roomInfoResponse = await getGamesInfo(); setRoomsInfoState(roomInfoResponse);