Skip to content

Commit a507424

Browse files
feat: show real error if it's a validation error in error modal (#1093)
1 parent 826f7e8 commit a507424

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed

src/components/modal/components/Profile/Lens/LensFormFields.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { Typography } from "../../../../ui/Typography";
66
import { ProfileFormFields } from "../ProfileFormFields";
77

88
interface Props {
9-
onBlurName?: () => void;
109
logoSubtitle?: string;
1110
coverSubtitle?: string;
1211
disableHandle?: boolean;
@@ -18,7 +17,6 @@ interface Props {
1817
}
1918

2019
export default function LensFormFields({
21-
onBlurName,
2220
logoSubtitle,
2321
coverSubtitle,
2422
disableHandle,
@@ -42,7 +40,6 @@ export default function LensFormFields({
4240
<div>{children}</div>
4341
</Grid>
4442
<ProfileFormFields
45-
onBlurName={onBlurName}
4643
logoSubtitle={logoSubtitle}
4744
coverSubtitle={coverSubtitle}
4845
handleComponent={

src/components/modal/components/Profile/ProfileFormFields.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { GridContainer } from "../../../ui/GridContainer";
1212
import { ProfilePreview } from "./ProfilePreview";
1313

1414
interface Props {
15-
onBlurName?: () => void;
1615
logoSubtitle?: string;
1716
coverSubtitle?: string;
1817
handleComponent?: ReactNode;
@@ -23,7 +22,6 @@ interface Props {
2322
}
2423

2524
export function ProfileFormFields({
26-
onBlurName,
2725
logoSubtitle,
2826
coverSubtitle,
2927
handleComponent: HandleComponent,
@@ -97,12 +95,7 @@ export function ProfileFormFields({
9795
</FormField>
9896
</GridContainer>
9997
<FormField title="Your brand / name" required>
100-
<Input
101-
name="name"
102-
placeholder="Name"
103-
onBlur={onBlurName}
104-
disabled={disableName}
105-
/>
98+
<Input name="name" placeholder="Name" disabled={disableName} />
10699
</FormField>
107100
{HandleComponent}
108101
<FormField title="Description" required>

src/pages/batch-create-offers/BatchCreateOffers.tsx

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ function BatchCreateOffers() {
120120
setOffersList([]);
121121
setInvalidFile(false);
122122
}
123+
if (e.target) {
124+
// reset value so the same file can be uploaded again (in case the file was modified)
125+
e.target.value = "";
126+
}
123127
};
124128

125129
const sellerOffers = useOffers(
@@ -232,12 +236,24 @@ function BatchCreateOffers() {
232236
if (hasUserRejectedTx) {
233237
showModal("TRANSACTION_FAILED");
234238
} else {
239+
const defaultError = "Please retry this action";
240+
const userFriendlyError = await extractUserFriendlyError(error, {
241+
txResponse: txResponse as providers.TransactionResponse,
242+
provider: signer?.provider as Provider,
243+
defaultError
244+
});
245+
const isValidationError =
246+
error &&
247+
typeof error === "object" &&
248+
"errors" in error &&
249+
Array.isArray(error.errors) &&
250+
Object.values(error.errors).every((err) => typeof err === "string");
235251
showModal("TRANSACTION_FAILED", {
236252
errorMessage: "Something went wrong",
237-
detailedErrorMessage: await extractUserFriendlyError(error, {
238-
txResponse: txResponse as providers.TransactionResponse,
239-
provider: signer?.provider as Provider
240-
})
253+
detailedErrorMessage:
254+
defaultError === userFriendlyError && isValidationError
255+
? (error?.errors as string[])?.join("\n") || defaultError
256+
: defaultError
241257
});
242258
}
243259
}

0 commit comments

Comments
 (0)