Skip to content

Commit fc84ba0

Browse files
authored
Fix type (#446)
1 parent 2d5e2be commit fc84ba0

File tree

2 files changed

+7
-4
lines changed
  • packages/donate-button-v4/src/components/widget

2 files changed

+7
-4
lines changed

packages/donate-button-v4/src/components/widget/components/PaymentProcess/PaymentMethodSelect/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,11 @@ const usePaymentMethods = () => {
4545
() =>
4646
methods
4747
.filter((method) => {
48+
// There is a bug where instead of being a proper array of disabled methods,
49+
// it comes as an array of length 1 with a comma-separated string inside
4850
if (
49-
nonprofit?.metadata?.disabledPaymentFlowOptions?.includes(method)
51+
nonprofit?.metadata?.disabledPaymentFlowOptions?.length === 1 &&
52+
nonprofit?.metadata?.disabledPaymentFlowOptions[0]?.includes(method)
5053
) {
5154
return false;
5255
}

packages/donate-button-v4/src/components/widget/types/Nonprofit.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ export interface Nonprofit {
1818
nteeCode: string | null;
1919
metadata?: {
2020
customTaxDeductible?: string;
21-
// Note that multiple payment methods can be disabled, but it still arrives as a single
22-
// comma-separated string from the API eg "card,paypal" so we type it as such here
23-
disabledPaymentFlowOptions?: string;
21+
// Note that multiple payment methods can be disabled, but for some reason it arrives
22+
// as an array of length 1 eg ["card,paypal"] from the API, so we type it as such here
23+
disabledPaymentFlowOptions?: string[];
2424
disablePrivateNotes?: boolean;
2525
granteeName?: string;
2626
prefixWithThe?: boolean;

0 commit comments

Comments
 (0)