aboutsummaryrefslogtreecommitdiff
path: root/packages/web-util/src
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2024-04-29 11:42:52 -0300
committerSebastian <sebasjm@gmail.com>2024-04-29 11:42:52 -0300
commit4ed3a05fdd97b08085e5a390963f9810b93a75fd (patch)
tree79b9a76aa3af65b83bcd4c77b42845b5c32d9af3 /packages/web-util/src
parent44308fb898372c059cf03a23ad1169d5a6e0c296 (diff)
downloadwallet-core-4ed3a05fdd97b08085e5a390963f9810b93a75fd.tar.xz
create form
Diffstat (limited to 'packages/web-util/src')
-rw-r--r--packages/web-util/src/components/Button.tsx4
-rw-r--r--packages/web-util/src/hooks/useNotifications.ts4
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 {