mirror of
https://github.com/gabehf/Prittee.git
synced 2026-03-13 17:30:38 -07:00
Calculate total points from post list
This commit is contained in:
parent
1a43cb6c4d
commit
695a447667
1 changed files with 2 additions and 1 deletions
|
|
@ -37,6 +37,7 @@ export default function Profile() {
|
||||||
{(value) => {
|
{(value) => {
|
||||||
let [ user, posts ] = value
|
let [ user, posts ] = value
|
||||||
user = user.user
|
user = user.user
|
||||||
|
const totalPoints = user.total_points > 0 ? user.total_points : posts.reduce((n, p) => n + p.points, 0);
|
||||||
return(
|
return(
|
||||||
<Box className='flex flex-col items-center'>
|
<Box className='flex flex-col items-center'>
|
||||||
<Box className='flex flex-row justify-around items-center' width={480}>
|
<Box className='flex flex-row justify-around items-center' width={480}>
|
||||||
|
|
@ -45,7 +46,7 @@ export default function Profile() {
|
||||||
</Box>
|
</Box>
|
||||||
<Box>
|
<Box>
|
||||||
<h2 className="text-2xl font-bold mb-2">{user.player_name}</h2>
|
<h2 className="text-2xl font-bold mb-2">{user.player_name}</h2>
|
||||||
<p>Total Points: {user.total_points}</p>
|
<p>Total Points: {totalPoints}</p>
|
||||||
<p>Posts: {posts.length}</p>
|
<p>Posts: {posts.length}</p>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue