Skip to content
Snippets Groups Projects
Commit 4b81d427 authored by Min Dong Hyeun's avatar Min Dong Hyeun
Browse files

[EDIT] HomeParticipateForm

parent c79dd678
No related branches found
No related tags found
No related merge requests found
...@@ -31,14 +31,15 @@ function HomeParticipateForm() { ...@@ -31,14 +31,15 @@ function HomeParticipateForm() {
} }
} }
const newHandleSubmit = async (event) => { const handleSubmit = async (event) => {
event.preventDefault(); event.preventDefault();
if (name === "") { if (name === "") {
alert('이름을 입력하세요') alert('이름을 입력하세요')
} }
else { else {
let checkParticipant = await checkParticipantExistence(); let checkParticipant = await checkParticipantExistence();
if(checkParticipant){ console.log(checkParticipant);
if (checkParticipant) { // DB에 해당 이름이 존재하지 않으면
try { try {
const response = await axios.post(`http://localhost:3000/meetings/${id}/participants`, { const response = await axios.post(`http://localhost:3000/meetings/${id}/participants`, {
name: name, name: name,
...@@ -94,19 +95,15 @@ function HomeParticipateForm() { ...@@ -94,19 +95,15 @@ function HomeParticipateForm() {
console.error(error); console.error(error);
} }
} }
else{ else { // 이미 DB에 참여자가 존재하는 경우
alert('이미 존재하는 이름입니다.');
}
}
};
const oldHandleSubmit = async (event) => {
event.preventDefault();
if (name === "") {
alert('이름을 입력하세요')
}
else {
try { try {
const response = await axios.post(`http://localhost:3000/meetings/${id}/entry`,{ const response = await axios.get(`http://localhost:3000/meetings/${id}/my/schedules`); //투표 여부 확인을 위해
if (response.data.schedules.length) { // 투표를 진행하였으면 결과 페이지로 이동
navigate('ResultEnd');
}
else { // 투표를 안했으면 투표페이지로 이동
try { // 쿠키 재생성
await axios.post(`http://localhost:3000/meetings/${id}/entry`, {
name: name, name: name,
password: password password: password
}, { }, {
...@@ -147,7 +144,12 @@ function HomeParticipateForm() { ...@@ -147,7 +144,12 @@ function HomeParticipateForm() {
} else { } else {
console.error(error); console.error(error);
} }
}
}
}
catch (error) {
console.err(error);
}
} }
} }
}; };
...@@ -156,7 +158,6 @@ function HomeParticipateForm() { ...@@ -156,7 +158,6 @@ function HomeParticipateForm() {
<form> <form>
<div> <div>
<h1>투표에 참여하기</h1> <h1>투표에 참여하기</h1>
{console.log({id})}
<Input <Input
type="text" type="text"
value={name} value={name}
...@@ -177,13 +178,8 @@ function HomeParticipateForm() { ...@@ -177,13 +178,8 @@ function HomeParticipateForm() {
/> />
<Button <Button
type='submit' type='submit'
text='신규참여' text='참여'
onClick={newHandleSubmit} onClick={handleSubmit}
/>
<Button
type='submit'
text='재참여'
onClick={oldHandleSubmit}
/> />
</div> </div>
</form> </form>
......
...@@ -23,7 +23,13 @@ function MeetingInfoForm() { ...@@ -23,7 +23,13 @@ function MeetingInfoForm() {
} }
const handleNumber = (event) => { const handleNumber = (event) => {
setNumber(event.target.value); const inputValue = event.target.value;
if(inputValue >= 0){
setNumber(inputValue);
}
else{
alert("양수만을 입력하세요");
}
} }
const handleVoteEnd = (event) => { const handleVoteEnd = (event) => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment