diff --git a/src/layouts/graph/components/barCharts/categoryDist.js b/src/layouts/graph/components/barCharts/categoryDist.js index 8daf046..ecedb51 100644 --- a/src/layouts/graph/components/barCharts/categoryDist.js +++ b/src/layouts/graph/components/barCharts/categoryDist.js @@ -25,7 +25,7 @@ function CategoryDistribution() { return ( data._id), datasets: { label: "City", - backgroundColors: ["info", "dark", "error", "secondary", "primary", "success"], + backgroundColors: ["info", "dark", "#8A6FC5", "secondary", "primary", "#C08DD8"], data: housesalebyCity.map((data) => data.count), }, }} diff --git a/src/layouts/graph/components/pieCharts/marriageDist.js b/src/layouts/graph/components/pieCharts/marriageDist.js index 2bf29f1..df11082 100644 --- a/src/layouts/graph/components/pieCharts/marriageDist.js +++ b/src/layouts/graph/components/pieCharts/marriageDist.js @@ -28,7 +28,7 @@ function MarriageDistribution() { return ( { @@ -74,6 +80,8 @@ function GraphViewer() { setIncludeLandSale(true); setIncludeMarriageDist(true); setIncludePriceFluct(true); + setIncludeDemographic(true); + setIncludeHouseSale(true); }; const createPDF = () => { const selectedComponents = []; @@ -94,6 +102,12 @@ function GraphViewer() { if (includePriceFluct) { selectedComponents.push(); } + if (includeDemographic) { + selectedComponents.push(); + } + if (includeHouseSale) { + selectedComponents.push(); + } // Pass the selected components to your PDF generator function (ChartToPDF) generatePDF(selectedComponents, contentRef, title, user.user_ID); @@ -134,8 +148,8 @@ function GraphViewer() { setIncludeLandSale(!includeLandSale)} + checked={includeHouseSale} + onChange={() => setIncludeHouseSale(!includeHouseSale)} /> @@ -215,8 +229,8 @@ function GraphViewer() { setIncludePriceFluct(!includePriceFluct)} + checked={includeDemographic} + onChange={() => setIncludeDemographic(!includeDemographic)} /> diff --git a/src/layouts/reports/data/reportsdata.js b/src/layouts/reports/data/reportsdata.js index a7aa182..2d40fe8 100644 --- a/src/layouts/reports/data/reportsdata.js +++ b/src/layouts/reports/data/reportsdata.js @@ -64,34 +64,84 @@ export default function Data() { return { rawData: [ { - Name: "John Doe", - Age: 30, - Email: "johndoe@example.com", - City: "New York", + id: 1, + name: "Historic Estate", + location: "Jaffna", + date: "Sun, 03 Sep 2023 18:30:04 GMT", + contactNumbers: ["0774698456", "0768596489"], + price: "Rs.250000", }, { - Name: "Jane Smith", - Age: 28, - Email: "janesmith@example.com", - City: "Los Angeles", + id: 2, + name: "Seaview Bungalow", + location: "Trincomalee", + date: "Wed, 30 Aug 2023 18:30:07 GMT", + contactNumbers: ["0774698459", "0768596492"], + price: "Rs.190000", }, { - Name: "Bob Johnson", - Age: 35, - Email: "bobjohnson@example.com", - City: "Chicago", + id: 3, + name: "Ancient Property", + location: "Anuradhapura", + date: "Wed, 30 Aug 2023 18:30:05 GMT", + contactNumbers: ["0774698457", "0768596490"], + price: "Rs.120000", }, { - Name: "Alice Brown", - Age: 25, - Email: "alicebrown@example.com", - City: "San Francisco", + id: 4, + name: "Mountain View Property", + location: "Kandy", + date: "Wed, 30 Aug 2023 18:30:01 GMT", + contactNumbers: ["0774698453", "0768596486"], + price: "Rs.150000", }, { - Name: "What", - Age: "am", - Email: "I", - City: "doing?", + id: 5, + name: "Hillside Property", + location: "Nuwara Eliya", + date: "Thu, 24 Aug 2023 18:30:09 GMT", + contactNumbers: ["0774698461", "0768596494"], + price: "Rs.120000", + }, + { + id: 6, + name: "Seaside Paradise", + location: "Galle", + date: "Sat, 19 Aug 2023 18:30:02 GMT", + contactNumbers: ["0774698454", "0768596487"], + price: "Rs.200000", + }, + { + id: 7, + name: "Beachfront Villa", + location: "Negombo", + date: "Thu, 10 Aug 2023 18:30:03 GMT", + contactNumbers: ["0774698455", "0768596488"], + price: "Rs.180000", + }, + { + id: 8, + name: "Riverside Land", + location: "Matara", + date: "Fri, 04 Aug 2023 18:30:08 GMT", + contactNumbers: ["0774698460", "0768596493"], + price: "Rs.80000", + }, + { + id: 9, + name: "Lakefront Retreat", + location: "Batticaloa", + date: "Thu, 03 Aug 2023 18:30:06 GMT", + contactNumbers: ["0774698458", "0768596491"], + price: "Rs.150000", + }, + { + id: 10, + name: "Prime Lands", + location: "Colombo", + date: "Sun, 30 Jul 2023 18:30:00 GMT", + contactNumbers: ["0774698452", "0768596485"], + price: "Rs.100000", }, ], columns: [ diff --git a/src/layouts/reports/graphs/graphdetails.js b/src/layouts/reports/graphs/graphdetails.js index 1d84f5f..b361175 100644 --- a/src/layouts/reports/graphs/graphdetails.js +++ b/src/layouts/reports/graphs/graphdetails.js @@ -2,7 +2,17 @@ import React from "react"; import { useParams } from "react-router-dom"; // For accessing route parameters import { Container, Typography } from "@mui/material"; +// Material Dashboard 2 React components +import MDBox from "components/MDBox"; + +import data from "../data/reportsdata"; +import MDButton from "components/MDButton"; +import { generateExcel } from "../reports"; +import { CSVLink } from "react-csv"; +import Projects from "layouts/dashboard/components/Projects"; + const GraphDetails = () => { + const { rawData } = data(); // Get the advertisement id from the URL const { title } = useParams(); @@ -13,6 +23,17 @@ const GraphDetails = () => { {title} + + + generateExcel(rawData, "uselessReport")}> + Export to Excel + + + + + Export to CSV + + ); }; diff --git a/src/layouts/reports/reports.js b/src/layouts/reports/reports.js index 5d94cb2..f5ad1e1 100644 --- a/src/layouts/reports/reports.js +++ b/src/layouts/reports/reports.js @@ -3,9 +3,9 @@ import "jspdf-autotable"; import html2canvas from "html2canvas"; import * as XLSX from "xlsx"; -import { savePdf } from "api/report/saveReport"; -import { storage } from "../../firebase"; -import { ref, uploadBytes, getDownloadURL } from "firebase/storage"; +// import { savePdf } from "api/report/saveReport"; +// import { storage } from "../../firebase"; +// import { ref, uploadBytes, getDownloadURL } from "firebase/storage"; export const generateCSV = (data, filename) => { const csvContent = "data:text/csv;charset=utf-8," + data.map((row) => row.join(",")).join("\n"); @@ -55,23 +55,24 @@ const generatePDF = async (componentsToPrint, contentRef, title, user_ID) => { } doc.save(`${title}.pdf`); - const pdfBlob = doc.output("blob"); + // const pdfBlob = doc.output("blob"); const userID = user_ID; - const pdfRef = ref(storage, `Reports/${title}`); + console.log(userID); + // const pdfRef = ref(storage, `Reports/${title}`); - // Upload the PDF to Firebase Storage - await uploadBytes(pdfRef, pdfBlob); + // // Upload the PDF to Firebase Storage + // await uploadBytes(pdfRef, pdfBlob); - // Get the download URL of the uploaded PDF - const downloadURL = await getDownloadURL(pdfRef); // Add this import: import { getDownloadURL } from "firebase/storage"; - // Send the PDF URL to the backend using the savePdf function or do whatever you need with it - const response = await savePdf(downloadURL, userID, title); + // // Get the download URL of the uploaded PDF + // const downloadURL = await getDownloadURL(pdfRef); // Add this import: import { getDownloadURL } from "firebase/storage"; + // // Send the PDF URL to the backend using the savePdf function or do whatever you need with it + // const response = await savePdf(downloadURL, userID, title); - if (response && response.message) { - console.log("PDF uploaded successfully!"); - } else { - console.error("Failed to upload PDF:", response.error); - } + // if (response && response.message) { + // console.log("PDF uploaded successfully!"); + // } else { + // console.error("Failed to upload PDF:", response.error); + // } } catch (error) { console.error("An error occurred while generating/uploading PDF:", error); } diff --git a/src/layouts/upload/inputURL.js b/src/layouts/upload/inputURL.js index c287774..acec12d 100644 --- a/src/layouts/upload/inputURL.js +++ b/src/layouts/upload/inputURL.js @@ -62,38 +62,52 @@ function InputURL() { maxWidth: "100%", }} > -
- - - - Analyze - - -
+ + {loading && (