-
Notifications
You must be signed in to change notification settings - Fork 13
[TASK-14287] fix: show error on dynamic bank account form #1147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -43,11 +43,20 @@ interface DynamicBankAccountFormProps { | |||||||||||||||||||||||||||
| initialData?: Partial<IBankAccountDetails> | ||||||||||||||||||||||||||||
| flow?: 'claim' | 'withdraw' | ||||||||||||||||||||||||||||
| actionDetailsProps?: Partial<PeanutActionDetailsCardProps> | ||||||||||||||||||||||||||||
| error: string | null | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| export const DynamicBankAccountForm = forwardRef<{ handleSubmit: () => void }, DynamicBankAccountFormProps>( | ||||||||||||||||||||||||||||
| ( | ||||||||||||||||||||||||||||
| { country, onSuccess, initialData, flow = 'withdraw', actionDetailsProps, countryName: countryNameFromProps }, | ||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||
| country, | ||||||||||||||||||||||||||||
| onSuccess, | ||||||||||||||||||||||||||||
| initialData, | ||||||||||||||||||||||||||||
| flow = 'withdraw', | ||||||||||||||||||||||||||||
| actionDetailsProps, | ||||||||||||||||||||||||||||
| countryName: countryNameFromProps, | ||||||||||||||||||||||||||||
| error, | ||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||
|
Comment on lines
+51
to
+59
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Prevent duplicate error rendering: coalesce external and internal errors into one alert. Right now both - {submissionError && <ErrorAlert description={submissionError} />}
- {error && <ErrorAlert description={error} />}
+ { (error ?? submissionError) && (
+ <ErrorAlert description={(error ?? submissionError)!} />
+ )}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||
| ref | ||||||||||||||||||||||||||||
| ) => { | ||||||||||||||||||||||||||||
| const { user } = useAuth() | ||||||||||||||||||||||||||||
|
|
@@ -394,6 +403,7 @@ export const DynamicBankAccountForm = forwardRef<{ handleSubmit: () => void }, D | |||||||||||||||||||||||||||
| Review | ||||||||||||||||||||||||||||
| </Button> | ||||||||||||||||||||||||||||
| {submissionError && <ErrorAlert description={submissionError} />} | ||||||||||||||||||||||||||||
| {error && <ErrorAlert description={error} />} | ||||||||||||||||||||||||||||
| </form> | ||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Make
errorprop optional to avoid breaking callers.This is a public API change; making
errorrequired will break any unupdated usages. Prefer optional with a safe default.📝 Committable suggestion
🤖 Prompt for AI Agents