-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fa855e9
commit cf1bab0
Showing
6 changed files
with
990 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
import React, { useState, useEffect } from "react"; | ||
import Container from "@mui/material/Container"; | ||
import Typography from "@mui/material/Typography"; | ||
import Card from "@mui/material/Card"; | ||
import CardContent from "@mui/material/CardContent"; | ||
import Button from "@mui/material/Button"; | ||
import Box from "@mui/material/Box"; | ||
import DashboardLayout from "examples/LayoutContainers/DashboardLayout"; | ||
import DashboardNavbar from "examples/Navbars/DashboardNavbar"; | ||
|
||
// Simulated data for advertisements pending approval | ||
const advertisements = [ | ||
{ | ||
id: 1, | ||
title: "Historic Estate", | ||
location: "Jaffna", | ||
date: "Sun, 03 Sep 2023 18:30:04 GMT", | ||
description: "This is a historic estate.", | ||
image: "image_url_here", | ||
}, | ||
{ | ||
id: 2, | ||
title: "Historic Estate", | ||
location: "Jaffna", | ||
date: "Sun, 03 Sep 2023 18:30:04 GMT", | ||
description: "This is a historic estate.", | ||
image: "image_url_here", | ||
}, | ||
// Add more advertisements as needed | ||
]; | ||
|
||
function ContentApprovalPage() { | ||
const [pendingAds, setPendingAds] = useState(advertisements); | ||
const [currentAdIndex, setCurrentAdIndex] = useState(0); | ||
|
||
useEffect(() => { | ||
// Fetch pending advertisements from the server here if needed | ||
// Update the 'pendingAds' state with the fetched data | ||
}, []); | ||
|
||
const approveAd = () => { | ||
// Handle approval logic here (e.g., send a request to the server) | ||
// Remove the current ad from the pending list | ||
const updatedAds = [...pendingAds]; | ||
updatedAds.splice(currentAdIndex, 1); | ||
setPendingAds(updatedAds); | ||
|
||
// Move to the next ad | ||
if (currentAdIndex < updatedAds.length) { | ||
setCurrentAdIndex(currentAdIndex + 1); | ||
} | ||
}; | ||
|
||
const rejectAd = () => { | ||
// Handle rejection logic here (e.g., send a request to the server) | ||
// Remove the current ad from the pending list | ||
const updatedAds = [...pendingAds]; | ||
updatedAds.splice(currentAdIndex, 1); | ||
setPendingAds(updatedAds); | ||
|
||
// Move to the next ad | ||
if (currentAdIndex < updatedAds.length) { | ||
setCurrentAdIndex(currentAdIndex + 1); | ||
} | ||
}; | ||
|
||
const currentAd = pendingAds[currentAdIndex]; | ||
|
||
return ( | ||
<DashboardLayout> | ||
<DashboardNavbar /> | ||
|
||
<Container maxWidth="sm"> | ||
<Typography variant="h4" align="center" gutterBottom> | ||
Content Approval | ||
</Typography> | ||
{currentAd ? ( | ||
<Card> | ||
<CardContent> | ||
<Typography variant="h5" gutterBottom> | ||
Advertisement ID: {currentAd.id} | ||
</Typography> | ||
<Typography variant="body1" gutterBottom> | ||
Title: {currentAd.title} | ||
</Typography> | ||
<Typography variant="body1" gutterBottom> | ||
Location: {currentAd.location} | ||
</Typography> | ||
<Typography variant="body1" gutterBottom> | ||
Date: {currentAd.date} | ||
</Typography> | ||
<Typography variant="body1" gutterBottom> | ||
Description: {currentAd.description} | ||
</Typography> | ||
{currentAd.image && ( | ||
<img | ||
src={currentAd.image} | ||
alt="Advertisement" | ||
style={{ maxWidth: "100%", marginTop: "16px" }} | ||
/> | ||
)} | ||
<Box mt={2} display="flex" justifyContent="center"> | ||
<Button | ||
variant="contained" | ||
color="primary" | ||
onClick={approveAd} | ||
style={{ marginRight: "16px" }} | ||
> | ||
Approve | ||
</Button> | ||
<Button variant="contained" color="secondary" onClick={rejectAd}> | ||
Reject | ||
</Button> | ||
</Box> | ||
</CardContent> | ||
</Card> | ||
) : ( | ||
<Typography variant="h6" align="center"> | ||
No pending advertisements. | ||
</Typography> | ||
)} | ||
</Container> | ||
</DashboardLayout> | ||
); | ||
} | ||
|
||
export default ContentApprovalPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import React from "react"; | ||
import { Card } from "@mui/material"; | ||
import MDTypography from "components/MDTypography"; | ||
import DashboardLayout from "examples/LayoutContainers/DashboardLayout"; | ||
import DashboardNavbar from "examples/Navbars/DashboardNavbar"; | ||
|
||
function ManageFeedback() { | ||
// Assuming feedbackData is an array of feedback objects | ||
const feedbackData = [ | ||
{ | ||
name: "John Doe", | ||
email: "[email protected]", | ||
date: "2023-09-01", | ||
message: | ||
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla eget justo eu urna condimentum elementum vel eget enim.", | ||
}, | ||
{ | ||
name: "Jane Smith", | ||
email: "[email protected]", | ||
date: "2023-09-02", | ||
message: | ||
"Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Maecenas quis fringilla libero.", | ||
}, | ||
{ | ||
name: "Alice Johnson", | ||
email: "[email protected]", | ||
date: "2023-09-03", | ||
message: | ||
"Vestibulum in metus eu ipsum finibus auctor. Curabitur feugiat urna eget elit dictum, eget elementum quam cursus.", | ||
}, | ||
// Add more feedback objects as needed | ||
]; | ||
|
||
return ( | ||
<DashboardLayout> | ||
<DashboardNavbar /> | ||
<h2>Manage Feedback</h2> | ||
{feedbackData.map((feedback, index) => ( | ||
<Card key={index} elevation={3} style={{ marginBottom: "16px" }}> | ||
<div style={{ padding: "16px" }}> | ||
<MDTypography variant="h6" fontWeight="bold"> | ||
{feedback.name} | ||
</MDTypography> | ||
<MDTypography variant="body2" color="textSecondary"> | ||
{feedback.email} | {feedback.date} | ||
</MDTypography> | ||
<MDTypography variant="body1" mt={2}> | ||
{feedback.message} | ||
</MDTypography> | ||
{/* You can add buttons or actions here for managing feedback */} | ||
</div> | ||
</Card> | ||
))} | ||
</DashboardLayout> | ||
); | ||
} | ||
|
||
export default ManageFeedback; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
/* eslint-disable react/prop-types */ | ||
/* eslint-disable react/function-component-definition */ | ||
/** | ||
* ========================================================= | ||
* Material Dashboard 2 React - v2.2.0 | ||
* ========================================================= | ||
* | ||
* Product Page: https://www.creative-tim.com/product/material-dashboard-react | ||
* Copyright 2023 Creative Tim (https://www.creative-tim.com) | ||
* | ||
* Coded by www.creative-tim.com | ||
* | ||
* ========================================================= | ||
* | ||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
*/ | ||
|
||
// Material Dashboard 2 React components | ||
import MDBox from "components/MDBox"; | ||
import MDTypography from "components/MDTypography"; | ||
import MDBadge from "components/MDBadge"; | ||
import { useEffect, useState } from "react"; | ||
import { getReportList } from "api/report/reportsdata"; | ||
|
||
export default function Data() { | ||
const Job = ({ title, description }) => ( | ||
<MDBox lineHeight={1} textAlign="left"> | ||
<MDTypography display="block" variant="caption" color="text" fontWeight="medium"> | ||
{title} | ||
</MDTypography> | ||
<MDTypography variant="caption">{description}</MDTypography> | ||
</MDBox> | ||
); | ||
|
||
const [reportDetails, setReportsDetails] = useState([]); | ||
|
||
useEffect(() => { | ||
// Fetch average price data from the Flask API endpoint | ||
getReportList() | ||
.then((data) => { | ||
setReportsDetails(data); | ||
console.log(data); // Use 'data' instead of 'reportDetails' | ||
}) | ||
.catch((error) => { | ||
console.error("Error fetching data:", error); | ||
}); | ||
}, []); | ||
|
||
const handleDownload = (pdf_Url) => { | ||
if (pdf_Url) { | ||
// Create an anchor element to trigger the download | ||
const anchor = document.createElement("a"); | ||
anchor.href = pdf_Url; | ||
anchor.target = "_blank"; // Open the link in a new tab | ||
anchor.download = "your_file_name.ext"; // Replace with the desired file name | ||
|
||
// Trigger the download | ||
anchor.click(); | ||
} else { | ||
console.error("Download URL is not available."); | ||
} | ||
}; | ||
|
||
return { | ||
columns: [ | ||
{ Header: "User", accessor: "author", align: "left" }, | ||
{ Header: "Profession", accessor: "function", align: "left" }, | ||
{ Header: "Status", accessor: "status", align: "center" }, | ||
{ Header: "Last Seen", accessor: "employed", align: "center" }, | ||
{ Header: "Manage", accessor: "action", align: "center" }, | ||
], | ||
rows: reportDetails.map((report) => ({ | ||
author: ( | ||
<MDTypography component="a" href="#" variant="caption" color="text" fontWeight="medium"> | ||
{report.Title} | ||
</MDTypography> | ||
), | ||
function: <Job title={report.UserID} description="Organization" />, | ||
status: ( | ||
<MDBox ml={-1}> | ||
<MDBadge badgeContent="pdf" color="error" variant="gradient" size="sm" /> | ||
</MDBox> | ||
), | ||
employed: ( | ||
<MDTypography component="a" href="#" variant="caption" color="text" fontWeight="medium"> | ||
{report.timestamp} | ||
</MDTypography> | ||
), | ||
action: ( | ||
<MDTypography | ||
component="a" | ||
href="#" | ||
variant="caption" | ||
color="text" | ||
fontWeight="medium" | ||
onClick={() => handleDownload(report.PDF_URL)} // Use an arrow function | ||
> | ||
Download | ||
</MDTypography> | ||
), | ||
})), | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import React from "react"; | ||
import Grid from "@mui/material/Grid"; | ||
import Card from "@mui/material/Card"; | ||
|
||
// Material Dashboard 2 React components | ||
import MDBox from "components/MDBox"; | ||
import MDTypography from "components/MDTypography"; | ||
|
||
import DataTable from "examples/Tables/DataTable"; | ||
|
||
import data from "./data/userData"; | ||
import DashboardLayout from "examples/LayoutContainers/DashboardLayout"; | ||
import DashboardNavbar from "examples/Navbars/DashboardNavbar"; | ||
// import MDButton from "components/MDButton"; | ||
// import { generateExcel } from "./reports"; | ||
// import { CSVLink } from "react-csv"; | ||
|
||
function UserView() { | ||
const { columns, rows } = data(); | ||
return ( | ||
<DashboardLayout> | ||
<DashboardNavbar /> | ||
<MDBox pt={6} pb={3}> | ||
<Grid container spacing={6}> | ||
<Grid item xs={12}> | ||
<Card> | ||
<MDBox | ||
mx={2} | ||
mt={-3} | ||
py={3} | ||
px={2} | ||
variant="gradient" | ||
bgColor="info" | ||
borderRadius="lg" | ||
coloredShadow="info" | ||
> | ||
<MDTypography variant="h6" color="white"> | ||
User History | ||
</MDTypography> | ||
</MDBox> | ||
<MDBox pt={3}> | ||
<DataTable | ||
table={{ columns, rows }} | ||
isSorted={false} | ||
entriesPerPage={false} | ||
showTotalEntries={false} | ||
noEndBorder | ||
/> | ||
</MDBox> | ||
</Card> | ||
</Grid> | ||
</Grid> | ||
</MDBox> | ||
</DashboardLayout> | ||
); | ||
} | ||
|
||
export default UserView; |
Oops, something went wrong.