Advertisement
chiplu

data

Oct 18th, 2024
15
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.95 KB | None | 0 0
  1. // Sample data for treks
  2. const trekData = [
  3. {
  4. id: 1,
  5. name: "Langtang",
  6. tours: "3 tours and activities",
  7. link: "langtang-treks",
  8. shortDes: "Explore the beautiful Langtang region with exciting treks.",
  9. treks: [
  10. {
  11. id: 101,
  12. name: "Langtang Trek",
  13. shortDes: "A scenic trek through the Langtang valley.",
  14. description: `Langtang Trek takes you through a beautiful valley with breathtaking mountain views, forests, and cultural villages.`,
  15. duration: "7 Days, 6 Nights",
  16. price: 350.00, // Price as a number
  17. rating: "4.7",
  18. reviews: "120 reviews",
  19. location: "Langtang",
  20. },
  21. {
  22. id: 102,
  23. name: "Langtang + Gosaikunda Trek",
  24. shortDes: "A combination trek through Langtang valley and Gosaikunda Lake.",
  25. description: `This trek combines the Langtang Valley with a visit to the sacred Gosaikunda Lake.`,
  26. duration: "10 Days, 9 Nights",
  27. price: 450.00,
  28. rating: "4.8",
  29. reviews: "80 reviews",
  30. location: "Langtang + Gosaikunda",
  31. },
  32. {
  33. id: 103,
  34. name: "Ama Yangri Trek",
  35. shortDes: "A shorter trek to Ama Yangri peak.",
  36. description: `This trek takes you to Ama Yangri peak, offering amazing views of the Himalayas.`,
  37. duration: "5 Days, 4 Nights",
  38. price: 300.00,
  39. rating: "4.5",
  40. reviews: "60 reviews",
  41. location: "Ama Yangri",
  42. },
  43. ],
  44. },
  45. // Add other region data here
  46. ];
  47.  
  48. // Function to filter treks based on price range
  49. const filterByPrice = (minPrice, maxPrice) => {
  50. return trekData.map(region => {
  51. const filteredTreks = region.treks.filter(trek => trek.price >= minPrice && trek.price <= maxPrice);
  52. return {
  53. ...region,
  54. treks: filteredTreks,
  55. };
  56. }).filter(region => region.treks.length > 0); // Filter out regions with no matching treks
  57. };
  58.  
  59. // Function to filter treks based on location
  60. const filterByLocation = (location) => {
  61. return trekData.map(region => {
  62. const filteredTreks = region.treks.filter(trek => trek.location.toLowerCase().includes(location.toLowerCase()));
  63. return {
  64. ...region,
  65. treks: filteredTreks,
  66. };
  67. }).filter(region => region.treks.length > 0); // Filter out regions with no matching treks
  68. };
  69.  
  70. // You can also combine the filters for price and location together
  71. const filterByPriceAndLocation = (minPrice, maxPrice, location) => {
  72. return trekData.map(region => {
  73. const filteredTreks = region.treks.filter(trek =>
  74. trek.price >= minPrice &&
  75. trek.price <= maxPrice &&
  76. trek.location.toLowerCase().includes(location.toLowerCase())
  77. );
  78. return {
  79. ...region,
  80. treks: filteredTreks,
  81. };
  82. }).filter(region => region.treks.length > 0); // Filter out regions with no matching treks
  83. };
  84.  
  85. export { trekData, filterByPrice, filterByLocation, filterByPriceAndLocation };
  86.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement