From 4456f9c931072251b3fa364dc54abfd406e584ca Mon Sep 17 00:00:00 2001 From: "rnjsals0905@gmail.com" <rnjsals0905@ajou.ac.kr> Date: Mon, 4 Dec 2023 22:23:59 +0900 Subject: [PATCH] =?UTF-8?q?[EDIT]=20=EB=93=B1=EB=A1=9D=EB=90=9C=20?= =?UTF-8?q?=EC=9D=B8=EC=9B=90=EC=97=90=20=EB=8C=80=ED=95=9C=20logic=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/HomeParticipateForm.js | 42 +++++++++++-------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/react-whenMeet/src/components/HomeParticipateForm.js b/react-whenMeet/src/components/HomeParticipateForm.js index 4ae6d20..c69f3cf 100644 --- a/react-whenMeet/src/components/HomeParticipateForm.js +++ b/react-whenMeet/src/components/HomeParticipateForm.js @@ -97,32 +97,26 @@ function HomeParticipateForm() { } else { // �대� DB�� 李몄뿬�먭� 議댁옱�섎뒗 寃쎌슦 try { + await axios.post(`http://localhost:3000/meetings/${id}/entry`, { + name: name, + password: password + }, { + withCredentials: true + }); const response = await axios.get(`http://localhost:3000/meetings/${id}/my/schedules`); //�ы몴 �щ� �뺤씤�� �꾪빐 - if (response.data.schedules.length) { // �ы몴瑜� 吏꾪뻾�섏��쇰㈃ 寃곌낵 �섏씠吏�濡� �대룞 - navigate('ResultEnd'); + const schedules = response.data.schedules; + if (schedules.length) { // �ы몴瑜� 吏꾪뻾�섏��쇰㈃ 寃곌낵 �섏씠吏�濡� �대룞 + navigate(`/result/${id}`); } else { // �ы몴瑜� �덊뻽�쇰㈃ �ы몴�섏씠吏�濡� �대룞 try { // 荑좏궎 �ъ깮�� - await axios.post(`http://localhost:3000/meetings/${id}/entry`, { - name: name, - password: password - }, { - withCredentials: true - }); try { const response = await axios.get(`http://localhost:3000/meetings/${id}/`); const startDate = response.data.startDate; const endDate = response.data.endDate; const startTime = response.data.availableVotingStartTime; const endTime = response.data.availableVotingEndTime; - try { - const response = await axios.get(`http://localhost:3000/meetings/${id}/my/schedules`); - // console.log(startDate, endDate); - navigate('UserTimeInfo', { state: { id: id, startTime: startTime, endTime: endTime, startDate: startDate, endDate: endDate, schedules: response.data.schedules } }); - } - catch (e) { - console.log(e); - } + navigate('UserTimeInfo', { state: { id: id, startTime: startTime, endTime: endTime, startDate: startDate, endDate: endDate, schedules: schedules } }); } catch (e) { console.log(e); @@ -148,7 +142,21 @@ function HomeParticipateForm() { } } catch (error) { - console.err(error); + if (error.response) { + if (error.response.status === 401) { + alert('Password瑜� �섎せ �낅젰�섏��듬땲��'); + } else if (error.response.status === 404) { + alert('�대떦�섎뒗 �대쫫�� 議댁옱�섏� �딆뒿�덈떎'); + } + else if (error.response.status === 400) { + alert("鍮꾨�踰덊샇瑜� �ㅼ젙�섏뀲�듬땲��. 鍮꾨�踰덊샇瑜� �낅젰�댁<�몄슂") + } + else { + alert(`Unexpected status code: ${error.response.status}`); + } + } else { + console.error(error); + } } } } -- GitLab