Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Chanuka-ChandraYapa committed Sep 12, 2023
2 parents f426bd4 + 6d539ff commit 43c650b
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/api/advertisementMap/advertisementLocation.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions src/layouts/advertisement_map/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -79,7 +79,7 @@ const MapComponent = () => {
}
};
fetchData();
}, [selectedData, test]);
}, [selectedData, test, selectedTime]);

// const fetchData = async () => {
// try {
Expand Down Expand Up @@ -224,8 +224,8 @@ const MapComponent = () => {
<MenuItem value="Overall">Overall</MenuItem>
<MenuItem value="Today">Today</MenuItem>
<MenuItem value="Yesterday">Yesterday</MenuItem>
<MenuItem value="Last Week">Last Week</MenuItem>
<MenuItem value="Last Month">Last Month</MenuItem>
<MenuItem value="LastWeek">Last Week</MenuItem>
<MenuItem value="LastMonth">Last Month</MenuItem>
</MDInput>
</MDBox>
{/* <MDBox color="text" px={2}>
Expand Down
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 43c650b

Please sign in to comment.