1 | import React from "react";
|
---|
2 | import Breakfast from "../../images/Breakfast.jpg";
|
---|
3 | import Lunch from "../../images/Lunch.jpg";
|
---|
4 | import Dinner from "../../images/Dinner.jpg";
|
---|
5 | import Dessert from "../../images/Dessert.jpg";
|
---|
6 | import styles from "../../css/HomeCss/categories.module.css";
|
---|
7 | import { useNavigate } from "react-router-dom";
|
---|
8 |
|
---|
9 |
|
---|
10 | function Categories() {
|
---|
11 | const navigate = useNavigate();
|
---|
12 |
|
---|
13 | const handleCategoriesClick = (category) => {
|
---|
14 | console.log("Selected category:", category);
|
---|
15 | navigate(`/recipes?category=${category}`);
|
---|
16 | };
|
---|
17 |
|
---|
18 |
|
---|
19 | return (
|
---|
20 | <section className={styles.categories}>
|
---|
21 | <div className={styles.container}>
|
---|
22 | <h2 className={styles.sectionTitle}>Explore by Category</h2>
|
---|
23 | <div className={styles.categoriesList}>
|
---|
24 | <div className={styles.category} onClick={() => handleCategoriesClick('Breakfast')}>
|
---|
25 | <img src={Breakfast} alt="Breakfast" />
|
---|
26 | <p>Breakfast</p>
|
---|
27 | </div>
|
---|
28 | <div className={styles.category} onClick={() => handleCategoriesClick('Lunch')}>
|
---|
29 | <img src={Dinner} alt="Lunch" />
|
---|
30 | <p>Lunch</p>
|
---|
31 | </div>
|
---|
32 | <div className={styles.category} onClick={() => handleCategoriesClick('Vegetarian')}>
|
---|
33 | <img src={Lunch} alt="Vegetarian" />
|
---|
34 | <p>Vegetarian</p>
|
---|
35 | </div>
|
---|
36 | <div className={styles.category} onClick={() => handleCategoriesClick('Dessert')}>
|
---|
37 | <img src={Dessert} alt="Desserts" />
|
---|
38 | <p>Desserts</p>
|
---|
39 | </div>
|
---|
40 | </div>
|
---|
41 | </div>
|
---|
42 | </section>
|
---|
43 | );
|
---|
44 | }
|
---|
45 |
|
---|
46 | export default Categories;
|
---|