Skip to content

fix: adjust order to save extra questions and values #787

Open
tomrndom wants to merge 2 commits intomasterfrom
fix/sponsor-extra-questions-save-order
Open

fix: adjust order to save extra questions and values #787
tomrndom wants to merge 2 commits intomasterfrom
fix/sponsor-extra-questions-save-order

Conversation

@tomrndom
Copy link

@tomrndom tomrndom commented Feb 10, 2026

ref: https://app.clickup.com/t/86b7vwpb2

Signed-off-by: Tomás Castillo tcastilloboireau@gmail.com

Summary by CodeRabbit

  • Refactor
    • Improved submission flow for extra questions to correctly handle new versus existing questions.
    • Ensures immediate close when there are no values to save and proper sequencing when values exist.
    • Fixes ordering so values are saved with the correct question reference before closing the popup.

…essages

Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
@tomrndom tomrndom requested a review from smarcet February 10, 2026 12:39
@coderabbitai
Copy link

coderabbitai bot commented Feb 10, 2026

📝 Walkthrough

Walkthrough

Refactors handleSubmitExtraQuestion to separate save flows based on whether values exist and whether the extra question has an id, ensuring correct sequencing when creating a question and saving its values before closing the popup.

Changes

Cohort / File(s) Summary
Async Logic Refactor
src/components/forms/sponsor-general-form/extra-questions.js
Reworked handleSubmitExtraQuestion to add a hasValues guard, early-exit when no values, and distinct branches for creating a new question (save question → use returned eq.id to save values) vs. updating an existing question (save values → save question). Adjusted promise sequencing and closure timing of the popup.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • smarcet

Poem

🐰 I hopped through promises, one by one,
Saved questions first, then values done.
The popup closes, tidy and neat —
All answers nested, snug and sweet. ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: adjust order to save extra questions and values' directly and accurately describes the main change—reordering the save sequence for extra questions and their values to fix issues with save order and popup closure.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/sponsor-extra-questions-save-order

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@fntechgit fntechgit deleted a comment from coderabbitai bot Feb 11, 2026
Copy link

@smarcet smarcet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tomrndom please review comments

Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +80 to 100
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()
);
});
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Locate request helpers and error handlers
rg -n "function postRequest|const postRequest|export const postRequest" -C3

Repository: fntechgit/summit-admin

Length of output: 48


🏁 Script executed:

#!/bin/bash
# Search for putRequest
rg -n "function putRequest|const putRequest|export const putRequest" -C3

Repository: fntechgit/summit-admin

Length of output: 48


🏁 Script executed:

#!/bin/bash
# Search for error handlers
rg -n "snackbarErrorHandler|authErrorHandler" -C3

Repository: fntechgit/summit-admin

Length of output: 50379


🏁 Script executed:

#!/bin/bash
# Find the saveSponsorExtraQuestion and saveSponsorExtraQuestionValue implementations
rg -n "saveSponsorExtraQuestion|saveSponsorExtraQuestionValue" -C3

Repository: fntechgit/summit-admin

Length of output: 11586


🏁 Script executed:

#!/bin/bash
# Get full implementation of saveSponsorExtraQuestion
sed -n '874,950p' src/actions/sponsor-actions.js

Repository: fntechgit/summit-admin

Length of output: 2403


🏁 Script executed:

#!/bin/bash
# Get full implementation of saveSponsorExtraQuestionValue
sed -n '967,1050p' src/actions/sponsor-actions.js

Repository: fntechgit/summit-admin

Length of output: 2553


🏁 Script executed:

#!/bin/bash
# Find authErrorHandler definition
rg -n "authErrorHandler" -C5 src/actions/sponsor-actions.js | head -50

Repository: 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.js

Repository: 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.js

Repository: 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=5

Repository: 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.js

Repository: 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 -80

Repository: 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 -60

Repository: 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" -A10

Repository: 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 -60

Repository: 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.js

Repository: 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 -80

Repository: 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants