Skip to content

Commit

Permalink
연타방지
Browse files Browse the repository at this point in the history
  • Loading branch information
bb2002 committed Jun 3, 2024
1 parent 29e9667 commit 45889da
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/components/ApartmentForm.component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default function ApartmentForm() {
password: "",
})
const [selectedApartment, setSelectedApartment] = useState()
const [submitClicked, setSubmitClicked] = useState(false)

const onApartmentNameChanged = async (e) => {
setSelectedApartment(null)
Expand All @@ -31,13 +32,16 @@ export default function ApartmentForm() {
}

const onSubmit = async () => {
setSubmitClicked(true)
if (createApartmentForm.nickname == "" || createApartmentForm.password == "") {
alert("닉네임 또는 비밀번호가 비어있습니다.");
setSubmitClicked(false)
return;
}

if (!selectedApartment) {
alert("아파트를 리스트에서 선택해주세요!");
setSubmitClicked(false)
return;
}

Expand All @@ -55,6 +59,7 @@ export default function ApartmentForm() {
alert("등록에 실패했습니다. :(")
}
}
setSubmitClicked(false)
}

return (
Expand Down Expand Up @@ -85,7 +90,7 @@ export default function ApartmentForm() {
...createApartmentForm, password: e.target.value })}/>
</div>
<br />
<button type="button" className="btn btn-primary submit" onClick={onSubmit}>등록하기</button>
<button type="button" className="btn btn-primary submit" onClick={onSubmit} disabled={submitClicked}>등록하기</button>
</div>
);
}

0 comments on commit 45889da

Please sign in to comment.