estatesfunding/ef-ui/src/components/Dashboard.jsx

184 lines
6.4 KiB
React
Raw Normal View History

2024-09-16 15:03:26 +00:00
import { useState } from "react";
2024-09-06 15:02:20 +00:00
import Footer from "./Footer";
import Navbar from "./Navbar";
2024-09-16 15:03:26 +00:00
import { useSelector } from "react-redux";
2024-09-11 17:14:28 +00:00
import profilepic from "../img/samplepic.jpg";
import Addproperty from "./Addproperty";
2024-09-16 15:03:26 +00:00
import UserProperties from "./UserProperties";
// import { fetchUserProperties } from "../redux/features/propertySlice";
2024-09-11 17:14:28 +00:00
import "../dashboard.css";
2024-09-11 17:18:52 +00:00
2024-09-06 15:02:20 +00:00
const Dashboard = () => {
2024-09-16 15:03:26 +00:00
// const dispatch = useDispatch();
2024-09-11 17:14:28 +00:00
const { user } = useSelector((state) => ({ ...state.auth }));
2024-09-16 15:03:26 +00:00
// const { userProperties} = useSelector((state) => state.property);
2024-09-11 17:14:28 +00:00
const [activeTab, setActiveTab] = useState("dashboard");
2024-09-16 10:55:17 +00:00
// Fetch user properties when "Active Properties" tab is selected
2024-09-16 15:03:26 +00:00
// useEffect(() => {
// if (activeTab === "activeProperties") {
// dispatch(fetchUserProperties(user?.result?.userId));
// }
// }, [activeTab, dispatch, user?.result?.userId]);
2024-09-16 10:55:17 +00:00
2024-09-11 17:14:28 +00:00
const renderTabContent = () => {
switch (activeTab) {
case "addProperty":
return <Addproperty />;
case "activeProperties":
2024-09-16 10:55:17 +00:00
return <div>
<h3>Active Properties</h3>
2024-09-16 15:03:26 +00:00
{/* {userProperties.length > 0 ? (
2024-09-16 10:55:17 +00:00
<ul>
{userProperties.map((property) => (
<li key={property._id}>{property.title}</li>
))}
</ul>
) : (
<p>No active properties found.</p>
2024-09-16 15:03:26 +00:00
)} */}
<UserProperties />
2024-09-16 10:55:17 +00:00
</div>;
2024-09-11 17:14:28 +00:00
case "closedProperties":
return <p>These are your closed properties.</p>;
default:
return (
<div className="d-flex justify-content-center mt-7 gap-2 p-3">
<div className="col-md-6">
<div className="card cardchildchild p-2">
<div className="profile1">
<img
src="https://i.imgur.com/NI5b1NX.jpg"
height={90}
width={90}
className="rounded-circle"
/>
</div>
<div className="d-flex flex-column justify-content-center align-items-center mt-5">
<span className="name">Bess Wills</span>
<span className="mt-1 braceletid">Bracelet ID: SFG 38393</span>
<span className="dummytext mt-3 p-3">
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Text elit more smtit. Kimto lee.
</span>
</div>
</div>
</div>
<div className="col-md-6">
<div className="card cardchildchild p-2">
<div className="profile1">
<img
src="https://i.imgur.com/YyoCGsa.jpg"
height={90}
width={90}
className="rounded-circle"
/>
</div>
<div className="d-flex flex-column justify-content-center align-items-center mt-5">
<span className="name">Bess Wills</span>
<span className="mt-1 braceletid">Bracelet ID: SFG 38393</span>
<span className="dummytext mt-3 p-3">
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Text elit more smtit. Kimto lee.
</span>
</div>
</div>
</div>
</div>
);
}
};
return (
<>
<Navbar />
<br />
<br />
<br />
<br />
<br />
<br />
<div className="d-flex flex-row">
{/* Left sidebar */}
<div className="col-md-3">
<div className="card card1 p-5">
<img
className="img-fluid"
src={profilepic}
alt="ProfileImage"
style={{
marginTop: "0px",
maxWidth: "200px",
maxHeight: "200px",
}}
/>
<hr className="hline" />
<div className="d-flex flex-column align-items-center">
<button
className={`btn ${activeTab === "dashboard" ? "active" : ""}`}
// style={{ backgroundColor: "#fda417", border: "#fda417" }}
onClick={() => setActiveTab("dashboard")}
>
<i className="fa fa-dashboard" style={{ color: "#F74B02" }} />
<span>Dashboard</span>
</button>
<button
className={`btn mt-3 ${activeTab === "addProperty" ? "active" : ""}`}
onClick={() => setActiveTab("addProperty")}
>
2024-09-11 17:22:23 +00:00
<span className="fa fa-home" style={{ color: "#F74B02" }} />
2024-09-11 17:14:28 +00:00
<span>Add Property</span>
</button>
<button
className={`btn mt-3 ${activeTab === "activeProperties" ? "active" : ""}`}
onClick={() => setActiveTab("activeProperties")}
>
2024-09-11 17:22:23 +00:00
<span className="fa fa-home" style={{ color: "#F74B02" }} />
2024-09-11 17:14:28 +00:00
<span>Active Properties</span>
</button>
<button
className={`btn mt-3 ${activeTab === "closedProperties" ? "active" : ""}`}
onClick={() => setActiveTab("closedProperties")}
>
2024-09-11 17:22:23 +00:00
<span className="fa fa-home" style={{ color: "#F74B02" }} />
2024-09-11 17:14:28 +00:00
<span>Closed Properties</span>
</button>
{/* <span className="other mt-4">Other Information</span>
<button className="btn mt-3">
<i className="fa fa-book" />
<span>Knowledge</span>
</button> */}
</div>
</div>
</div>
2024-09-06 15:02:20 +00:00
2024-09-11 17:14:28 +00:00
{/* Main content area */}
<div className="col-md-9">
2024-09-22 14:00:31 +00:00
<div className="card card2 p-1">
2024-09-11 17:14:28 +00:00
{/* Static Dashboard greeting */}
2024-09-22 14:00:31 +00:00
<br />
2024-09-11 17:14:28 +00:00
<span>
Welcome to{" "}
<span style={{ color: "#067ADC" }}>
{user.result.title}. {user.result.firstName} {user.result.middleName} {user.result.lastName}
</span>
</span>
2024-09-22 14:00:31 +00:00
<br />
2024-09-11 17:14:28 +00:00
{/* Dynamic content based on the selected tab */}
2024-09-22 14:00:31 +00:00
<div className="tab-content p-2">
2024-09-11 17:14:28 +00:00
{renderTabContent()}
</div>
</div>
2024-09-06 16:40:57 +00:00
</div>
2024-09-11 17:14:28 +00:00
</div>
<Footer />
</>
);
2024-09-06 15:02:20 +00:00
};
export default Dashboard;