Skip to content

Commit

Permalink
ENH: 캘린더 데이터 하나만 담기는 오류 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
khj1998 committed Feb 23, 2023
1 parent 301895f commit 4bf04aa
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions frontend/src/Components/calendar/CalendarView.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,49 +66,45 @@ const NewDate = {
"end":""
}


function CalendarView(){
const [newEvent, setNewEvent] = useState({ title: "", start: "", end: "" });
const [newDate, setNewDate] = useState({ title: "", start: "", end: "" });
const [allEvents, setAllEvents] = useState([]);


useEffect(()=>{
loadUser();
}, []);


const loadUser=async ()=>{
const result=await axios.get(`http://localhost:8080/cotato`)
.then(function (response) {
let appointments = response.data;
let map = new Map([])

let map = [];
console.log(appointments)

appointments.map(i => {
let temp = { "title":"","start":"","end":""};
let startShow = new Date(i.startYear+"."+i.startMonth+"."+i.startDay);
let endShow = new Date(i.endYear+"."+i.endMonth+"."+i.endDay);

NewDate.title = i.content;
NewDate.start = startShow;
NewDate.end = endShow;
temp.title = i.content;
temp.start = startShow;
temp.end = endShow;

console.log(NewDate);
console.log(temp);

map.set(NewDate)
map.push(temp);
})

for (let i = 0; i < appointments.length; i++) {

let startShow = new Date(appointments[i].startYear+"."+appointments[i].startMonth+"."+appointments[i].startDay);
let endShow = new Date(appointments[i].endYear+"."+appointments[i].endMonth+"."+appointments[i].endDay);

NewDate.title = appointments[i].content;
NewDate.start = startShow;
NewDate.end = endShow;

allEvents.push(NewDate);
NewDate.title = appointments[i].content;
NewDate.start = startShow;
NewDate.end = endShow;
allEvents.push(NewDate);
}

console.log(allEvents)
Expand Down

0 comments on commit 4bf04aa

Please sign in to comment.