diff --git a/code/Software/Frontend/src/AdminDashboard/AdminDashboard.jsx b/code/Software/Frontend/src/AdminDashboard/AdminDashboard.jsx index fe35a4a..7982383 100644 --- a/code/Software/Frontend/src/AdminDashboard/AdminDashboard.jsx +++ b/code/Software/Frontend/src/AdminDashboard/AdminDashboard.jsx @@ -15,7 +15,7 @@ function AdminDashboard(){
-
+
diff --git a/code/Software/Frontend/src/AdminDashboard/Dashboard.css b/code/Software/Frontend/src/AdminDashboard/Dashboard/Dashboard.css similarity index 51% rename from code/Software/Frontend/src/AdminDashboard/Dashboard.css rename to code/Software/Frontend/src/AdminDashboard/Dashboard/Dashboard.css index fe77942..5a26bfe 100644 --- a/code/Software/Frontend/src/AdminDashboard/Dashboard.css +++ b/code/Software/Frontend/src/AdminDashboard/Dashboard/Dashboard.css @@ -24,24 +24,3 @@ padding: 40px; } - - .container_for_topselling { - display: flex; - justify-content: center; - align-items: center; - max-width: 900px; - border-radius: 25px; - - } - .square-card_topselling { - height: 90%; - border-radius: 1px; - aspect-ratio: 1/1; - border-color: rgb(45, 49, 49); - margin: 0; - margin-top: 15px; - height: 20vh; - } - .card-body_topselling{ - padding: 2px; - } \ No newline at end of file diff --git a/code/Software/Frontend/src/AdminDashboard/Dashboard.jsx b/code/Software/Frontend/src/AdminDashboard/Dashboard/Dashboard.jsx similarity index 75% rename from code/Software/Frontend/src/AdminDashboard/Dashboard.jsx rename to code/Software/Frontend/src/AdminDashboard/Dashboard/Dashboard.jsx index 6686f8f..1c06407 100644 --- a/code/Software/Frontend/src/AdminDashboard/Dashboard.jsx +++ b/code/Software/Frontend/src/AdminDashboard/Dashboard/Dashboard.jsx @@ -3,6 +3,8 @@ import React, { useState, useEffect } from 'react'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faShoppingCart, faDollarSign, faChartBar } from '@fortawesome/free-solid-svg-icons'; import './Dashboard.css'; +import TopProducts from './TopProducts'; +import TopSellingProducts from './TopSellingProducts'; const Dashboard = () => { @@ -11,7 +13,7 @@ const Dashboard = () => { const [totalSaleYesterday, setTotalSaleYesterday] = useState(0); const [percentageChange, setPercentageChange] = useState(0); - const [totalBillToday, setTotalBillToday] = useState(0); + const [billCountToday, setTotalBillToday] = useState(0); const [totalBillYesterday, setTotalBillYesterday] = useState(0); const [percentageChangeBills, setPercentageChangeBills] = useState(0); @@ -43,10 +45,11 @@ const Dashboard = () => { console.log(data); // Destructure data and set state for bills - const { totalBillToday, totalBillYesterday, percentageChange } = data; - setTotalBillToday(totalBillToday); + const { billCountToday, totalBillYesterday, percentageChange } = data; + setTotalBillToday(billCountToday); setTotalBillYesterday(totalBillYesterday); setPercentageChangeBills(percentageChange); + } catch (error) { console.error('Error fetching bill data:', error); } @@ -102,7 +105,7 @@ const Dashboard = () => {


-

{totalBillToday}

+

{billCountToday}

Total Bills

{percentageChangeBills}% from yesterday

@@ -125,43 +128,9 @@ const Dashboard = () => {


- -
-

Top Selling Products

-

View and Manage your top selling products

-
-
-
-
-
-
- image will be here -

product name

-

sold count

-
-
-
-
-
-
- image will be here -

product name

-

sold count

-
-
-
-
-
-
- image will be here -

product name

-

sold count

-
-
-
-
-
-
+ +

+
); }; diff --git a/code/Software/Frontend/src/AdminDashboard/Dashboard/TopProducts.jsx b/code/Software/Frontend/src/AdminDashboard/Dashboard/TopProducts.jsx new file mode 100644 index 0000000..01bdce3 --- /dev/null +++ b/code/Software/Frontend/src/AdminDashboard/Dashboard/TopProducts.jsx @@ -0,0 +1,58 @@ +import React, { useEffect, useState } from 'react'; +//import './TopProducts.css'; + +const TopProducts = () => { + const [products, setProducts] = useState([]); + + useEffect(() => { + // Fetch top products data and set it to the state + // can make an API call or use any other method to get the data + const fetchData = async () => { + // Example data + const topProductsData = [ + { id: 1, name: 'Apple', image: 'https://healthjade.com/wp-content/uploads/2017/10/apple-fruit.jpg', popularity: '88%', sales: 345 }, + { id: 2, name: 'Chocolate Biscuit', image: 'https://objectstorage.ap-mumbai-1.oraclecloud.com/n/softlogicbicloud/b/cdn/o/products/600-600/114800--01--1623926473.jpeg', popularity: '61%', sales: 280 }, + { id: 3, name: 'Organic Milk Box', image: 'https://horizon.com/wp-content/uploads/horizon-organic-whole-dha-omega-3-milk.png', popularity: '52%', sales: 220 }, + { id: 4, name: 'Chocolate Bar', image: 'https://upload.wikimedia.org/wikipedia/commons/thumb/c/cd/Green_and_Black%27s_dark_chocolate_bar_2.jpg/640px-Green_and_Black%27s_dark_chocolate_bar_2.jpg', popularity: '34%', sales: 180 }, + ]; + + setProducts(topProductsData); + }; + + fetchData(); + }, []); + + return ( +
+

Top Products

+
+
+ + + + + + + + + + + + {products.map((product, index) => ( + + + + + + + + ))} + +
RankProduct NameImagePopularitySales
{index + 1}{product.name}{product.name}{product.popularity}{product.sales}
+ +
+
+ ); +}; + +export default TopProducts; diff --git a/code/Software/Frontend/src/AdminDashboard/Dashboard/TopSellingProduct.css b/code/Software/Frontend/src/AdminDashboard/Dashboard/TopSellingProduct.css new file mode 100644 index 0000000..4daca3c --- /dev/null +++ b/code/Software/Frontend/src/AdminDashboard/Dashboard/TopSellingProduct.css @@ -0,0 +1,30 @@ + +.container_for_topselling { + display: flex; + justify-content: center; + align-items: center; + max-width: 900px; + border-radius: 25px; + margin-bottom: 30px; + padding: 40px; + +} +.square-card_topselling { + height: 37vh; /* Adjust as needed */ + border-radius: 5px; + aspect-ratio: 1/1; + border-color: rgb(45, 49, 49); + justify-content: center; + align-items: center; + padding: 40px; +} + +.card-img-top { + width: 70%; + height: 200px; /* Adjust the height according to your preference */ + object-fit: cover; + align-content: center; +} +.col{ + gap: 10000px; +} diff --git a/code/Software/Frontend/src/AdminDashboard/Dashboard/TopSellingProducts.jsx b/code/Software/Frontend/src/AdminDashboard/Dashboard/TopSellingProducts.jsx new file mode 100644 index 0000000..ad82f5d --- /dev/null +++ b/code/Software/Frontend/src/AdminDashboard/Dashboard/TopSellingProducts.jsx @@ -0,0 +1,49 @@ +import React from 'react' +import { useState, useEffect } from 'react'; +//import './Dashboard.css' +import './TopSellingProduct.css' + + +function TopSellingProducts() { + const [topSellingProducts, settopSellingProducts] = useState([]); + + useEffect(() => { + // Fetch top products data and set it to the state + // You can make an API call or use any other method to get the data + const fetchData = async () => { + // Example data + const topProductsData = [ + { id: 1, name: 'Apple', image: 'https://healthjade.com/wp-content/uploads/2017/10/apple-fruit.jpg', popularity: '88%', sales: 345 }, + { id: 2, name: 'Chocolate Biscuit', image: 'https://objectstorage.ap-mumbai-1.oraclecloud.com/n/softlogicbicloud/b/cdn/o/products/600-600/114800--01--1623926473.jpeg', popularity: '61%', sales: 280 }, + { id: 3, name: 'Organic Milk Box', image: 'https://horizon.com/wp-content/uploads/horizon-organic-whole-dha-omega-3-milk.png', popularity: '52%', sales: 220 }, + ]; + + settopSellingProducts(topProductsData); + }; + + fetchData(); + }, []); + return ( +
+

Top Selling Products

+

View and Manage your top selling products

+
+
+
+ {topSellingProducts.map((product) => ( +
+
+ {product.name} +
+

{product.name}

+

Sold count: {product.sales}

+
+
+
+ ))} +
+
+
+ ) +} +export default TopSellingProducts \ No newline at end of file diff --git a/code/Software/Frontend/src/AdminDashboard/Invoices.jsx b/code/Software/Frontend/src/AdminDashboard/Invoices.jsx index ad4470b..2ce52fe 100644 --- a/code/Software/Frontend/src/AdminDashboard/Invoices.jsx +++ b/code/Software/Frontend/src/AdminDashboard/Invoices.jsx @@ -4,8 +4,13 @@ import "./Invoices.css"; function Invoices() { const [invoices, setInvoices] = useState([]); const [newInvoice, setNewInvoice] = useState({}); + const formattedNewInvoice = { + data: [newInvoice] + }; + const handleCreate = async () => { + console.log("Creating invoice:", newInvoice); try { const response = await fetch("http://localhost:5555/bill/", { method: "POST", @@ -13,6 +18,7 @@ function Invoices() { "Content-Type": "application/json", }, body: JSON.stringify(newInvoice), + }); if (!response.ok) { @@ -38,7 +44,7 @@ function Invoices() { const handleUpdate = async (id, updatedData) => { const { updatedInvoiceId, updatedDate, updatedAmount } = updatedData; - // Display the update space + //Display the update space document.getElementById("update-space").style.display = "block"; // Populate the updated data in the space @@ -60,7 +66,7 @@ function Invoices() { } catch (error) { console.error("Error updating invoice:", error); } - }; + };*/ const handleDelete = async (id) => { try { @@ -69,11 +75,11 @@ function Invoices() { }); // Remove the deleted invoice from the state - setInvoices(invoices.filter((invoice) => invoice.id !== id)); + setInvoices(invoices.filter((invoice) => invoice._id !== id)); } catch (error) { console.error("Error deleting invoice:", error); } - };*/ + }; useEffect(() => { const fetchData = async () => { @@ -125,7 +131,7 @@ function Invoices() { - + ))} @@ -141,8 +147,8 @@ function Invoices() { setNewInvoice({ ...newInvoice, amount: e.target.value })} + value={newInvoice.totalAmount || ""} + onChange={(e) => setNewInvoice({ ...newInvoice, totalAmount: e.target.value })} /> diff --git a/code/Software/Frontend/src/App.jsx b/code/Software/Frontend/src/App.jsx index 1c360ba..6b1aa68 100644 --- a/code/Software/Frontend/src/App.jsx +++ b/code/Software/Frontend/src/App.jsx @@ -4,7 +4,7 @@ import Signup from './signin_Page/Signup'; import Login from './Login_Page/Login'; import { BrowserRouter, Routes, Route } from 'react-router-dom'; import AdminDashboard from './AdminDashboard/AdminDashboard'; -import Dashboard from './AdminDashboard/Dashboard'; +import Dashboard from './AdminDashboard/Dashboard/Dashboard'; import Invoices from './AdminDashboard/Invoices'; import Sales from './AdminDashboard/Sales'; import Security_Footage from './AdminDashboard/Security_Footage'; diff --git a/code/Software/Frontend/src/Login_Page/Login.css b/code/Software/Frontend/src/Login_Page/Login.css index 729ca2a..ee02bcb 100644 --- a/code/Software/Frontend/src/Login_Page/Login.css +++ b/code/Software/Frontend/src/Login_Page/Login.css @@ -115,6 +115,8 @@ color: #ccc; } - +.login_button{ + width: 400px; +} \ No newline at end of file diff --git a/code/Software/Frontend/src/Login_Page/Login.jsx b/code/Software/Frontend/src/Login_Page/Login.jsx index 941d87b..04c3926 100644 --- a/code/Software/Frontend/src/Login_Page/Login.jsx +++ b/code/Software/Frontend/src/Login_Page/Login.jsx @@ -52,23 +52,24 @@ const Login = () => { id="password" value={password} onChange={(e) => setPassword(e.target.value)} - placeholder="strong password" + placeholder="Password" required />
- +
-
- setRememberMe(e.target.checked)} - /> -
+ +

Don't have an account? Sign Up diff --git a/code/Software/Frontend/src/signin_Page/Signup.jsx b/code/Software/Frontend/src/signin_Page/Signup.jsx index 05edf51..ec34e00 100644 --- a/code/Software/Frontend/src/signin_Page/Signup.jsx +++ b/code/Software/Frontend/src/signin_Page/Signup.jsx @@ -119,7 +119,7 @@ const Signup = () => { {!isPasswordMatch &&

Passwords do not match

}
- +
diff --git a/code/Software/Server/controllers/itemPurchasedController.js b/code/Software/Server/controllers/itemPurchasedController.js index 2831ffa..6df84ed 100644 --- a/code/Software/Server/controllers/itemPurchasedController.js +++ b/code/Software/Server/controllers/itemPurchasedController.js @@ -239,4 +239,4 @@ export const getTotalProductQuantities = async () => { throw error; } }; - \ No newline at end of file + \ No newline at end of file diff --git a/code/Software/Server/routes/itemPurchasedRoute.js b/code/Software/Server/routes/itemPurchasedRoute.js index 574125d..4155eeb 100644 --- a/code/Software/Server/routes/itemPurchasedRoute.js +++ b/code/Software/Server/routes/itemPurchasedRoute.js @@ -14,6 +14,9 @@ import { const router = express.Router(); router.use(cors()); +// Route for get top selling products +//router.get("/topselling", getTopSellingProducts); + // Route for get total sale today router.get("/saletoday", getProductsSoldToday); @@ -35,4 +38,5 @@ router.put("/:id", updateItemsPurchased); router.delete("/:id", deleteItemsPurchasedById); + export default router; \ No newline at end of file