Edit app-9xzmfic2e4g1/src/components/trip/Map.tsx via Editor
This commit is contained in:
parent
fbad1021e0
commit
f589c87d66
@ -87,12 +87,12 @@ export function TripMap({ itinerary, activePlaceId, onMarkerClick, onAddPlace }:
|
|||||||
'place_id', 'name', 'editorial_summary', 'rating', 'user_ratings_total',
|
'place_id', 'name', 'editorial_summary', 'rating', 'user_ratings_total',
|
||||||
'opening_hours', 'reviews', 'types', 'formatted_address',
|
'opening_hours', 'reviews', 'types', 'formatted_address',
|
||||||
],
|
],
|
||||||
},
|
language: 'tr',
|
||||||
|
} as any,
|
||||||
(place, status) => {
|
(place, status) => {
|
||||||
setDetailLoading(false);
|
setDetailLoading(false);
|
||||||
if (status !== google.maps.places.PlacesServiceStatus.OK || !place) return;
|
if (status !== google.maps.places.PlacesServiceStatus.OK || !place) return;
|
||||||
|
|
||||||
// Build why_visit from types + editorial_summary
|
|
||||||
const typeLabels: Record<string, string> = {
|
const typeLabels: Record<string, string> = {
|
||||||
tourist_attraction: 'Turistik bir cazibe noktası — ziyaret değer.',
|
tourist_attraction: 'Turistik bir cazibe noktası — ziyaret değer.',
|
||||||
museum: 'Tarihi ve kültürel bir müze deneyimi sunar.',
|
museum: 'Tarihi ve kültürel bir müze deneyimi sunar.',
|
||||||
@ -104,23 +104,38 @@ export function TripMap({ itinerary, activePlaceId, onMarkerClick, onAddPlace }:
|
|||||||
mosque: 'Tarihi ve mimari açıdan ilgi çekici bir yapı.',
|
mosque: 'Tarihi ve mimari açıdan ilgi çekici bir yapı.',
|
||||||
point_of_interest: 'Bölgenin önemli ilgi noktalarından biri.',
|
point_of_interest: 'Bölgenin önemli ilgi noktalarından biri.',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// why_visit: önce AI'dan gelen poi.why_visit, yoksa tip etiketlerine bak
|
||||||
const whyVisit: string[] = [];
|
const whyVisit: string[] = [];
|
||||||
if (place.editorial_summary?.overview) whyVisit.push(place.editorial_summary.overview);
|
if ((poi as any).why_visit) {
|
||||||
for (const t of (place.types || [])) {
|
whyVisit.push((poi as any).why_visit);
|
||||||
const label = typeLabels[t];
|
} else {
|
||||||
if (label && !whyVisit.includes(label)) { whyVisit.push(label); break; }
|
for (const t of (place.types || [])) {
|
||||||
|
const label = typeLabels[t];
|
||||||
|
if (label) { whyVisit.push(label); break; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build tips from top-rated reviews
|
// Tips: önce AI'dan gelen personal_tip, sonra Türkçe yorumlar
|
||||||
const tips: string[] = (place.reviews || [])
|
const tips: string[] = [];
|
||||||
|
if ((poi as any).personal_tip) {
|
||||||
|
tips.push((poi as any).personal_tip);
|
||||||
|
}
|
||||||
|
const reviewTips = (place.reviews || [])
|
||||||
.filter(r => r.rating >= 4 && r.text?.length > 30)
|
.filter(r => r.rating >= 4 && r.text?.length > 30)
|
||||||
.slice(0, 2)
|
.slice(0, tips.length > 0 ? 1 : 2)
|
||||||
.map(r => `"${r.text.slice(0, 120).trim()}…"`);
|
.map(r => `"${r.text.slice(0, 120).trim()}…"`);
|
||||||
|
tips.push(...reviewTips);
|
||||||
|
|
||||||
|
// summary: editorial_summary sadece Türkçe ise göster, değilse boş bırak
|
||||||
|
const rawSummary = place.editorial_summary?.overview || '';
|
||||||
|
const isTurkish = /[çğışöüÇĞİŞÖÜ]/.test(rawSummary) || !/[a-zA-Z]{4,}/.test(rawSummary);
|
||||||
|
const summary = isTurkish ? rawSummary : '';
|
||||||
|
|
||||||
const detail: PlaceDetail = {
|
const detail: PlaceDetail = {
|
||||||
place_id: place.place_id || poi.place_id,
|
place_id: place.place_id || poi.place_id,
|
||||||
name: place.name || poi.name,
|
name: place.name || poi.name,
|
||||||
summary: place.editorial_summary?.overview || '',
|
summary,
|
||||||
rating: place.rating,
|
rating: place.rating,
|
||||||
total_ratings: place.user_ratings_total,
|
total_ratings: place.user_ratings_total,
|
||||||
is_open_now: place.opening_hours?.isOpen?.() ?? null,
|
is_open_now: place.opening_hours?.isOpen?.() ?? null,
|
||||||
@ -206,7 +221,8 @@ export function TripMap({ itinerary, activePlaceId, onMarkerClick, onAddPlace }:
|
|||||||
{
|
{
|
||||||
placeId,
|
placeId,
|
||||||
fields: ['place_id', 'name', 'formatted_address', 'geometry', 'rating', 'photos', 'types'],
|
fields: ['place_id', 'name', 'formatted_address', 'geometry', 'rating', 'photos', 'types'],
|
||||||
},
|
language: 'tr',
|
||||||
|
} as any,
|
||||||
(place, status) => {
|
(place, status) => {
|
||||||
if (status !== google.maps.places.PlacesServiceStatus.OK || !place?.geometry?.location) return;
|
if (status !== google.maps.places.PlacesServiceStatus.OK || !place?.geometry?.location) return;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user