Skip to content

Commit

Permalink
Profile page Updated
Browse files Browse the repository at this point in the history
  • Loading branch information
NadunSanjeevana committed Sep 12, 2023
1 parent cd0a97e commit 6d539ff
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 13 deletions.
61 changes: 57 additions & 4 deletions src/layouts/authentication/sign-in/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,44 @@ function Basic() {
});
};

// const handleLogin = () => {
// if (!email || !password) {
// alert("Please enter both email and password");
// return;
// }
// fetch("/login", {
// method: "POST",
// headers: {
// "Content-Type": "application/json",
// },
// body: JSON.stringify({
// email: email,
// password: password,
// }),
// })
// .then((response) => {
// if (!response.ok) {
// throw response.status;
// }
// return response.json();
// })
// .then((data) => {
// console.log(data);
// // Display a success message if applicable
// login({ name: email, role: "user" });
// navigate("/dashboard");
// })
// .catch((status) => {
// console.log(status, "error");
// if (status === 400) {
// alert("Email and password are required.");
// } else if (status === 401) {
// alert("Invalid User Name or Incorrect Password.");
// } else {
// alert("An error occurred during login.");
// }
// });
// };
const handleLogin = () => {
if (!email || !password) {
alert("Please enter both email and password");
Expand All @@ -82,10 +120,25 @@ function Basic() {
return response.json();
})
.then((data) => {
console.log(data);
// Display a success message if applicable
login({ name: email, role: "user" });
navigate("/dashboard");
if (data && data.user) {
// Display a success message if applicable
const userData = data.user;
console.log(userData);
login({
name: userData.User_Name,
full_name: userData.Full_Name,
role: "user",
email: userData.email,
phone_Number: userData.Contact_Number,
profession: userData.Profession,
});
// Now you can use userData as needed in your frontend
// For example, you can store it in state or context for later use
// login({ name: userData.User_Name, role: "user" });
navigate("/dashboard");
} else {
alert("User data not found in the response.");
}
})
.catch((status) => {
console.log(status, "error");
Expand Down
6 changes: 4 additions & 2 deletions src/layouts/profile/components/Header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ import breakpoints from "assets/theme/base/breakpoints";
// Images
import burceMars from "assets/images/bruce-mars.jpg";
import backgroundImage from "assets/images/bg-profile.jpeg";
import { useUser } from "utils/userContext";

function Header({ children }) {
const [tabsOrientation, setTabsOrientation] = useState("horizontal");
const [tabValue, setTabValue] = useState(0);
const { user } = useUser();

useEffect(() => {
// A function that sets the orientation state of the tabs.
Expand Down Expand Up @@ -110,10 +112,10 @@ function Header({ children }) {
<Grid item>
<MDBox height="100%" mt={0.5} lineHeight={1}>
<MDTypography variant="h5" fontWeight="medium">
Richard Davis
{user.name}
</MDTypography>
<MDTypography variant="button" color="text" fontWeight="regular">
CEO / Co-Founder
{user.profession}
</MDTypography>
</MDBox>
</Grid>
Expand Down
19 changes: 12 additions & 7 deletions src/layouts/profile/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ import team1 from "assets/images/team-1.jpg";
import team2 from "assets/images/team-2.jpg";
import team3 from "assets/images/team-3.jpg";
import team4 from "assets/images/team-4.jpg";
import { useUser } from "utils/userContext";

function Overview() {
const { user } = useUser();
return (
<DashboardLayout>
<DashboardNavbar />
Expand All @@ -68,24 +70,27 @@ function Overview() {
title="profile information"
description="Hi, I’m Alec Thompson, Decisions: If you can’t decide, the answer is no. If two equally difficult paths, choose the one more painful in the short term (pain avoidance is creating an illusion of equality)."
info={{
fullName: "Alec M. Thompson",
mobile: "(44) 123 1234 123",
email: "[email protected]",
location: "USA",
// fullName: "Alec M. Thompson",
fullName: user.full_name,
// mobile: "(44) 123 1234 123",
mobile: user.phone_Number,
// email: "[email protected]",
email: user.email,
location: "Sri Lanka",
}}
social={[
{
link: "https://www.facebook.com/CreativeTim/",
link: "https://www.facebook.com",
icon: <FacebookIcon />,
color: "facebook",
},
{
link: "https://twitter.com/creativetim",
link: "https://twitter.com",
icon: <TwitterIcon />,
color: "twitter",
},
{
link: "https://www.instagram.com/creativetimofficial/",
link: "https://www.instagram.com",
icon: <InstagramIcon />,
color: "instagram",
},
Expand Down

0 comments on commit 6d539ff

Please sign in to comment.