diff --git a/react-whenMeet/src/components/MeetingInfoForm.js b/react-whenMeet/src/components/MeetingInfoForm.js index bf48ea3bda6763d27fa1a37206a40b2d78c7a7d0..ef63d4c7425c190a079b2104bf5a813d35e50e9b 100644 --- a/react-whenMeet/src/components/MeetingInfoForm.js +++ b/react-whenMeet/src/components/MeetingInfoForm.js @@ -30,11 +30,11 @@ function MeetingInfoForm() { setEndVote(event.target.value); } const handleStartTimeChange = (selectedHour, selectedMinute) => { - setStartTime(`${selectedHour}:${selectedMinute}`); + setStartTime(`${selectedHour}:${selectedMinute}:00`); }; const handleEndTimeChange = (selectedHour, selectedMinute) => { - setEndTime(`${selectedHour}:${selectedMinute}`); + setEndTime(`${selectedHour}:${selectedMinute}:00`); }; @@ -59,6 +59,8 @@ function MeetingInfoForm() { transformedPurpose = 'ETC'; } try { + console.log(startTime); + console.log(endTime); const response = await axios.post("http://localhost:3000/meetings", { title: title, adminPassword: password, diff --git a/react-whenMeet/src/components/TimeInput.js b/react-whenMeet/src/components/TimeInput.js index de4126333e27c68c97fe76632206657ecf056c7d..a126852e47bf878a7c0ff8d9c6366dbdae5a5713 100644 --- a/react-whenMeet/src/components/TimeInput.js +++ b/react-whenMeet/src/components/TimeInput.js @@ -1,38 +1,24 @@ import { useState } from "react"; -function TimeInput({onTimeChange}) { - const [hours, setHours] = useState("00"); - const [minutes, setMinutes] = useState("00"); - const handleHoursChange = (event) => { - setHours(event.target.value); - onTimeChange(event.target.value, minutes); - }; +function TimeInput({ onTimeChange }) { + const [time, setTime] = useState(""); - const handleMinutesChange = (event) => { - setMinutes(event.target.value); - onTimeChange(hours, event.target.value); + const handleTimeChange = (event) => { + setTime(event.target.value); // select의 value를 그대로 저장 + onTimeChange(event.target.value.slice(0, 2), event.target.value.slice(3)); }; - return ( <div> <label> - 시: - <select value={hours} onChange={handleHoursChange}> - {Array.from({ length: 24 }, (_, i) => i.toString().padStart(2, "0")).map((hour) => ( - <option key={hour} value={hour}> - {hour} - </option> - ))} - </select> - </label> - - <label> - 분: - <select value={minutes} onChange={handleMinutesChange}> - {Array.from({ length: 60 }, (_, i) => i.toString().padStart(2, "0")).map((minute) => ( - <option key={minute} value={minute}> - {minute} + <select value={time} onChange={handleTimeChange}> + {Array.from({ length: 48 }, (_, i) => { + const paddedHour = Math.floor(i / 2).toString().padStart(2, "0"); + const paddedMinute = (i % 2 === 0 ? "00" : "30"); + return `${paddedHour}:${paddedMinute}`; + }).map((time) => ( + <option key={time} value={time}> + {time} </option> ))} </select> @@ -40,4 +26,5 @@ function TimeInput({onTimeChange}) { </div> ); } -export default TimeInput; \ No newline at end of file + +export default TimeInput;