Skip to content

Commit

Permalink
Add default filter setter to Payments (#135)
Browse files Browse the repository at this point in the history
* add default filters setter

* return wrapper

* update connect.js version

* add type in useUpdateWithSetter

* remove comment
  • Loading branch information
hhuang-stripe authored Oct 17, 2024
1 parent 3a97dae commit 92b0334
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"@babel/preset-react": "7.18.6",
"@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-replace": "^2.3.1",
"@stripe/connect-js": "3.3.14",
"@stripe/connect-js": "3.3.16",
"@types/jest": "^24.0.25",
"@types/react": "^16.8.0",
"@types/react-dom": "^16.8.0",
Expand Down Expand Up @@ -84,7 +84,7 @@
"zx": "^4.2.0"
},
"peerDependencies": {
"@stripe/connect-js": ">=3.3.14",
"@stripe/connect-js": ">=3.3.16",
"react": ">=16.8.0",
"react-dom": ">=16.8.0"
}
Expand Down
7 changes: 6 additions & 1 deletion src/Components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
LoaderStart,
NotificationCount,
StepChange,
PaymentsListDefaultFilters
} from '@stripe/connect-js';

export type CommonComponentProps = {
Expand All @@ -13,9 +14,10 @@ export type CommonComponentProps = {
};

export const ConnectPayments = ({
defaultFilters,
onLoadError,
onLoaderStart,
}: CommonComponentProps): JSX.Element => {
}: {defaultFilters?: PaymentsListDefaultFilters} & CommonComponentProps): JSX.Element => {
const {wrapper, component: payments} = useCreateComponent('payments');

useUpdateWithSetter(payments, onLoaderStart, (comp, val) => {
Expand All @@ -24,6 +26,9 @@ export const ConnectPayments = ({
useUpdateWithSetter(payments, onLoadError, (comp, val) => {
comp.setOnLoadError(val);
});
useUpdateWithSetter(payments, defaultFilters, (comp, val) => {
comp.setDefaultFilters(val);
});

return wrapper;
};
Expand Down
2 changes: 2 additions & 0 deletions src/utils/useUpdateWithSetter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
LoaderStart,
NotificationCount,
StepChange,
PaymentsListDefaultFilters
} from '@stripe/connect-js';

export const useUpdateWithSetter = <
Expand All @@ -13,6 +14,7 @@ export const useUpdateWithSetter = <
| string
| boolean
| string[]
| PaymentsListDefaultFilters
| (() => void)
| CollectionOptions
| ((notificationCount: NotificationCount) => void)
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1439,10 +1439,10 @@
dependencies:
"@sinonjs/commons" "^3.0.0"

"@stripe/connect-js@3.3.14":
version "3.3.14"
resolved "https://registry.yarnpkg.com/@stripe/connect-js/-/connect-js-3.3.14.tgz#4510042e5b9bab98ef4706a79010cacd11c74b48"
integrity sha512-jQ6ee5JVY4XMDL6PhAFv47om1/H0JjE6G4GpuEItRQkmVScAi3tTzx7g7/1/2LhvYW+4HejZJAIq51ymFIneLw==
"@stripe/connect-js@3.3.16":
version "3.3.16"
resolved "https://registry.yarnpkg.com/@stripe/connect-js/-/connect-js-3.3.16.tgz#36af5211c863c18520a080403c4f736c0160f8a1"
integrity sha512-lMUKJJaDl6qzjp+czNn+N6wMwFXwLawmB2jNNgds8SeR+bXCVCXevzJ8dfF92KfmexKg++hBYagF9e99sEMBJQ==

"@tootallnate/once@2":
version "2.0.0"
Expand Down

0 comments on commit 92b0334

Please sign in to comment.