From 66cab853f1731f64b6c237292c495855931625a1 Mon Sep 17 00:00:00 2001 From: HotelSync Date: Sun, 12 Apr 2026 00:26:06 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20widget=20rooms=20mode=20=E2=80=94=20show?= =?UTF-8?q?=20real=20photos,=20hide=20mock-only=20meta=20fields?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - displayRooms now maps r.photos (URL strings) to photoUrls[] - Collapsed thumbnail: shows if real photo URL exists, falls back to emoji - Expanded gallery: full-width for real photos, gradient for mock - Thumbnail strip: renders real photo thumbnails when available - Photo nav buttons use totalPhotos (real or mock count) - beds/area/rating hidden when value is 0 (real rooms have no beds/area/rating data) Co-Authored-By: Claude Sonnet 4.6 --- src/pages/BookingWidgetPage.tsx | 121 +++++++++++++++++++------------- 1 file changed, 73 insertions(+), 48 deletions(-) diff --git a/src/pages/BookingWidgetPage.tsx b/src/pages/BookingWidgetPage.tsx index db4c9a5..b9d3ac1 100644 --- a/src/pages/BookingWidgetPage.tsx +++ b/src/pages/BookingWidgetPage.tsx @@ -76,6 +76,7 @@ interface MockRoom { area: number // m² description: string photos: { bg: string; emoji: string; label: string }[] + photoUrls: string[] // real photo URLs (empty for mock rooms) amenities: string[] has3dTour: boolean } @@ -90,7 +91,7 @@ const MOCK_ROOMS: MockRoom[] = [ { bg: 'from-amber-100 to-amber-200', emoji: '🪟', label: 'Окно' }, ], amenities: ['Wi-Fi', 'TV', 'Кондиционер', 'Фен', 'Мини-холодильник', 'Сейф'], - has3dTour: false, + photoUrls: [], has3dTour: false, }, { id: 'r2', name: 'Комфорт', beds: 1, guests: 2, price: 6500, area: 30, @@ -102,7 +103,7 @@ const MOCK_ROOMS: MockRoom[] = [ { bg: 'from-lime-100 to-lime-200', emoji: '🛋️', label: 'Зона отдыха' }, ], amenities: ['Wi-Fi', 'TV', 'Кондиционер', 'Мини-бар', 'Халат', 'Фен', 'Сейф', 'Кофемашина'], - has3dTour: false, + photoUrls: [], has3dTour: false, }, { id: 'r3', name: 'Делюкс', beds: 2, guests: 3, price: 8900, area: 45, @@ -115,7 +116,7 @@ const MOCK_ROOMS: MockRoom[] = [ { bg: 'from-cyan-100 to-cyan-200', emoji: '🍽️', label: 'Мини-кухня' }, ], amenities: ['Wi-Fi', 'Smart TV', 'Кондиционер', 'Джакузи', 'Мини-бар', 'Халат', 'Тапочки', 'Кофемашина', 'Сейф', 'Балкон'], - has3dTour: true, + photoUrls: [], has3dTour: true, }, { id: 'r4', name: 'Пентхаус', beds: 2, guests: 4, price: 15000, area: 80, @@ -129,7 +130,7 @@ const MOCK_ROOMS: MockRoom[] = [ { bg: 'from-amber-100 to-yellow-100', emoji: '🍸', label: 'Бар' }, ], amenities: ['Wi-Fi 1Гбит', 'Smart TV 75"', 'Кондиционер', 'Сауна', 'Мини-бар', 'Джакузи', 'Терраса', 'Дворецкий', 'Кофемашина', 'Халат', 'Тапочки', 'Сейф'], - has3dTour: true, + photoUrls: [], has3dTour: true, }, ] @@ -239,9 +240,12 @@ export function WidgetPreview({ settings, slug, realRooms, realCategories, realR // Use real rooms if available, otherwise mock const displayRooms = realRooms && realRooms.length > 0 ? realRooms.map(r => ({ - id: r.id, name: r.name || `Номер ${r.number}`, beds: 1, + id: r.id, name: r.name || `Номер ${r.number}`, beds: 0, guests: r.maxGuests, price: r.baseRate, area: 0, - description: r.description, photos: [], amenities: r.amenities, + description: r.description ?? '', + photos: [] as { bg: string; emoji: string; label: string }[], + photoUrls: r.photos ?? [], + amenities: r.amenities ?? [], has3dTour: false, })) : MOCK_ROOMS @@ -966,8 +970,11 @@ export function WidgetPreview({ settings, slug, realRooms, realCategories, realR {displayRooms.map(room => { const isExpanded = expandedRoom === room.id const isSelected = selected === room.id - const curPhoto = photoIndex[room.id] ?? 0 + const hasRealPhotos = room.photoUrls.length > 0 + const totalPhotos = hasRealPhotos ? room.photoUrls.length : room.photos.length + const curPhoto = Math.min(photoIndex[room.id] ?? 0, Math.max(0, totalPhotos - 1)) const photo = room.photos[curPhoto] ?? { bg: 'from-slate-200 to-slate-300', emoji: '🛏️', label: 'Фото' } + const curPhotoUrl = hasRealPhotos ? room.photoUrls[curPhoto] : null return (
setSelected(room.id === selected ? null : room.id)} > {/* Thumbnail */} -
- {photo.emoji} -
+ {curPhotoUrl ? ( + {room.name} + ) : ( +
+ {photo.emoji} +
+ )}

{room.name}

@@ -997,13 +1008,14 @@ export function WidgetPreview({ settings, slug, realRooms, realCategories, realR до {room.guests} - - {room.beds} кровати - - {room.area} м² - - 4.8 - + {room.beds > 0 && ( + + {room.beds} кр. + + )} + {room.area > 0 && ( + {room.area} м² + )}
@@ -1033,16 +1045,17 @@ export function WidgetPreview({ settings, slug, realRooms, realCategories, realR
{/* Photo gallery */}
-
- {photo.emoji} - {photo.label} -
+ {curPhotoUrl ? ( + {room.name} + ) : ( +
+ {photo.emoji} + {photo.label} +
+ )} {/* Photo nav */} - {room.photos.length > 1 && ( + {totalPhotos > 1 && ( <> {/* Dots */}
- {room.photos.map((_, i) => ( + {Array.from({ length: totalPhotos }).map((_, i) => (
{/* Thumbnail strip */} -
- {room.photos.map((p, i) => ( - - ))} -
+ {totalPhotos > 1 && ( +
+ {hasRealPhotos + ? room.photoUrls.map((url, i) => ( + + )) + : room.photos.map((p, i) => ( + + )) + } +
+ )} {/* Description */}