-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ratings API fixes and UI in place. (#67)
* refactor: post rating api * dep: added recharts to the dependencies * fix: added the UI for the charts * fix: fetch the count details for graph from backend * fix: exception when count key is not present * fix: exception due to updated_at typo * fix: fallback condition for ui if no ratings available
- Loading branch information
1 parent
4485488
commit ee50da6
Showing
6 changed files
with
78 additions
and
23 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React from "react"; | ||
import { BarChart, Bar, XAxis, Tooltip } from "recharts"; | ||
|
||
const PackageRatingGraph = ({ data }) => { | ||
const graphData = data; | ||
|
||
const parsedArray = Object.entries(graphData).map(([key, value]) => ({ | ||
name: `${key} ⭐`, | ||
star: value, | ||
})); | ||
|
||
return parsedArray.length === 0 ? ( | ||
<div> | ||
No stats available right now. This will update as soon as the package gets | ||
rated. | ||
</div> | ||
) : ( | ||
<BarChart width={600} height={500} data={parsedArray}> | ||
<XAxis dataKey="name" /> | ||
<Bar dataKey="star" fill="#8884d8" /> | ||
<Tooltip /> | ||
</BarChart> | ||
); | ||
}; | ||
|
||
export default PackageRatingGraph; |
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