Skip to content

Commit

Permalink
refactor: remove conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
prachigarg19 committed Nov 9, 2023
1 parent aad5bf4 commit cd00b92
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
14 changes: 7 additions & 7 deletions src/Donations/Components/DonationsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function DonationsForm(): ReactElement {
//Only used for native pay. Is this still applicable, or should this be removed?
const onPaymentFunction = async (
paymentMethod: PaymentMethod,
paymentRequest: PaymentRequest,
paymentRequest: PaymentRequest
) => {
// eslint-disable-next-line no-underscore-dangle
setPaymentType(paymentRequest._activeBackingLibraryName); //TODOO - is _activeBackingLibraryName a private variable?
Expand Down Expand Up @@ -223,7 +223,7 @@ function DonationsForm(): ReactElement {
amount: getFormatedCurrency(
i18n.language,
currency,
paymentSetup.unitCost * quantity,
paymentSetup.unitCost * quantity
),
});
break;
Expand All @@ -233,7 +233,7 @@ function DonationsForm(): ReactElement {
amount: getFormatedCurrency(
i18n.language,
currency,
paymentSetup.unitCost * quantity,
paymentSetup.unitCost * quantity
),
});
break;
Expand Down Expand Up @@ -389,13 +389,13 @@ function DonationsForm(): ReactElement {
paymentSetup?.gateways?.stripe?.account &&
currency ? (
<NativePay
isApplePayEnabled={false}
isGooglePayEnabled={false}
// isApplePayEnabled={true}
// isGooglePayEnabled={true}
country={country}
currency={currency}
amount={formatAmountForStripe(
paymentSetup?.unitCost * quantity,
currency.toLowerCase(),
currency.toLowerCase()
)}
onPaymentFunction={onPaymentFunction}
paymentSetup={paymentSetup}
Expand All @@ -405,7 +405,7 @@ function DonationsForm(): ReactElement {
query: { ...router.query, step: CONTACT },
},
undefined,
{ shallow: true },
{ shallow: true }
);
setRetainQuantityValue(true);
}}
Expand Down
4 changes: 2 additions & 2 deletions src/Donations/PaymentMethods/PaymentMethodTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ export default function PaymentMethodTabs({
{/*9 May 2023 - Apple Pay / Google Pay is disabled currently as it is not working correctly*/}
{showNativePay && (
<NativePay
isApplePayEnabled={false}
isGooglePayEnabled={false}
// isApplePayEnabled={true}
// isGooglePayEnabled={true}
country={country}
currency={currency}
amount={formatAmountForStripe(
Expand Down
30 changes: 15 additions & 15 deletions src/Donations/PaymentMethods/PaymentRequestCustomButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ interface PaymentButtonProps {
paymentLabel: string;
frequency: string | null;
paymentSetup: PaymentOptions;
isApplePayEnabled: boolean;
isGooglePayEnabled: boolean;
// isApplePayEnabled: boolean;
// isGooglePayEnabled: boolean;
}

export const PaymentRequestCustomButton = ({
Expand All @@ -43,9 +43,9 @@ export const PaymentRequestCustomButton = ({
paymentLabel,
frequency,
paymentSetup,
isApplePayEnabled,
isGooglePayEnabled,
}: PaymentButtonProps): ReactElement | null => {
}: // isApplePayEnabled,
// isGooglePayEnabled,
PaymentButtonProps): ReactElement | null => {
const { t, ready } = useTranslation(["common"]);
const { paymentRequest, setPaymentRequest } = useContext(QueryParamContext);

Expand Down Expand Up @@ -74,6 +74,7 @@ export const PaymentRequestCustomButton = ({
if (result) {
setPaymentRequest(pr);
}
console.log(result);
});
}
}, [stripe, paymentRequest, country, currency, amount]);
Expand Down Expand Up @@ -130,6 +131,7 @@ export const PaymentRequestCustomButton = ({
}
};
}, [paymentRequest, onPaymentFunction]);
console.log(paymentRequest);

return ready ? (
<div
Expand All @@ -146,8 +148,7 @@ export const PaymentRequestCustomButton = ({
(frequency !== "once"
? paymentSetup?.recurrency?.methods?.includes("card")
: true) ? (
paymentRequest._canMakePaymentAvailability.APPLE_PAY &&
isApplePayEnabled ? ( //TODOO - is _canMakePaymentAvailability a private variable?
paymentRequest._canMakePaymentAvailability.APPLE_PAY ? ( //TODOO - is _canMakePaymentAvailability a private variable?
<div className="w-100">
<button
onClick={() => paymentRequest.show()}
Expand All @@ -170,8 +171,7 @@ export const PaymentRequestCustomButton = ({
<div className="separator-text mb-10">{t("or")}</div>
)}
</div>
) : paymentRequest._canMakePaymentAvailability.GOOGLE_PAY &&
isGooglePayEnabled ? ( //TODOO - is _canMakePaymentAvailability a private variable?
) : paymentRequest._canMakePaymentAvailability.GOOGLE_PAY ? ( //TODOO - is _canMakePaymentAvailability a private variable?
<div className="w-100">
<button
onClick={() => {
Expand Down Expand Up @@ -215,8 +215,8 @@ export const PaymentRequestCustomButton = ({
/* 9 May 2023 - Apple Pay / Google Pay is disabled currently as it is not working correctly*/

interface NativePayProps {
isApplePayEnabled: boolean;
isGooglePayEnabled: boolean;
// isApplePayEnabled: boolean;
// isGooglePayEnabled: boolean;
country: string;
currency: string;
amount: number;
Expand All @@ -231,8 +231,8 @@ interface NativePayProps {
frequency: string | null;
}
export const NativePay = ({
isApplePayEnabled = false,
isGooglePayEnabled = false,
// isApplePayEnabled = true,
// isGooglePayEnabled = true,
country,
currency,
amount,
Expand Down Expand Up @@ -279,8 +279,8 @@ export const NativePay = ({
paymentLabel={paymentLabel}
frequency={frequency}
paymentSetup={paymentSetup}
isApplePayEnabled={isApplePayEnabled}
isGooglePayEnabled={isGooglePayEnabled}
// isApplePayEnabled={true}
// isGooglePayEnabled={true}
/>
</Elements>
);
Expand Down

0 comments on commit cd00b92

Please sign in to comment.