chore(angular-react): Migrate FavoriteButtonComponent to React#4
Open
devin-ai-integration[bot] wants to merge 3 commits intomainfrom
Open
chore(angular-react): Migrate FavoriteButtonComponent to React#4devin-ai-integration[bot] wants to merge 3 commits intomainfrom
devin-ai-integration[bot] wants to merge 3 commits intomainfrom
Conversation
Co-Authored-By: Lukas Burger <lukaskburger@gmail.com>
feat: translate template to JSX feat: wire up inputs, events, and dependencies Co-Authored-By: Lukas Burger <lukaskburger@gmail.com>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Co-Authored-By: Lukas Burger <lukaskburger@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a React equivalent of the Angular
FavoriteButtonComponentatsrc/app/features/article/components/FavoriteButton.tsx. This is a 1:1 migration as part of an Angular-to-React conversion effort. The original Angular component is not removed.Key translation decisions:
signal()(isSubmitting) →useState@Output() toggleEventEmitter →onTogglecallback prop@Input() article→articleprop with locally-definedArticleinterfaceswitchMap/takeUntilDestroyed→async/awaitwithuseCallback<ng-content>→props.childrenArticlesService,UserService,Router) → callback props (onFavorite,onUnfavorite,isAuthenticated,onNavigateToRegister) with TODO comments for future wiringUpdates since last revision
onToggleemission: WhenonFavorite/onUnfavoritecallbacks are not provided, the component now returns early instead of falling through toonToggle, which would have falsely signalled a state change to the parent. This matches the Angular original wheretoggle.emit()only fires after a real service response.Review & Testing Checklist for Human
Articleinterface is redefined locally instead of importing from the existing shared model. Verify it matches the canonicalArticletype insrc/app/core/api-types/and decide whether to extract a shared type file.catch {}block (L85) is a no-op, matching the Angular version's empty error callback. Confirm this is acceptable or if errors should be surfaced/logged.@types/reactare not installed in this Angular project, so this file cannot be compiled or rendered yet. Manually review the TypeScript for correctness.<FavoriteButton article={mockArticle} isAuthenticated={true} onFavorite={...} onUnfavorite={...}>♥ 5</FavoriteButton>and verify: (1) correct CSS class toggles betweenbtn-primary/btn-outline-primarybased onfavorited, (2) button disables during submission, (3) unauthenticated users triggeronNavigateToRegister, (4) omittingonFavorite/onUnfavoritedoes not fireonToggle.Notes
ChangeDetectionStrategy.OnPushwith signals — the React equivalent relies on standard React reconciliation, which is functionally equivalent for this use case.favoritesCountis included in theArticleinterface but not rendered directly by this component (it was rendered by the parent via<ng-content>in Angular, and viachildrenin React). This is intentional.onFavorite/onUnfavoriteare optional callback props with TODO comments. The component safely no-ops when they are absent.Link to Devin session: https://app.devin.ai/sessions/f9f1660d80a8458aa947e102c96b7405
Requested by: @lburgers