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

feat: domain gift page #801

Merged
merged 24 commits into from
Jun 6, 2024
Merged

feat: domain gift page #801

merged 24 commits into from
Jun 6, 2024

Conversation

Marchand-Nicolas
Copy link
Collaborator

@Marchand-Nicolas Marchand-Nicolas commented May 22, 2024

close: #791
NEEDED IN ENV VARS: NEXT_PUBLIC_DOMAIN_GIFT_CONTRACT=0x064b630cd6824e1c49b9eab5ca07014889b3e4e3d88a348393172c6f48155b56 (SEPOLIA)

Summary by CodeRabbit

  • New Features

    • Introduced a new FreeRegistration page to manage free registration discount campaigns.
    • Added a DomainGift component for managing domain gift campaigns.
  • Enhancements

    • Added coupon code support and validation in the RegisterDiscount component.
    • Updated RegisterSummary to display "Free" for free registrations.
    • Refactored RegisterCheckboxes to use a new TermCheckbox component for better code organization.
    • Improved styling with new CSS classes for better UI consistency.
  • Renaming

    • Renamed FreeRenewalDiscount to FreeRenewalCheckout.
    • Renamed DiscountRenewalScreen to FreeRenewalPresentation.
  • Bug Fixes

    • Fixed issues with coupon validation and error handling in the registration process.
  • New Utilities

    • Added getFreeRegistrationCalls function for generating call data for free domain registration.
    • Introduced getFreeDomain function to fetch free domain details.
    • Added DomainGift and FreeRegistration types for better type management in discount campaigns.

@Marchand-Nicolas Marchand-Nicolas added the 🚧 In progress do not merge Pull Request in progress, please do not merge label May 22, 2024
Copy link

vercel bot commented May 22, 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 Jun 3, 2024 6:02pm
sepolia-app-starknet-id ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 3, 2024 6:02pm

Copy link
Contributor

coderabbitai bot commented May 22, 2024

Walkthrough

This update introduces new components and refactors existing ones to support discount campaigns for domain registration and renewal. Key additions include FreeRegisterCheckout, FreeRegisterPresentation, and DomainGift components. Changes also involve renaming components and updating their props to enhance functionality and user experience. The updates ensure seamless integration of coupon validation, terms acceptance, and campaign-specific screens.

Changes

File Path Summary
components/discount/registerDiscount.tsx Added new props and states for coupon handling, integrated coupon validation, and updated UI accordingly.
components/discount/freeRegisterCheckout.tsx Introduced FreeRegisterCheckout component for free domain registration with coupon and terms acceptance.
components/discount/freeRegisterPresentation.tsx Added expiry prop to FreeRegisterPresentation component and updated its UI.
components/discount/freeRenewalCheckout.tsx Renamed FreeRenewalDiscount to FreeRenewalCheckout and updated related props and exports.
components/discount/freeRenewalPresentation.tsx Renamed DiscountRenewalScreen to FreeRenewalPresentation and updated related props and exports.
components/domains/registerCheckboxes.tsx Refactored to use TermCheckbox component for better code organization.
components/domains/registerSummary.tsx Added isFree prop to conditionally render "Free" in the summary.
components/domains/termCheckbox.tsx Introduced TermCheckbox component for terms and policies acceptance.
pages/domain-gift.tsx Added DomainGift component to handle discount screens for a domain gift campaign.
pages/freeregistration.tsx Introduced FreeRegistration component to manage a free registration discount campaign.
pages/freerenewal.tsx Updated to use FreeRenewalPresentation and FreeRenewalCheckout components.
pages/quantumleap.tsx Updated to use RegisterDiscount instead of DiscountCheckoutScreen.
styles/discount.module.css Renamed and added new classes to adjust styling for different screen sizes.
types/frontTypes.d.ts Updated Discount type to include optional couponCode and couponHelper fields.
utils/callData/registrationCalls.ts Added getFreeRegistrationCalls function to generate call data for free domain registration.
utils/campaignService.ts Introduced getFreeDomain function to fetch a free domain asynchronously.
utils/discounts/domainGift.ts Added DomainGift type and exported domainGift object with campaign details.
utils/discounts/freeRegistration.ts Introduced FreeRegistration type and exported freeRegistration object with offer details.

Sequence Diagram(s) (Beta)

sequenceDiagram
    participant User
    participant FreeRegistrationPage
    participant FreeRegisterPresentation
    participant FreeRegisterCheckout
    participant CampaignService
    participant RegistrationCalls

    User ->> FreeRegistrationPage: Accesses free registration page
    FreeRegistrationPage ->> FreeRegisterPresentation: Displays registration form
    User ->> FreeRegisterPresentation: Enters domain and coupon code
    FreeRegisterPresentation ->> FreeRegisterCheckout: Proceeds to checkout
    FreeRegisterCheckout ->> CampaignService: Validates coupon
    CampaignService ->> FreeRegisterCheckout: Returns validation result
    FreeRegisterCheckout ->> RegistrationCalls: Generates registration call data
    RegistrationCalls ->> FreeRegisterCheckout: Returns call data
    FreeRegisterCheckout ->> User: Confirms registration completion

Assessment against linked issues

Objective Addressed Explanation
Domain gift page (#791)

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 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

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.
  • 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: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between d80ca1b and ba22ed4.
Files selected for processing (8)
  • components/discount/discountCheckoutScreen.tsx (3 hunks)
  • components/discount/discountOfferScreenVariant.tsx (1 hunks)
  • components/discount/registerDiscount.tsx (9 hunks)
  • components/domains/registerSummary.tsx (3 hunks)
  • pages/domain-gift.tsx (1 hunks)
  • styles/discount.module.css (4 hunks)
  • types/frontTypes.d.ts (1 hunks)
  • utils/discounts/domainGift.ts (1 hunks)
Files skipped from review due to trivial changes (4)
  • components/discount/discountCheckoutScreen.tsx
  • components/discount/discountOfferScreenVariant.tsx
  • styles/discount.module.css
  • utils/discounts/domainGift.ts
Additional comments not posted (9)
pages/domain-gift.tsx (3)

26-58: Review the conditional rendering logic for different screens.

The conditional rendering based on the screen state is implemented correctly. Each condition correctly renders a specific component for different states of the domain gift campaign.


11-62: Ensure proper handling of undefined or null values in state and props.

While the code generally looks good, it's crucial to ensure that all props, especially those from domainGift, handle potential undefined or null values gracefully to prevent runtime errors.


19-19: Verify the logic for setting the screen based on the campaign expiry.

The logic to set the screen to 0 when the current timestamp is greater than or equal to domainGift.expiry seems correct. However, ensure that the domainGift.expiry is always a valid date and consider what should happen right at the moment of expiry.

Verification successful

The domainGift.expiry is initialized in utils/discounts/domainGift.ts with a hardcoded timestamp value. This ensures that domainGift.expiry is always a valid date. The logic to set the screen to 0 when the current timestamp is greater than or equal to domainGift.expiry is correct and should work as intended.

  • utils/discounts/domainGift.ts:

    export const domainGift: DomainGift = {
      name: "Domain Gift",
      image: "/register/gift.webp",
      expiry: 1726382280 * 1000, // timestamp in ms
      discountMailGroupId: "X",
      offer: {
        // offer details
      }
    };
  • pages/domain-gift.tsx:

    useEffect(() => {
      const currentDate = new Date();
      const timestamp = currentDate.getTime();
    
      if (timestamp >= domainGift.expiry) setScreen(0);
    }, []);

The initialization ensures that domainGift.expiry is always a valid timestamp, and the logic in the useEffect hook correctly handles the expiry check.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the handling of campaign expiry in DomainGift component.

# Test: Search for usage of `domainGift.expiry`. Expect: Proper date handling and edge cases considered.
rg --type typescript $'domainGift\\.expiry'

Length of output: 78



Script:

#!/bin/bash
# Description: Verify the handling of campaign expiry in DomainGift component.

# Test: Search for usage of `domainGift.expiry`. Expect: Proper date handling and edge cases considered.
rg --type ts 'domainGift\.expiry'

Length of output: 170



Script:

#!/bin/bash
# Extract lines around the first occurrence of `domainGift.expiry` in `pages/domain-gift.tsx`
rg --type ts --context 5 'domainGift\.expiry' pages/domain-gift.tsx

Length of output: 674



Script:

#!/bin/bash
# Search for the initialization and validation of `domainGift.expiry`
rg --type ts 'domainGift\s*=\s*{[^}]*expiry' --context 5

Length of output: 188



Script:

#!/bin/bash
# Search for the initialization and validation of `domainGift.expiry`
rg --type ts 'domainGift\s*=\s*{[^}]*expiry' --context 5

Length of output: 188



Script:

#!/bin/bash
# Search for the initialization of `domainGift` and manually inspect for `expiry`
rg --type ts 'domainGift\s*=' --context 5

Length of output: 43



Script:

#!/bin/bash
# Search for any initialization or assignment to `domainGift` across all TypeScript files
rg --type ts 'domainGift' --context 5

Length of output: 3847

types/frontTypes.d.ts (1)

59-62: Ensure consistency in the use of optional properties in the Discount type.

The addition of couponCode and couponHelper as optional properties in the Discount type is consistent with the updates in the component props. This ensures type safety and better integration with the updated components.

components/domains/registerSummary.tsx (2)

155-165: Review the conditional rendering logic for displaying price information.

The conditional rendering based on the isFree prop is implemented correctly. It either displays "Free" or the calculated token price, ensuring a clear and accurate presentation of cost information to the user.


32-32: Validate the default value and usage of the isFree prop.

The isFree prop is used to conditionally render the registration cost as "Free". Ensure that this prop is always passed correctly from parent components and consider providing a default value in the prop destructuring to handle cases where it might not be provided.

Also applies to: 50-50

Verification successful

The isFree prop in registerSummary.tsx is correctly provided with a default value of false and is used consistently in conditional rendering.

  • components/domains/registerSummary.tsx:
    • Line 32: isFree?: boolean;
    • Line 50: isFree = false,
    • Line 54: {isFree ? (
    • Line 58: {isFree ? null : areArCurrenciesEnabled ? (
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the handling and default value of `isFree` prop in RegisterSummary component.

# Test: Search for usage of `isFree` prop. Expect: Default value provided and used consistently.
rg --type typescript $'isFree'

Length of output: 64



Script:

#!/bin/bash
# Description: Verify the handling and default value of `isFree` prop in RegisterSummary component.

# Test: Search for usage of `isFree` prop. Expect: Default value provided and used consistently.
rg --type ts 'isFree'
rg --type tsx 'isFree'

Length of output: 485

components/discount/registerDiscount.tsx (3)

333-336: Review the implementation of the changeCoupon function.

The changeCoupon function correctly updates the coupon state and sets couponError based on whether the coupon value is empty. This ensures proper validation and user feedback.


388-398: Validate the conditional rendering and error handling for the coupon code input.

The conditional rendering based on the couponCode prop and the error handling for the coupon input are implemented correctly. This ensures that the coupon code feature is optional and that errors are handled appropriately.


52-54: Ensure proper handling and default values for new props in RegisterDiscount.

The new props couponCode, couponHelper, and banner are used to enhance the component's functionality. Verify that these props are always provided when the component is used, or consider setting sensible default values.

Also applies to: 65-67

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: 4

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between ba22ed4 and 83269b3.
Files selected for processing (4)
  • components/discount/discountCheckoutScreen.tsx (4 hunks)
  • components/discount/registerDiscount.tsx (12 hunks)
  • pages/domain-gift.tsx (1 hunks)
  • utils/campaignService.ts (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • components/discount/discountCheckoutScreen.tsx
  • pages/domain-gift.tsx
Additional comments not posted (1)
components/discount/registerDiscount.tsx (1)

61-64: Ensure correct prop types for couponCode, couponHelper, and banner.

Check if couponCode should be a boolean (as defined) or if it should be a string or other type based on its usage in the component.

Verification successful

Ensure correct prop types for couponCode, couponHelper, and banner.

The prop types for couponCode, couponHelper, and banner in the RegisterDiscountProps interface are correctly defined as boolean, string, and string respectively. Their usage within the component aligns with these types:

  • couponCode is used in a conditional rendering, which is appropriate for a boolean.

  • couponHelper is assigned to helperText, which is appropriate for a string.

  • banner is used as the src attribute of an img tag, which is appropriate for a string.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the prop types for `couponCode`, `couponHelper`, and `banner` are correctly used throughout the component.

# Test: Search for prop usage in the component.
ast-grep --lang javascript --pattern $'const RegisterDiscount: FunctionComponent<RegisterDiscountProps> = ($_) {
  $$$
  $_($_)
}'

Length of output: 644



Script:

#!/bin/bash
# Description: Verify that the prop types for `couponCode`, `couponHelper`, and `banner` are correctly used throughout the component.

# Test: Search for prop usage in the component.
ast-grep --lang typescript --pattern 'const RegisterDiscount: FunctionComponent<$_> = ($$) => { $$$ }'

Length of output: 104



Script:

#!/bin/bash
# Description: Verify the prop types for `couponCode`, `couponHelper`, and `banner` in the `RegisterDiscountProps` interface and their usage in the component.

# Step 1: Search for the `RegisterDiscountProps` interface definition.
ast-grep --lang typescript --pattern 'interface RegisterDiscountProps { $$$ }'

# Step 2: Verify the usage of `couponCode`, `couponHelper`, and `banner` within the component.
rg 'couponCode|couponHelper|banner' components/discount/registerDiscount.tsx

Length of output: 416

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

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 83269b3 and 89ee166.
Files selected for processing (1)
  • components/discount/discountOfferScreenVariant.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • components/discount/discountOfferScreenVariant.tsx

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Contributor

@fricoben fricoben left a comment

Choose a reason for hiding this comment

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

Code only

For now I've looked only at the code, we have a lot of small recommendations here and there.

@@ -0,0 +1,86 @@
import React, { useEffect, useState } from "react";
Copy link
Contributor

Choose a reason for hiding this comment

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

freeregistration.tsx

import DiscountCheckoutScreen from "../components/discount/discountCheckoutScreen";

// Create a new discount in utils to create a new discount campaign
import { domainGift } from "../utils/discounts/domainGift";
Copy link
Contributor

Choose a reason for hiding this comment

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

Replace domain gift by freeRegistration everywhere.

It's a better naming cause for the code it gives more information about you're doing.

setScreen(screen - 1);
}

const getCustomCalls: GetCustomCalls = (
Copy link
Contributor

Choose a reason for hiding this comment

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

add to registrationCall.ts adding a relevant naming :)

/>
) : null}
{screen === 1 ? (
<DiscountOfferScreenVariant
Copy link
Contributor

Choose a reason for hiding this comment

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

No description provided.

import SearchBar from "../UI/searchBar";
import Timer from "../UI/timer";

type DiscountOfferScreenVariantProps = {
Copy link
Contributor

Choose a reason for hiding this comment

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

change name to what FreeRegisterDiscount

@@ -40,6 +40,15 @@ import {
getDomainPriceAltcoin,
getTokenQuote,
} from "../../utils/altcoinService";
import { getFreeDomain } from "@/utils/campaignService";

export type GetCustomCalls = (
Copy link
Contributor

Choose a reason for hiding this comment

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

no need for a type.

Use the Call type and follow what we do in registrationCalls.ts

couponCode,
couponHelper,
banner = "/visuals/register.webp",
getCustomCalls,
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think of creating a freeRegister.tsx component based on this one instead of reusing it ?

you wouldn't need to pass the calls in props ...

I think it would be clearer tbh

@@ -1,6 +1,6 @@
import React, { FunctionComponent } from "react";
import styles from "../../styles/discount.module.css";
import RegisterDiscount from "./registerDiscount";
import RegisterDiscount, { GetCustomCalls } from "./registerDiscount";

type DiscountCheckoutScreenProps = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this component really useful ? It seems like a wrapper for RegisterDiscount

It would delete a lot of useless code to directly use RegisterDiscount where needed and add <div className={styles.container}> in it

You have more context than me as I don't remember so well this part of the code. Wdyt ?

@fricoben fricoben requested a review from irisdv May 22, 2024 16:42
@fricoben fricoben added ❌ Change request Change requested from reviewer and removed 🔥 Ready for review This pull request needs a review labels May 22, 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: 2

Outside diff range and nitpick comments (1)
pages/quantumleap.tsx (1)

89-102: Consider using a context or Redux for managing the state across multiple components and screens.

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 89ee166 and 10063fd.
Files selected for processing (8)
  • components/discount/discountCheckoutScreen.tsx (3 hunks)
  • components/discount/freeRegisterDiscount.tsx (1 hunks)
  • components/discount/registerDiscount.tsx (12 hunks)
  • pages/freeregistration.tsx (1 hunks)
  • pages/quantumleap.tsx (2 hunks)
  • utils/callData/registrationCalls.ts (2 hunks)
  • utils/campaignService.ts (1 hunks)
  • utils/discounts/freeRegistration.ts (1 hunks)
Files not reviewed due to errors (2)
  • utils/callData/registrationCalls.ts (no review received)
  • components/discount/registerDiscount.tsx (no review received)
Files skipped from review due to trivial changes (1)
  • utils/discounts/freeRegistration.ts
Files skipped from review as they are similar to previous changes (2)
  • components/discount/discountCheckoutScreen.tsx
  • utils/campaignService.ts
Additional comments not posted (6)
components/discount/freeRegisterDiscount.tsx (2)

28-49: The component structure and JSX are well-organized and readable.


6-12: Ensure SearchResult type is properly defined and imported.

pages/freeregistration.tsx (2)

28-66: The page component handles different screens effectively using conditional rendering.


17-22: Ensure that the campaign expiry logic is correctly implemented and tested.

Verification successful

The search results indicate that freeRegistration.expiry is used in two places within pages/freeregistration.tsx:

  • Line 17: In the useEffect hook to check if the current timestamp is greater than or equal to the expiry.
  • Line 22: As a prop in a JSX element.

Both usages appear to be consistent with the intended functionality of checking and displaying the campaign expiry. The logic seems correctly implemented.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the campaign expiry logic.

# Test: Search for the usage of `freeRegistration.expiry` in the codebase.
rg --type typescript $'freeRegistration.expiry'

Length of output: 81



Script:

#!/bin/bash
# Description: Verify the campaign expiry logic.

# Test: Search for the usage of `freeRegistration.expiry` in the codebase.
rg --type ts $'freeRegistration.expiry'

Length of output: 195

pages/quantumleap.tsx (2)

89-102: The component structure and JSX are well-organized and readable.


89-102: Ensure that the RegisterDiscount component is correctly integrated and receiving all required props.

Verification successful

The RegisterDiscount component is correctly integrated and receiving all required props in pages/quantumleap.tsx. The props passed to RegisterDiscount in QuantumLeap match the expected RegisterDiscountProps type defined in components/discount/registerDiscount.tsx.

  • domain: searchResult?.name ?? ""
  • duration: getDuration()
  • discountId: getDiscountId()
  • customMessage: getCustomMessage()
  • priceInEth: getPrice()
  • mailGroups: [process.env.NEXT_PUBLIC_MAILING_LIST_GROUP ?? "", quantumLeapDiscount.discountMailGroupId]
  • goBack: goBack

No issues were found with the integration.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the integration of `RegisterDiscount` component.

# Test: Search for the usage of `RegisterDiscount` in the codebase.
rg --type typescript $'RegisterDiscount'

Length of output: 74



Script:

#!/bin/bash
# Description: Verify the integration of `RegisterDiscount` component.

# Test: Search for the usage of `RegisterDiscount` in the codebase.
rg --type ts,tsx 'RegisterDiscount'

Length of output: 66



Script:

#!/bin/bash
# Description: Verify the integration of `RegisterDiscount` component.

# Test: Search for the usage of `RegisterDiscount` in the codebase.
rg --type ts 'RegisterDiscount'
rg --type tsx 'RegisterDiscount'

Length of output: 1262



Script:

#!/bin/bash
# Description: Extract relevant portions of files for `RegisterDiscount` integration review.

# Extract the relevant portion from `pages/quantumleap.tsx`.
rg --type ts 'RegisterDiscount' pages/quantumleap.tsx -A 10 -B 10

# Extract the relevant portion from `components/discount/registerDiscount.tsx`.
rg --type ts 'RegisterDiscount' components/discount/registerDiscount.tsx -A 10 -B 10

Length of output: 3028

components/discount/freeRegisterDiscount.tsx Outdated Show resolved Hide resolved
pages/freeregistration.tsx Outdated Show resolved Hide resolved
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between baf51ff and 2061244.

Files selected for processing (1)
  • utils/callData/registrationCalls.ts (2 hunks)
Additional context used
Biome
utils/callData/registrationCalls.ts

[error] 1-1: All these imports are only used as types.

Additional comments not posted (1)
utils/callData/registrationCalls.ts (1)

224-224: Consider removing the unnecessary flat() method.

- calldata: [newTokenId, encodedDomain, signature, txMetadataHash].flat(),
+ calldata: [newTokenId, encodedDomain, ...signature, txMetadataHash],

The array [newTokenId, encodedDomain, signature, txMetadataHash] is already flat, and signature is spread into the array to ensure all elements are at the same level.

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: 8

Outside diff range and nitpick comments (7)
components/discount/freeRenewalPresentation.tsx (3)

7-7: Ensure the title prop structure is documented in the prop types.

It's good practice to document the expected structure of object props, especially when they are complex. This helps other developers understand what properties are expected without needing to dig through the code.


Line range hint 22-22: Add an alt attribute to the image for accessibility.

- <img src={image} className={styles.illustration} />
+ <img src={image} className={styles.illustration} alt="Renewal illustration" />

Images should have an alt attribute to provide a text alternative for screen readers. This improves accessibility for users with visual impairments.


Line range hint 1-1: Consider using import type for type-only imports.

- import React, { FunctionComponent } from "react";
+ import React from "react";
+ import type { FunctionComponent } from "react";

This change clarifies that FunctionComponent is used for type checking only, which can help during the TypeScript compilation process to skip the JavaScript output for these imports.

components/discount/FreeRegisterPresentation.tsx (1)

6-13: Ensure the title prop structure is documented in the prop types.

It's good practice to document the expected structure of object props, especially when they are complex. This helps other developers understand what properties are expected without needing to dig through the code.

components/discount/freeRenewalDiscount.tsx (3)

Line range hint 435-435: Add an alt attribute to the image for accessibility.

- <img className={styles.image} src="/visuals/register.webp" />
+ <img className={styles.image} src="/visuals/register.webp" alt="Visual representation of the registration process" />

Images should have an alt attribute to provide a text alternative for screen readers. This improves accessibility for users with visual impairments.


Line range hint 1-2: Consider using import type for type-only imports.

- import { FunctionComponent, useEffect, useState } from "react";
- import { Call } from "starknet";
+ import type { FunctionComponent, useEffect, useState } from "react";
+ import type { Call } from "starknet";

This change clarifies that these imports are used for type checking only, which can help during the TypeScript compilation process to skip the JavaScript output for these imports.

Also applies to: 14-15


Line range hint 108-108: Specify all necessary dependencies in the useEffect hook.

- }, [renewData]);
+ }, [renewData, addTransaction, groups, needMetadata, salt, metadataHash, email, isSwissResident]);

It's important to include all variables used inside a useEffect hook in its dependency array to avoid issues with stale closures and ensure the hook reacts to changes in these variables.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2061244 and 8177da2.

Files selected for processing (7)
  • components/discount/FreeRegisterPresentation.tsx (1 hunks)
  • components/discount/freeRenewalDiscount.tsx (3 hunks)
  • components/discount/freeRenewalPresentation.tsx (2 hunks)
  • components/discount/registerFree.tsx (1 hunks)
  • pages/freeregistration.tsx (1 hunks)
  • pages/freerenewal.tsx (3 hunks)
  • tests/utils/campaignService.test.js (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • pages/freeregistration.tsx
  • tests/utils/campaignService.test.js
Additional context used
Biome
components/discount/freeRenewalPresentation.tsx

[error] 22-22: Provide a text alternative through the alt, aria-label or aria-labelledby attribute


[error] 1-1: Some named imports are only used as types.

components/discount/FreeRegisterPresentation.tsx

[error] 30-30: Template literals are preferred over string concatenation.


[error] 39-39: Provide a text alternative through the alt, aria-label or aria-labelledby attribute


[error] 1-1: Some named imports are only used as types.

components/discount/registerFree.tsx

[error] 219-219: Avoid the words "image", "picture", or "photo" in img element alt text.


[error] 102-102: This hook does not specify all of its dependencies: addTransaction

components/discount/freeRenewalDiscount.tsx

[error] 242-242: Unnecessary use of boolean literals in conditional expression.


[error] 284-284: Change to an optional chain.


[error] 435-435: Provide a text alternative through the alt, aria-label or aria-labelledby attribute


[error] 1-2: Some named imports are only used as types.


[error] 14-15: All these imports are only used as types.


[error] 104-104: This hook specifies more dependencies than necessary: setPotentialPrice


[error] 108-108: This hook does not specify all of its dependencies: addTransaction


[error] 108-108: This hook does not specify all of its dependencies: groups


[error] 108-108: This hook does not specify all of its dependencies: needMetadata


[error] 108-108: This hook does not specify all of its dependencies: salt


[error] 108-108: This hook does not specify all of its dependencies: metadataHash


[error] 108-108: This hook does not specify all of its dependencies: email


[error] 108-108: This hook does not specify all of its dependencies: isSwissResident


[error] 154-154: This hook does not specify all of its dependencies: quoteData


[error] 154-154: This hook does not specify all of its dependencies: quoteData.max_quote_validity


[error] 154-154: This hook specifies more dependencies than necessary: price


[error] 173-173: Use Number.parseInt instead of the equivalent global.


[error] 199-199: This hook specifies more dependencies than necessary: address


[error] 210-210: Use Number.parseInt instead of the equivalent global.


[error] 256-256: This hook specifies more dependencies than necessary: price, salesTaxAmount, duration, discountId, needMetadata

Additional comments not posted (2)
pages/freerenewal.tsx (2)

36-36: Verify the correct handling of the setScreen function.

Ensure that the setScreen function correctly handles the screen state transitions, especially in edge cases where the state might not update as expected.


46-46: Review the use of environment variables and group IDs.

Ensure that the environment variable NEXT_PUBLIC_MAILING_LIST_GROUP_AUTO_RENEWAL is used consistently and securely throughout the codebase.

components/discount/FreeRegisterPresentation.tsx Outdated Show resolved Hide resolved
components/discount/FreeRegisterPresentation.tsx Outdated Show resolved Hide resolved
components/discount/FreeRegisterPresentation.tsx Outdated Show resolved Hide resolved
pages/freerenewal.tsx Show resolved Hide resolved
components/discount/registerFree.tsx Outdated Show resolved Hide resolved
components/discount/registerFree.tsx Outdated Show resolved Hide resolved
components/discount/registerFree.tsx Outdated Show resolved Hide resolved
components/discount/freeRenewalDiscount.tsx Show resolved Hide resolved
Marchand-Nicolas and others added 4 commits May 31, 2024 21:29
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Contributor

@fricoben fricoben left a comment

Choose a reason for hiding this comment

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

Quick changes and we're good !

banner: string;
};

const FreeRegisterCheckout: FunctionComponent<FreeRegisterCheckoutProps> = ({
Copy link
Contributor

Choose a reason for hiding this comment

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

the name of the file is different that the name of the component

<TxConfirmationModal
txHash={registerData?.transaction_hash}
isTxModalOpen={isTxModalOpen}
closeModal={() => setIsTxModalOpen(false)}
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of having this modal, you can reuse the model we have on the registration part by sending it to a different page (confirmation.tsx with the URL /confirmation?tokenId=ID).

@fricoben fricoben added ❌ Change request Change requested from reviewer and removed 🔥 Ready for review This pull request needs a review labels Jun 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/discount/freeRegisterCheckout.tsx (1)

163-229: The JSX structure is comprehensive, handling various states and user interactions effectively. Consider adding aria-labels for accessibility improvements.

// Add aria-labels for better accessibility
<Button aria-label="Register my domain" onClick={handleRegister}>Register my domain</Button>
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8177da2 and e2a19d0.

Files selected for processing (5)
  • components/discount/freeRegisterCheckout.tsx (1 hunks)
  • components/discount/freeRegisterPresentation.tsx (1 hunks)
  • pages/freeregistration.tsx (1 hunks)
  • styles/components/registerV2.module.css (1 hunks)
  • utils/discounts/freeRegistration.ts (1 hunks)
Files skipped from review due to trivial changes (1)
  • styles/components/registerV2.module.css
Files skipped from review as they are similar to previous changes (2)
  • pages/freeregistration.tsx
  • utils/discounts/freeRegistration.ts
Additional comments not posted (4)
components/discount/freeRegisterPresentation.tsx (3)

7-14: The addition of the expiry prop is well-integrated and aligns with the PR objectives to include an expiry timer in the UI.


16-49: The main function logic for handling search results and screen transitions is clear and effective.


24-49: The JSX structure is well-organized, effectively using conditional rendering and integrating the Timer component. Styling with CSS modules enhances maintainability.

components/discount/freeRegisterCheckout.tsx (1)

25-33: The addition of couponCode and couponHelper props supports the new functionality of handling coupon codes, aligning with the PR objectives.

components/discount/freeRegisterCheckout.tsx Show resolved Hide resolved
@Marchand-Nicolas Marchand-Nicolas added 🔥 Ready for review This pull request needs a review and removed ❌ Change request Change requested from reviewer labels Jun 5, 2024
Copy link
Contributor

@fricoben fricoben left a comment

Choose a reason for hiding this comment

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

lgtm

@fricoben fricoben merged commit df74337 into testnet Jun 6, 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.

Domain gift page
3 participants