diff --git a/src/components/reservation/myReservationList/modal/MeetingDetailModal.tsx b/src/components/reservation/myReservationList/modal/MeetingDetailModal.tsx index f2b40a8..6ebb569 100644 --- a/src/components/reservation/myReservationList/modal/MeetingDetailModal.tsx +++ b/src/components/reservation/myReservationList/modal/MeetingDetailModal.tsx @@ -144,7 +144,7 @@ const MeetingDetailModal = () => { image { {data?.participants.map((member: participantsType, i: number) => (
- image + image
diff --git a/src/components/reservation/rechargingRoom/RechargingRoomIndex.tsx b/src/components/reservation/rechargingRoom/RechargingRoomIndex.tsx index a8e3189..0b48650 100644 --- a/src/components/reservation/rechargingRoom/RechargingRoomIndex.tsx +++ b/src/components/reservation/rechargingRoom/RechargingRoomIndex.tsx @@ -29,9 +29,11 @@ const RechargingRoomIndex = () => { }); const currentBranch = - updatedTimeSelected && updatedTimeReserved && updatedTimeSelected > updatedTimeReserved - ? selectedBranch - : reservedBranch || selectedBranch; + updatedTimeSelected && + updatedTimeReserved && + updatedTimeSelected > updatedTimeReserved + ? selectedBranch + : reservedBranch || selectedBranch; const branchId = currentBranch?.branchId as number; @@ -43,7 +45,7 @@ const RechargingRoomIndex = () => { } ); - if (data == undefined) { + if (data == undefined || data?.status == 'FAIL') { return null; } diff --git a/src/components/reservation/rechargingRoom/RechargingRoomItem.tsx b/src/components/reservation/rechargingRoom/RechargingRoomItem.tsx index b22d098..a0d46d5 100644 --- a/src/components/reservation/rechargingRoom/RechargingRoomItem.tsx +++ b/src/components/reservation/rechargingRoom/RechargingRoomItem.tsx @@ -1,6 +1,7 @@ import React, { Dispatch } from 'react'; import { rechargingRoomDataType } from '../model/recharging'; import { SelectedState } from './RechargingRoomIndex'; +import { checkValidRecharging } from '../remote/recharging'; interface RechargingRoomItemType { roomData: rechargingRoomDataType; @@ -13,12 +14,31 @@ const RechargingRoomItem = ({ isSelected, setIsSelected }: RechargingRoomItemType) => { - const handleTimeBtn = (startAt: string) => { - setIsSelected({ - rechargingRoomId: roomData?.rechargingRoomId, - startAt, - rechargingRoomName: roomData?.rechargingRoomName - }); + const formatDateWithCurrentDate = (time: string): string => { + const today = new Date(); + const [hours, minutes] = time.split(':'); + today.setHours(parseInt(hours, 10)); + today.setMinutes(parseInt(minutes, 10)); + today.setSeconds(0); + today.setMilliseconds(0); + const yyyy = today.getFullYear(); + const mm = String(today.getMonth() + 1).padStart(2, '0'); + const dd = String(today.getDate()).padStart(2, '0'); + + return `${yyyy}-${mm}-${dd}T${time}:00`; + }; + + const handleTimeBtn = async (startAt: string) => { + const formattedStartAt = startAt ? formatDateWithCurrentDate(startAt) : ''; + const data = await checkValidRecharging(formattedStartAt); + console.log(data); + if (data?.status == 'SUCCESS') { + setIsSelected({ + rechargingRoomId: roomData?.rechargingRoomId, + startAt, + rechargingRoomName: roomData?.rechargingRoomName + }); + } }; return (