Skip to content

Commit

Permalink
Merge pull request #96 from SrishtiChamoli/ReviewFeature
Browse files Browse the repository at this point in the history
Added review feature in home page solving issue #91
  • Loading branch information
yazdanhaider authored Oct 24, 2024
2 parents c708d86 + 721bf5b commit bf3ac26
Show file tree
Hide file tree
Showing 5 changed files with 141 additions and 5 deletions.
1 change: 1 addition & 0 deletions Frontend/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import TermsOfService from './pages/TermsOfService';
import ContactUs from './pages/ContactUs';
import SignUp from './components/SignUp';
import Login from './components/Login';
import Review from './components/Review';
import { useState } from 'react';

function App() {
Expand Down
2 changes: 2 additions & 0 deletions Frontend/src/components/Home.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import { motion } from 'framer-motion';
import { Link } from 'react-router-dom';
import Review from './Review';
import { FaHospital, FaUserMd, FaCalendarCheck, FaHeartbeat, FaAmbulance, FaLaptopMedical } from 'react-icons/fa';

const Home = () => {
Expand Down Expand Up @@ -180,6 +181,7 @@ const Home = () => {
</Link>
</div>
</section>
<Review />
</div>
);
};
Expand Down
84 changes: 84 additions & 0 deletions Frontend/src/components/Review.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import React, { useState, useEffect } from 'react';

const Review = () => {
const [rating, setRating] = useState(0);
const [hover, setHover] = useState(0);
const [comment, setComment] = useState('');
const [visible, setVisible] = useState(false);

// Show the component after 15 seconds
useEffect(() => {
const timer = setTimeout(() => {
setVisible(true);
}, 15000);
return () => clearTimeout(timer);
}, []);

// Function to handle comment change
const handleCommentChange = (e) => {
setComment(e.target.value);
};

// Function to handle form submit
const handleSubmit = (e) => {
e.preventDefault();
alert(`Thank you for your review!!`);
setComment('');
setRating(0);
setVisible(false);
};

return (
<>
{visible && (
<div className="fixed inset-0 flex justify-center items-center bg-black bg-opacity-50 backdrop-blur-sm z-50">
<div className="bg-navy-800 p-6 rounded-lg shadow-lg w-full max-w-md text-white">
<h2 className="text-2xl font-bold mb-2 text-center">Rate Us</h2> {/* Centered Heading */}
<p className="text-center mb-2">Please take a second to review our services!</p>
{/* Star Rating */}
<div className="flex justify-center mb-4">
{[...Array(5)].map((_, index) => {
const starValue = index + 1;
return (
<button
key={index}
type="button"
className={`text-5xl transition duration-300 ${
starValue <= (hover || rating) ? 'text-yellow-500' : 'text-gray-400'
}`}
onClick={() => setRating(starValue)}
onMouseEnter={() => setHover(starValue)}
onMouseLeave={() => setHover(0)}
>
</button>
);
})}
</div>

{/* Comment Box */}
<form onSubmit={handleSubmit}>
<textarea
className="w-full p-2 rounded-lg bg-navy-700 text-black focus:outline-none mb-4" // changed text-white to text-black
placeholder="Leave a comment..."
rows="4"
value={comment}
onChange={handleCommentChange}
></textarea>

{/* Submit Button */}
<button
type="submit"
className="bg-yellow-500 text-navy-900 font-bold py-2 px-4 rounded-lg w-full hover:bg-yellow-600 transition duration-300"
>
Submit
</button>
</form>
</div>
</div>
)}
</>
);
};

export default Review;
2 changes: 2 additions & 0 deletions Frontend/tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export default {
'secondary': '#19252BFF',
'light': '#F6F6F6',
'accent': '#FFCB74',
'navy-800': '#0a1128',
'navy-900': '#001f3f'
},
fontFamily: {
montserrat: ['Montserrat', 'sans-serif'],
Expand Down
57 changes: 52 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bf3ac26

Please sign in to comment.