From a50742430fbd51b8e0e10985a99146e1a773bf40 Mon Sep 17 00:00:00 2001
From: albertfolch-redeemeum
<102516373+albertfolch-redeemeum@users.noreply.github.com>
Date: Thu, 20 Jun 2024 14:53:03 +0200
Subject: [PATCH] feat: show real error if it's a validation error in error
modal (#1093)
---
.../Profile/Lens/LensFormFields.tsx | 3 ---
.../components/Profile/ProfileFormFields.tsx | 9 +------
.../batch-create-offers/BatchCreateOffers.tsx | 24 +++++++++++++++----
3 files changed, 21 insertions(+), 15 deletions(-)
diff --git a/src/components/modal/components/Profile/Lens/LensFormFields.tsx b/src/components/modal/components/Profile/Lens/LensFormFields.tsx
index 2cddf55d3..18c88e1ed 100644
--- a/src/components/modal/components/Profile/Lens/LensFormFields.tsx
+++ b/src/components/modal/components/Profile/Lens/LensFormFields.tsx
@@ -6,7 +6,6 @@ import { Typography } from "../../../../ui/Typography";
import { ProfileFormFields } from "../ProfileFormFields";
interface Props {
- onBlurName?: () => void;
logoSubtitle?: string;
coverSubtitle?: string;
disableHandle?: boolean;
@@ -18,7 +17,6 @@ interface Props {
}
export default function LensFormFields({
- onBlurName,
logoSubtitle,
coverSubtitle,
disableHandle,
@@ -42,7 +40,6 @@ export default function LensFormFields({
{children}
void;
logoSubtitle?: string;
coverSubtitle?: string;
handleComponent?: ReactNode;
@@ -23,7 +22,6 @@ interface Props {
}
export function ProfileFormFields({
- onBlurName,
logoSubtitle,
coverSubtitle,
handleComponent: HandleComponent,
@@ -97,12 +95,7 @@ export function ProfileFormFields({
-
+
{HandleComponent}
diff --git a/src/pages/batch-create-offers/BatchCreateOffers.tsx b/src/pages/batch-create-offers/BatchCreateOffers.tsx
index f9359a6a5..c0025d59f 100644
--- a/src/pages/batch-create-offers/BatchCreateOffers.tsx
+++ b/src/pages/batch-create-offers/BatchCreateOffers.tsx
@@ -120,6 +120,10 @@ function BatchCreateOffers() {
setOffersList([]);
setInvalidFile(false);
}
+ if (e.target) {
+ // reset value so the same file can be uploaded again (in case the file was modified)
+ e.target.value = "";
+ }
};
const sellerOffers = useOffers(
@@ -232,12 +236,24 @@ function BatchCreateOffers() {
if (hasUserRejectedTx) {
showModal("TRANSACTION_FAILED");
} else {
+ const defaultError = "Please retry this action";
+ const userFriendlyError = await extractUserFriendlyError(error, {
+ txResponse: txResponse as providers.TransactionResponse,
+ provider: signer?.provider as Provider,
+ defaultError
+ });
+ const isValidationError =
+ error &&
+ typeof error === "object" &&
+ "errors" in error &&
+ Array.isArray(error.errors) &&
+ Object.values(error.errors).every((err) => typeof err === "string");
showModal("TRANSACTION_FAILED", {
errorMessage: "Something went wrong",
- detailedErrorMessage: await extractUserFriendlyError(error, {
- txResponse: txResponse as providers.TransactionResponse,
- provider: signer?.provider as Provider
- })
+ detailedErrorMessage:
+ defaultError === userFriendlyError && isValidationError
+ ? (error?.errors as string[])?.join("\n") || defaultError
+ : defaultError
});
}
}