Skip to content

Commit

Permalink
fix : 시간 데이터 정렬 및 로그 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
ChoiSangwon committed Jun 19, 2024
1 parent da21401 commit ae104ef
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/pages/main/timeselect/timeselect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ const TimeSelect = () => {
const handleTimeSlotClick = (timeSlot: string) => {
setSelectedTimeSlot(timeSlot);
};

useEffect(() => {
const url = `https://cogo.life/api/v1/mentor/possibleDates/${username}`;
console.log(username);
fetch(url, {
method: "GET",
headers: {
Expand All @@ -35,15 +35,17 @@ const TimeSelect = () => {
.then((data) => {
const formedData = getFormattedTimeSlots(data);
setTimeSlots(formedData);
console.log(data);
})
.catch((error) => {
console.error("Error:", error);
});
}, []);
}, [token, username]);

const getFormattedTimeSlots = (fetchData: TimeSlot[]) => {
return fetchData.map((slot: TimeSlot) => {
const sortedData = fetchData.sort(
(a, b) => new Date(a.date).getTime() - new Date(b.date).getTime()
);
return sortedData.map((slot: TimeSlot) => {
const date = new Date(slot.date);
const dayOfWeek = date.toLocaleString("ko-KR", { weekday: "short" });
const formattedDate = date.toLocaleDateString("ko-KR");
Expand Down

0 comments on commit ae104ef

Please sign in to comment.