Skip to content

Commit

Permalink
removed show checkmark if a person already has a paypal account
Browse files Browse the repository at this point in the history
  • Loading branch information
LiudmylaMasliuk committed Feb 27, 2024
1 parent 2149be7 commit c9ad2ce
Showing 1 changed file with 24 additions and 13 deletions.
37 changes: 24 additions & 13 deletions src/components/PayPal/PayPalMask.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const PayPalMask: React.FC<CustomPayPalButtonsComponentProps> = (
handleCreateVaultSetupToken,
handleApproveVaultSetupToken,
} = usePayment();
const { settings } = useSettings();
const { settings, paymentTokens } = useSettings();
const { isLoading } = useLoader();
const { notify } = useNotifications();
const { t } = useTranslation();
Expand All @@ -28,6 +28,15 @@ export const PayPalMask: React.FC<CustomPayPalButtonsComponentProps> = (

const storeInVaultOnSuccess = settings?.storeInVaultOnSuccess;

const hasPaypalToken = useMemo(() => {
if (paymentTokens?.payment_tokens) {
return paymentTokens.payment_tokens.some(
(token) => token.payment_source.paypal,
);
}
return false;
}, [paymentTokens]);

const style = useMemo(() => {
if (restprops.style || !settings) {
return restprops.style;
Expand Down Expand Up @@ -76,18 +85,20 @@ export const PayPalMask: React.FC<CustomPayPalButtonsComponentProps> = (
{...actions}
onError={(err) => errorFunc(err, isLoading, notify, t)}
/>
{(enableVaulting || storeInVaultOnSuccess) && (
<label>
<input
type="checkbox"
id="save"
name="save"
ref={save}
className="mr-1"
/>
Save for future purchases
</label>
)}
{!vaultOnly &&
!hasPaypalToken &&
(enableVaulting || storeInVaultOnSuccess) && (
<label>
<input
type="checkbox"
id="save"
name="save"
ref={save}
className="mr-1"
/>
Save for future purchases
</label>
)}

{paypalMessages && <PayPalMessages {...paypalMessages} />}
</>
Expand Down

0 comments on commit c9ad2ce

Please sign in to comment.