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

chore(cal-com): support custom domains #158

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

bejoinka
Copy link
Contributor

@bejoinka bejoinka commented Oct 8, 2024

PR Type

enhancement


Description

  • Added support for custom domains by introducing a calOrigin property in both CalDotComScheduling and CalDotcomActivity components.
  • Updated Storybook stories to include the calOrigin property with a default value of 'https://cal.com'.
  • Modified components to use the calOrigin property, allowing for enterprise customization.

Changes walkthrough 📝

Relevant files
Enhancement
CalDotComScheduling.stories.tsx
Add `calOrigin` property to CalDotComScheduling story       

src/atoms/scheduling/cal.com/CalDotComScheduling.stories.tsx

  • Added calOrigin property to story arguments.
  • Set default value for calOrigin to 'https://cal.com'.
  • Passed calOrigin to CalDotComSchedulingComponent.
  • +7/-1     
    CalDotComScheduling.tsx
    Support custom `calOrigin` in CalDotComScheduling component

    src/atoms/scheduling/cal.com/CalDotComScheduling.tsx

  • Introduced optional calOrigin property in CalDotComSchedulingProps.
  • Used calOrigin in Cal component with a default fallback.
  • +4/-1     
    calDotcomActivity.stories.tsx
    Add `calOrigin` property to CalDotcomActivity story           

    src/hostedPages/activities/scheduling/cal.com/calDotcomActivity.stories.tsx

  • Added calOrigin property to story arguments.
  • Set default value for calOrigin to 'https://cal.com'.
  • Passed calOrigin to CalDotcomActivityComponent.
  • +7/-0     
    types.ts
    Extend CalDotComActivityProps with `calOrigin`                     

    src/hostedPages/activities/scheduling/cal.com/types.ts

    • Added optional calOrigin property to CalDotComActivityProps.
    +1/-0     

    💡 PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    Copy link

    github-actions bot commented Oct 8, 2024

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Default Value Redundancy
    The default value for 'calOrigin' is set redundantly in multiple components. Consider centralizing or ensuring it is set in a single, appropriate location to avoid discrepancies and ease future changes.

    Copy link

    github-actions bot commented Oct 8, 2024

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Enhancement
    Simplify component logic by providing default values for optional props

    Provide a default value for calOrigin in the function parameters to simplify the
    component logic and avoid repeated fallbacks.

    src/atoms/scheduling/cal.com/CalDotComScheduling.tsx [19]

     export const CalDotComScheduling: FC<CalDotComSchedulingProps> = ({
       calLink,
    -  calOrigin,
    +  calOrigin = 'https://cal.com',
       hideEventTypeDetails = false,
       onBookingSuccessful,
       metadata,
     }) => {
    Suggestion importance[1-10]: 8

    Why: Providing a default value for 'calOrigin' in the function parameters simplifies the component logic and avoids repeated fallbacks, enhancing code readability and maintainability.

    8
    Best practice
    Use constants for default values to improve code maintainability and avoid duplication

    Use a constant for the default calOrigin value to avoid hardcoding URLs in multiple
    places, which improves maintainability.

    src/atoms/scheduling/cal.com/CalDotComScheduling.tsx [86]

    -calOrigin={calOrigin ?? 'https://cal.com'}
    +calOrigin={calOrigin ?? DEFAULT_CAL_ORIGIN}
    Suggestion importance[1-10]: 7

    Why: Using a constant for the default 'calOrigin' value improves maintainability by avoiding hardcoding URLs in multiple places, reducing the risk of errors and making updates easier.

    7
    Validate URL inputs to ensure they are correctly formatted and prevent potential errors

    Validate the calOrigin prop to ensure it contains a valid URL format to prevent
    errors in the component usage.

    src/hostedPages/activities/scheduling/cal.com/calDotcomActivity.stories.tsx [17-19]

     calOrigin: {
       control: 'text',
       name: 'origin',
       defaultValue: 'https://cal.com',
    +  validate: isValidUrl,
     }
    Suggestion importance[1-10]: 6

    Why: Adding validation for the 'calOrigin' prop to ensure it contains a valid URL format is a good practice that can prevent potential errors, although it may require additional implementation for the validation function.

    6

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    1 participant