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

ref: delete mail #934

Merged
merged 2 commits into from
Dec 12, 2024
Merged

ref: delete mail #934

merged 2 commits into from
Dec 12, 2024

Conversation

fricoben
Copy link
Contributor

@fricoben fricoben commented Dec 2, 2024

close #932 I tested that the add_metadata still works on /renewal.

I'll let you make some E2E tests also (the reviewer) on another page.

Summary by CodeRabbit

Release Notes

  • New Features

    • Simplified user interactions by removing email input across multiple components, streamlining the registration and renewal processes.
  • Bug Fixes

    • Enhanced clarity in button labeling and control flow, ensuring users receive appropriate messages based on application state.
  • Chores

    • Removed unnecessary props and email-related functionalities from various components to improve maintainability and user experience.

Copy link

vercel bot commented Dec 2, 2024

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

Name Status Preview Comments Updated (UTC)
app-starknet-id ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 2, 2024 6:46am
sepolia-app-starknet-id ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 2, 2024 6:46am

Copy link
Contributor

coderabbitai bot commented Dec 2, 2024

Walkthrough

The pull request introduces significant modifications across multiple components by removing email-related functionality. This includes the elimination of email state management, validation, and associated UI elements from components such as FreeRenewalCheckout, RegisterDiscount, UserInfoForm, and others. Additionally, the groups prop has been removed from various components and pages, simplifying their interfaces. The changes streamline the codebase by focusing on essential functionalities without email dependencies, while maintaining overall control flow and error handling.

Changes

File Path Change Summary
components/discount/freeRegisterCheckout.tsx Removed second argument from computeMetadataHash call; restructured button label logic for clarity.
components/discount/freeRenewalCheckout.tsx Removed email-related functionality and validation; hardcoded email to "none" in metadata submission.
components/discount/registerDiscount.tsx Eliminated email state management and validation; hardcoded email to "none" in metadata processing.
components/domains/autorenewal.tsx Removed SubscriptionProps type and email state management; hardcoded email to "none".
components/domains/registerV3.tsx Removed groups prop from RegisterV3Props type and its usage.
components/domains/renewalV2.tsx Removed groups property from props and updated function signature accordingly.
components/domains/steps/checkoutCard.tsx Removed groups prop; updated email handling to hardcode to "none"; removed subscription request.
components/domains/steps/userInfoForm.tsx Removed email-related logic and state; replaced email input with SwissForm component.
context/FormProvider.tsx Removed email from FormState and initialState; updated metadata hash computation to exclude email.
pages/freerenewal.tsx Removed groups prop from FreeRenewalCheckout component.
pages/register/[domainToRegister].tsx Removed groups prop from RegisterV3 component.
pages/renewal.tsx Removed groups prop from RenewalV2 component.
pages/subscription.tsx Removed groups prop from AutoRenewal component.
tests/utils/userDataService.test.js Updated test cases for computeMetadataHash to use hardcoded email value "none".

Assessment against linked issues

Objective Addressed Explanation
Delete necessary e-mail from all forms (#932)
Delete necessary e-mail from all forms (#932)
Delete necessary e-mail from all forms (#932)
Delete necessary e-mail from all forms (#932)
Delete necessary e-mail from all forms (#932)

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>, please review it.
    • Generate unit testing code for this file.
    • 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 generate unit testing code 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 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 generate unit testing code.
    • @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.

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

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.

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (3)
context/FormProvider.tsx (1)

Email functionality still actively used and needs proper removal plan

The verification shows that email-related code is not just legacy code but is actively integrated:

  1. Newsletter functionality is still active with dedicated pages
  2. Email validation is imported and used in pages/newsletter.tsx
  3. Components with email references are used in active pages:
    • subscription.tsx
    • freerenewal.tsx

This suggests that removing email functionality requires a broader refactoring effort beyond the current changes. The removal should be handled in a separate, dedicated PR that:

  1. Removes the newsletter feature completely
  2. Updates the subscription and renewal flows to remove email dependencies
  3. Removes email-related utilities and tests
  4. Updates connector naming in connectorWrapper.ts
🔗 Analysis chain

Line range hint 1-124: Verify complete removal of email collection across the codebase

While the changes in these files correctly remove email functionality, we should verify complete removal across the entire codebase, including:

  1. API endpoints
  2. Database schemas
  3. Configuration files
  4. Documentation

Email-related code still present in multiple locations

Several files still contain email-related functionality that should be removed:

  • utils/stringService.ts: Contains isValidEmail validation function
  • utils/connectorWrapper.ts: References "Email" connector name
  • pages/newsletter.tsx and pages/newsletter/confirm.tsx: Complete newsletter pages with email functionality
  • Multiple components still have email-related code:
    • components/domains/autorenewal.tsx
    • components/domains/steps/checkoutCard.tsx
    • components/discount/registerDiscount.tsx
    • components/discount/freeRenewalCheckout.tsx

Let me verify if these files are actually being used or just legacy code:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Comprehensive check for remaining email-related code
echo "Checking for email-related code..."
rg -i "email" .

echo "Checking for email-related API endpoints..."
rg -i "api.*email|email.*api" .

echo "Checking for email-related environment variables..."
rg -i "email" .env* || true

echo "Checking for email-related documentation..."
rg -i "email" docs/ README.md || true

Length of output: 3607


Script:

#!/bin/bash
# Check for imports of email-related functionality
echo "Checking for imports of isValidEmail..."
rg -l "import.*isValidEmail" .

echo "Checking for newsletter page routes..."
rg -l "newsletter" pages/_app.tsx pages/index.tsx

echo "Checking component usage..."
rg -l "autorenewal|checkoutCard|registerDiscount|freeRenewalCheckout" pages/

Length of output: 470

components/domains/steps/userInfoForm.tsx (1)

116-116: Remove unnecessary empty line.

This empty line appears to be left after removing the email-related form field.

-
-
components/discount/registerDiscount.tsx (1)

Line range hint 49-49: Remove unused mailGroups prop

The mailGroups prop in the component props is no longer needed since email functionality has been removed.

type RegisterDiscountProps = {
  domain: string;
  durationInDays: number;
  discountId: string;
  customMessage: string;
  priceInEth: bigint;
-  mailGroups: string[];
  goBack: () => void;
  sponsor?: string;
};
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 365e157 and 6197b2f.

📒 Files selected for processing (15)
  • components/discount/freeRegisterCheckout.tsx (2 hunks)
  • components/discount/freeRenewalCheckout.tsx (3 hunks)
  • components/discount/registerDiscount.tsx (3 hunks)
  • components/domains/autorenewal.tsx (4 hunks)
  • components/domains/registerV3.tsx (0 hunks)
  • components/domains/renewalV2.tsx (1 hunks)
  • components/domains/steps/checkoutCard.tsx (3 hunks)
  • components/domains/steps/userInfoForm.tsx (3 hunks)
  • context/FormProvider.tsx (1 hunks)
  • pages/freerenewal.tsx (0 hunks)
  • pages/register/[domainToRegister].tsx (0 hunks)
  • pages/renewal.tsx (1 hunks)
  • pages/subscription.tsx (1 hunks)
  • tests/utils/userDataService.test.js (2 hunks)
  • utils/userDataService.ts (1 hunks)
💤 Files with no reviewable changes (3)
  • pages/register/[domainToRegister].tsx
  • pages/freerenewal.tsx
  • components/domains/registerV3.tsx
🔇 Additional comments (16)
pages/subscription.tsx (1)

11-11: LGTM! Email collection removal properly implemented.

The removal of the groups prop from <AutoRenewal /> aligns with the PR objective of removing email collection functionality.

pages/renewal.tsx (1)

13-13: LGTM! Verify FormProvider context updates.

The removal of the groups prop from <RenewalV2 /> is correct. However, let's verify that the FormProvider context has been updated to remove any email-related state management.

✅ Verification successful

FormProvider context is clean - no email-related state found

After reviewing the FormProvider implementation, I can confirm that there is no email-related state or logic in the context. The form state only manages properties related to NFTs, domains, metadata, and tax information. The removal of the groups prop from <RenewalV2 /> is safe.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check FormProvider implementation for any remaining email-related code
rg -l "email" --type ts --type tsx "context/FormProvider"

Length of output: 83


Script:

#!/bin/bash
# First, let's find the FormProvider file
fd "FormProvider" --type f

# Then check for email-related code in the found files
rg "email" --type ts

Length of output: 1437


Script:

#!/bin/bash
# Let's check the content of FormProvider.tsx specifically
cat context/FormProvider.tsx

Length of output: 3581

utils/userDataService.ts (2)

Line range hint 21-29: LGTM! Hash computation remains secure.

The implementation maintains security best practices:

  • Proper use of crypto.subtle for hashing
  • Salt-based randomization
  • SHA-256 algorithm

18-21: Breaking change: Verify all computeMetadataHash call sites.

The removal of the email parameter from computeMetadataHash is aligned with the PR objectives. However, this is a breaking change that requires careful verification:

  1. All call sites must be updated to use the new signature
  2. Hash values will be different for existing data due to the modified input format
✅ Verification successful

All computeMetadataHash call sites have been properly updated

Based on the verification results:

  1. All call sites (FormProvider.tsx, autorenewal.tsx, registerDiscount.tsx, freeRenewalCheckout.tsx, freeRegisterCheckout.tsx) are using the new two-parameter signature correctly
  2. The test cases have been updated to match the new signature
  3. No residual email-related code exists in userDataService.ts
  4. The only email-related code in utils is in stringService.ts, which is unrelated to this change
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Find all calls to computeMetadataHash to ensure they've been updated
echo "Searching for computeMetadataHash usage..."
ast-grep --pattern 'computeMetadataHash($$$)'

# Look for any remaining email-related code in nearby files
echo "Checking for any missed email-related code..."
rg -l "email" --type ts --type tsx "utils/"

Length of output: 1670


Script:

#!/bin/bash
# Search for email-related code in utils directory with proper file type
echo "Checking for any missed email-related code in utils..."
rg -l "email" utils/

# Get the content of userDataService.ts to verify the complete function implementation
echo "Checking userDataService.ts content..."
cat utils/userDataService.ts

# Search for test cases to verify the changes
echo "Checking test cases..."
rg -A 5 "computeMetadataHash" tests/utils/userDataService.test.js

Length of output: 2075

components/domains/renewalV2.tsx (1)

14-14: LGTM! Verify complete removal of email functionality

The component changes align with the PR objective of removing email collection. The removal of the groups prop and email-related code simplifies the component while maintaining core renewal functionality.

✅ Verification successful

Let me check the context of these remaining email occurrences to ensure they're not related to the removed email collection functionality.


Email functionality has been properly removed

The remaining occurrences of "email" are just API payload defaults where "none" is used as a value, indicating that email collection has been properly removed from the user interface and form handling. These occurrences are part of the API contract and don't represent any remaining email collection functionality.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify no remaining email-related code in renewal components
rg -i "email" components/domains/

Length of output: 160


Script:

#!/bin/bash
# Check the context of remaining email occurrences
rg -i "email" components/domains/autorenewal.tsx -B 2 -A 2
rg -i "email" components/domains/steps/checkoutCard.tsx -B 2 -A 2

Length of output: 506

tests/utils/userDataService.test.js (1)

Line range hint 62-78: LGTM! Test updates correctly reflect metadata hash changes

The test case has been properly updated to reflect the removal of email from metadata hash computation while maintaining security and correctness of the hash calculation.

✅ Verification successful

Test updates correctly reflect the implementation of metadata hash computation

The verification confirms that:

  • The test file accurately matches the implementation in userDataService.ts
  • Both the implementation and test only use taxState and salt parameters
  • The hash computation logic is consistent between test and implementation
  • No email-related metadata computation exists in the codebase
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify complete removal of email from metadata computation
rg -i "email.*metadata" .

Length of output: 27


Script:

#!/bin/bash
# Let's search for metadata-related code to verify the changes
rg -l "metadata" .

Length of output: 657


Script:

#!/bin/bash
# Search for any remaining email references in hash computation
ast-grep --pattern 'function computeMetadataHash($_) { $$$ }'

Length of output: 63


Script:

#!/bin/bash
# Check the test file content for better context
cat tests/utils/userDataService.test.js

Length of output: 3284


Script:

#!/bin/bash
# Let's check the implementation of computeMetadataHash
rg -A 5 "export.*computeMetadataHash" .

Length of output: 393


Script:

#!/bin/bash
# Check for any previous versions or references to email in metadata hash
git log -p --all -S "computeMetadataHash.*email"

Length of output: 0


Script:

#!/bin/bash
# Check the implementation file directly
cat utils/userDataService.ts

Length of output: 1230

context/FormProvider.tsx (2)

46-48: Style: Minor formatting improvements

The spacing after arrow functions has been standardized.


Line range hint 7-22: LGTM! FormState properly updated

The FormState type has been correctly updated to remove email-related fields while maintaining all necessary state management for tax and metadata purposes.

✅ Verification successful

Email fields have been properly removed from FormState and related components

Based on the verification results:

  1. The FormState type in FormProvider.tsx no longer contains any email-related fields
  2. The form-related components (userInfoForm, swissForm, transferFormModal) don't contain any email field implementations
  3. Remaining email references in the codebase are unrelated to the form state:
    • Newsletter-related functionality in /pages/newsletter
    • Email validation utilities in /utils/stringService.ts
    • Test files for email validation
    • "Email" connector name in wallet integration
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify complete removal of email from form state and context
rg -i "email" context/

Length of output: 22


Script:

#!/bin/bash
# Let's verify if there are any email-related fields or usages in the entire codebase
# This will help ensure the removal was complete across the application
rg -i "email" .

Length of output: 3073


Script:

#!/bin/bash
# Let's also check the git diff to see what was removed
git diff HEAD~1 -- context/FormProvider.tsx

Length of output: 45


Script:

#!/bin/bash
# Let's check for any form-related components that might still reference email
fd -e tsx -e ts form

Length of output: 174


Script:

#!/bin/bash
# Let's check the content of form-related components to ensure no email fields remain
cat components/domains/steps/userInfoForm.tsx components/domains/swissForm.tsx components/identities/actions/transferFormModal.tsx

Length of output: 11945


Script:

#!/bin/bash
# Let's also check for any email-related interfaces or types in the codebase
ast-grep --pattern 'interface $_ {
  $$$
  email
  $$$
}'

ast-grep --pattern 'type $_ = {
  $$$
  email
  $$$
}'

Length of output: 116

components/domains/steps/userInfoForm.tsx (1)

94-96: LGTM! Button text logic simplified.

The button text logic has been appropriately simplified after removing email validation checks.

components/discount/freeRegisterCheckout.tsx (1)

109-109: LGTM! Email parameter removed from metadata hash.

The metadata hash computation has been correctly updated to remove the email parameter.

components/domains/steps/checkoutCard.tsx (2)

167-167: LGTM! Email hardcoded to "none" in metadata.

The email field has been correctly hardcoded to "none" in the metadata, aligning with the PR objective to remove email collection.


246-247: LGTM! Improved formatting and simplified conditions.

The code formatting and condition simplification improve readability while maintaining the same functionality.

Also applies to: 313-314

components/domains/autorenewal.tsx (2)

111-114: LGTM: Clean email removal implementation

The metadata handling has been correctly updated to use a hardcoded "none" for email, aligning with the PR objectives.


378-381: LGTM: Improved button text clarity

The button text changes provide clearer feedback to users about the subscription status and requirements.

components/discount/freeRenewalCheckout.tsx (2)

204-204: LGTM: Minor changes

The dependency array update and button text formatting changes look good.

Also applies to: 321-322


96-96: Verify metadata structure compatibility

The email field is now hardcoded to "none" in the metadata submission. While this aligns with removing email collection, we should verify that the sales server API (/add_metadata) properly handles this default value.

✅ Verification successful

Hardcoded email value "none" is consistently used across the codebase

The verification shows that all checkout components (autorenewal.tsx, checkoutCard.tsx, registerDiscount.tsx, and freeRenewalCheckout.tsx) consistently use the same hardcoded value "none" for the email field in metadata submissions, indicating this is an established pattern across the codebase. This change aligns with the broader initiative to remove email collection while maintaining API compatibility.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if the sales server API validates the "none" email value

# Search for email validation in the sales server API
rg -A 5 "add_metadata" --type ts --type js

# Check for any email validation patterns
ast-grep --pattern 'email: $_'

Length of output: 2042

components/discount/freeRegisterCheckout.tsx Outdated Show resolved Hide resolved
components/discount/registerDiscount.tsx Show resolved Hide resolved
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.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (6)
components/domains/autorenewal.tsx (2)

112-112: LGTM with a suggestion for future improvement

The hardcoding of email as "none" in metadata handling is a clean way to remove email collection while maintaining compatibility with existing systems. However, consider creating a follow-up task to remove the email field from the backend API entirely.

Consider creating a technical debt ticket to:

  1. Remove the email field from the backend API schema
  2. Update the metadata structure to exclude email-related fields
  3. Clean up any email-related database columns

Also applies to: 152-158


379-382: Fix indentation for consistency

While the button text messages are clear and appropriate, the indentation is inconsistent with the rest of the file.

Apply this formatting fix:

-                  ? "Select a domain to subscribe"
-                  : callData.length === 0
-                    ? "You're already subscribed"
-                    : "Enable subscription"}
+                ? "Select a domain to subscribe"
+                : callData.length === 0
+                ? "You're already subscribed"
+                : "Enable subscription"}
components/discount/registerDiscount.tsx (1)

Line range hint 29-37: Remove unused mailGroups prop

Since email functionality has been removed, the mailGroups prop should be removed from the RegisterDiscountProps type and the component's parameter list.

type RegisterDiscountProps = {
  domain: string;
  durationInDays: number;
  discountId: string;
  customMessage: string;
  priceInEth: bigint;
-  mailGroups: string[];
  goBack: () => void;
  sponsor?: string;
};
context/FormProvider.tsx (1)

Line range hint 1-130: Consider documenting the metadata hash format

Since we're making a significant change to how metadata is handled (removing email), it would be helpful to add documentation about the expected format of the metadata hash and what "none" signifies in this context.

  useMemo(() => {
    if (!formState.salt || !formState.needMetadata) return;
    (async () => {
+     // Metadata hash format: hash(email="none", country="switzerland"|"none", salt)
+     // "none" is used as a placeholder since email collection has been removed
      updateFormState({
        metadataHash: await computeMetadataHash(
          "none",
          formState.isSwissResident ? "switzerland" : "none",
          formState.salt as string
        ),
      });
    })();
  }, [
components/discount/freeRenewalCheckout.tsx (1)

96-96: Consider using a constant for the default email value

The hardcoded string "none" is used as a default email value. Consider defining this as a constant to maintain consistency and make future updates easier.

+ const DEFAULT_EMAIL = "none";
- email: "none",
+ email: DEFAULT_EMAIL,
components/domains/steps/userInfoForm.tsx (1)

Line range hint 116-126: Clean up unnecessary whitespace

While the email field removal and SwissForm implementation look good, there's unnecessary whitespace that could be removed to improve code readability.

-

-
            {formState.needMetadata ? (
+            {formState.needMetadata ? (
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 6197b2f and da3630e.

📒 Files selected for processing (14)
  • components/discount/freeRegisterCheckout.tsx (2 hunks)
  • components/discount/freeRenewalCheckout.tsx (3 hunks)
  • components/discount/registerDiscount.tsx (3 hunks)
  • components/domains/autorenewal.tsx (4 hunks)
  • components/domains/registerV3.tsx (0 hunks)
  • components/domains/renewalV2.tsx (1 hunks)
  • components/domains/steps/checkoutCard.tsx (3 hunks)
  • components/domains/steps/userInfoForm.tsx (3 hunks)
  • context/FormProvider.tsx (2 hunks)
  • pages/freerenewal.tsx (0 hunks)
  • pages/register/[domainToRegister].tsx (0 hunks)
  • pages/renewal.tsx (1 hunks)
  • pages/subscription.tsx (1 hunks)
  • tests/utils/userDataService.test.js (1 hunks)
💤 Files with no reviewable changes (3)
  • pages/freerenewal.tsx
  • pages/register/[domainToRegister].tsx
  • components/domains/registerV3.tsx
🚧 Files skipped from review as they are similar to previous changes (5)
  • pages/subscription.tsx
  • pages/renewal.tsx
  • tests/utils/userDataService.test.js
  • components/discount/freeRegisterCheckout.tsx
  • components/domains/steps/checkoutCard.tsx
🔇 Additional comments (12)
components/domains/autorenewal.tsx (1)

49-49: LGTM: Clean removal of unused props type

The removal of SubscriptionProps type aligns with the PR objective of removing email functionality, as the component no longer needs to accept any props.

components/discount/registerDiscount.tsx (3)

110-116: LGTM: Email parameter correctly hardcoded

The metadata hash computation has been updated to use a hardcoded "none" value for email, which aligns with the removal of email collection functionality.


Line range hint 290-294: Remove unused mailGroups parameter

While email has been correctly set to "none", the mailGroups parameter is still being sent in the request body despite the removal of email functionality.

body: JSON.stringify({
  meta_hash: metadataHash,
  email: "none",
-  groups: mailGroups, // Domain Owner group
  tax_state: isSwissResident ? "switzerland" : "none",
  salt: salt,
}),

398-405: LGTM: Button validation logic updated

The button's disabled condition has been correctly updated to remove email validation while maintaining all other necessary checks.

context/FormProvider.tsx (2)

46-46: LGTM: Minor formatting changes

The formatting changes to the empty arrow functions are consistent with the codebase style.

Also applies to: 48-48


104-107: Verify the impact of hardcoding email to "none"

The change to use "none" as a hardcoded email value aligns with the PR objective to remove email collection. However, we should verify that:

  1. This change is consistent across all components using computeMetadataHash
  2. The metadata hash computation remains valid with this hardcoded value
✅ Verification successful

Based on the results, I can now generate the final response:

Hardcoded email value "none" is consistently used across the codebase

The verification confirms that:

  • All calls to computeMetadataHash across the codebase consistently use "none" as the email parameter
  • No email state management types were found in the codebase
  • The function signature in utils/userDataService.ts still accepts email as a parameter, but this is acceptable for backward compatibility
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify consistent email removal across codebase

# Check for any remaining email-related computeMetadataHash calls
echo "Checking for remaining email-related metadata hash computations..."
rg -A 3 "computeMetadataHash" 

# Check for any remaining email state management
echo "Checking for remaining email state management..."
ast-grep --pattern 'email: string'

Length of output: 4444

components/domains/renewalV2.tsx (1)

14-14: LGTM: Props removal aligns with email removal objective

The removal of the groups prop from RenewalV2 component aligns with the PR objective of removing email collection functionality. The component maintains its core renewal flow functionality while eliminating unnecessary email-related props.

components/discount/freeRenewalCheckout.tsx (2)

322-323: LGTM: Clear user guidance in button text

The button text provides clear guidance for domain selection, maintaining good UX despite the removal of email-related functionality.


197-205: 🛠️ Refactor suggestion

Simplify metadata hash computation parameters

The metadata hash computation still includes the email parameter even though it's hardcoded. Consider refactoring the computeMetadataHash function to remove the email parameter entirely since it's no longer needed.

✅ Verification successful

Remove unused email parameter from computeMetadataHash function

The verification confirms that while computeMetadataHash accepts an email parameter, all current usages in the codebase pass "none" as the email argument. The function implementation shows that email is only used as part of the message string for hashing. Since it's consistently passed as "none", the parameter can be safely removed.

  • utils/userDataService.ts: Remove the email parameter from the computeMetadataHash function and update its implementation to use only taxState and salt
  • Update the following files to remove the "none" argument:
    • components/domains/autorenewal.tsx
    • context/FormProvider.tsx
    • components/discount/freeRenewalCheckout.tsx
    • components/discount/registerDiscount.tsx
    • components/discount/freeRegisterCheckout.tsx
    • tests/utils/userDataService.test.js
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if computeMetadataHash is used elsewhere with email parameter
ast-grep --pattern 'computeMetadataHash($_email, $_, $_)'

Length of output: 59


Script:

#!/bin/bash
# Let's first find the computeMetadataHash function definition
ast-grep --pattern 'const computeMetadataHash = $_'

# Also search for any usage of computeMetadataHash
rg "computeMetadataHash" -A 2

Length of output: 3343


Script:

#!/bin/bash
# Let's check the actual implementation of computeMetadataHash function
cat utils/userDataService.ts

Length of output: 1254

components/domains/steps/userInfoForm.tsx (3)

Line range hint 1-19: LGTM! Import statements are clean and aligned with changes

The removal of email-related imports is consistent with the PR objectives.


94-97: LGTM! Button text logic properly simplified

The function maintains essential domain selection validation while removing unnecessary email-related checks.


Line range hint 1-168: Verify FormContext cleanup

While the component changes look good, we should verify that the FormContext has been properly updated to remove email-related state.

✅ Verification successful

FormContext has been properly cleaned up

The FormContext implementation has been verified and shows no traces of email-related state. The FormState type and initialState object are clean, containing only the necessary fields for domain registration and renewal (isSwissResident, tokenId, durationInYears, selectedDomains, metadata fields, etc.). The email field has been completely removed from the context.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining email-related code in FormContext
rg -i "email" "context/FormProvider"

# Check for any remaining email-related types or interfaces
ast-grep --pattern 'interface $_ {
  $$$
  email
  $$$
}'

Length of output: 155


Script:

#!/bin/bash
# Try to find FormProvider/FormContext files in the repository
fd -t f "FormProvider|FormContext"

# Search for any email-related code in the entire codebase
rg -i "email.*formcontext|formcontext.*email"

# Search for FormContext imports to locate the file
rg "FormContext"

Length of output: 1362


Script:

#!/bin/bash
# Check the content of FormProvider.tsx to verify email-related state
cat context/FormProvider.tsx

Length of output: 3599

@fricoben fricoben added 🔥 Ready for review This pull request needs a review and removed 🚧 In progress do not merge Pull Request in progress, please do not merge labels Dec 2, 2024
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.

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (1)
components/domains/steps/checkoutCard.tsx (1)

232-236: Consider enhancing type safety for button text.

The function handles validation states well, but could benefit from type safety improvements.

Consider this type-safe implementation:

-  const getButtonText = () => {
+  const getButtonText = (): string => {
     if (!termsBox) return "Please accept terms & policies";
     if (invalidBalance) return `You don't have enough ${displayedCurrency}`;
     return "Purchase";
   };
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between da3630e and 5551369.

📒 Files selected for processing (3)
  • components/discount/freeRegisterCheckout.tsx (3 hunks)
  • components/domains/steps/checkoutCard.tsx (4 hunks)
  • tests/utils/userDataService.test.js (0 hunks)
💤 Files with no reviewable changes (1)
  • tests/utils/userDataService.test.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/discount/freeRegisterCheckout.tsx
🔇 Additional comments (2)
components/domains/steps/checkoutCard.tsx (2)

252-253: LGTM: Formatting improvement.

The condition refinement improves readability while maintaining the same logic.


316-316: LGTM: Clean implementation of button text.

The button text implementation correctly uses the helper function.

@@ -166,7 +164,7 @@ const CheckoutCard: FunctionComponent<CheckoutCardProps> = ({
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
meta_hash: formState.metadataHash,
email: formState.email,
email: "none",
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Found additional email-related code that needs attention

There are still instances of email-related code in other components that should be reviewed for consistency:

  • components/domains/autorenewal.tsx: Contains email: "none"
  • components/discount/freeRenewalCheckout.tsx: Contains email: "none"
  • components/discount/registerDiscount.tsx: Contains mailGroups prop and usage, along with email: "none"
🔗 Analysis chain

LGTM: Email removal aligns with PR objectives.

The hardcoded "none" value maintains API compatibility while removing email collection.

Let's verify no other email-related code remains:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining email-related code
rg -i 'email|mail' --type ts --type tsx

Length of output: 69


Script:

#!/bin/bash
# Search for any remaining email-related code, using ripgrep without file type filters
rg -i 'email|mail' components/

Length of output: 503

Copy link
Collaborator

@irisdv irisdv left a comment

Choose a reason for hiding this comment

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

lgtm

@irisdv irisdv merged commit c9c94e4 into testnet Dec 12, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔥 Ready for review This pull request needs a review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Delete necessary e-mail from all forms
2 participants