Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/slider #337

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 71 additions & 3 deletions frontend/package-lock.json

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

5 changes: 4 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@
"react-icons": "^5.3.0",
"react-responsive": "^10.0.0",
"react-router-dom": "^6.26.2",

"react-slick": "^0.30.2",
"react-toastify": "^9.1.3",
"tailwing": "^0.0.1"
"slick-carousel": "^1.8.1"

},
"devDependencies": {
"@types/react": "^18.2.43",
Expand Down
Binary file added frontend/public/image-login.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/public/registerimage.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
105 changes: 67 additions & 38 deletions frontend/src/Pages/Landing.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,59 @@ import massa from "../assets/Images/Massaman.png";
import { useNavigate } from "react-router-dom";
import axios from "axios";
import RecipeCardSkeleton from "./RecipeSkeleton.jsx";
import Testimonial from "../Components/Testimonial.jsx";

/*import React Slick */
import Slider from 'react-slick'
/* slick-carousel CSS */
import "slick-carousel/slick/slick.css";
import "slick-carousel/slick/slick-theme.css";

const Landing = () => {
const navigator = useNavigate();
const [best, setBest] = useState([])
const [loading, setLoading] = useState(true);
const backendURL = import.meta.env.VITE_BACKEND_URL;
const [reviews, setReviews] = useState(null);
const fetchFeedbacks = async () => {
setLoading(true);
try {
const response = await fetch(`${import.meta.env.VITE_BACKEND_URL}/api/getFeedback`);
if (!response.ok) throw new Error('Network response was not ok');

const feedbacks = await response.json();
const reviews = feedbacks.data;

// Set infiniteReviews only after ensuring the data is valid
if (reviews.length > 0) {
setReviews(reviews);

const backendURL = import.meta.env.VITE_BACKEND_URL;
{/*Slider Configuration */}
const sliderSettings = {
dots: true,
infinite: true,
speed: 500,
slidesToShow: 3,
autoplay: true,
autoplaySpeed: 2000,
cssEase: "linear",
slidesToScroll: 1,

responsive: [
{
breakpoint: 1024,
settings: {
slidesToShow: 3,
slidesToScroll: 1,
infinite: true,
dots: true
}
},
{
breakpoint: 600,
settings: {
slidesToShow: 1,
slidesToScroll: 1,
initialSlide: 1
}
},
{
breakpoint: 480,
settings: {
slidesToShow: 1,
slidesToScroll: 1
}
}
} catch (error) {
console.error('Error fetching feedbacks:', error);
} finally {
setLoading(false);
}
]
};


useEffect(()=>{
let token = localStorage.getItem("tastytoken");
if(token){
Expand Down Expand Up @@ -168,24 +194,27 @@ const Landing = () => {

{/* -------------------------- Best Dishes Section ---------------------- */}
<section id="Trending" className="py-4 my-20 mx-8">
<h1 className="text-center font-semibold text-4xl text-red-700 my-4 font-[Merriweather]">
World's Best Dishes
</h1>
{/* integrated a loading skeleton for landing page */}
{loading ? (
<div className="grid grid-cols-1 gap-3 sm:grid-cols-2 md:grid-cols-3 py-4">
{Array.from({ length: 6 }).map((_, i) => (
<RecipeCardSkeleton key={i} />
))}
</div>
) : (
<div className="grid grid-cols-1 md:grid-cols-3 gap-6">
{best.map((food) => (
<Cards dish={food} key={food._id} />
))}
</div>
)}
</section>
<h1 className="text-center font-semibold text-4xl text-red-700 my-4 font-[Merriweather]">
World's Best Dishes
</h1>
{/* integrated a loading skeleton for landing page */}
{loading ? (
<div className="grid grid-cols-1 gap-3 sm:grid-cols-2 md:grid-cols-3 py-4">
{Array.from({ length: 3 }).map((_, i) => (
<RecipeCardSkeleton key={i} />
))}
</div>
) :

(

<Slider {...sliderSettings}>
{best.map((food) => (
<Cards dish={food} key={food._id} />
))}
</Slider>
)}
</section>

{/* -------------------------- About Section ---------------------- */}
<section
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/Pages/Login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import { useNavigate } from "react-router-dom";


import useGoogleAuth from "../../common/useGoogleAuth"

import image from "../../public/newFoodSignup.jpeg"


const Login = () => {
const navigate = useNavigate();
const backendURL = import.meta.env.VITE_BACKEND_URL;
Expand Down Expand Up @@ -183,4 +185,4 @@ const Login = () => {
);
};

export default Login;
export default Login;
Loading