diff options
author | Sebastian <sebasjm@gmail.com> | 2024-04-29 11:42:52 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2024-04-29 11:42:52 -0300 |
commit | 4ed3a05fdd97b08085e5a390963f9810b93a75fd (patch) | |
tree | 79b9a76aa3af65b83bcd4c77b42845b5c32d9af3 /packages/web-util | |
parent | 44308fb898372c059cf03a23ad1169d5a6e0c296 (diff) | |
download | wallet-core-4ed3a05fdd97b08085e5a390963f9810b93a75fd.tar.xz |
create form
Diffstat (limited to 'packages/web-util')
-rw-r--r-- | packages/web-util/src/components/Button.tsx | 4 | ||||
-rw-r--r-- | packages/web-util/src/hooks/useNotifications.ts | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/packages/web-util/src/components/Button.tsx b/packages/web-util/src/components/Button.tsx index 18cecbdab..b142114e7 100644 --- a/packages/web-util/src/components/Button.tsx +++ b/packages/web-util/src/components/Button.tsx @@ -46,7 +46,7 @@ export interface ButtonHandler<T extends OperationResult<A, B>, A, B> { onClick: () => Promise<T | undefined>; onNotification: (n: NotificationMessage) => void; onOperationSuccess: OnOperationSuccesReturnType<T>; - onOperationFail: OnOperationFailReturnType<T>; + onOperationFail?: OnOperationFailReturnType<T>; onOperationComplete?: () => void; } @@ -99,7 +99,7 @@ export function Button<T extends OperationResult<A, B>, A, B>({ if (resp.type === "fail") { const d = 'detail' in resp ? resp.detail : undefined - const title = handler.onOperationFail(resp as any); + const title = !handler.onOperationFail ? "Unexpected error." as TranslatedString : handler.onOperationFail(resp as any); handler.onNotification({ title, type: "error", diff --git a/packages/web-util/src/hooks/useNotifications.ts b/packages/web-util/src/hooks/useNotifications.ts index 81a1ae91e..103b88c86 100644 --- a/packages/web-util/src/hooks/useNotifications.ts +++ b/packages/web-util/src/hooks/useNotifications.ts @@ -209,7 +209,7 @@ export function useLocalNotification(): [ type HandlerMaker = <T extends OperationResult<A, B>, A, B>( onClick: () => Promise<T | undefined>, onOperationSuccess: OnOperationSuccesReturnType<T>, - onOperationFail: OnOperationFailReturnType<T>, + onOperationFail?: OnOperationFailReturnType<T>, onOperationComplete?: () => void, ) => ButtonHandler<T, A, B>; @@ -231,7 +231,7 @@ export function useLocalNotificationHandler(): [ function makeHandler<T extends OperationResult<A, B>, A, B>( onClick: () => Promise<T | undefined>, onOperationSuccess:OnOperationSuccesReturnType<T>, - onOperationFail: OnOperationFailReturnType<T>, + onOperationFail?: OnOperationFailReturnType<T>, onOperationComplete?: () => void, ): ButtonHandler<T, A, B> { return { |