@fantastic.dev/better-stripe 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/README.md +30 -1
- package/dist/client/connect/disputes.d.ts +20 -0
- package/dist/client/connect/disputes.d.ts.map +1 -1
- package/dist/client/connect/disputes.js +55 -0
- package/dist/client/connect/disputes.js.map +1 -1
- package/dist/client/costRecovery-invoices.d.ts +10 -4
- package/dist/client/costRecovery-invoices.d.ts.map +1 -1
- package/dist/client/costRecovery-invoices.js +4 -0
- package/dist/client/costRecovery-invoices.js.map +1 -1
- package/dist/client/costRecovery.d.ts +18 -2
- package/dist/client/costRecovery.d.ts.map +1 -1
- package/dist/client/costRecovery.js +4 -0
- package/dist/client/costRecovery.js.map +1 -1
- package/dist/client/errors.d.ts +1 -1
- package/dist/client/errors.d.ts.map +1 -1
- package/dist/client/errors.js.map +1 -1
- package/dist/client/index.d.ts +5 -14
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +3 -7
- package/dist/client/index.js.map +1 -1
- package/dist/component/_generated/component.d.ts +59 -0
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/costRecovery/claims.d.ts +12 -0
- package/dist/component/costRecovery/claims.d.ts.map +1 -1
- package/dist/component/costRecovery/imports.d.ts +53 -0
- package/dist/component/costRecovery/imports.d.ts.map +1 -0
- package/dist/component/costRecovery/imports.js +67 -0
- package/dist/component/costRecovery/imports.js.map +1 -0
- package/dist/component/costRecovery/mutations.d.ts +47 -0
- package/dist/component/costRecovery/mutations.d.ts.map +1 -1
- package/dist/component/costRecovery/mutations.js +7 -1
- package/dist/component/costRecovery/mutations.js.map +1 -1
- package/dist/component/costRecovery/queries.d.ts +12 -0
- package/dist/component/costRecovery/queries.d.ts.map +1 -1
- package/dist/component/costRecovery/schema.d.ts +72 -2
- package/dist/component/costRecovery/schema.d.ts.map +1 -1
- package/dist/component/costRecovery/schema.js +13 -0
- package/dist/component/costRecovery/schema.js.map +1 -1
- package/dist/component/schema.d.ts +19 -1
- package/dist/react/workflows/EvidenceUpload.d.ts +18 -0
- package/dist/react/workflows/EvidenceUpload.d.ts.map +1 -0
- package/dist/react/workflows/EvidenceUpload.js +35 -0
- package/dist/react/workflows/EvidenceUpload.js.map +1 -0
- package/dist/react/workflows/Onboarding.d.ts +3 -3
- package/dist/react/workflows/Onboarding.d.ts.map +1 -1
- package/dist/react/workflows/Onboarding.js +8 -6
- package/dist/react/workflows/Onboarding.js.map +1 -1
- package/dist/react/workflows/index.d.ts +2 -0
- package/dist/react/workflows/index.d.ts.map +1 -1
- package/dist/react/workflows/index.js +1 -0
- package/dist/react/workflows/index.js.map +1 -1
- package/dist/react/workflows/useWorkflowAction.d.ts +1 -1
- package/dist/react/workflows/useWorkflowAction.d.ts.map +1 -1
- package/dist/react/workflows/useWorkflowAction.js +6 -2
- package/dist/react/workflows/useWorkflowAction.js.map +1 -1
- package/docs/react-workflows.md +42 -0
- package/package.json +1 -1
- package/src/client/connect/dispute-upload.test.ts +208 -0
- package/src/client/connect/disputes.ts +103 -0
- package/src/client/costRecovery-import.test.ts +174 -0
- package/src/client/costRecovery-invoices.test.ts +69 -0
- package/src/client/costRecovery-invoices.ts +32 -0
- package/src/client/costRecovery.ts +16 -0
- package/src/client/errors.ts +1 -0
- package/src/client/index.ts +14 -13
- package/src/component/_generated/api.ts +2 -0
- package/src/component/_generated/component.ts +65 -0
- package/src/component/costRecovery/imports.ts +74 -0
- package/src/component/costRecovery/mutations.ts +8 -0
- package/src/component/costRecovery/schema.ts +13 -0
- package/src/react/workflows/EvidenceUpload.test.tsx +56 -0
- package/src/react/workflows/EvidenceUpload.tsx +71 -0
- package/src/react/workflows/Onboarding.test.tsx +73 -0
- package/src/react/workflows/Onboarding.tsx +8 -5
- package/src/react/workflows/index.ts +3 -0
- package/src/react/workflows/useWorkflowAction.ts +6 -1
|
@@ -51,10 +51,13 @@ export function useOnboarding(props: OnboardingActions) {
|
|
|
51
51
|
? result.url
|
|
52
52
|
: undefined;
|
|
53
53
|
if (!url) throw new Error("Stripe did not return an onboarding URL.");
|
|
54
|
-
|
|
55
|
-
return true;
|
|
54
|
+
return url;
|
|
56
55
|
},
|
|
57
56
|
props.scopeKey,
|
|
57
|
+
(url) => {
|
|
58
|
+
if (typeof url === "string")
|
|
59
|
+
(props.onNavigate ?? ((url) => window.location.assign(url)))(url);
|
|
60
|
+
},
|
|
58
61
|
);
|
|
59
62
|
const run = action.run;
|
|
60
63
|
return {
|
|
@@ -69,9 +72,9 @@ export function useOnboarding(props: OnboardingActions) {
|
|
|
69
72
|
createError: operation === "create" ? action.error : null,
|
|
70
73
|
linkError: operation === "link" ? action.error : null,
|
|
71
74
|
restartError: operation === "close" ? action.error : null,
|
|
72
|
-
create: () => run("create"),
|
|
73
|
-
continue: () => run("link"),
|
|
74
|
-
close: () => run("close"),
|
|
75
|
+
create: async () => ((await run("create")) ? true : undefined),
|
|
76
|
+
continue: async () => ((await run("link")) ? true : undefined),
|
|
77
|
+
close: async () => ((await run("close")) ? true : undefined),
|
|
75
78
|
};
|
|
76
79
|
}
|
|
77
80
|
export type OnboardingAccount = {
|
|
@@ -12,6 +12,7 @@ export type WorkflowActionState<T, Args extends unknown[]> = {
|
|
|
12
12
|
export function useWorkflowAction<T, Args extends unknown[]>(
|
|
13
13
|
action: (...args: Args) => Promise<T>,
|
|
14
14
|
scope: string = "default",
|
|
15
|
+
onSuccess?: (result: T) => void,
|
|
15
16
|
): WorkflowActionState<T, Args> {
|
|
16
17
|
const initial = {
|
|
17
18
|
scope,
|
|
@@ -22,11 +23,13 @@ export function useWorkflowAction<T, Args extends unknown[]>(
|
|
|
22
23
|
const [state, setState] = useState(initial);
|
|
23
24
|
if (state.scope !== scope) setState(initial);
|
|
24
25
|
const callback = useRef(action);
|
|
26
|
+
const success = useRef(onSuccess);
|
|
25
27
|
const lifecycle = useRef({ version: 0, mounted: false });
|
|
26
28
|
const lock = useRef<number | null>(null);
|
|
27
29
|
useEffect(() => {
|
|
28
30
|
callback.current = action;
|
|
29
|
-
|
|
31
|
+
success.current = onSuccess;
|
|
32
|
+
}, [action, onSuccess]);
|
|
30
33
|
useEffect(() => {
|
|
31
34
|
const version = ++lifecycle.current.version;
|
|
32
35
|
lifecycle.current.mounted = true;
|
|
@@ -51,9 +54,11 @@ export function useWorkflowAction<T, Args extends unknown[]>(
|
|
|
51
54
|
setState({ scope, isPending: true, error: null, result: undefined });
|
|
52
55
|
const current = () =>
|
|
53
56
|
lifecycle.current.mounted && lifecycle.current.version === version;
|
|
57
|
+
const complete = success.current;
|
|
54
58
|
try {
|
|
55
59
|
const result = await callback.current(...args);
|
|
56
60
|
if (!current()) return undefined;
|
|
61
|
+
complete?.(result);
|
|
57
62
|
setState({ scope, isPending: false, error: null, result });
|
|
58
63
|
return result;
|
|
59
64
|
} catch (error) {
|