Skip to content

Commit

Permalink
fix: For orgs show money spent instead of money received (#8337)
Browse files Browse the repository at this point in the history
* fix: for orgs show money spent instead of money received

* fix: change money spent to contributed

* fix: make sure we re-use the format string
  • Loading branch information
SudharakaP authored Nov 10, 2022
1 parent 71e5be8 commit e8cec08
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 15 deletions.
52 changes: 37 additions & 15 deletions components/search-page/SearchCollectiveCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,39 @@ const SearchCollectiveCard = ({ collective, ...props }) => {
)}
</P>

{collective.stats.totalAmountReceived.valueInCents > 0 && (
<Box pb="6px">
<Span fontSize="14px" fontWeight={700} color="black.900">
<Currency
currency={collective.stats.totalAmountReceived.currency}
formatWithSeparators
value={collective.stats.totalAmountReceived.valueInCents}
/>
</Span>
{` `}
<Span fontSize="12px" fontWeight={400} color="black.700">
<FormattedMessage defaultMessage="Money raised" />
</Span>
</Box>
)}
{collective.type !== CollectiveType.ORGANIZATION &&
collective.stats.totalAmountReceived.valueInCents > 0 && (
<Box pb="6px">
<Span fontSize="14px" fontWeight={700} color="black.900">
<Currency
currency={collective.stats.totalAmountReceived.currency}
formatWithSeparators
value={collective.stats.totalAmountReceived.valueInCents}
/>
</Span>
{` `}
<Span fontSize="12px" fontWeight={400} color="black.700">
<FormattedMessage defaultMessage="Money raised" />
</Span>
</Box>
)}

{collective.type === CollectiveType.ORGANIZATION &&
Math.abs(collective.stats.totalAmountSpent.valueInCents) > 0 && (
<Box pb="6px">
<Span fontSize="14px" fontWeight={700} color="black.900">
<Currency
currency={collective.stats.totalAmountSpent.currency}
formatWithSeparators
value={Math.abs(collective.stats.totalAmountSpent.valueInCents)}
/>
</Span>
{` `}
<Span fontSize="12px" fontWeight={400} color="black.700">
<FormattedMessage id="AmountContributed" defaultMessage="Contributed" />
</Span>
</Box>
)}
</React.Fragment>
)}
{collective.description && (
Expand Down Expand Up @@ -120,6 +138,10 @@ SearchCollectiveCard.propTypes = {
valueInCents: PropTypes.number,
currency: PropTypes.string,
}),
totalAmountSpent: PropTypes.shape({
valueInCents: PropTypes.number,
currency: PropTypes.string,
}),
}),
host: PropTypes.shape({
totalHostedCollectives: PropTypes.number,
Expand Down
4 changes: 4 additions & 0 deletions pages/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,10 @@ export const searchPageQuery = gql`
currency
valueInCents
}
totalAmountSpent {
currency
valueInCents
}
}
... on Organization {
host {
Expand Down

2 comments on commit e8cec08

@vercel
Copy link

@vercel vercel bot commented on e8cec08 Nov 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on e8cec08 Nov 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.