diff --git a/src/AppRouter.tsx b/src/AppRouter.tsx index e345acc..10b48f8 100644 --- a/src/AppRouter.tsx +++ b/src/AppRouter.tsx @@ -222,7 +222,7 @@ export function AppRouter({ } /> - diff --git a/src/Redux/services/itinerary.service.ts b/src/Redux/services/itinerary.service.ts index 7934c46..ece4428 100644 --- a/src/Redux/services/itinerary.service.ts +++ b/src/Redux/services/itinerary.service.ts @@ -23,6 +23,9 @@ export const itineraryApi = createApi({ query: (itineraryId: number) => `/website/itinerary/${itineraryId}`, }), + getUserItineraries: builder.query({ + query: () => `/website/itinerary/all-initineraries`, + }), }) }); @@ -30,4 +33,5 @@ export const itineraryApi = createApi({ export const { useCreateMagicItineraryMutation, useGetItineraryDetailsByIdQuery, + useGetUserItinerariesQuery } = itineraryApi; \ No newline at end of file diff --git a/src/pages/ItineraryViewPageDesign.tsx b/src/pages/ItineraryViewPageDesign.tsx index bb78d02..6ce81a9 100644 --- a/src/pages/ItineraryViewPageDesign.tsx +++ b/src/pages/ItineraryViewPageDesign.tsx @@ -7,6 +7,9 @@ import { Badge } from '../components/ui/badge'; import Navbar from '../components/Navbar'; import { Footer } from '../components/Footer'; import { ImageWithFallback } from '../components/figma/ImageWithFallback'; +import { useGetItineraryDetailsByIdQuery } from '../Redux/services/itinerary.service'; +import { useParams } from 'react-router-dom'; +import LoadingSpinner from '../components/LoadingSpinner'; interface ItineraryViewPageDesignProps { onBackClick: () => void; @@ -35,18 +38,6 @@ interface ItineraryViewPageDesignProps { user?: { email: string; name: string; } | null; } -// Enhanced activity type with more details -interface Activity { - time: string; - activity: string; - location: string; - address: string; - image: string; - categories: string[]; - description: string[]; - isFavorite?: boolean; -} - export function ItineraryViewPageDesign({ onBackClick, onHomeClick, @@ -74,304 +65,36 @@ export function ItineraryViewPageDesign({ user }: ItineraryViewPageDesignProps) { const [viewMode, setViewMode] = useState<'daily' | 'summary'>('daily'); - const [favorites, setFavorites] = useState>(new Set()); + // const [favorites, setFavorites] = useState>(new Set()); - const toggleFavorite = (activityKey: string) => { - setFavorites(prev => { - const newSet = new Set(prev); - if (newSet.has(activityKey)) { - newSet.delete(activityKey); - } else { - newSet.add(activityKey); - } - return newSet; - }); - }; + // ── API Integration ────────────────────────────────────────────────────────── + const { itineraryId } = useParams(); + const { data: itineraryDetails, isLoading } = useGetItineraryDetailsByIdQuery(itineraryId); - // Enhanced itinerary data with images, addresses, and detailed info - const generatedItinerary = { - destination: { - name: 'Melbourne', - country: 'Australia', - weather: '18°C, Sunny', - image: 'https://images.unsplash.com/photo-1514395462725-fb4566210144?w=400&h=300&fit=crop' - }, - totalDays: 3, - estimatedCost: '$450 AUD', - includedActivities: 18, - dailyPlans: [ - { - day: 1, - title: "City Center & Culture", - activities: [ - { - time: '8:00 am', - activity: 'The Langham Melbourne', - location: 'The Langham Melbourne', - address: '1 Southgate Avenue, Southbank VIC 3006', - image: 'https://images.unsplash.com/photo-1566073771259-6a8506099945?w=800&h=600&fit=crop', - categories: ['Accommodation', 'Luxury'], - description: [ - 'Check-in at luxury riverside hotel', - 'Enjoy complimentary breakfast', - 'Relax at the spa facilities', - 'Explore the surrounding Southbank area' - ] - }, - { - time: '10:00 am', - activity: 'Federation Square', - location: 'Federation Square', - address: 'Corner Swanston & Flinders Streets, Melbourne VIC 3000', - image: 'https://images.unsplash.com/photo-1514395462725-fb4566210144?w=800&h=600&fit=crop', - categories: ['Culture', 'Landmark'], - description: [ - 'Explore Melbourne\'s cultural precinct', - 'Visit the ACMI museum', - 'Enjoy street performances', - 'Take photos at iconic locations' - ] - }, - { - time: '12:00 pm', - activity: 'Degrave Street Café', - location: 'Degrave Street Espresso Bar', - address: '23-25 Degraves Street, Melbourne VIC 3000', - image: 'https://images.unsplash.com/photo-1554118811-1e0d58224f24?w=800&h=600&fit=crop', - categories: ['Food', 'Drinks', 'Culture'], - description: [ - 'Coffee at Pellegrini\'s Espresso Bar (iconic old-school cafe)', - 'Try the famous jam doughnuts', - 'Shop for fresh produce in the Deli Hall', - 'Pick up unique souvenirs in the General Merchandise section' - ] - }, - { - time: '2:00 pm', - activity: 'Royal Botanic Gardens', - location: 'Royal Botanic Gardens Victoria', - address: 'Birdwood Avenue, South Yarra VIC 3141', - image: 'https://images.unsplash.com/photo-1585320806297-9794b3e4eeae?w=800&h=600&fit=crop', - categories: ['Nature', 'Culture'], - description: [ - 'Stroll through stunning landscaped gardens', - 'Visit the Australian Forest Walk', - 'Relax by the Ornamental Lake', - 'Join a free guided walking tour' - ] - }, - { - time: '4:00 pm', - activity: 'National Gallery of Victoria', - location: 'NGV International', - address: '180 St Kilda Road, Melbourne VIC 3006', - image: 'https://images.unsplash.com/photo-1564399577149-749794d74eee?w=800&h=600&fit=crop', - categories: ['Culture', 'Art'], - description: [ - 'Explore Australia\'s oldest art museum', - 'View international and Australian art collections', - 'Visit the stunning water wall entrance', - 'Browse the NGV design store' - ] - }, - { - time: '7:00 pm', - activity: 'Dinner at Chin Chin', - location: 'Chin Chin Restaurant', - address: '125 Flinders Lane, Melbourne VIC 3000', - image: 'https://images.unsplash.com/photo-1552566626-52f8b828add9?w=800&h=600&fit=crop', - categories: ['Food', 'Drinks'], - description: [ - 'Experience modern Thai cuisine', - 'Try signature dishes like the Betel Leaf', - 'Enjoy the vibrant atmosphere', - 'Book ahead or walk-in for bar seating' - ] - } - ] - }, - { - day: 2, - title: "Markets & Neighborhoods", - activities: [ - { - time: '8:00 am', - activity: 'Queen Victoria Market', - location: 'Queen Victoria Market', - address: 'Queen Street, Melbourne VIC 3000', - image: 'https://images.unsplash.com/photo-1555939594-58d7cb561ad1?w=800&h=600&fit=crop', - categories: ['Food', 'Shopping', 'Culture'], - description: [ - 'Explore Melbourne\'s historic market (since 1878)', - 'Sample fresh local produce', - 'Shop for artisan goods and souvenirs', - 'Grab breakfast at the Deli Hall' - ] - }, - { - time: '10:30 am', - activity: 'Fitzroy Street Art Tour', - location: 'Fitzroy Arts Precinct', - address: 'Gertrude Street, Fitzroy VIC 3065', - image: 'https://images.unsplash.com/photo-1499781350541-7783f6c6a0c8?w=800&h=600&fit=crop', - categories: ['Culture', 'Art'], - description: [ - 'Walk through famous street art laneways', - 'Discover works by renowned artists', - 'Visit independent galleries', - 'Explore vintage and record stores' - ] - }, - { - time: '12:30 pm', - activity: 'Brunswick Street Lunch', - location: 'Brunswick Street Precinct', - address: 'Brunswick Street, Fitzroy VIC 3065', - image: 'https://images.unsplash.com/photo-1517248135467-4c7edcad34c4?w=800&h=600&fit=crop', - categories: ['Food', 'Drinks'], - description: [ - 'Choose from diverse dining options', - 'Try local cafes and restaurants', - 'Explore bookshops and boutiques', - 'Enjoy the vibrant neighborhood atmosphere' - ] - }, - { - time: '2:30 pm', - activity: 'Carlton Gardens', - location: 'Carlton Gardens', - address: 'Carlton Gardens, Carlton VIC 3053', - image: 'https://images.unsplash.com/photo-1519331379826-f10be5486c6f?w=800&h=600&fit=crop', - categories: ['Nature', 'Culture', 'Landmark'], - description: [ - 'Visit the UNESCO World Heritage site', - 'See the Royal Exhibition Building', - 'Stroll through Victorian-era gardens', - 'Relax by the ornamental fountains' - ] - }, - { - time: '4:00 pm', - activity: 'Melbourne Museum', - location: 'Melbourne Museum', - address: '11 Nicholson Street, Carlton VIC 3053', - image: 'https://images.unsplash.com/photo-1566127992631-137a642a90f4?w=800&h=600&fit=crop', - categories: ['Culture', 'Museum'], - description: [ - 'Explore natural and cultural history', - 'Visit the Bunjilaka Aboriginal Centre', - 'See the Forest Gallery living ecosystem', - 'Discover Melbourne\'s story exhibition' - ] - }, - { - time: '7:00 pm', - activity: 'Rooftop Bar Experience', - location: 'Naked for Satan', - address: '285 Brunswick Street, Fitzroy VIC 3065', - image: 'https://images.unsplash.com/photo-1514933651103-005eec06c04b?w=800&h=600&fit=crop', - categories: ['Drinks', 'Food'], - description: [ - 'Enjoy sunset views from the rooftop', - 'Try Spanish-style pintxos', - 'Sample craft cocktails and local beers', - 'Experience Melbourne\'s bar culture' - ] - } - ] - }, - { - day: 3, - title: "Coastal Adventure", - activities: [ - { - time: '8:00 am', - activity: 'St. Kilda Beach', - location: 'St. Kilda Beach', - address: 'Jacka Boulevard, St Kilda VIC 3182', - image: 'https://images.unsplash.com/photo-1505142468610-359e7d316be0?w=800&h=600&fit=crop', - categories: ['Nature', 'Beach'], - description: [ - 'Morning walk along the iconic beach', - 'Visit the historic St Kilda Pier', - 'See the little penguins at sunset', - 'Explore the Sunday Esplanade Market (weekends)' - ] - }, - { - time: '10:00 am', - activity: 'Acland Street Cafes', - location: 'Acland Street', - address: 'Acland Street, St Kilda VIC 3182', - image: 'https://images.unsplash.com/photo-1495474472287-4d71bcdd2085?w=800&h=600&fit=crop', - categories: ['Food', 'Drinks'], - description: [ - 'Brunch at famous cake shops', - 'Try traditional European pastries', - 'Visit Lentil as Anything (pay-as-you-feel)', - 'Browse vintage shops and bookstores' - ] - }, - { - time: '12:00 pm', - activity: 'Luna Park Melbourne', - location: 'Luna Park Melbourne', - address: '18 Lower Esplanade, St Kilda VIC 3182', - image: 'https://images.unsplash.com/photo-1513026705753-bc3fffca8bf4?w=800&h=600&fit=crop', - categories: ['Entertainment', 'Landmark'], - description: [ - 'Visit Melbourne\'s iconic amusement park', - 'Ride the historic Scenic Railway (1912)', - 'Take photos at Mr Moon entrance', - 'Enjoy carnival games and rides' - ] - }, - { - time: '2:00 pm', - activity: 'Brighton Beach Boxes', - location: 'Brighton Beach', - address: 'Esplanade, Brighton VIC 3186', - image: 'https://images.unsplash.com/photo-1520208422220-d12a3c588e6c?w=800&h=600&fit=crop', - categories: ['Culture', 'Landmark'], - description: [ - 'Photograph the famous colorful bathing boxes', - 'Walk along the pristine beach', - 'Learn about the heritage structures', - 'Relax in the beachside atmosphere' - ] - }, - { - time: '4:00 pm', - activity: 'Southbank Promenade', - location: 'Southbank', - address: 'Southbank Promenade, Southbank VIC 3006', - image: 'https://images.unsplash.com/photo-1559827260-dc66d52bef19?w=800&h=600&fit=crop', - categories: ['Culture', 'Shopping'], - description: [ - 'Stroll along the Yarra River', - 'Visit arts and craft markets', - 'Explore restaurants and cafes', - 'Enjoy river views and street performers' - ] - }, - { - time: '7:00 pm', - activity: 'Farewell Dinner at Vue de Monde', - location: 'Vue de Monde', - address: 'Level 55, Rialto, 525 Collins Street, Melbourne VIC 3000', - image: 'https://images.unsplash.com/photo-1414235077428-338989a2e8c0?w=800&h=600&fit=crop', - categories: ['Food', 'Drinks', 'Luxury'], - description: [ - 'Experience fine dining at 55th floor', - 'Enjoy panoramic Melbourne views', - 'Taste modern Australian cuisine', - 'Celebrate the end of your journey' - ] - } - ] - } - ] - }; + const generatedItinerary = itineraryDetails ?? null; + const days = generatedItinerary?.days ?? []; + const summaries = generatedItinerary?.summary ?? []; + // ───────────────────────────────────────────────────────────────────────────── + + // const toggleFavorite = (activityKey: string) => { + // setFavorites(prev => { + // const newSet = new Set(prev); + // if (newSet.has(activityKey)) { + // newSet.delete(activityKey); + // } else { + // newSet.add(activityKey); + // } + // return newSet; + // }); + // }; + + // ── Loading State ───────────────────────────────────────────────────────────── + if (isLoading) { + return ( + + ); + } + // ───────────────────────────────────────────────────────────────────────────── return (
@@ -422,12 +145,14 @@ export function ItineraryViewPageDesign({

Your{' '} - Magic Itinerary + + {generatedItinerary?.title ?? 'Magic Itinerary'} +

- Here's your personalized {generatedItinerary.totalDays}-day adventure in {generatedItinerary.destination.name}! + Here's your personalized {generatedItinerary?.totalDays}-day adventure in {generatedItinerary?.city}!

@@ -437,6 +162,7 @@ export function ItineraryViewPageDesign({
+ {/* View Toggle */}
@@ -459,31 +185,46 @@ export function ItineraryViewPageDesign({
- {/* Itinerary Overview */} + {/* Itinerary Overview Card */} - -
-
-
{generatedItinerary.totalDays}
-
Days
+ {/* Banner Image */} + +
+ +
+
+

Your Trip

+

{generatedItinerary?.city}

-
-
{generatedItinerary.includedActivities}
-
Activities
+
+ + {/* Stats Row */} +
+
+ {generatedItinerary?.totalDays} + Days
-
-
{generatedItinerary.estimatedCost}
-
Estimated Cost
+
+ {generatedItinerary?.totalStops} + Stops +
+
+ {days[0]?.date} + Start Date
- {/* Daily Plans - Enhanced View */} + {/* ── Daily View ──────────────────────────────────────────────────── */} {viewMode === 'daily' && ( - {generatedItinerary.dailyPlans.map((day, dayIndex) => ( + {days.map((day: any, dayIndex: number) => (
- {/* Location Header with Weather - Only show for first day or when city actually changes */} - {(() => { - // Get current day's destination (fallback to main destination if not specified) - const currentDestination = (day as any).destination || generatedItinerary.destination; - - // Check if this is the first day - if (dayIndex === 0) return true; - - // Check if destination changed from previous day - if (dayIndex > 0) { - const previousDay = generatedItinerary.dailyPlans[dayIndex - 1]; - const previousDestination = (previousDay as any).destination || generatedItinerary.destination; - - // Only show if city name is different - return currentDestination.name !== previousDestination.name; - } - - return false; - })() && ( + + {/* City / Weather header — only on first day */} + {dayIndex === 0 && (

- {((day as any).destination || generatedItinerary.destination).name}, {((day as any).destination || generatedItinerary.destination).country} + {generatedItinerary?.city}, Australia

-

{((day as any).destination || generatedItinerary.destination).weather}

-
-
-
+
)} @@ -540,24 +262,28 @@ export function ItineraryViewPageDesign({ className="flex items-center gap-4 pl-2" >
- {day.day} + {day.dayNumber}
-

Day {day.day}

+

+ Day {day.dayNumber} +

{day.title}

- {/* GMT Label */} + {/* Time-zone label */}
-

GMT

+

+ {day.date} +

- {/* Activity Cards - Desktop Grid Layout */} + {/* Activity Cards */}
- {day.activities.map((activity, actIndex) => { - const activityKey = `day${day.day}-act${actIndex}`; - const isFavorite = favorites.has(activityKey); + {day.items?.map((activity: any, actIndex: number) => { + const activityKey = `day${day.dayNumber}-act${actIndex}`; + // const isFavorite = favorites.has(activityKey); return ( {/* Time Column */}
-
{activity.time}
+
+ {activity.timeSlot} +
{/* Activity Card */}
- {/* Hero Image with Overlay Buttons */} + {/* Hero Image */}
- - {/* Favorite Heart Button - Top Right */} -
+ + {/* Favourite Button */} + {/*
-
+
*/} - {/* Get Directions Button - Bottom Left */} + {/* Get Directions — links to Google Maps via lat/lng */}
-
- {/* Content Section */} + {/* Content */}
- {/* Location Name & Address */}

- {activity.activity} + {activity.title}

- {activity.address} + + {activity.locationName} +
{/* Category Badges */}
- {activity.categories.map((category, catIndex) => ( - ( + - {category} + {cat} ))}
- {/* Activity Details - Bullet Points */} + {/* Description */}
- {activity.description.map((detail, detailIndex) => ( -
- - {detail} -
- ))} +
+ + + {activity.description} + +
@@ -655,7 +390,7 @@ export function ItineraryViewPageDesign({ )} - {/* Summary View */} + {/* ── Summary View ─────────────────────────────────────────────────── */} {viewMode === 'summary' && ( -

Trip Summary

+

+ Trip Summary +

- {generatedItinerary.dailyPlans.map((day, index) => ( -
-
- -

Day {day.day}: {day.title}

-
-
- {day.activities.map((activity, actIndex) => ( -
- -
- {activity.activity} -
- {activity.time} - - {activity.location} + {days.map((day: any, dayIndex: number) => { + // ✅ Match summary to the correct day by dayNumber + const daySummary = summaries.find((s: any) => s.dayNumber === day.dayNumber); + + const dayDate = days[0]?.date + ? new Date( + new Date(days[0].date).setDate( + new Date(days[0].date).getDate() + dayIndex + ) + ).toLocaleDateString('en-AU', { + day: '2-digit', + month: '2-digit', + year: 'numeric', + }) + : ''; + + return ( +
+
+
+ +

+ Day {day.dayNumber}: {daySummary?.title ?? day.title} +

+
+ {dayDate} +
+ +
+ {daySummary?.items?.map((item: any, actIndex: number) => ( +
+ +
+ {item.title} +
+ {item.timeSlot} + + {item.locationName} +
-
- ))} + ))} +
-
- ))} + ); + })}
@@ -709,16 +469,11 @@ export function ItineraryViewPageDesign({ Create Another - - @@ -728,7 +483,7 @@ export function ItineraryViewPageDesign({
{/* Footer */} -