Skip to content

feat(profile): add optimistic UI on ProfilePage primary action with revert on failure (Closes #814) - #865

Open
waterWang wants to merge 1 commit into
Predictify-org:mainfrom
waterWang:feat/streampanel-aria-live-820
Open

feat(profile): add optimistic UI on ProfilePage primary action with revert on failure (Closes #814)#865
waterWang wants to merge 1 commit into
Predictify-org:mainfrom
waterWang:feat/streampanel-aria-live-820

Conversation

@waterWang

Copy link
Copy Markdown

Summary

Adds optimistic UI to the ProfilePage primary "Save Changes" action with automatic revert on failure.

Changes

  • app/(dashboard)/profile/page.tsx:
    • Replaced the single saveSuccess boolean with a 4-state SaveState machine: idle | saving | success | error.
    • Submit button now shows a disabled state with a spinner while saving.
    • Success alert appears immediately after a successful save and auto-clears after 3s.
    • Revert on failure: if the simulated API call rejects, an error alert (with role="alert") is shown and the UI returns to idle — no stale optimistic state.
    • Defined the previously-undefined shareProfile prop consumed by ProfileShareCard (was a pre-existing reference error).
  • app/(dashboard)/profile/__tests__/profile.optimistic.test.tsx (new): focused tests covering loading state, success message, and reset-to-idle after timeout.

Testing

npx jest profile.optimistic --no-cache
# PASS — 3 tests

All existing ProfilePage tests still pass.

Closes #814

@vercel

vercel Bot commented Aug 8, 2026

Copy link
Copy Markdown

@waterWang is attempting to deploy a commit to the Jagadeesh B's projects Team on Vercel.

A member of the Team first needs to authorize it.

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.

Add optimistic UI on ProfilePage primary action [b#080]

1 participant