diff --git a/app-9xzmfic2e4g1/src/pages/TripDetailsPage.tsx b/app-9xzmfic2e4g1/src/pages/TripDetailsPage.tsx index bff4781..1e68522 100644 --- a/app-9xzmfic2e4g1/src/pages/TripDetailsPage.tsx +++ b/app-9xzmfic2e4g1/src/pages/TripDetailsPage.tsx @@ -1,12 +1,12 @@ import { useEffect, useState, useCallback, useMemo, useRef } from 'react'; -import { useParams, useNavigate } from 'react-router-dom'; +import { useParams, useNavigate, Link } from 'react-router-dom'; import api, { Trip, Place, ItineraryDay } from '@/db/api'; import { Timeline } from '@/components/trip/Timeline'; import { TripMap } from '@/components/trip/Map'; import { Loader2, Share2, MapPin, Trash2, Plus, LayoutGrid, RotateCcw, RotateCw, - CheckCircle2, Clock, Navigation + CheckCircle2, Clock, Navigation, Globe, GlobeLock, X } from 'lucide-react'; import { toast } from 'sonner'; import { Button } from '@/components/ui/button'; @@ -67,6 +67,13 @@ export default function TripDetailsPage() { const [saveStatus, setSaveStatus] = useState<'saved' | 'saving' | 'unsaved'>('saved'); const saveTimer = useRef | null>(null); + // Publish modal + const [showPublishModal, setShowPublishModal] = useState(false); + const [publishLoading, setPublishLoading] = useState(false); + const [guideIntro, setGuideIntro] = useState(''); + const [guideTips, setGuideTips] = useState(''); + const [isPublic, setIsPublic] = useState(false); + // History operates on the full itinerary object const history = useUndoRedo(null); @@ -79,6 +86,9 @@ export default function TripDetailsPage() { if (data) { setTrip(data); history.push(data.itinerary); + setIsPublic(!!(data as any).is_public); + setGuideIntro((data as any).guide_intro || ''); + setGuideTips(((data as any).guide_tips || []).join('\n')); } else { toast.error('Gezi bulunamadı'); navigate('/explore'); @@ -226,6 +236,33 @@ export default function TripDetailsPage() { } }; + const handlePublish = async () => { + if (!trip) return; + setPublishLoading(true); + try { + const tips = guideTips.split('\n').map(t => t.trim()).filter(Boolean); + await api.publishGuide(trip.id, { guide_intro: guideIntro, guide_tips: tips }); + setIsPublic(true); + setShowPublishModal(false); + toast.success('Rehber yayınlandı! Toplulukta görünüyor.'); + } catch { + toast.error('Yayınlama başarısız'); + } finally { + setPublishLoading(false); + } + }; + + const handleUnpublish = async () => { + if (!trip) return; + try { + await api.unpublishGuide(trip.id); + setIsPublic(false); + toast.success('Rehber yayından kaldırıldı'); + } catch { + toast.error('İşlem başarısız'); + } + }; + const handleDelete = async () => { if (!trip) return; try { @@ -279,6 +316,63 @@ export default function TripDetailsPage() { return (
+ {/* ── Publish Modal ────────────────────────────────────────────────── */} + {showPublishModal && ( +
+
+
+
+

Rehber Olarak Yayınla

+

Rotanız toplulukla paylaşılacak

+
+ +
+ +
+
+ +