Skip to content
Draft
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
8 changes: 8 additions & 0 deletions app/_locales/en/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions app/_locales/en_GB/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added app/images/shield-reward.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions ui/pages/shield-plan/shield-plan.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ import {
import ApiErrorHandler from '../../components/app/api-error-handler';
import { MetaMaskReduxDispatch } from '../../store/store';
import { setLastUsedSubscriptionPaymentDetails } from '../../store/actions';
import { RewardsBadge } from '../../components/app/rewards/RewardsBadge';
import { ShieldPaymentModal } from './shield-payment-modal';
import { ShieldRewardsModal } from './shield-rewards-modal';
import { Plan } from './types';
import { getProductPrice } from './utils';

Expand Down Expand Up @@ -343,7 +345,16 @@ const ShieldPlan = () => {
return details;
}, [t, isTrialed, selectedProductPrice]);

const planDetailsRewardsText = useMemo(() => {
const points =
selectedPlan === RECURRING_INTERVALS.year ? '10,000' : '1,000';
const interval =
selectedPlan === RECURRING_INTERVALS.year ? 'year' : 'month';
return t('shieldPlanDetailsRewards', [points, interval]);
}, [t, selectedPlan]);

const [showPaymentModal, setShowPaymentModal] = useState(false);
const [showRewardsModal, setShowRewardsModal] = useState(false);

const handleBack = () => {
const source = new URLSearchParams(search).get('source');
Expand Down Expand Up @@ -536,6 +547,17 @@ const ShieldPlan = () => {
<Text variant={DSTextVariant.bodyMd}>{detail}</Text>
</Box>
))}
<Box>
<RewardsBadge
boxClassName="gap-1 px-2 py-0.5 bg-background-muted rounded-lg w-fit"
textClassName="font-medium"
withPointsSuffix={false}
formattedPoints={`+${planDetailsRewardsText}`}
onClick={() => {
setShowRewardsModal(true);
}}
/>
</Box>
</Box>
</Box>
{selectedPaymentMethod === PAYMENT_TYPES.byCrypto &&
Expand All @@ -560,6 +582,11 @@ const ShieldPlan = () => {
availableTokenBalances={availableTokenBalances}
tokensSupported={tokensSupported}
/>
<ShieldRewardsModal
isOpen={showRewardsModal}
rewardsText={planDetailsRewardsText}
onClose={() => setShowRewardsModal(false)}
/>
</Content>
<Footer
className="shield-plan-page__footer"
Expand Down
82 changes: 82 additions & 0 deletions ui/pages/shield-plan/shield-rewards-modal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import React from 'react';
import {
Modal,
ModalBody,
ModalContent,
ModalHeader,
ModalOverlay,
} from '../../components/component-library';
import { RewardsBadge } from '../../components/app/rewards/RewardsBadge';
import { useI18nContext } from '../../hooks/useI18nContext';
import {

Check failure on line 11 in ui/pages/shield-plan/shield-rewards-modal.tsx

View workflow job for this annotation

GitHub Actions / test-lint / Test lint

`@metamask/design-system-react` import should occur before import of `../../components/component-library`
Button,
ButtonSize,
ButtonVariant,
Text,
TextColor,
TextVariant,
} from '@metamask/design-system-react';
import {
AlignItems,
Display,
FlexDirection,
} from '../../helpers/constants/design-system';

export const ShieldRewardsModal = ({
isOpen,
onClose,
rewardsText,
}: {
isOpen: boolean;
onClose: () => void;
rewardsText: string;
}) => {
const t = useI18nContext();

return (
<Modal
isOpen={isOpen}
onClose={() => undefined}
autoFocus={false}
className="shield-rewards-modal"
data-testid="shield-rewards-modal"
>
<ModalOverlay />
<ModalContent>
<ModalHeader onClose={onClose}>Rewards</ModalHeader>
<ModalBody
display={Display.Flex}
flexDirection={FlexDirection.Column}
alignItems={AlignItems.center}
gap={4}
>
<img
src="./images/shield-reward.png"
style={{ width: 'auto', height: '170px' }}
alt="Rewards"
/>

<RewardsBadge
boxClassName="gap-1 px-2 py-0.5 bg-background-muted rounded-lg w-fit"
textClassName="font-medium"
withPointsSuffix={false}
formattedPoints={rewardsText}
/>

<Text variant={TextVariant.BodyMd} color={TextColor.TextAlternative}>
{t('shieldPlanDetailsRewardsDescription', [rewardsText])}
</Text>

<Button
variant={ButtonVariant.Primary}
size={ButtonSize.Lg}
onClick={onClose}
className="w-full"
>
{t('gotIt')}
</Button>
</ModalBody>
</ModalContent>
</Modal>
);
};
Loading