source: CookCraft-FrontEnd/CookCraft-FrontEnd-master/cookcraft-app/src/components/ProfileView.jsx

Last change on this file was d7b7f00, checked in by Gorazd Biskoski <gorazdbiskoskii@…>, 4 weeks ago

Add project

  • Property mode set to 100644
File size: 2.3 KB
RevLine 
[d7b7f00]1import styles from '../css/ProfileCss/profile-view-style.module.css';
2import { useState, useEffect } from "react";
3import Sidebar from './ProfileComponents/Sidebar';
4import ProfileSection from './ProfileComponents/ProfileSection';
5import FavoriteRecipesSection from "./ProfileComponents/FavoriteRecipesSection";
6import MyReviewsSection from "./ProfileComponents/MyReviewsSection";
7import OrderHistorySection from "./ProfileComponents/OrderHistorySection";
8import { useLocation, useNavigate } from 'react-router-dom';
9import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
10import { faArrowLeft } from '@fortawesome/free-solid-svg-icons';
11
12const ProfileView = () => {
13 const location = useLocation();
14 const navigate = useNavigate();
15 const selectedFromState = location.state?.selected || 0;
16 const sidebarItems = ["Profile", "Favorite Recipes", "My Reviews", "Order History"];
17 const [selectedSideBar, setSelectedSideBar] = useState(selectedFromState);
18
19 useEffect(() => {
20 setSelectedSideBar(selectedFromState);
21 }, [selectedFromState]);
22
23 let heading = sidebarItems[selectedSideBar];
24
25 const handleBackToHome = () => {
26 navigate('/');
27 };
28
29 return (
30 <>
31 <div className={styles.parent}>
32 <div className={styles.settingsContainer}>
33 <div className={styles.header}>
34 <div className={styles.backArrow} onClick={handleBackToHome}>
35 <FontAwesomeIcon icon={faArrowLeft} />
36 </div>
37 <div className={styles.settingsWrapper}><h2>{heading}</h2></div>
38 </div>
39 <div className={styles.contentWrapper}>
40 <Sidebar
41 items={sidebarItems}
42 selected={selectedSideBar}
43 onSelect={setSelectedSideBar}
44 />
45 <div className={styles.mainContent}>
46 {selectedSideBar === 0 && <ProfileSection/>}
47 {selectedSideBar === 1 && <FavoriteRecipesSection/>}
48 {selectedSideBar === 2 && <MyReviewsSection/>}
49 {selectedSideBar === 3 && <OrderHistorySection/>}
50 </div>
51 </div>
52 </div>
53 </div>
54 </>
55 );
56};
57
58export default ProfileView;
Note: See TracBrowser for help on using the repository browser.