@@ -18,7 +62,7 @@ const Blog = () => {
{blog.title}
-
{blog.date}
+
{formattedDate}
{blog.views} Views
@@ -31,7 +75,7 @@ const Blog = () => {
{/* {blog.hooks.map((hook, index) => (
{hook}
))} */}
- {blog.content.map((paragraph, index) => (
+ {blog.content.split('\n').map((paragraph, index) => (
{paragraph}
))}
diff --git a/Frontend/react/src/components/Blogs.js b/Frontend/react/src/components/Blogs.js
index 66146e1..aaf9461 100644
--- a/Frontend/react/src/components/Blogs.js
+++ b/Frontend/react/src/components/Blogs.js
@@ -1,6 +1,6 @@
import React, { useEffect, useState } from 'react';
import axios from 'axios';
-import blogs from '../data/blogs.json';
+// import blogs from '../data/blogs.json';
import BlogCard from "./BlogCard";
import { Pagination } from 'swiper/modules';
import { Swiper, SwiperSlide } from 'swiper/react';
diff --git a/Frontend/react/src/components/CityCard.js b/Frontend/react/src/components/CityCard.js
index 450365b..219f861 100644
--- a/Frontend/react/src/components/CityCard.js
+++ b/Frontend/react/src/components/CityCard.js
@@ -2,10 +2,10 @@ import React from 'react';
import axios from 'axios';
const CityCard = ({ name, image, description, onClick }) => {
- axios
- .get('http://localhost:8000/api/hostels/')
- .then((response) => console.log(response.data))
- .catch((error) => console.error('Error:', error));
+ // axios
+ // .get('http://localhost:8000/api/hostels/')
+ // .then((response) => console.log(response.data))
+ // .catch((error) => console.error('Error:', error));
return (
diff --git a/Frontend/react/src/components/FeaturedHostels.js b/Frontend/react/src/components/FeaturedHostels.js
index 06c264f..8eca576 100644
--- a/Frontend/react/src/components/FeaturedHostels.js
+++ b/Frontend/react/src/components/FeaturedHostels.js
@@ -1,7 +1,8 @@
import React from 'react';
import HostelCard from './HostelCard';
import '../style.css';
-import hostels from '../data/hostels.json';
+// import hostels from '../data/hostels.json';
+import {useState, useEffect} from 'react';
import { Pagination, Navigation } from 'swiper/modules';
import { Swiper, SwiperSlide } from 'swiper/react';
@@ -11,6 +12,42 @@ import 'swiper/css/navigation';
const FeaturedHostels = () => {
+ const [featured, setFeatured]=useState([]);
+ const [loading, setLoading] = useState(false);
+ const [error, setError] = useState(null);
+
+ const fetchFeaturedHostels = async () => {
+ setLoading(true);
+ setError(null);
+
+ // const payload = {};
+
+ try {
+ const response = await fetch('http://127.0.0.1:8000/api/hostels/', {
+ method: 'GET',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ // body: JSON.stringify(payload),
+ });
+ if (!response.ok) {
+ throw new Error('Failed to fetch hostels. Please try again.');
+ }
+
+ const data = await response.json();
+ setFeatured(data.hostels);
+ // console.log(featured);
+ } catch (err) {
+ setError(err.message);
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ useEffect(() => {
+ fetchFeaturedHostels();
+ }, []);
+
return (
Featured Hostels
@@ -36,7 +73,7 @@ const FeaturedHostels = () => {
}}
modules={[Pagination, Navigation]}
>
- {hostels.filter(hostel => hostel.isFeatured).map((hostel, index) => (
+ {featured.filter(hostel => !hostel.isFeatured).map((hostel, index) => (
- {isFeatured && Featured
}
+ {!isFeatured && Featured
}
{name}
@@ -18,8 +18,10 @@ const HostelCard = ({ id, image, name, isFeatured, rating, location, price, gend
{location}
-
Rs. {price}
-
{gender} Hostel
+ {/*
Rs. {price}
*/}
+
+ {gender === 0 ? 'Girls Hostel' : 'Boys Hostel'}
+
);
diff --git a/Frontend/react/src/components/TopCities.js b/Frontend/react/src/components/TopCities.js
index 3ff3ba9..e687ac7 100644
--- a/Frontend/react/src/components/TopCities.js
+++ b/Frontend/react/src/components/TopCities.js
@@ -1,17 +1,19 @@
import React, { useState } from 'react';
+import { useNavigate } from 'react-router-dom';
import CityCard from './CityCard';
import topCitiesData from '../data/topcities.json';
const TopCities = () => {
const [showAll, setShowAll] = useState(false);
+ const navigate = useNavigate();
const toggleCityRows = () => {
setShowAll(!showAll);
};
const goToDetails = (city) => {
- // Implement navigation logic here
console.log(`Navigating to details of ${city}`);
+ navigate(`/search-results?location=${city}&lat=${0}&lon=${0}`);
};
return (