Skip to content

Feature/newsletter page #451

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Feature/newsletter page #451

wants to merge 5 commits into from

Conversation

marcin-hoa
Copy link
Contributor

@marcin-hoa marcin-hoa commented May 29, 2025

We now have a /newsletter page with success state. So on /newsletter?nm=confirmed you will see another content of the page. /newsletter without any queryParams still has the newsletter description and form.

Summary by CodeRabbit

  • New Features

    • Added a dedicated newsletter navigation link labeled "Angular.letter".
    • Introduced a name input field to the newsletter sign-up form for personalized subscriptions.
    • Enhanced the newsletter page with a detailed description and a more informative subscription confirmation message.
    • Implemented a new, accessible confirmation screen after successful newsletter sign-up.
  • Refactor

    • Improved newsletter page structure for clearer separation between subscription and confirmation views.
    • Migrated templates to external files and adopted a more reactive, modular approach for better maintainability.
  • Localization

    • Updated English and Polish translations to reflect new newsletter features and improved page structure.

Copy link

coderabbitai bot commented May 29, 2025

Walkthrough

The changes introduce a new newsletter feature to the blog application. This includes updates to English and Polish localization files, the addition of a "newsletter" navigation link, a new input field for the user's name in the newsletter form, and a significant refactor of the newsletter page to use modular components, reactive signals, and a confirmation success component.

Changes

File(s) Change Summary
apps/blog/src/assets/i18n/en.json, apps/blog/src/assets/i18n/pl.json Updated and restructured localization content for newsletter navigation, form placeholders, and confirmation messages.
libs/blog/layouts/ui-navigation/src/lib/navigation/navigation.component.ts Added "newsletter" navigation item with translation key and route.
libs/blog/newsletter/feature-newsletter/src/lib/feature-newsletter/newsletter.component.html Added a name input field to the newsletter signup form, with localization and accessibility attributes.
libs/blog/newsletter/feature-newsletter/src/lib/feature-newsletter/newsletter.component.ts Added name form control with required validation to the newsletter form.
libs/blog/newsletter/feature-newsletter/src/lib/page/newsletter-page.component.html New template: renders newsletter description, signup form, and confirmation component based on query parameters.
libs/blog/newsletter/feature-newsletter/src/lib/page/newsletter-page.component.ts Refactored to use external template, reactive signals, and modular UI components; added confirmation page logic.
libs/blog/newsletter/feature-newsletter/src/lib/page/newsletter-succes/newsletter-succes.component.html New presentational template for newsletter subscription success confirmation.
libs/blog/newsletter/feature-newsletter/src/lib/page/newsletter-succes/newsletter-succes.component.ts New presentational Angular component for displaying newsletter subscription success.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Navigation
    participant NewsletterPage
    participant NewsletterForm
    participant NewsletterSuccess

    User->>Navigation: Clicks "Newsletter" link
    Navigation->>NewsletterPage: Navigates to /newsletter
    NewsletterPage->>NewsletterForm: Displays newsletter signup form
    User->>NewsletterForm: Enters name and email, submits form
    NewsletterForm->>NewsletterPage: On success, redirect with ?nm=confirmed
    NewsletterPage->>NewsletterSuccess: Shows confirmation message
    NewsletterSuccess->>User: User sees thank you and return button
Loading

Poem

In the warren of code, a letter takes flight,
With name and email, you sign up just right.
A hop to success, a message appears—
"Thank you, dear bunny, for lending your ears!"
Now newsletters bloom in languages two,
Angular.letter brings something new!
🐇💌


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fc5e887 and 766d70b.

📒 Files selected for processing (1)
  • libs/blog/newsletter/feature-newsletter/src/lib/page/newsletter-page.component.html (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • libs/blog/newsletter/feature-newsletter/src/lib/page/newsletter-page.component.html

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@valueadd-robot
Copy link

PR is detected, will deploy to dev environment

@valueadd-robot
Copy link

Deployed to dev environment
Branch: feature/newsletter-page
BFF URL: https://67efbc48-blog-bff-dev.contact-ef8.workers.dev
Deploy URL: https://cbf49bb2.angular-love-client.pages.dev
Alias URL: https://feature-newsletter-page.angular-love-client.pages.dev

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
libs/blog/newsletter/feature-newsletter/src/lib/page/newsletter-succes/newsletter-succes.component.html (1)

1-19: LGTM! Excellent accessibility and UX implementation.

The success component template demonstrates excellent practices:

  • Proper focus management with cdkTrapFocus and cdkFocusInitial
  • Good semantic HTML structure with appropriate headings
  • Internationalization support throughout
  • Clean, centered layout

Note: There appears to be a typo in the directory name "newsletter-succes" (should be "newsletter-success"), but this doesn't affect functionality and would be a breaking change to fix now.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 885edf3 and fc5e887.

📒 Files selected for processing (9)
  • apps/blog/src/assets/i18n/en.json (2 hunks)
  • apps/blog/src/assets/i18n/pl.json (2 hunks)
  • libs/blog/layouts/ui-navigation/src/lib/navigation/navigation.component.ts (1 hunks)
  • libs/blog/newsletter/feature-newsletter/src/lib/feature-newsletter/newsletter.component.html (1 hunks)
  • libs/blog/newsletter/feature-newsletter/src/lib/feature-newsletter/newsletter.component.ts (1 hunks)
  • libs/blog/newsletter/feature-newsletter/src/lib/page/newsletter-page.component.html (1 hunks)
  • libs/blog/newsletter/feature-newsletter/src/lib/page/newsletter-page.component.ts (1 hunks)
  • libs/blog/newsletter/feature-newsletter/src/lib/page/newsletter-succes/newsletter-succes.component.html (1 hunks)
  • libs/blog/newsletter/feature-newsletter/src/lib/page/newsletter-succes/newsletter-succes.component.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
libs/blog/newsletter/feature-newsletter/src/lib/page/newsletter-succes/newsletter-succes.component.ts (1)
libs/blog/newsletter/feature-newsletter/src/lib/page/newsletter-page.component.ts (1)
  • Component (18-37)
🔇 Additional comments (10)
libs/blog/layouts/ui-navigation/src/lib/navigation/navigation.component.ts (1)

53-57: LGTM! Navigation item follows established patterns.

The new newsletter navigation item is correctly implemented with proper translation path, routing, and test attributes, consistent with other navigation items.

libs/blog/newsletter/feature-newsletter/src/lib/feature-newsletter/newsletter.component.html (1)

16-23: LGTM! Name input follows accessibility best practices.

The new name input field is well-implemented with proper:

  • Accessibility attributes (aria-required, aria-label)
  • Form binding (formControlName="name")
  • Internationalization support (t('namePlaceholder'))
  • Consistent styling with other form elements
libs/blog/newsletter/feature-newsletter/src/lib/feature-newsletter/newsletter.component.ts (2)

41-43: LGTM! Form control properly configured.

The name form control is correctly implemented with appropriate validation.


69-77:

❓ Verification inconclusive

Verify if name data should be included in the API call.

The form now collects the user's name but the postEmailAddress method only sends the email address to the newsletter store. Consider whether the name should also be included in the subscription request.


🏁 Script executed:

#!/bin/bash
# Check if the newsletter store supports name parameter
ast-grep --pattern 'postEmailAddress($$$) {
  $$$
}'

Length of output: 54


🏁 Script executed:

#!/bin/bash
# Search for all references and definitions of postEmailAddress
rg -n "postEmailAddress"

echo "----- Component imports and constructor -----"
sed -n '1,50p' libs/blog/newsletter/feature-newsletter/src/lib/feature-newsletter/newsletter.component.ts

echo "----- Locating NewsletterStore implementations -----"
rg -l "class.*NewsletterStore" | xargs -I {} sh -c 'echo "File: {}"; sed -n "1,50p" "{}"'

Length of output: 2325


🏁 Script executed:

#!/bin/bash
# Display the implementation of NewsletterStore to inspect postEmailAddress signature
sed -n '1,200p' libs/blog/newsletter/data-access/src/lib/state/newsletter.store.ts

Length of output: 1336


Review NewsletterStore API method signature

The postEmailAddress store method is defined as rxMethod<string>, so it only ever sends the email string:

  • NewsletterStore (libs/blog/newsletter/data-access/src/lib/state/newsletter.store.ts)
    postEmailAddress: rxMethod<string>()
  • NewsletterService.subscribe is only called with a single email.

Your form now collects name, but that value isn’t passed through to the API. Please confirm whether:

  • The backend subscription endpoint supports submitting both name and email.
    • If yes, update:
      • NewsletterService.subscribe to accept a { name: string; email: string } payload.
      • postEmailAddress to rxMethod<{ name: string; email: string }>(…).
      • The component call to pass both this.form.controls['name'].value and email.
  • If the API only accepts email, remove the name field or shelve it for future use.
apps/blog/src/assets/i18n/en.json (1)

28-28: LGTM! Well-structured localization updates.

The localization changes are well-organized and support the new newsletter feature effectively:

  • Navigation item follows existing patterns
  • Form placeholders are appropriately added
  • Newsletter page structure correctly separates main content from success state
  • Success object provides comprehensive localization for the confirmation flow

Also applies to: 99-99, 106-112

libs/blog/newsletter/feature-newsletter/src/lib/page/newsletter-page.component.html (1)

1-26: Excellent template structure with modern Angular features.

The template demonstrates several best practices:

  • Proper use of Angular's new control flow syntax (@if/@else)
  • Clean conditional rendering based on reactive signals
  • Responsive design with appropriate breakpoint handling
  • Good accessibility with aria-labelledby attribute
  • Well-structured component composition with card components
libs/blog/newsletter/feature-newsletter/src/lib/page/newsletter-succes/newsletter-succes.component.ts (1)

10-23: Good component structure and performance optimization.

The component demonstrates good practices:

  • Appropriate imports for required functionality
  • OnPush change detection strategy for optimal performance
  • Clean, minimal component class appropriate for a presentational component
apps/blog/src/assets/i18n/pl.json (1)

28-28: Consistent and well-translated Polish localization.

The Polish translations maintain excellent consistency with the English version:

  • Navigation item appropriately uses the same "Angular.letter" branding
  • Form placeholders are properly translated
  • Newsletter page structure mirrors the English organization
  • Success messages provide clear and appropriate Polish translations

Also applies to: 102-102, 109-115

libs/blog/newsletter/feature-newsletter/src/lib/page/newsletter-page.component.ts (2)

2-9: Excellent use of modern Angular reactive patterns.

The refactoring demonstrates excellent modern Angular practices:

  • Proper use of inject() function for dependency injection
  • Reactive programming with toSignal() for converting observables to signals
  • Clean computed property that derives state from query parameters
  • The logic correctly checks for nm=confirmed query parameter

Also applies to: 31-36


23-27: Good architectural improvements with external template.

The refactoring improves the component architecture:

  • External template enhances maintainability and readability
  • Component imports are correctly updated for the new functionality
  • Better separation of concerns with the dedicated success component

AlLocalizePipe,
ButtonComponent,
],
templateUrl: './newsletter-succes.component.html',
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix spelling error in template filename.

The template filename contains a spelling error: newsletter-succes.component.html should be newsletter-success.component.html. This affects both the file reference and likely the actual filename.

Apply this diff to fix the spelling:

-  templateUrl: './newsletter-succes.component.html',
+  templateUrl: './newsletter-success.component.html',

Also ensure the actual template file is renamed accordingly.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
templateUrl: './newsletter-succes.component.html',
templateUrl: './newsletter-success.component.html',
🤖 Prompt for AI Agents
In
libs/blog/newsletter/feature-newsletter/src/lib/page/newsletter-succes/newsletter-succes.component.ts
at line 20, fix the spelling error in the templateUrl by changing
'newsletter-succes.component.html' to 'newsletter-success.component.html'. Also,
rename the actual template file to match this corrected filename to ensure the
component loads the template correctly.

class="flex flex-col p-2 lg:flex-row"
>
<div class="mr-14 flex w-full flex-col items-center justify-center">
<p class="px-12 text-xl">{{ t('description') }}</p>
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider removing this class on mobile devices. To me, it looks better without it

@valueadd-robot
Copy link

PR is detected, will deploy to dev environment

@valueadd-robot
Copy link

Deployed to dev environment
Branch: feature/newsletter-page
BFF URL: https://2e8ef99e-blog-bff-dev.contact-ef8.workers.dev
Deploy URL: https://538663ad.angular-love-client.pages.dev
Alias URL: https://feature-newsletter-page.angular-love-client.pages.dev

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