Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 26 additions & 9 deletions src/components/forms/sponsor-general-form/extra-questions.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,36 @@ const SponsorExtraQuestions = ({

const handleSubmitExtraQuestion = (extraQuestion) => {
const { valuesToSave, ...extraQuestionToSave } = extraQuestion;
saveSponsorExtraQuestion(extraQuestionToSave).then((eq) => {
// after save question, check if values needs to be saved
if (valuesToSave && valuesToSave.length > 0) {
const extraQuestionId = extraQuestionToSave.id || eq.id;

const hasValues = valuesToSave && valuesToSave.length > 0;

if (!hasValues) {
saveSponsorExtraQuestion(extraQuestionToSave).then(() =>
handleCloseExtraQuestionPopup()
);
return;
}

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

};

Expand Down