diff --git a/pages/index.tsx b/pages/index.tsx index f90e825..d2057c6 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -27,6 +27,7 @@ function Home() { const router = useRouter(); const { openModal, closeModal } = useModal(); const [page, setPage] = useState(0); + const [totalElements, setTotalElements] = useState(0); // TODO: 전체 페이지보다 크면 페이징 처리 안되도록 수정 @@ -34,6 +35,7 @@ function Home() { try { const data = await getRooms({ page }); setRooms(data?.content || []); + setTotalElements(data?.totalElements || 0); } catch (error) { console.error(error); } @@ -217,7 +219,7 @@ function Home() { })} - There are {`${rooms.length} rooms`} in total! + There are {`${totalElements} rooms`} in total! {rooms.map((room, idx) => ( // Nav 영역 맨 마지막 부분 잘리는 문제로 추가!! diff --git a/pages/room/[id].tsx b/pages/room/[id].tsx index c83746a..8c0bc5f 100644 --- a/pages/room/[id].tsx +++ b/pages/room/[id].tsx @@ -113,7 +113,7 @@ const Page = () => { } const roomsFurnishings = data.furnishings.map((furnishing) => { - const roomFurnishing = furnishings.find((item) => item.id === furnishing); + const roomFurnishing = furnishings.find((item) => item.id === furnishing.id); if (!roomFurnishing) { return null; @@ -158,22 +158,29 @@ const Page = () => { {room && ( <>
- handleSlideChange(event.realIndex)} - > - {room.imageFiles.map((image, idx) => ( - - {`room-${idx}`} - - ))} -
- {currentSlide + 1}/{room.imageFiles.length} -
-
+ {room.imageFiles.length > 0 ? ( + handleSlideChange(event.realIndex)} + > + {room.imageFiles.map((image, idx) => ( + + {`room-${idx}`} + + ))} +
+ {currentSlide + 1}/{room.imageFiles.length} +
+
+ ) : ( +
+ )}
diff --git a/pages/room/add/step1.tsx b/pages/room/add/step1.tsx index 8cefb46..4e59795 100644 --- a/pages/room/add/step1.tsx +++ b/pages/room/add/step1.tsx @@ -56,7 +56,7 @@ export default function AddRoom() { locationId: data.dong.value, monthlyRent: data.monthPrice, deposit: data.depositPrice, - maintananceFee: data.maintananceFee, + maintenanceFee: data.maintananceFee, availableDate: formatDateForAPI(data.dateAvailable), gasIncluded: data.gasChecked, waterIncluded: data.waterChecked, diff --git a/public/types/room.ts b/public/types/room.ts index 7b66d10..a24246b 100644 --- a/public/types/room.ts +++ b/public/types/room.ts @@ -56,6 +56,14 @@ export interface Furnishing { desc: string; } +export interface FurnishingData { + createdAt: string; + deleted: boolean; + id: number; + type: string; + updatedAt: string; +} + export interface RoomFile { createdAt: string; deleted: boolean; @@ -133,7 +141,7 @@ export interface RoomSearch { cleaningIncluded: number; }; roomInfo: RoomInfo; - furnishings: number[]; + furnishings: FurnishingData[]; availableDate: string; description: string; imageFiles: ImageFile[];