Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional reward cards for point history #93

Merged
merged 2 commits into from
Apr 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions components/rewards/PointsHistory.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ function PointsHistory({ transactions }) {
storeName={item.storeName}
subtotal={item.subtotal}
totalSale={item.totalSale}
rewardsUnlocked={item.rewardsUnlocked}
rewardsApplied={item.rewardsApplied}
/>
)}
keyExtractor={item => item.id}
Expand Down
86 changes: 69 additions & 17 deletions components/rewards/Transaction.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import PropTypes from 'prop-types';
import React from 'react';
import { View } from 'react-native';
import Colors from '../../constants/Colors';
import { displayDollarValue } from '../../lib/common';
import { ContentContainer, TransactionCard } from '../../styled/transaction';
Expand All @@ -11,30 +12,77 @@ import CircleIcon from '../CircleIcon';
* */

function Transaction(props) {
const { date, storeName, pointsEarned, totalSale } = props;
const {
date,
storeName,
pointsEarned,
totalSale,
rewardsUnlocked,
rewardsApplied,
} = props;
const options = {
weekday: 'short',
year: 'numeric',
month: 'short',
day: 'numeric',
};
return (
<TransactionCard>
<CircleIcon
icon="check"
iconColor={Colors.primaryGreen}
circleColor={Colors.lightestGreen}
/>
<ContentContainer>
<Caption color={Colors.secondaryText}>
{`${date.toLocaleDateString('en-US', options)} • ${storeName}`}
</Caption>
<Subhead>{`${pointsEarned} points earned`}</Subhead>
<Caption color={Colors.secondaryText}>
{`for ${displayDollarValue(totalSale || 0)} of healthy products`}
</Caption>
</ContentContainer>
</TransactionCard>
<View>
{/* Display rewards unlocked */}
{[...Array(rewardsUnlocked).keys()].map(() => (
<TransactionCard>
<CircleIcon
icon="star"
iconColor={Colors.primaryGreen}
circleColor={Colors.lightestGreen}
/>
<ContentContainer>
<Caption color={Colors.secondaryText}>
{`${date.toLocaleDateString('en-US', options)} • ${storeName}`}
</Caption>
<Subhead>{`$5 reward unlocked`}</Subhead>
<Caption color={Colors.secondaryText}>
{`for 500 earned points`}
</Caption>
</ContentContainer>
</TransactionCard>
))}

{/* Display points earned */}
<TransactionCard>
<CircleIcon
icon="check"
iconColor={Colors.primaryGreen}
circleColor={Colors.lightestGreen}
/>
<ContentContainer>
<Caption color={Colors.secondaryText}>
{`${date.toLocaleDateString('en-US', options)} • ${storeName}`}
</Caption>
<Subhead>{`${pointsEarned} points earned`}</Subhead>
<Caption color={Colors.secondaryText}>
{`for ${displayDollarValue(totalSale || 0)} of healthy products`}
Copy link
Member

Choose a reason for hiding this comment

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

I know it was like this before but would this make more sense to be subtotal?

Copy link
Member

Choose a reason for hiding this comment

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

Oh nevermind I guess it makes sense that the number of points directly corresponds to the total sale (bc the rewards points are deducted?) but this language might not fit since they did actually pay more for the total healthy products...if that makes sense
cc @12aschen ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's probably easiest to match what we do in Clerk (which I cannot currently recall) but I would guess this is a quacetion that we can defer. Just don't forget to check in on it 😅

</Caption>
</ContentContainer>
</TransactionCard>

{/* Display rewards applied */}
{[...Array(rewardsApplied).keys()].map(() => (
<TransactionCard>
<CircleIcon
icon="star"
iconColor={Colors.primaryOrange}
circleColor={Colors.lightestOrange}
/>
<ContentContainer>
<Caption color={Colors.secondaryText}>
{`${date.toLocaleDateString('en-US', options)} • ${storeName}`}
</Caption>
<Subhead>{`$5 reward redeemed`}</Subhead>
</ContentContainer>
</TransactionCard>
))}
</View>
);
}

Expand All @@ -43,12 +91,16 @@ Transaction.propTypes = {
storeName: PropTypes.array,
pointsEarned: PropTypes.number,
totalSale: PropTypes.number,
rewardsUnlocked: PropTypes.number,
rewardsApplied: PropTypes.number,
};

Transaction.defaultProps = {
storeName: null,
pointsEarned: 0,
totalSale: 0,
rewardsUnlocked: null,
rewardsApplied: 0,
};

export default Transaction;
Loading