Skip to content

Quiz#122

Merged
Yash200237 merged 2 commits intomasterfrom
quiz
May 21, 2025
Merged

Quiz#122
Yash200237 merged 2 commits intomasterfrom
quiz

Conversation

@vinukab
Copy link
Copy Markdown
Contributor

@vinukab vinukab commented May 21, 2025

No description provided.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances user feedback by adding loading indicators and refining form data handling in the quiz and portfolio optimization flows.

  • Introduce isLoading state with a spinner on the quiz submission button.
  • Add loading states (issLoading and isRiskLoading) and spinners in the portfolio optimization component.
  • Update formData keys to snake_case and adjust JSX formatting for consistency.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/app/(dashboard)/dashboard/portfolio/quiz/page.tsx Added isLoading state, loader spinner, and disabled state for quiz submission button
src/app/(dashboard)/dashboard/portfolio/_components/port-opt-form.tsx Introduced issLoading/isRiskLoading states, loader spinner for quiz redirect, and updated formData fields to snake_case
Comments suppressed due to low confidence (1)

src/app/(dashboard)/dashboard/portfolio/_components/port-opt-form.tsx:114

  • The state variable issLoading and its setter setissLoading appear to have a typo and inconsistent casing. Rename them to isLoading and setIsLoading for clarity and to match standard camelCase convention.
const [issLoading, setissLoading] = useState(false);

Comment on lines +176 to 179
setIsLoading(true);
if (!user) return;
const val = totalScore;
if (val === null || isNaN(val)) return;
Copy link

Copilot AI May 21, 2025

Choose a reason for hiding this comment

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

Calling setIsLoading(true) before the guard clauses (if (!user) return; and if (val === null || isNaN(val)) return;) can leave isLoading stuck in true if those early returns run. Move the loading flag after those checks or ensure it’s cleared in those branches.

Suggested change
setIsLoading(true);
if (!user) return;
const val = totalScore;
if (val === null || isNaN(val)) return;
if (!user) return;
const val = totalScore;
if (val === null || isNaN(val)) return;
setIsLoading(true);

Copilot uses AI. Check for mistakes.
Comment on lines +327 to +333
const qs = new URLSearchParams({
tickers: JSON.stringify(selectedTickers),
years,
inv: investmentAmount,
tgt: targetAmount,
}).toString();
router.push(`/dashboard/portfolio/quiz?${qs}`);
Copy link

Copilot AI May 21, 2025

Choose a reason for hiding this comment

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

You call setissLoading(true) on click but never reset it. If router.push fails or takes time, the button may remain disabled indefinitely. Consider resetting the loading state in a finally block or after navigation completes.

Suggested change
const qs = new URLSearchParams({
tickers: JSON.stringify(selectedTickers),
years,
inv: investmentAmount,
tgt: targetAmount,
}).toString();
router.push(`/dashboard/portfolio/quiz?${qs}`);
try {
const qs = new URLSearchParams({
tickers: JSON.stringify(selectedTickers),
years,
inv: investmentAmount,
tgt: targetAmount,
}).toString();
await router.push(`/dashboard/portfolio/quiz?${qs}`);
} catch (error) {
console.error("Navigation failed:", error);
// Optionally, show an error message to the user here
} finally {
setissLoading(false);
}

Copilot uses AI. Check for mistakes.
@Yash200237 Yash200237 merged commit 6b0ba43 into master May 21, 2025
3 checks passed
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.

3 participants