From 7d9111502a0ef9adcf3ddd2ebb73731c60e58923 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B2=9C=EC=A7=80=EC=9C=A4?= <70828192+cheonjiyun@users.noreply.github.com> Date: Thu, 26 Dec 2024 17:25:09 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EA=B2=BD=EC=B0=B0=20=EC=9D=B4=EB=AF=B8?= =?UTF-8?q?=20=EC=82=AC=EC=9A=A9=ED=96=88=EC=9D=84=20=EB=95=8C=EB=8A=94=20?= =?UTF-8?q?=ED=86=A0=EC=8A=A4=ED=8A=B8,=20=EC=95=84=EC=A7=81=20=EC=95=88?= =?UTF-8?q?=EC=99=94=EC=9D=84=20=EB=95=8C=EB=8A=94=20=EC=95=88=EB=9D=84?= =?UTF-8?q?=EC=9B=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/job/PoliceNight.tsx | 5 +--- src/components/modal/InvestResult.tsx | 38 +++++++++++++++++++-------- 2 files changed, 28 insertions(+), 15 deletions(-) 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' ? '마피아가 맞습니다' : '마피아가 아닙니다'} +

+
+
+ )} + + ); }