diff --git a/src/api/advertisementMap/advertisementLocation.js b/src/api/advertisementMap/advertisementLocation.js
index d77f776..daf57f5 100644
--- a/src/api/advertisementMap/advertisementLocation.js
+++ b/src/api/advertisementMap/advertisementLocation.js
@@ -1,9 +1,9 @@
import axios from "axios";
// Function to fetch data from the backend
-export async function getRecentAdLocation(ad_type) {
+export async function getRecentAdLocation(ad_type, duration) {
try {
- const response = await axios.get(`/getRecentAdLocation${ad_type}`); // Adjust the endpoint URL
+ const response = await axios.get(`/getRecentAdLocation?adtype=${ad_type}&duration=${duration}`); // Adjust the endpoint URL
console.log(response.data);
return response.data;
} catch (error) {
diff --git a/src/layouts/advertisement_map/map.js b/src/layouts/advertisement_map/map.js
index 7d7d18f..8ad4976 100644
--- a/src/layouts/advertisement_map/map.js
+++ b/src/layouts/advertisement_map/map.js
@@ -70,7 +70,7 @@ const MapComponent = () => {
}
} else {
try {
- const data = await getRecentAdLocation(selectedData);
+ const data = await getRecentAdLocation(selectedData, selectedTime);
setMarkers(data);
console.log(markers);
} catch (error) {
@@ -79,7 +79,7 @@ const MapComponent = () => {
}
};
fetchData();
- }, [selectedData, test]);
+ }, [selectedData, test, selectedTime]);
// const fetchData = async () => {
// try {
@@ -224,8 +224,8 @@ const MapComponent = () => {
-
-
+
+
{/*
diff --git a/src/layouts/authentication/sign-in/index.js b/src/layouts/authentication/sign-in/index.js
index a04d1a2..bff917a 100644
--- a/src/layouts/authentication/sign-in/index.js
+++ b/src/layouts/authentication/sign-in/index.js
@@ -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");
@@ -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");
diff --git a/src/layouts/profile/components/Header/index.js b/src/layouts/profile/components/Header/index.js
index 59bd407..9a8fc4c 100644
--- a/src/layouts/profile/components/Header/index.js
+++ b/src/layouts/profile/components/Header/index.js
@@ -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.
@@ -110,10 +112,10 @@ function Header({ children }) {
- Richard Davis
+ {user.name}
- CEO / Co-Founder
+ {user.profession}
diff --git a/src/layouts/profile/index.js b/src/layouts/profile/index.js
index 982a1aa..9c82c2f 100644
--- a/src/layouts/profile/index.js
+++ b/src/layouts/profile/index.js
@@ -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 (
@@ -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: "alecthompson@mail.com",
- location: "USA",
+ // fullName: "Alec M. Thompson",
+ fullName: user.full_name,
+ // mobile: "(44) 123 1234 123",
+ mobile: user.phone_Number,
+ // email: "alecthompson@mail.com",
+ email: user.email,
+ location: "Sri Lanka",
}}
social={[
{
- link: "https://www.facebook.com/CreativeTim/",
+ link: "https://www.facebook.com",
icon: ,
color: "facebook",
},
{
- link: "https://twitter.com/creativetim",
+ link: "https://twitter.com",
icon: ,
color: "twitter",
},
{
- link: "https://www.instagram.com/creativetimofficial/",
+ link: "https://www.instagram.com",
icon: ,
color: "instagram",
},