fix: adjust order to save extra questions and values #787
fix: adjust order to save extra questions and values #787
Conversation
…essages Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
📝 WalkthroughWalkthroughRefactors Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/components/forms/sponsor-general-form/extra-questions.js`:
- Around line 80-100: The dialog is closed unconditionally and promise chains
aren't returned; update the create, update, and no-values flows to return the
composed promises and only close the popup on successful saves: when creating
(saveSponsorExtraQuestion -> saveSponsorExtraQuestionValue), replace the
Promise.all(...).finally(...) with Promise.all(...).then(() =>
handleCloseExtraQuestionPopup()) and return the promise chain (including the
outer saveSponsorExtraQuestion promise); when updating (valuesToSave ->
saveSponsorExtraQuestionValue then saveSponsorExtraQuestion), return the
Promise.all(...).then(() => saveSponsorExtraQuestion(...).then(() =>
handleCloseExtraQuestionPopup())) so failures propagate; and in the no-values
path return saveSponsorExtraQuestion(...).then(() =>
handleCloseExtraQuestionPopup()) so callers can handle rejections.
Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/components/forms/sponsor-general-form/extra-questions.js`:
- Around line 80-100: The current flows using saveSponsorExtraQuestion and
saveSponsorExtraQuestionValue (for extraQuestionToSave and valuesToSave) only
handle success paths and can leave the popup open on API rejection; update all
three promise chains (the branch that creates the question then saves values,
the branch that saves values for an existing question, and the branch that saves
values then the question) to attach .catch handlers that either call
handleCloseExtraQuestionPopup() on error or set an error state/notification
before closing; ensure every Promise.all(...) and every
saveSponsorExtraQuestion(...) has a .catch that handles/reports the error and
then closes the popup so the UI never remains stuck on failure.
| if (!extraQuestionToSave.id) { | ||
| saveSponsorExtraQuestion(extraQuestionToSave).then((eq) => { | ||
| const saveValuePromises = valuesToSave.map((value) => | ||
| saveSponsorExtraQuestionValue(extraQuestionId, value) | ||
| saveSponsorExtraQuestionValue(eq.id, value) | ||
| ); | ||
| Promise.all(saveValuePromises).finally(() => | ||
| Promise.all(saveValuePromises).then(() => | ||
| handleCloseExtraQuestionPopup() | ||
| ); | ||
| } else { | ||
| handleCloseExtraQuestionPopup(); | ||
| } | ||
| }); | ||
| return; | ||
| } | ||
|
|
||
| const saveValuePromises = valuesToSave.map((value) => | ||
| saveSponsorExtraQuestionValue(extraQuestionToSave.id, value) | ||
| ); | ||
|
|
||
| Promise.all(saveValuePromises).then(() => { | ||
| saveSponsorExtraQuestion(extraQuestionToSave).then(() => | ||
| handleCloseExtraQuestionPopup() | ||
| ); | ||
| }); |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Locate request helpers and error handlers
rg -n "function postRequest|const postRequest|export const postRequest" -C3Repository: fntechgit/summit-admin
Length of output: 48
🏁 Script executed:
#!/bin/bash
# Search for putRequest
rg -n "function putRequest|const putRequest|export const putRequest" -C3Repository: fntechgit/summit-admin
Length of output: 48
🏁 Script executed:
#!/bin/bash
# Search for error handlers
rg -n "snackbarErrorHandler|authErrorHandler" -C3Repository: fntechgit/summit-admin
Length of output: 50379
🏁 Script executed:
#!/bin/bash
# Find the saveSponsorExtraQuestion and saveSponsorExtraQuestionValue implementations
rg -n "saveSponsorExtraQuestion|saveSponsorExtraQuestionValue" -C3Repository: fntechgit/summit-admin
Length of output: 11586
🏁 Script executed:
#!/bin/bash
# Get full implementation of saveSponsorExtraQuestion
sed -n '874,950p' src/actions/sponsor-actions.jsRepository: fntechgit/summit-admin
Length of output: 2403
🏁 Script executed:
#!/bin/bash
# Get full implementation of saveSponsorExtraQuestionValue
sed -n '967,1050p' src/actions/sponsor-actions.jsRepository: fntechgit/summit-admin
Length of output: 2553
🏁 Script executed:
#!/bin/bash
# Find authErrorHandler definition
rg -n "authErrorHandler" -C5 src/actions/sponsor-actions.js | head -50Repository: fntechgit/summit-admin
Length of output: 1427
🏁 Script executed:
#!/bin/bash
# Find where authErrorHandler is imported from
rg -n "import.*authErrorHandler|from.*authErrorHandler" src/actions/sponsor-actions.jsRepository: fntechgit/summit-admin
Length of output: 48
🏁 Script executed:
#!/bin/bash
# Find imports at the top of sponsor-actions.js
head -40 src/actions/sponsor-actions.jsRepository: fntechgit/summit-admin
Length of output: 1309
🏁 Script executed:
#!/bin/bash
# Find the definition/source of postRequest and putRequest
rg -n "export.*postRequest|export.*putRequest|function postRequest|function putRequest" --max-count=5Repository: fntechgit/summit-admin
Length of output: 48
🏁 Script executed:
#!/bin/bash
# Find where postRequest/putRequest are imported from
rg -n "import.*postRequest|import.*putRequest" src/actions/sponsor-actions.jsRepository: fntechgit/summit-admin
Length of output: 48
🏁 Script executed:
#!/bin/bash
# Search for snackbarErrorHandler definition and usage pattern
rg -n "snackbarErrorHandler|snackbarSuccessHandler" -A2 -B2 | head -80Repository: fntechgit/summit-admin
Length of output: 5798
🏁 Script executed:
#!/bin/bash
# Look for patterns of how putRequest/postRequest handle errors by examining actual usage
rg -n "putRequest|postRequest" -A3 -B1 src/actions/ | grep -E "(putRequest|postRequest|\.then|\.catch)" | head -60Repository: fntechgit/summit-admin
Length of output: 3326
🏁 Script executed:
#!/bin/bash
# Check if there's any .catch or error handling after the .then calls in extra-questions.js
cat -n src/components/forms/sponsor-general-form/extra-questions.js | sed -n '70,105p'Repository: fntechgit/summit-admin
Length of output: 1258
🏁 Script executed:
#!/bin/bash
# Find base-actions.js where snackbarErrorHandler is defined
fd -n "base-actions.js"Repository: fntechgit/summit-admin
Length of output: 296
🏁 Script executed:
#!/bin/bash
# Find the definition of snackbarErrorHandler and snackbarSuccessHandler
rg -n "export.*snackbarErrorHandler|export.*snackbarSuccessHandler|function snackbarErrorHandler|function snackbarSuccessHandler" -A10Repository: fntechgit/summit-admin
Length of output: 659
🏁 Script executed:
#!/bin/bash
# Search for authErrorHandler definition - it's imported from openstack-uicore-foundation
# but let's check if there's a wrapper or override in this codebase
rg -n "export.*authErrorHandler" src/Repository: fntechgit/summit-admin
Length of output: 48
🏁 Script executed:
#!/bin/bash
# Look at the context around snackbarErrorHandler to understand error handling flow
cat -n src/actions/base-actions.js | head -60Repository: fntechgit/summit-admin
Length of output: 2316
🏁 Script executed:
#!/bin/bash
# Check if promises are being caught anywhere in the extra-questions flow
rg -n "\.catch\|\.finally" src/components/forms/sponsor-general-form/extra-questions.jsRepository: fntechgit/summit-admin
Length of output: 48
🏁 Script executed:
#!/bin/bash
# Look for more complete context - check how putRequest/postRequest from openstack-uicore-foundation work
# by examining similar patterns in the codebase with .catch handlers
rg -n "postRequest.*snackbarErrorHandler|putRequest.*snackbarErrorHandler" -A5 src/actions/ | head -80Repository: fntechgit/summit-admin
Length of output: 48
Add error handling to close popup on request failures.
The popup closure depends on successful .then() callbacks, but if saveSponsorExtraQuestion or saveSponsorExtraQuestionValue reject (which they do on API errors), the popup remains open without user feedback. Add .catch() to close the popup or display error state in all three flows (lines 74–76, 81–88, 96–100).
🤖 Prompt for AI Agents
In `@src/components/forms/sponsor-general-form/extra-questions.js` around lines 80
- 100, The current flows using saveSponsorExtraQuestion and
saveSponsorExtraQuestionValue (for extraQuestionToSave and valuesToSave) only
handle success paths and can leave the popup open on API rejection; update all
three promise chains (the branch that creates the question then saves values,
the branch that saves values for an existing question, and the branch that saves
values then the question) to attach .catch handlers that either call
handleCloseExtraQuestionPopup() on error or set an error state/notification
before closing; ensure every Promise.all(...) and every
saveSponsorExtraQuestion(...) has a .catch that handles/reports the error and
then closes the popup so the UI never remains stuck on failure.
ref: https://app.clickup.com/t/86b7vwpb2
Signed-off-by: Tomás Castillo tcastilloboireau@gmail.com
Summary by CodeRabbit