Skip to content

chore(angular-react): Migrate SettingsComponent to React#8

Open
devin-ai-integration[bot] wants to merge 4 commits intomainfrom
devin/1776186449-angular-to-react-settings
Open

chore(angular-react): Migrate SettingsComponent to React#8
devin-ai-integration[bot] wants to merge 4 commits intomainfrom
devin/1776186449-angular-to-react-settings

Conversation

@devin-ai-integration
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot commented Apr 14, 2026

Summary

Adds a React functional component (SettingsComponent.tsx) alongside the existing Angular SettingsComponent, as part of an incremental Angular-to-React migration. The original Angular files are not modified or removed.

The React component faithfully ports:

  • Form state (image, username, bio, email, password) via useState, replacing Angular's FormGroup/FormControl
  • Mount logic via useEffect with a useRef guard for mount-only execution, replacing ngOnInit — loads current user and populates form
  • Submit handler with isSubmitting guard and error display, replacing (ngSubmit) + takeUntilDestroyed subscription
  • Logout handler, replacing (click)="logout()"
  • JSX template using the same CSS class names from the Angular template
  • An inline ListErrors helper mirroring the Angular ListErrorsComponent

External dependencies (UserService, Router) are passed as props with TODO comments marking where React context/hooks should replace them.

Updates since last revision

  • Fixed useEffect mount-only initialization: added a useRef(false) guard so the effect body executes exactly once, preventing parent re-renders from resetting in-progress form edits (addresses Devin Review feedback).
  • Widened updateUser prop type from Partial<User> to Partial<User> & { password?: string } so that type-safe implementers won't silently drop the password field from the API payload (addresses Devin Review feedback).

Review & Testing Checklist for Human

  • Component is entirely untested at runtime: React is not installed in this Angular project, so the TSX has never been compiled or rendered. Review the component side-by-side with the Angular source (settings.component.ts + settings.component.html) and confirm all form fields, event handlers, and control flow are faithfully ported.
  • Unsafe error type cast (line ~170): setErrors(err as Errors) assumes the rejected promise value matches the Errors interface. This mirrors the Angular code's behavior but could break at runtime if the API returns a different error shape. Consider whether a type guard or normalization is needed.
  • Password required validator dropped: The Angular version had Validators.required on the password FormControl, but the React version has no equivalent validation. Confirm this is intentional.
  • Duplicated User/Errors interfaces: These are copy-pasted from the Angular models rather than imported. Verify alignment with the source types and consider whether shared types are preferable once more components are migrated.

Suggested test plan: Since React cannot be compiled in this project yet, the best verification is a manual side-by-side review of the Angular and React sources. Once React is added as a dependency in a future step, render the component with mock props and verify: (1) form populates from getCurrentUser, (2) edits persist across re-renders, (3) submit calls updateUser with all fields including password, (4) errors display correctly, (5) logout fires the callback.

Notes

  • Prettier formatting passes cleanly (bun run format produced no changes).
  • TypeScript compilation fails as expected since react and react-dom are not project dependencies — this is by design for this incremental migration step.
  • Pre-existing test failures (missing zone.js in vitest) are unrelated to this change.

Link to Devin session: https://app.devin.ai/sessions/12fd2d3198254e8bbe9b9293879f09f4
Requested by: @lburgers


Open with Devin

devin-ai-integration Bot and others added 2 commits April 14, 2026 17:08
Co-Authored-By: Lukas Burger <lukaskburger@gmail.com>
- useState for form fields (image, username, bio, email, password), errors, isSubmitting
- useEffect for ngOnInit logic (load current user on mount)
- onSubmit handler for form submission with error handling
- handleLogout handler for logout functionality
- Controlled inputs replacing Angular reactive form bindings
- JSX template converted from Angular template with existing CSS classes
- TODO comments for UserService and Router dependencies

Co-Authored-By: Lukas Burger <lukaskburger@gmail.com>
@devin-ai-integration
Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

devin-ai-integration[bot]

This comment was marked as resolved.

Addresses Devin Review feedback: the useEffect had getCurrentUser in its
dependency array, causing it to re-run on every parent re-render (since
function props create new references). This would silently discard
unsaved form edits.

Added a useRef(false) guard so the effect body executes exactly once,
matching Angular's ngOnInit semantics.

Co-Authored-By: Lukas Burger <lukaskburger@gmail.com>
devin-ai-integration[bot]

This comment was marked as resolved.

The User interface has no password field, so Partial<User> would cause
type-safe implementers to silently drop password updates. Widen the
updateUser prop type to Partial<User> & { password?: string }.

Co-Authored-By: Lukas Burger <lukaskburger@gmail.com>
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.

1 participant