diff --git a/react-whenMeet/src/components/HomeParticipateForm.js b/react-whenMeet/src/components/HomeParticipateForm.js index 4ae6d205a129cc95831cfc2efcb2bd0a1635b1b3..c69f3cf59fd3bd2ada2b67eda2e8378f9a88ffe2 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); + } } } }