diff --git a/src/AppRouter.tsx b/src/AppRouter.tsx index 52bf4f0..b3e28a0 100644 --- a/src/AppRouter.tsx +++ b/src/AppRouter.tsx @@ -88,7 +88,7 @@ export function AppRouter({ } /> {/* Home Route */} - @@ -106,7 +106,7 @@ export function AppRouter({ } /> {/* Attractions Routes */} - @@ -265,7 +265,7 @@ export function AppRouter({ } /> - diff --git a/src/Redux/services/cities.service.ts b/src/Redux/services/cities.service.ts index 9754016..acc5b31 100644 --- a/src/Redux/services/cities.service.ts +++ b/src/Redux/services/cities.service.ts @@ -20,15 +20,28 @@ export const citiesApi = createApi({ }), getUpcomingCities: builder.query({ - query: (listType) => `/cities/list/all?listType=${listType}`, }), - getSelectedCityDetails:builder.query({ - query: (cityId) => `/website/${cityId}`, - }) + getSelectedCityDetails: builder.query({ + query: (cityId) => `/website/${cityId}`, + }), + + getSelectedCityOffers: builder.query({ + query: ({ cityId, categoryId, page, limit }) => { + const params = new URLSearchParams() + + params.append('cityXid', cityId); + + if (categoryId) params.append('categoryXid', categoryId); + if (page) params.append('page', page); + if (limit) params.append('limit', limit); + + return `/website/super-savings/list/offers?${params.toString()}`; + } + }), }), }); -export const { useGetCityListWithBannerQuery,useGetUpcomingCitiesQuery,useGetSelectedCityDetailsQuery } = citiesApi; \ No newline at end of file +export const { useGetCityListWithBannerQuery, useGetUpcomingCitiesQuery, useGetSelectedCityDetailsQuery, useGetSelectedCityOffersQuery } = citiesApi; \ No newline at end of file diff --git a/src/components/CitySelectionDialog.tsx b/src/components/CitySelectionDialog.tsx index d478f84..188d4a0 100644 --- a/src/components/CitySelectionDialog.tsx +++ b/src/components/CitySelectionDialog.tsx @@ -42,20 +42,9 @@ export function CitySelectionDialog({ const handleCityClick = (city: City) => { console.log('Selected city:', city.cityName); - - // ✅ Call the onCitySelect callback if provided (passing cityId) - if (onCitySelect) { - // onCitySelect(String(city.cityName)); - // navigate(`/${city.cityName}/${city.id}`) - - navigate(`/${slugify(city.cityName)}`); - localStorage.setItem("cityId", String(city.id)) - localStorage.setItem("cityName", String(city.cityName)) - } else { - // ✅ Default behavior: navigate to passes page - navigate(`/passes?city=${encodeURIComponent(city.cityName)}`); - } - + navigate(`/${slugify(city.cityName)}`); + localStorage.setItem("cityId", String(city.id)) + localStorage.setItem("cityName", String(city.cityName)) onClose(); }; diff --git a/src/pages/SuperSavingsPage.tsx b/src/pages/SuperSavingsPage.tsx index eb8263d..8b9e680 100644 --- a/src/pages/SuperSavingsPage.tsx +++ b/src/pages/SuperSavingsPage.tsx @@ -15,6 +15,8 @@ import { MobileAppSection } from '../components/MobileAppSection'; import { ReviewsSection } from '../components/ReviewsSection'; import { TrustedCompanies } from '../components/TrustedCompanies'; import { Layout } from '../Layout'; +import { useGetSelectedCityOffersQuery } from '../Redux/services/cities.service'; +import LoadingSpinner from '../components/LoadingSpinner'; interface SuperSavingsPageProps { onBackClick: () => void; @@ -44,138 +46,6 @@ interface SuperSavingsPageProps { user?: { email: string; name: string; } | null; } -// Mock super savings data -const savingsData = [ - { - id: '1', - business: 'Grand Hotels Melbourne', - title: 'Up to 50% Off on luxury hotel stays across Melbourne', - discount: '50% OFF', - savedAmount: 'Save up to $300', - image: 'https://images.unsplash.com/photo-1566073771259-6a8506099945?w=400', - category: 'hotels' - }, - { - id: '2', - business: 'Adventure Tours', - title: '40% Off on guided adventure tours and experiences', - discount: '40% OFF', - savedAmount: 'Save up to $150', - image: 'https://images.unsplash.com/photo-1571019613454-1cb2f99b2d8b?w=400', - category: 'tours' - }, - { - id: '3', - business: 'Premium Spa & Wellness', - title: '45% Off on spa packages and wellness treatments', - discount: '45% OFF', - savedAmount: 'Save up to $200', - image: 'https://images.unsplash.com/photo-1544161515-4ab6ce6db874?w=400', - category: 'wellness' - }, - { - id: '4', - business: 'Culinary Delights', - title: '35% Off on fine dining at Michelin-starred restaurants', - discount: '35% OFF', - savedAmount: 'Save up to $120', - image: 'https://images.unsplash.com/photo-1414235077428-338989a2e8c0?w=400', - category: 'dining' - }, - { - id: '5', - business: 'Entertainment Pass', - title: '60% Off on theater shows and concert tickets', - discount: '60% OFF', - savedAmount: 'Save up to $250', - image: 'https://images.unsplash.com/photo-1514306191717-452ec28c7814?w=400', - category: 'entertainment' - }, - { - id: '6', - business: 'Museum Pass', - title: '55% Off on museum entries and special exhibitions', - discount: '55% OFF', - savedAmount: 'Save up to $180', - image: 'https://images.unsplash.com/photo-1566127992631-137a642a90f4?w=400', - category: 'museums' - }, - { - id: '7', - business: 'Luxury Shopping', - title: '30% Off on designer boutiques and luxury shopping', - discount: '30% OFF', - savedAmount: 'Save up to $500', - image: 'https://images.unsplash.com/photo-1441986300917-64674bd600d8?w=400', - category: 'shopping' - }, - { - id: '8', - business: 'Water Sports', - title: '45% Off on water sports and beach activities', - discount: '45% OFF', - savedAmount: 'Save up to $175', - image: 'https://images.unsplash.com/photo-1476514525535-07fb3b4ae5f1?w=400', - category: 'sports' - }, - { - id: '9', - business: 'Wine Tasting Tours', - title: '40% Off on wine country tours and tastings', - discount: '40% OFF', - savedAmount: 'Save up to $160', - image: 'https://images.unsplash.com/photo-1506377247377-2a5b3b417ebb?w=400', - category: 'tours' - }, - { - id: '10', - business: 'Family Fun Parks', - title: '50% Off on family entertainment and theme parks', - discount: '50% OFF', - savedAmount: 'Save up to $220', - image: 'https://images.unsplash.com/photo-1524850011238-e3d235c7d4c9?w=400', - category: 'entertainment' - }, - { - id: '11', - business: 'Boutique Stays', - title: '55% Off on boutique hotels and bed & breakfasts', - discount: '55% OFF', - savedAmount: 'Save up to $280', - image: 'https://images.unsplash.com/photo-1551882547-ff40c63fe5fa?w=400', - category: 'hotels' - }, - { - id: '12', - business: 'Art Galleries', - title: '35% Off on contemporary art galleries and workshops', - discount: '35% OFF', - savedAmount: 'Save up to $140', - image: 'https://images.unsplash.com/photo-1561214115-f2f134cc4912?w=400', - category: 'museums' - }, - { - id: '13', - business: 'Luxury Cruises', - title: '65% Off on harbor cruises and yacht experiences', - discount: '65% OFF', - savedAmount: 'Save up to $400', - image: 'https://images.unsplash.com/photo-1544551763-46a013bb70d5?w=400', - category: 'tours' - } -]; - -const filterCategories = [ - { value: 'hotels', label: 'Hotels', count: 2 }, - { value: 'tours', label: 'Tours', count: 3 }, - { value: 'wellness', label: 'Wellness', count: 1 }, - { value: 'dining', label: 'Dining', count: 1 }, - { value: 'entertainment', label: 'Entertainment', count: 2 }, - { value: 'museums', label: 'Museums', count: 2 }, - { value: 'shopping', label: 'Shopping', count: 1 }, - { value: 'sports', label: 'Sports', count: 1 } -]; - // Categories data for the Super Savings Categories section const categoriesData = [ { @@ -242,504 +112,504 @@ export function SuperSavingsPage({ currentPage, user }: SuperSavingsPageProps) { - const [searchQuery, setSearchQuery] = useState(''); - const [selectedCategories, setSelectedCategories] = useState([]); - const [currentPage_, setCurrentPage_] = useState(1); - const [showLoadMore, setShowLoadMore] = useState(true); - const toggleCategory = (category: string) => { - setSelectedCategories(prev => - prev.includes(category) - ? prev.filter(c => c !== category) - : [...prev, category] - ); - }; + const [categoryId, setCategoryId] = useState(null) + const [page, setPage] = useState(1) + const [limit, setLimit] = useState(4) + const cityId = localStorage.getItem("cityId") + const { data, isLoading } = useGetSelectedCityOffersQuery({ cityId, categoryId, page, limit }) - const filteredSavings = savingsData.filter(saving => { - const matchesSearch = saving.title.toLowerCase().includes(searchQuery.toLowerCase()) || - saving.business.toLowerCase().includes(searchQuery.toLowerCase()); - const matchesCategory = selectedCategories.length === 0 || selectedCategories.includes(saving.category); + // optional chaining ensures no crash if data is undefined + const offers = data?.offers ?? []; + const categories = data?.categories ?? []; - return matchesSearch && matchesCategory; - }); + const totalOffers = data?.paginationData.total ?? 0; + const totalPages = Math.ceil(totalOffers / limit); - const itemsPerPage = 12; - const displayedSavings = filteredSavings.slice(0, currentPage_ * itemsPerPage); - const hasMoreItems = filteredSavings.length > displayedSavings.length; + const baseUrl = import.meta.env.VITE_BASE_URL; - const handleLoadMore = () => { - setCurrentPage_(prev => prev + 1); - if (!hasMoreItems) setShowLoadMore(false); - }; - - // Show different layouts based on login state - if (!user) { - // Not logged in - show marketing/landing page + if (isLoading) { return ( - -
+ + ); + } - {/* Hero Section */} -
- {/* Background gradient */} -
- -
-
+ return ( + +
-
- + {/* Background gradient */} +
+ +
+
+ +
+ +

+ Unlock{' '} + + Super Savings + +

+

+ Experience incredible discounts up to 65% off on premium experiences, luxury stays, and unforgettable attractions. +

+ -
-
+ Start Saving Now + +
+
- {/* Decorative elements */} -
-
-
+ {/* Decorative elements */} +
+
+ - {/* Trusted By Companies Section */} -
-
-
-
-

- Trusted by the - world's best -

-

- Join thousands of savvy travelers enjoying massive savings on premium experiences -

-
- -
-
-
- - {/* Featured Super Savings Section */} -
-
- -

- Featured{' '} - - Super Savings - + {/* Trusted By Companies Section */} +
+
+
+
+

+ Trusted by the + world's best

-

- Check out our biggest discounts and start saving on premium experiences +

+ Join thousands of savvy travelers enjoying massive savings on premium experiences

- +
+ +
+
+
-
-
- {/* Left Sidebar - Filters */} -
- -
- {/* Search by header */} -
-
-

Search by

-
+ {/* Featured Super Savings Section */} +
+
+ +

+ Featured{' '} + + Super Savings + +

+

+ Check out our biggest discounts and start saving on premium experiences +

+
- {/* Filter categories */} -
- {filterCategories.map(category => ( -
- toggleCategory(category.value)} - className="border-gray-400" - /> - -
- ))} -
+
+
+ {/* Left Sidebar - Filters */} +
+ +
+ {/* Search by header */} +
+
+

Search by

- -
- {/* Main Content */} -
- {/* Breadcrumb */} -
-

- {fromSource === 'passes' ? ( - <> - My Profile{'>'}My passes{'>'} - Super Savings - - ) : ( - <> - Our Products{'>'} - Super Savings - - )} -

-
- - {/* Header Section */} -
-

- Super Savings -

-

- Exclusive discounts up to 65% off on premium experiences -

-
- - {/* Savings Grid */} -
- {displayedSavings.map((saving, index) => ( - - - {/* Image */} -
- - - - {/* Discount Badge */} -
- {saving.discount} -
-
- - - {/* Business Name */} -
-
- {saving.business} -
- - {/* Title */} -

- {saving.title} -

- - {/* Saved Amount Display */} -
-
- - - {saving.savedAmount} - -
-
-
-
-
- ))} -
- - {/* Minimal Pagination */} -
-
- - -
- {[1, 2, 3].map((page) => ( - - ))} -
- - + {category.categoryName} ({category.offerCount}) + +
+ ))}
+
+
+ + {/* Main Content */} +
+ {/* Breadcrumb */} +
+

+ {fromSource === 'passes' ? ( + <> + My Profile{'>'}My passes{'>'} + Super Savings + + ) : ( + <> + Our Products{'>'} + Super Savings + + )} +

+
+ + {/* Header Section */} +
+

+ Super Savings +

+

+ Exclusive discounts up to 65% off on premium experiences +

+
+ + {/* Offers Grid */} +
+ {offers.map((offer: any, index: number) => ( + + + {/* Image */} +
+ + {/* */} + + {/* Discount Badge */} +
+ {offer.offerCode} +
+
+ + + {/* Business Name */} +
+
+ {offer.partnerName} +
+ + {/* Title */} +

+ {offer.description} +

+ + {/* Saved Amount Display */} +
+
+ {/* */} + + {offer.title} + +
+
+
+
+
+ ))} +
+ + {/* Minimal Pagination */} +
+
+ {/* Previous button */} + + + {/* Page numbers */} +
+ {Array.from({ length: totalPages }, (_, i) => i + 1).map(p => ( + + ))} +
+ + {/* Next button */} + +
- -
- -
-
- {/* How It Works Section */} -
- {/* Background decorative elements */} -
-
- -
- +
-
+
+

- {/* Categories Section */} -
- {/* Abstract Travel Patterns */} -
+ {/* How It Works Section */} +
+ {/* Background decorative elements */} +
+
-
- {/* Section Header */} -
- -
-
- Explore Collections -
-

- Curated for the Modern Traveler -

-

- Discover exclusive savings across our most sought-after travel categories. -

-
- - - - +
+ +
+
+ Simple Process +
+

+ Start Saving in Minutes +

+

+ Your journey to smarter travel and bigger savings begins with three simple steps. +

+
- {/* Bento Grid Layout */} -
- {categoriesData.map((category, index) => ( +
+ {/* Connecting line for desktop */} +
+ +
+ {[ + { + step: '01', + title: 'Unlock Access', + description: 'Get your CityCards pass to instantly activate membership perks.', + icon: MapPinned + }, + { + step: '02', + title: 'Discover Deals', + description: 'Browse exclusive offers on hotels, flights, and experiences.', + icon: Search + }, + { + step: '03', + title: 'Enjoy Savings', + description: 'Redeem discounts instantly and watch your travel budget grow.', + icon: Percent + } + ].map((item, index) => ( -
+ {/* Icon Container */} +
+
+
+ +
+
+ {index + 1} +
+
+ +

+ {item.title} +

+

+ {item.description} +

+
+
+ ))} +
+
+ + +
+
+ + {/* Categories Section */} +
+ {/* Abstract Travel Patterns */} +
+ +
+ {/* Section Header */} +
+ +
+
+ Explore Collections +
+

+ Curated for the Modern Traveler +

+

+ Discover exclusive savings across our most sought-after travel categories. +

+
+ + + + +
+ + {/* Bento Grid Layout */} +
+ {categoriesData.map((category, index) => ( + +
- {/* Background Gradient Hover */} -
+ > + {/* Background Gradient Hover */} +
- {/* Large Watermark Icon for visual depth */} - + {/* Large Watermark Icon for visual depth */} + -
-
-
+
+
- -
- - {category.savings} - +
- -

- {category.title} -

-

- {category.description} -

+ + {category.savings} +
-
- Explore Deals - -
+

+ {category.title} +

+

+ {category.description} +

- - ))} -
- {/* Mobile View All Button */} -
- -
+
+ Explore Deals + +
+
+
+ ))}
-
- {/* Access Your CityCards Section */} -
- -
+ {/* Mobile View All Button */} +
+ +
+
+ + + {/* Access Your CityCards Section */} +
+ +
+ + +
+ ); - - - ); - } }