diff --git a/Frontend/src/pages/UserPanel/Farm/FinanceSummary.jsx b/Frontend/src/pages/UserPanel/Farm/FinanceSummary.jsx
index 9949beb..f24245a 100644
--- a/Frontend/src/pages/UserPanel/Farm/FinanceSummary.jsx
+++ b/Frontend/src/pages/UserPanel/Farm/FinanceSummary.jsx
@@ -20,7 +20,7 @@ const FinanceSummary = ({ farmId, financeId }) => {
const [loading, setLoading] = useState(true);
const [error, setError] = useState("");
- console.log("Finance id /mljkfgj is : ", financeId);
+
const {
data: transaction,
@@ -28,7 +28,7 @@ const FinanceSummary = ({ farmId, financeId }) => {
isLoading,
} = useGetTransactionsQuery(financeId);
- console.log("Transaction data is : ", transaction);
+
useEffect(() => {
const fetchSummary = async () => {
@@ -39,7 +39,7 @@ const FinanceSummary = ({ farmId, financeId }) => {
`http://localhost:8000/api/v1/finance/summary/${financeId}`,
{ credentials: "include" }
);
- console.log("Summary response:", response);
+
if (!response.ok) {
throw new Error("Failed to fetch summary");
}
diff --git a/Frontend/src/pages/UserPanel/Farm/Transactions.jsx b/Frontend/src/pages/UserPanel/Farm/Transactions.jsx
index d261d65..b93b789 100644
--- a/Frontend/src/pages/UserPanel/Farm/Transactions.jsx
+++ b/Frontend/src/pages/UserPanel/Farm/Transactions.jsx
@@ -13,7 +13,7 @@ const Transactions = ({ farmId }) => {
.then((response) => response.json())
.then((data) => {
setData(data);
- console.log("Fetched data:", data);
+
setLoading(false);
})
.catch((error) => {
diff --git a/Frontend/src/pages/UserPanel/MainUserPanel.jsx b/Frontend/src/pages/UserPanel/MainUserPanel.jsx
index bda3460..c811694 100644
--- a/Frontend/src/pages/UserPanel/MainUserPanel.jsx
+++ b/Frontend/src/pages/UserPanel/MainUserPanel.jsx
@@ -25,7 +25,7 @@ const MainUserPanel = () => {
const data = await responce.json();
- //console.log("User Logged out data is : ", data);
+
if (data.success === true) {
navigate("/user/login");
diff --git a/Frontend/src/pages/UserPanel/MentorSessionCard.jsx b/Frontend/src/pages/UserPanel/MentorSessionCard.jsx
index fa28b0a..0f735c1 100644
--- a/Frontend/src/pages/UserPanel/MentorSessionCard.jsx
+++ b/Frontend/src/pages/UserPanel/MentorSessionCard.jsx
@@ -20,14 +20,14 @@ const MentorSessionCard = ({ session }) => {
const user = useSelector((store) => store.user);
- //console.log("User in the Dashborde : ");
+
let timeStringToDayName = (dateStr) => {
// for getting day name by time string
// const dateStr = "2024-09-26T04:31:50.646+00:00";
const date = new Date(dateStr);
const dayName = date.toLocaleDateString("en-US", { weekday: "long" });
- //console.log(dayName);
+
return dayName;
};
@@ -48,7 +48,7 @@ const MentorSessionCard = ({ session }) => {
};
const istDate = date.toLocaleString("en-US", options);
- console.log(istDate); // Output: "September 26, 2024, 10:01:50 AM"
+
return istDate;
};
diff --git a/Frontend/src/pages/UserPanel/Monitoring.jsx b/Frontend/src/pages/UserPanel/Monitoring.jsx
index 2be5c52..3ab8305 100644
--- a/Frontend/src/pages/UserPanel/Monitoring.jsx
+++ b/Frontend/src/pages/UserPanel/Monitoring.jsx
@@ -5,31 +5,67 @@ import PerformanceChart from "../../components/monitoring charts/PerformanceChar
import AlertsPanel from "../../components/monitoring charts/AlertsPanel";
import ActivityFeed from "../../components/monitoring charts/ActivityField";
import Piechart from "../../components/monitoring charts/Piechart";
+import { useGetFarmsQuery } from "../../store/api/farmApi";
+import PerformanceChart2 from "../../components/monitoring charts/PerformanceChart2";
+
+const calculateSpend = (farms) => {
+ let totalSpend = 0;
+ for (let i = 0; i < farms.length; i++) {
+ if (!farms[i]) continue;
+ if (!farms[i]?.finances) continue;
+ if (!farms[i]?.finances?.totalExpenses) continue;
+ totalSpend += farms[i]?.finances?.totalExpenses;
+ }
+ return totalSpend;
+};
+
+const calculateRevenue = (farms) => {
+ let totalSpend = 0;
+ for (let i = 0; i < farms.length; i++) {
+ if (!farms[i]) continue;
+ if (!farms[i]?.finances) continue;
+ if (!farms[i]?.finances?.totalRevenue) continue;
+ totalSpend += farms[i]?.finances?.totalRevenue;
+ }
+ return totalSpend;
+};
const MonitoringPage = () => {
+ const { data: farms, error, isLoading } = useGetFarmsQuery();
+
+
+
return (
{/* Summary Metrics */}
-
-
-
+
+
+
{/* Performance Trend Chart */}
-
Performance Trend
+
Expence Trend
+
Revenue Trend
+
-
*/}
{/* Alerts and Activity Feed */}
-
+ {/*
Alerts
@@ -38,7 +74,7 @@ const MonitoringPage = () => {
Recent Activity
-
+
*/}
);
diff --git a/Frontend/src/pages/UserPanel/Notifications.jsx b/Frontend/src/pages/UserPanel/Notifications.jsx
index d287b4d..66375d8 100644
--- a/Frontend/src/pages/UserPanel/Notifications.jsx
+++ b/Frontend/src/pages/UserPanel/Notifications.jsx
@@ -75,29 +75,7 @@ const Notifications = () => {
},
];
- // for getting day name by time string
- // const dateStr = '2024-09-26T04:31:50.646+00:00';
- // const date = new Date(dateStr);
- // const dayName = date.toLocaleDateString('en-US', { weekday: 'long' });
- // console.log(dayName); // Output: "Thursday"
-
- // for converting the to get time in am or pm
- // const utcDateStr = '2024-09-26T04:31:50.646+00:00';
- // const date = new Date(utcDateStr);
- // India TimeZone is Asia/Kolkata, which is UTC+5:30
- // const options = {
- // timeZone: 'Asia/Kolkata',
- // hour: 'numeric',
- // minute: 'numeric',
- // second: 'numeric',
- // hour12: true,
- // year: 'numeric',
- // month: 'long',
- // day: 'numeric'
- // };
-
- // const istDate = date.toLocaleString('en-US', options);
- // console.log(istDate); // Output: "September 26, 2024, 10:01:50 AM"
+
return (
<>
diff --git a/Frontend/src/pages/UserPanel/Settings.jsx b/Frontend/src/pages/UserPanel/Settings.jsx
index 4688118..93a8596 100644
--- a/Frontend/src/pages/UserPanel/Settings.jsx
+++ b/Frontend/src/pages/UserPanel/Settings.jsx
@@ -18,8 +18,6 @@ const Settings = () => {
const loader = useSelector((store) => store.loader);
- //console.log("Before the user is : ", user);
-
const dispatch = useDispatch();
// Optimise the call for the database here you are refreshing the page again and again which makes read and write operation
@@ -27,11 +25,9 @@ const Settings = () => {
event.preventDefault();
formData.append("avatar", avatar);
- //console.log("forma daata is : ", formData);
-
if (avatar) {
dispatch(loaderSliceActions.showLoader());
- //console.log("The loader values is : ", loader);
+
const responce = await fetch(`${BACKEND_URL}/api/v1/user/avatar`, {
method: "PUT",
credentials: "include",
@@ -40,13 +36,11 @@ const Settings = () => {
const finalResponce = await responce.json();
- //console.log("Our final responce is : ", finalResponce);
-
if (finalResponce.success) {
dispatch(loaderSliceActions.hideLoader());
- //console.log("The loader values is : ", loader);
+
dispatch(userSliceActions.addUser(finalResponce.data));
- // console.log("Updated User is : ", user);
+
window.location.reload();
}
}
@@ -68,8 +62,6 @@ const Settings = () => {
const user = await responce.json();
- //console.log("User Login Data is here : ", user);
-
dispatch(userSliceActions.addUser(user.data));
emailElement.current.value = "";
@@ -90,7 +82,7 @@ const Settings = () => {
-

+
@@ -144,7 +136,6 @@ const Settings = () => {
className="hidden"
onChange={(e) => {
setAvatar(e.target.files[0]);
- //console.log(e.target.files[0]);
}}
/>