From d44406967ad825f5659c84835bcbaedcfebff784 Mon Sep 17 00:00:00 2001 From: hojin Date: Mon, 10 Jun 2024 00:20:23 +0900 Subject: [PATCH] =?UTF-8?q?fix=20:=20=EB=A6=AC=EC=B0=A8=EC=A7=95=EB=A3=B8?= =?UTF-8?q?=20api=20=EB=B3=80=EA=B2=BD,=20=EB=AF=B8=ED=8C=85=EB=A3=B8=20?= =?UTF-8?q?=EB=AA=A8=EB=8B=AC=20=EC=9D=B8=EC=9B=90=20=EC=9D=B4=EB=AF=B8?= =?UTF-8?q?=EC=A7=80=20=ED=81=AC=EA=B8=B0=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modal/MeetingDetailModal.tsx | 8 +++-- .../rechargingRoom/RechargingRoomIndex.tsx | 10 +++--- .../rechargingRoom/RechargingRoomItem.tsx | 32 +++++++++++++++---- 3 files changed, 38 insertions(+), 12 deletions(-) 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 (