-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #460 from Ansh101112/notification
New UI integrated and bugs fixed of no response from server
- Loading branch information
Showing
5 changed files
with
133 additions
and
11 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,25 @@ | ||
/* DashboardOverview.css */ | ||
.cards { | ||
display: flex; | ||
justify-content: space-around; | ||
margin-bottom: 20px; | ||
} | ||
|
||
.card { | ||
background: #fff; | ||
border-radius: 8px; | ||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); | ||
padding: 20px; | ||
text-align: center; | ||
width: 20%; | ||
} | ||
|
||
.card-content { | ||
margin: 0 auto; | ||
} | ||
|
||
.charts { | ||
display: flex; | ||
justify-content: space-around; | ||
} | ||
|
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,96 @@ | ||
import React from 'react'; | ||
import { Line } from 'react-chartjs-2'; | ||
import { Chart, LineElement, PointElement, LinearScale, CategoryScale, Title, Tooltip, Legend } from 'chart.js'; | ||
|
||
// Register Chart.js components | ||
Chart.register(LineElement, PointElement, LinearScale, CategoryScale, Title, Tooltip, Legend); | ||
|
||
const DashboardOverview = ({ products }) => { | ||
// Extract and validate product dates | ||
const validProducts = products.filter(product => { | ||
const date = new Date(product.addedDate); | ||
return !isNaN(date); | ||
}); | ||
|
||
// Extract dates | ||
const productDates = validProducts.map(product => new Date(product.addedDate)); | ||
|
||
// Aggregate products added per day | ||
const productsAddedPerDay = productDates.reduce((acc, date) => { | ||
const day = date.toISOString().split('T')[0]; | ||
acc[day] = (acc[day] || 0) + 1; | ||
return acc; | ||
}, {}); | ||
|
||
// Prepare chart data | ||
const labels = Object.keys(productsAddedPerDay).sort(); | ||
const data = labels.map(label => productsAddedPerDay[label]); | ||
|
||
// Debugging: Log chart data | ||
console.log('Chart Data:', { labels, data }); | ||
|
||
// Default chartData if no data is present | ||
const chartData = { | ||
labels: labels.length > 0 ? labels : ['No Data'], | ||
datasets: [ | ||
{ | ||
label: 'Products Added', | ||
data: data.length > 0 ? data : [1], | ||
borderColor: 'blue', | ||
backgroundColor: 'rgba(0,0,255,0.2)', | ||
fill: true, | ||
}, | ||
], | ||
}; | ||
|
||
const options = { | ||
responsive: true, | ||
plugins: { | ||
legend: { | ||
position: 'top', | ||
}, | ||
tooltip: { | ||
callbacks: { | ||
label: function (context) { | ||
return `Products Added: ${context.raw}`; | ||
}, | ||
}, | ||
}, | ||
}, | ||
scales: { | ||
x: { | ||
title: { | ||
display: true, | ||
text: 'Date', | ||
}, | ||
}, | ||
y: { | ||
title: { | ||
display: true, | ||
text: 'Number of Products', | ||
}, | ||
beginAtZero: true, | ||
}, | ||
}, | ||
}; | ||
|
||
return ( | ||
<div> | ||
<div className="cards"> | ||
<div className="card"> | ||
<div className="card-content"> | ||
<h3>{products.length}</h3> | ||
<p>Total Products</p> | ||
</div> | ||
</div> | ||
{/* Add more cards if needed */} | ||
</div> | ||
<div className="charts"> | ||
<Line data={chartData} options={options} /> | ||
{/* Add other charts here */} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default DashboardOverview; |
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
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