Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Sample data for treks
- const trekData = [
- {
- id: 1,
- name: "Langtang",
- tours: "3 tours and activities",
- link: "langtang-treks",
- shortDes: "Explore the beautiful Langtang region with exciting treks.",
- treks: [
- {
- id: 101,
- name: "Langtang Trek",
- shortDes: "A scenic trek through the Langtang valley.",
- description: `Langtang Trek takes you through a beautiful valley with breathtaking mountain views, forests, and cultural villages.`,
- duration: "7 Days, 6 Nights",
- price: 350.00, // Price as a number
- rating: "4.7",
- reviews: "120 reviews",
- location: "Langtang",
- },
- {
- id: 102,
- name: "Langtang + Gosaikunda Trek",
- shortDes: "A combination trek through Langtang valley and Gosaikunda Lake.",
- description: `This trek combines the Langtang Valley with a visit to the sacred Gosaikunda Lake.`,
- duration: "10 Days, 9 Nights",
- price: 450.00,
- rating: "4.8",
- reviews: "80 reviews",
- location: "Langtang + Gosaikunda",
- },
- {
- id: 103,
- name: "Ama Yangri Trek",
- shortDes: "A shorter trek to Ama Yangri peak.",
- description: `This trek takes you to Ama Yangri peak, offering amazing views of the Himalayas.`,
- duration: "5 Days, 4 Nights",
- price: 300.00,
- rating: "4.5",
- reviews: "60 reviews",
- location: "Ama Yangri",
- },
- ],
- },
- // Add other region data here
- ];
- // Function to filter treks based on price range
- const filterByPrice = (minPrice, maxPrice) => {
- return trekData.map(region => {
- const filteredTreks = region.treks.filter(trek => trek.price >= minPrice && trek.price <= maxPrice);
- return {
- ...region,
- treks: filteredTreks,
- };
- }).filter(region => region.treks.length > 0); // Filter out regions with no matching treks
- };
- // Function to filter treks based on location
- const filterByLocation = (location) => {
- return trekData.map(region => {
- const filteredTreks = region.treks.filter(trek => trek.location.toLowerCase().includes(location.toLowerCase()));
- return {
- ...region,
- treks: filteredTreks,
- };
- }).filter(region => region.treks.length > 0); // Filter out regions with no matching treks
- };
- // You can also combine the filters for price and location together
- const filterByPriceAndLocation = (minPrice, maxPrice, location) => {
- return trekData.map(region => {
- const filteredTreks = region.treks.filter(trek =>
- trek.price >= minPrice &&
- trek.price <= maxPrice &&
- trek.location.toLowerCase().includes(location.toLowerCase())
- );
- return {
- ...region,
- treks: filteredTreks,
- };
- }).filter(region => region.treks.length > 0); // Filter out regions with no matching treks
- };
- export { trekData, filterByPrice, filterByLocation, filterByPriceAndLocation };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement