Skip to content
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

♻️ Remove use of context from email package #981

Merged
merged 1 commit into from
Jan 17, 2024
Merged

Conversation

lukevella
Copy link
Owner

@lukevella lukevella commented Jan 16, 2024

This is needed to allow us to use the next-auth API in server components.

Summary by CodeRabbit

  • New Features

    • Email templates now include domain context for enhanced personalization.
  • Refactor

    • Email context handling has been centralized for more consistent usage across components.
    • Email components now receive the domain context directly as a prop.
  • Bug Fixes

    • Fixed an issue with email template rendering to ensure proper use of the domain context.

Copy link

vercel bot commented Jan 16, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
app ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 16, 2024 11:48am
landing ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 16, 2024 11:48am

Copy link
Contributor

coderabbitai bot commented Jan 16, 2024

Walkthrough

The overarching modification across multiple components and files is the transition from using a context hook to directly passing the email context as a prop. This change streamlines the access to the domain information derived from the baseUrl, ensuring that each email component receives the necessary context directly, thus simplifying the context management within the email rendering logic.

Changes

File Path Change Summary
apps/web/src/utils/emails.ts Added domain to emailClient context from baseUrl.
packages/emails/src/send-email.tsx Modified TemplateProps to exclude "ctx"; adjusted Template to include "ctx".
packages/emails/src/templates/components/email-context.tsx Updated useEmailContext to include domain; removed context creation.
packages/emails/src/templates/components/email-layout.tsx Added ctx prop to EmailLayoutProps.
packages/emails/src/templates/components/notification-email.tsx
packages/emails/src/templates/components/styled-components.tsx
packages/emails/src/templates/finalized-host.tsx
packages/emails/src/templates/login.tsx
packages/emails/src/templates/new-participant-confirmation.tsx
packages/emails/src/templates/new-poll.tsx
packages/emails/src/templates/finalized-participant.tsx
packages/emails/src/templates/new-comment.tsx
packages/emails/src/templates/new-participant.tsx
packages/emails/src/templates/register.tsx
Components now receive ctx as prop instead of using useEmailContext.

Poem

🐇 "A hop, a skip, a code commit,
Through fields of syntax, we transmit.
No longer hooks, but props we pass,
A change embraced by the dev class!" 🌟

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

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>.
    • Generate unit-tests for this file.
  • 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 generate unit tests for this file.
    • @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 generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link
Contributor

@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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 668a4b5 and ea6889f.
Files selected for processing (10)
  • apps/web/src/utils/emails.ts (1 hunks)
  • packages/emails/src/send-email.tsx (2 hunks)
  • packages/emails/src/templates/components/email-context.tsx (1 hunks)
  • packages/emails/src/templates/components/email-layout.tsx (2 hunks)
  • packages/emails/src/templates/components/notification-email.tsx (3 hunks)
  • packages/emails/src/templates/components/styled-components.tsx (2 hunks)
  • packages/emails/src/templates/finalized-host.tsx (3 hunks)
  • packages/emails/src/templates/login.tsx (3 hunks)
  • packages/emails/src/templates/new-participant-confirmation.tsx (1 hunks)
  • packages/emails/src/templates/new-poll.tsx (3 hunks)
Additional comments: 31
packages/emails/src/templates/components/email-context.tsx (1)
  • 4-4: The addition of the domain property to the EmailContext type is consistent with the PR's objective to refactor how context is managed.
apps/web/src/utils/emails.ts (1)
  • 24-24: The inclusion of the domain property in the emailClient's context object aligns with the changes made in the EmailContext type and is a logical step in the refactoring process.
packages/emails/src/templates/components/notification-email.tsx (4)
  • 1-1: The import change from useEmailContext to EmailContext is correct and aligns with the refactoring goal.
  • 10-10: The addition of the ctx prop to the NotificationEmailProps interface is consistent with the new pattern of passing context as a prop.
  • 23-25: The replacement of the useEmailContext hook with the ctx prop within the NotificationEmail component is in line with the PR's objectives.
  • 28-28: Passing the ctx prop to the EmailLayout component is a necessary change following the removal of the context hook.
packages/emails/src/templates/new-participant-confirmation.tsx (5)
  • 1-1: The import statement change from useEmailContext to EmailContext is correct.
  • 9-9: Adding the ctx prop to the NewParticipantConfirmationEmailProps interface is consistent with the refactor.
  • 15-17: The use of the ctx prop within the NewParticipantConfirmationEmail component is in line with the PR's objectives.
  • 20-20: Passing the ctx prop to the EmailLayout component is appropriate following the removal of the context hook.
  • 24-25: The Domain component now correctly receives the ctx prop, aligning with the new pattern of passing context.
packages/emails/src/templates/login.tsx (5)
  • 1-1: The change from useEmailContext to EmailContext in the import statement is correct.
  • 16-16: The addition of the ctx prop to the LoginEmailProps interface is consistent with the refactor.
  • 23-23: The use of the ctx prop within the LoginEmail component is in line with the PR's objectives.
  • 27-27: Passing the ctx prop to the EmailLayout component is appropriate following the removal of the context hook.
  • 31-32: The Domain component now correctly receives the ctx prop, aligning with the new pattern of passing context.
packages/emails/src/templates/finalized-host.tsx (4)
  • 3-3: The import statement change from useEmailContext to EmailContext is correct.
  • 17-17: Adding the ctx prop to the FinalizeHostEmailProps interface is consistent with the refactor.
  • 28-28: The use of the ctx prop within the FinalizeHostEmail component is in line with the PR's objectives.
  • 31-31: Passing the ctx prop to the EmailLayout component is appropriate following the removal of the context hook.
packages/emails/src/templates/components/email-layout.tsx (3)
  • 11-11: The change from useEmailContext to EmailContext in the import statement is correct.
  • 18-18: The addition of the ctx prop to the EmailLayoutProps interface is consistent with the refactor.
  • 46-48: The use of the ctx prop within the EmailLayout component is in line with the PR's objectives.
packages/emails/src/templates/new-poll.tsx (4)
  • 1-1: The change from useEmailContext to EmailContext in the import statement is correct.
  • 10-10: The addition of the ctx prop to the NewPollEmailProps interface is consistent with the refactor.
  • 41-43: The use of the ctx prop within the NewPollEmail component is in line with the PR's objectives.
  • 46-46: Passing the ctx prop to the EmailLayout component is appropriate following the removal of the context hook.
packages/emails/src/templates/components/styled-components.tsx (2)
  • 13-13: The change from useEmailContext to EmailContext in the import statement is correct.
  • 35-36: The Domain component now correctly receives the ctx prop, aligning with the new pattern of passing context.
packages/emails/src/send-email.tsx (2)
  • 16-18: The modification of the TemplateProps type to exclude the "ctx" property is consistent with the refactor to pass context as a prop.
  • 83-87: The adjustment in the rendering of the Template component to include the "ctx" property is appropriate and aligns with the changes made throughout the PR.

Copy link
Contributor

@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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 668a4b5 and 868d40b.
Files selected for processing (14)
  • apps/web/src/utils/emails.ts (1 hunks)
  • packages/emails/src/send-email.tsx (2 hunks)
  • packages/emails/src/templates/components/email-context.tsx (1 hunks)
  • packages/emails/src/templates/components/email-layout.tsx (2 hunks)
  • packages/emails/src/templates/components/notification-email.tsx (3 hunks)
  • packages/emails/src/templates/components/styled-components.tsx (2 hunks)
  • packages/emails/src/templates/finalized-host.tsx (3 hunks)
  • packages/emails/src/templates/finalized-participant.tsx (3 hunks)
  • packages/emails/src/templates/login.tsx (3 hunks)
  • packages/emails/src/templates/new-comment.tsx (1 hunks)
  • packages/emails/src/templates/new-participant-confirmation.tsx (1 hunks)
  • packages/emails/src/templates/new-participant.tsx (1 hunks)
  • packages/emails/src/templates/new-poll.tsx (3 hunks)
  • packages/emails/src/templates/register.tsx (2 hunks)
Files skipped from review as they are similar to previous changes (9)
  • apps/web/src/utils/emails.ts
  • packages/emails/src/send-email.tsx
  • packages/emails/src/templates/components/email-layout.tsx
  • packages/emails/src/templates/components/notification-email.tsx
  • packages/emails/src/templates/components/styled-components.tsx
  • packages/emails/src/templates/finalized-host.tsx
  • packages/emails/src/templates/login.tsx
  • packages/emails/src/templates/new-participant-confirmation.tsx
  • packages/emails/src/templates/new-poll.tsx
Additional comments: 11
packages/emails/src/templates/components/email-context.tsx (1)
  • 4-4: The addition of the domain property to the EmailContext type is consistent with the PR objectives to standardize URL handling within the email system.
packages/emails/src/templates/new-comment.tsx (2)
  • 16-16: The ctx prop has been correctly added to the NewCommentEmailProps interface.
  • 20-20: The ctx prop is appropriately passed to the NotificationEmail component, aligning with the PR's goal of prop-based context management.
packages/emails/src/templates/new-participant.tsx (2)
  • 16-16: The ctx prop has been correctly added to the NewParticipantEmailProps interface.
  • 20-20: The ctx prop is appropriately passed to the NotificationEmail component, aligning with the PR's goal of prop-based context management.
packages/emails/src/templates/register.tsx (4)
  • 1-1: The import of EmailContext is consistent with the changes made to the EmailContext type.
  • 13-13: The ctx prop has been correctly added to the RegisterEmailProps interface.
  • 23-23: The ctx prop is correctly passed to the EmailLayout component.
  • 27-28: The Domain component is now receiving the ctx prop, and the footnote text correctly uses this prop.
packages/emails/src/templates/finalized-participant.tsx (2)
  • 18-18: The ctx prop has been correctly added to the FinalizeParticipantEmailProps interface.
  • 33-33: The ctx prop is correctly passed to the EmailLayout component, which is in line with the PR's objectives.

@lukevella lukevella merged commit e2c4cc7 into main Jan 17, 2024
5 checks passed
@lukevella lukevella deleted the server-emails branch January 17, 2024 03:33
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