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: implemented auth, ui for most, and fixed cors #217

Merged
merged 11 commits into from
May 18, 2024
Merged

Conversation

kriptonian1
Copy link
Contributor

@kriptonian1 kriptonian1 commented May 13, 2024

User description

Description

Give a summary of the change that you have made

Fixes #[ISSUENO]

Dependencies

Mention any dependencies/packages used

Future Improvements

Mention any improvements to be done in future related to any file/feature

Mentions

Mention and tag the people

Screenshots of relevant screens

Add screenshots of relevant screens

Developer's checklist

  • My PR follows the style guidelines of this project
  • I have performed a self-check on my work

If changes are made in the code:

  • I have followed the coding guidelines
  • My changes in code generate no new warnings
  • My changes are breaking another fix/feature of the project
  • I have added test cases to show that my feature works
  • I have added relevant screenshots in my PR
  • There are no UI/UX issues

Documentation Update

  • This PR requires an update to the documentation at docs.keyshade.xyz
  • I have made the necessary updates to the documentation, or no documentation changes are required.

PR Type

enhancement, bug_fix


Description

  • Implemented various UI components like Menubar, Team Table, Context Menu, Dropdown Menu, Command UI, Sheet, Dialog, Profile Settings Page, Project Card, Navbar, Account Details Page, Team Header, Table, OTP Verification Page, Combobox, Main Page Layout, Line Tab, OTP Input, Detailed Project Page, Search Model, Button, Sidebar, Scroll Area, Sidebar Tab, Toaster, Avatar, Popover, Switch, and Settings Layout using libraries like Radix UI, cmdk, and Tanstack React Table.
  • Enhanced existing components with new features, improved styles, accessibility, and exported them for external usage.
  • Connected components with backend APIs for dynamic data handling and implemented navigation and state management for various user interactions.
  • Styled components for consistency across light and dark themes and ensured responsive design.

Changes walkthrough 📝

Relevant files
Enhancement
31 files
menubar.tsx
Implement Comprehensive Menubar Component with Radix UI   

apps/platform/src/components/ui/menubar.tsx

  • Implemented a comprehensive menubar component using Radix UI
    primitives.
  • Added various subcomponents like MenubarTrigger, MenubarItem,
    MenubarCheckboxItem, etc.
  • Utilized utility functions for class name manipulations and
    conditional rendering.
  • Exported all subcomponents for external usage.
  • +233/-0 
    index.tsx
    Add Team Table Component with Sorting and Pagination         

    apps/platform/src/components/teams/teamTable/index.tsx

  • Created a new team table component using Tanstack React Table.
  • Defined columns and data integration for displaying team payment
    information.
  • Added UI elements like buttons and dropdown menus for actions on table
    items.
  • Implemented pagination and sorting functionality.
  • +327/-0 
    context-menu.tsx
    Develop Context Menu Component with Radix UI                         

    apps/platform/src/components/ui/context-menu.tsx

  • Developed a context menu component using Radix UI primitives.
  • Included subcomponents like ContextMenuTrigger, ContextMenuItem, and
    ContextMenuCheckboxItem.
  • Styled components for both light and dark themes.
  • Exported all necessary subcomponents for reuse.
  • +197/-0 
    dropdown-menu.tsx
    Create Dropdown Menu Component Using Radix UI                       

    apps/platform/src/components/ui/dropdown-menu.tsx

  • Created a dropdown menu component with Radix UI primitives.
  • Added subcomponents like DropdownMenuTrigger, DropdownMenuItem, and
    DropdownMenuCheckboxItem.
  • Configured animations and theming for the dropdown components.
  • Exported all subcomponents for external use.
  • +197/-0 
    command.tsx
    Implement Command UI Component with cmdk Library                 

    apps/platform/src/components/ui/command.tsx

  • Implemented a command UI component using cmdk library.
  • Added subcomponents like CommandDialog, CommandInput, and CommandList
    for modular command inputs.
  • Integrated theme support and provided export of all subcomponents.
  • +157/-0 
    sheet.tsx
    Implement Sheet Component for Modal Dialogues Using Radix UI

    apps/platform/src/components/ui/sheet.tsx

  • Implemented a sheet component using Radix UI for modal dialogues.
  • Added subcomponents like SheetContent, SheetHeader, and SheetFooter
    for structured content.
  • Configured animations and accessibility features.
  • Exported all components for reuse.
  • +144/-0 
    page.tsx
    Create OTP Verification Page for Authentication Flow         

    apps/platform/src/app/auth/otp/page.tsx

  • Created a new page for OTP verification during authentication.
  • Integrated OTP input handling and validation with backend API.
  • Added UI elements for user interaction and feedback.
  • Implemented navigation based on OTP verification result.
  • +147/-0 
    dialog.tsx
    Develop Dialog Component Using Radix UI                                   

    apps/platform/src/components/ui/dialog.tsx

  • Developed a dialog component using Radix UI primitives.
  • Included subcomponents like DialogContent, DialogTrigger, and
    DialogClose.
  • Styled the dialog for consistency across themes.
  • Exported all subcomponents for external usage.
  • +123/-0 
    page.tsx
    Create Profile Settings Page for User Management                 

    apps/platform/src/app/(main)/settings/@profile/page.tsx

  • Created a profile settings page for user profile management.
  • Added input fields for user information like email and username.
  • Integrated API for saving changes to the user profile.
  • Implemented UI feedback for action results.
  • +117/-0 
    index.tsx
    Develop Project Card Component with Context Menu Integration

    apps/platform/src/components/dashboard/projectCard/index.tsx

  • Developed a project card component for dashboard views.
  • Integrated context menu for project actions like edit and delete.
  • Displayed project details such as environment and configuration
    counts.
  • Added navigation to detailed project views.
  • +141/-0 
    index.tsx
    Enhance Navbar with Search and Account Dropdown Features 

    apps/platform/src/components/shared/navbar/index.tsx

  • Updated the navbar component with new features.
  • Added search functionality with a dropdown for account actions.
  • Integrated theme switching and user avatar display.
  • Improved responsive design and accessibility.
  • +111/-0 
    page.tsx
    Create Account Details Completion Page for New Users         

    apps/platform/src/app/auth/account-details/page.tsx

  • Created a new page for users to complete their account details
    post-signup.
  • Added input fields for additional user information.
  • Connected the form to the backend for data submission.
  • Implemented navigation based on the completion of the account setup.
  • +114/-0 
    index.tsx
    Implement Team Header Component with Role and Member Addition

    apps/platform/src/components/teams/teamHeader/index.tsx

  • Implemented a header component for the team management section.
  • Added buttons for creating new roles and adding team members.
  • Integrated dialogs for inputting new team member and role details.
  • +125/-0 
    table.tsx
    Implement Basic Table Component with Modular Subcomponents

    apps/platform/src/components/ui/table.tsx

  • Implemented a table component using basic HTML table elements.
  • Added subcomponents like TableHeader, TableRow, and TableCell for
    modular table construction.
  • Styled the table for a consistent look across themes.
  • Exported all subcomponents for external usage.
  • +123/-0 
    page.tsx
    Create Teammate Invitation Page for User Onboarding           

    apps/platform/src/app/auth/invite/page.tsx

  • Created a new page for inviting teammates to the platform.
  • Added input handling for email invitations.
  • Implemented UI elements for user interaction and feedback.
  • Connected the invitation process with the backend API.
  • +88/-0   
    page.tsx
    Create Authentication Page with Email and Third-Party Options

    apps/platform/src/app/auth/page.tsx

  • Created a new authentication page for user login and signup.
  • Added input fields for email and integrated third-party authentication
    options.
  • Connected the authentication process with the backend API.
  • Implemented navigation based on authentication status.
  • +108/-0 
    combobox.tsx
    Implement Combobox Component with Search Functionality     

    apps/platform/src/components/ui/combobox.tsx

  • Implemented a combobox component using Radix UI.
  • Added a dropdown for selecting options with search functionality.
  • Styled the combobox for a consistent look across themes.
  • Exported the component for external usage.
  • +111/-0 
    page.tsx
    Create Main Page Layout with Project Summary and Edit Functionality

    apps/platform/src/app/(main)/page.tsx

  • Created a main page layout for the platform.
  • Integrated project card components for displaying project summaries.
  • Added a sheet component for editing project details.
  • Implemented navigation and state management for UI interactions.
  • +106/-0 
    line-tab.tsx
    Implement Line Tab Component for Settings Navigation         

    apps/platform/src/components/ui/line-tab.tsx

  • Implemented a line tab component for navigation within settings.
  • Added dynamic tab generation based on provided labels.
  • Integrated URL-based navigation for tab switching.
  • Styled the tabs for a consistent look across themes.
  • +90/-0   
    input-otp.tsx
    Implement OTP Input Component with Structured Subcomponents

    apps/platform/src/components/ui/input-otp.tsx

  • Implemented an OTP input component using custom hooks.
  • Added subcomponents like InputOTPSlot and InputOTPSeparator for
    structured OTP input.
  • Styled the OTP input for a consistent look across themes.
  • Exported all subcomponents for external usage.
  • +68/-0   
    page.tsx
    Create Detailed Project Page with Secret Management           

    apps/platform/src/app/(main)/project/[project]/page.tsx

  • Created a detailed project page for individual project management.
  • Added input fields for project secrets and configurations.
  • Integrated a dialog component for adding new project keys.
  • Styled the page for a consistent look across themes.
  • +88/-0   
    index.tsx
    Develop Search Model Component for Navbar with Command UI

    apps/platform/src/components/shared/navbar/searchModel/index.tsx

  • Developed a search model component for the navbar.
  • Integrated command UI for search functionality.
  • Added suggestions and settings options within the search interface.
  • Styled the component for a consistent look across themes.
  • +84/-0   
    button.tsx
    Update Button Component with New Styles and Accessibility Features

    apps/platform/src/components/ui/button.tsx

  • Updated the button component with new styles and variants.
  • Added disabled state handling and improved accessibility features.
  • Styled the button for a consistent look across themes.
  • Exported the component for external usage.
  • +3/-3     
    index.tsx
    Implement Sidebar Component with Navigation Links and Combobox

    apps/platform/src/components/shared/sidebar/index.tsx

  • Implemented a sidebar component for navigation.
  • Added links to main sections like Dashboard, Teams, and Settings.
  • Integrated a combobox component for additional interactions.
  • Styled the sidebar for a consistent look across themes.
  • +71/-0   
    scroll-area.tsx
    Implement Scroll Area Component with Custom Scrollbar       

    apps/platform/src/components/ui/scroll-area.tsx

  • Implemented a scroll area component using Radix UI.
  • Added a custom scrollbar for improved interaction.
  • Styled the scroll area for a consistent look across themes.
  • Exported the component for external usage.
  • +45/-0   
    index.tsx
    Develop Sidebar Tab Component with Active State Handling 

    apps/platform/src/components/shared/sidebar/sidebarTab/index.tsx

  • Developed a sidebar tab component for individual navigation items.
  • Added icons and links for each tab.
  • Integrated active state handling based on the current route.
  • Styled the tabs for a consistent look across themes.
  • +55/-0   
    sonner.tsx
    Implement Toaster Component with Theme Support and Configurable
    Options

    apps/platform/src/components/ui/sonner.tsx

  • Implemented a toaster component using the Sonner library.
  • Integrated theme support for consistent styling.
  • Configured toast options for different types of notifications.
  • Exported the component for external usage.
  • +32/-0   
    avatar.tsx
    Develop Avatar Component with Image and Fallback Support 

    apps/platform/src/components/ui/avatar.tsx

  • Developed an avatar component using Radix UI.
  • Added subcomponents like AvatarImage and AvatarFallback for flexible
    usage.
  • Styled the avatar for a consistent look across themes.
  • Exported all subcomponents for external usage.
  • +47/-0   
    popover.tsx
    Implement Popover Component with Configurable Positioning and
    Animations

    apps/platform/src/components/ui/popover.tsx

  • Implemented a popover component using Radix UI.
  • Added a trigger and content area for interactive popovers.
  • Configured animations and positioning for the popover.
  • Exported the component for external usage.
  • +28/-0   
    switch.tsx
    Implement Switch Component with Toggle Functionality         

    apps/platform/src/components/ui/switch.tsx

  • Implemented a switch component using Radix UI.
  • Added a thumb subcomponent for toggle functionality.
  • Styled the switch for a consistent look across themes.
  • Exported the component for external usage.
  • +26/-0   
    layout.tsx
    Create Settings Layout Component with Dynamic Tab Rendering

    apps/platform/src/app/(main)/settings/layout.tsx

  • Created a layout component for settings pages.
  • Integrated dynamic rendering based on the selected settings tab.
  • Styled the layout for a consistent look across themes.
  • +29/-0   

    💡 PR-Agent usage:
    Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    Copy link

    codecov bot commented May 13, 2024

    Codecov Report

    All modified and coverable lines are covered by tests ✅

    Project coverage is 91.60%. Comparing base (7bb3d21) to head (056b454).
    Report is 77 commits behind head on develop.

    Additional details and impacted files
    @@             Coverage Diff              @@
    ##           develop     #217       +/-   ##
    ============================================
    + Coverage    62.20%   91.60%   +29.40%     
    ============================================
      Files           76      110       +34     
      Lines         1503     2467      +964     
      Branches       260      463      +203     
    ============================================
    + Hits           935     2260     +1325     
    + Misses         568      207      -361     
    Flag Coverage Δ
    api-e2e-tests 91.60% <ø> (+29.40%) ⬆️

    Flags with carried forward coverage won't be shown. Click here to find out more.

    ☔ View full report in Codecov by Sentry.
    📢 Have feedback on the report? Share it here.

    Copy link
    Contributor

    PR Description updated to latest commit (87ab406)

    Copy link
    Contributor

    PR Review 🔍

    ⏱️ Estimated effort to review [1-5]

    5, because the PR includes a large number of files with significant changes across multiple components and features. It involves UI components, backend integration, and state management which increases the complexity and the time required to thoroughly review and test the changes.

    🧪 Relevant tests

    No

    ⚡ Possible issues

    Possible Bug: The PR lacks tests for the new features and changes. This could lead to regressions or unnoticed bugs.

    Code Duplication: There seems to be repetitive code across different components which could be refactored into reusable utilities or components.

    Inconsistent Styling: The use of inline styles and utility classes from Tailwind CSS might lead to inconsistent styling. It's recommended to standardize the approach to maintain consistency.

    🔒 Security concerns

    No apparent security issues in the provided code snippets. However, without seeing the backend changes or how data is handled, it's difficult to fully assess potential security implications.

    Copy link
    Contributor

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Score
    Security
    Enhance user safety by adding a confirmation step before account deletion

    Consider disabling the 'Delete' button until a confirmation step is completed to prevent
    accidental account deletions.

    apps/platform/src/app/(main)/settings/@profile/page.tsx [110]

    -<Button variant="destructive">Delete</Button>
    +<Button variant="destructive" disabled={!isConfirmed}>Delete</Button>
     
    Suggestion importance[1-10]: 9

    Why: This suggestion addresses a significant security and user experience concern by preventing accidental deletions, which is critical for such a destructive action.

    9
    Accessibility
    Enhance accessibility by adding ARIA attributes to interactive components

    To ensure accessibility, consider adding appropriate ARIA attributes to the
    ContextMenuSubTrigger component, such as aria-haspopup and potentially aria-expanded based
    on the component's state.

    apps/platform/src/components/ui/context-menu.tsx [24-34]

     <ContextMenuPrimitive.SubTrigger
    +    aria-haspopup="true"
    +    aria-expanded={props.open}
         className={cn(
             'flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-zinc-100 focus:text-zinc-900 data-[state=open]:bg-zinc-100 data-[state=open]:text-zinc-900 dark:focus:bg-zinc-800 dark:focus:text-zinc-50 dark:data-[state=open]:bg-zinc-800 dark:data-[state=open]:text-zinc-50',
             inset && 'pl-8',
             className
         )}
         ref={ref}
         {...props}
     >
         {children}
         <ChevronRight className="ml-auto h-4 w-4" />
     </ContextMenuPrimitive.SubTrigger>
     
    Suggestion importance[1-10]: 8

    Why: Adding ARIA attributes such as aria-haspopup and aria-expanded is crucial for accessibility, especially for interactive components like ContextMenuSubTrigger. This suggestion directly improves user experience for assistive technologies.

    8
    Improve accessibility by adding descriptive labels to interactive elements

    Add an aria-label to the delete button to improve accessibility for screen readers.

    apps/platform/src/app/(main)/settings/@profile/page.tsx [110]

    -<Button variant="destructive">Delete</Button>
    +<Button variant="destructive" aria-label="Delete account">Delete</Button>
     
    Suggestion importance[1-10]: 6

    Why: Enhancing accessibility is important, and adding aria-label is a straightforward improvement. The suggestion is correct and applies to the new code.

    6
    Error handling
    Add error handling for network failures in the fetch call

    Consider adding error handling for the fetch call to handle cases where the network
    request fails due to reasons other than the response status being 401. This can be done by
    checking if the response is ok (response.ok) before processing the JSON data.

    apps/platform/src/app/auth/otp/page.tsx [56-65]

     const response = await fetch(
       `${process.env.NEXT_PUBLIC_BACKEND_URL}/api/auth/validate-otp?email=${userEmail}&otp=${userOtp}`,
       {
         method: 'POST',
         credentials: 'include'
       }
     )
    -if (response.status === 401) {
    +if (!response.ok) {
       setIsLoading(false)
    +  throw new Error('Network response was not ok.')
     }
     
    Suggestion importance[1-10]: 8

    Why: Adding comprehensive error handling for the fetch call is crucial to handle network failures effectively, which improves the robustness of the application.

    8
    Enhancement
    Add email format validation to improve data integrity

    Implement form validation for the email input to ensure the user enters a valid email
    format.

    apps/platform/src/app/(main)/settings/@profile/page.tsx [48-54]

     <Input
       onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
    -    setEmail(e.target.value)
    +    if (isValidEmail(e.target.value)) {
    +      setEmail(e.target.value)
    +    }
       }}
       placeholder="email"
       value={email}
     />
     
    Suggestion importance[1-10]: 8

    Why: Adding validation for email inputs is crucial for maintaining data integrity and improving user experience. The suggestion is directly relevant to the new code in the PR.

    8
    Enhance component flexibility by initializing state from props

    Replace the hardcoded initial state values for email and username with props or context
    values to enhance flexibility and reusability of the component.

    apps/platform/src/app/(main)/settings/@profile/page.tsx [8-9]

    -const [email, setEmail] = useState<string>('sawan@keyshade.xyz')
    -const [username, setUsername] = useState<string>('kriptonian')
    +const [email, setEmail] = useState<string>(props.initialEmail)
    +const [username, setUsername] = useState<string>(props.initialUsername)
     
    Suggestion importance[1-10]: 7

    Why: The suggestion correctly identifies the hardcoded values and proposes a more flexible approach using props, which is a good practice in React for component reusability.

    7
    Best practice
    Improve type safety by providing a default value for the inset prop

    Consider using a more specific type for the inset prop in MenubarSubTrigger, MenubarItem,
    MenubarLabel components instead of the optional boolean. This can help avoid potential
    bugs related to the handling of undefined values. For instance, you can default inset to
    false if not provided.

    apps/platform/src/components/ui/menubar.tsx [49]

    -inset?: boolean
    +inset: boolean = false
     
    Suggestion importance[1-10]: 7

    Why: Providing a default value for the inset prop enhances type safety and clarity, ensuring that the property is always a boolean and reducing the risk of bugs related to undefined values.

    7
    Improve type safety by specifying a more detailed type for the className prop

    Consider using a more specific type for the className prop in ContextMenuSubTrigger to
    ensure type safety and better integration with potential CSS-in-JS solutions. For example,
    you can extend from string to a specific type that matches your project's styling
    approach.

    apps/platform/src/components/ui/context-menu.tsx [20-21]

     React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubTrigger> & {
    -    inset?: boolean
    +    inset?: boolean,
    +    className?: CustomClassNameType
     }
     
    Suggestion importance[1-10]: 7

    Why: The suggestion correctly identifies an opportunity to enhance type safety by specifying a more detailed type for the className prop, which is beneficial for integration with CSS-in-JS solutions.

    7
    Replace console.error with a more robust logging mechanism

    Replace the direct use of the console.error for logging errors with a more robust logging
    mechanism that can be controlled based on the environment (development, production, etc.).
    This will help in better managing the log levels and formats, especially in production
    environments where console logging is not advisable.

    apps/platform/src/app/auth/otp/page.tsx [79-83]

    -console.error(`Invalid user data: ${error.message}`)
    -console.error(`Failed to verify OTP: ${error}`)
    +logger.error(`Invalid user data: ${error.message}`)
    +logger.error(`Failed to verify OTP: ${error}`)
     
    Suggestion importance[1-10]: 7

    Why: Replacing console.error with a more robust logging mechanism like logger.error is a good practice for better log management, especially in production environments.

    7
    Use environment variables for sensitive data and URLs

    Use environment variables for sensitive URLs and data in the application. This prevents
    hardcoding sensitive information in the source code and allows for easier configuration
    changes without code modifications.

    apps/platform/src/app/auth/otp/page.tsx [56-62]

    +const backendUrl = process.env.NEXT_PUBLIC_BACKEND_URL || 'default_backend_url';
     const response = await fetch(
    -  `${process.env.NEXT_PUBLIC_BACKEND_URL}/api/auth/validate-otp?email=${userEmail}&otp=${userOtp}`,
    +  `${backendUrl}/api/auth/validate-otp?email=${userEmail}&otp=${userOtp}`,
       {
         method: 'POST',
         credentials: 'include'
       }
     )
     
    Suggestion importance[1-10]: 6

    Why: Using environment variables for sensitive URLs and data is a best practice that enhances security and flexibility in configuration management.

    6
    Performance
    Improve performance by preventing unnecessary re-renders using React.memo

    Consider using a memoization technique with React.memo for the MenubarItem component to
    prevent unnecessary re-renders when props do not change. This is particularly useful in
    performance-sensitive applications where the component could be re-rendered frequently.

    apps/platform/src/components/ui/menubar.tsx [107-121]

    -const MenubarItem = React.forwardRef<
    +const MenubarItem = React.memo(React.forwardRef<
       React.ElementRef<typeof MenubarPrimitive.Item>,
       React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Item> & {
         inset?: boolean
       }
     >(({ className, inset, ...props }, ref) => (
       <MenubarPrimitive.Item
         className={cn(
           'relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-white/25 focus:text-white data-[disabled]:pointer-events-none data-[disabled]:opacity-50 dark:focus:bg-zinc-800 dark:focus:text-zinc-50',
           inset && 'pl-8',
           className
         )}
         ref={ref}
         {...props}
       />
    -))
    +)))
     
    Suggestion importance[1-10]: 7

    Why: Using React.memo for the MenubarItem component is a good practice to enhance performance by avoiding unnecessary re-renders, especially in components that might not frequently change.

    7
    Use memoization to improve performance by preventing unnecessary re-renders

    Consider using a memoization technique for components like ContextMenuSubTrigger that are
    likely to re-render frequently. This can help improve performance by avoiding unnecessary
    re-renders.

    apps/platform/src/components/ui/context-menu.tsx [18-36]

    -React.forwardRef<
    -    React.ElementRef<typeof ContextMenuPrimitive.SubTrigger>,
    -    React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubTrigger> & {
    -        inset?: boolean
    -    }
    ->(({ className, inset, children, ...props }, ref) => (
    -    <ContextMenuPrimitive.SubTrigger
    -        className={cn(
    -            'flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-zinc-100 focus:text-zinc-900 data-[state=open]:bg-zinc-100 data-[state=open]:text-zinc-900 dark:focus:bg-zinc-800 dark:focus:text-zinc-50 dark:data-[state=open]:bg-zinc-800 dark:data-[state=open]:text-zinc-50',
    -            inset && 'pl-8',
    -            className
    -        )}
    -        ref={ref}
    -        {...props}
    -    >
    -        {children}
    -        <ChevronRight className="ml-auto h-4 w-4" />
    -    </ContextMenuPrimitive.SubTrigger>
    -))
    +const MemoizedContextMenuSubTrigger = React.memo(ContextMenuSubTrigger);
     
    Suggestion importance[1-10]: 6

    Why: The suggestion to use memoization is appropriate for components that re-render frequently, which can help in improving performance. However, the impact might be moderate depending on the actual usage and re-render patterns of the component.

    6
    Maintainability
    Improve maintainability by extracting complex conditional styles into a CSS module or styled component

    It's recommended to avoid using complex string literals directly in the className
    attribute for readability and maintainability. Consider defining these styles in a CSS
    module or using a styled-components approach, especially for conditional styles like those
    dependent on the state and side.

    apps/platform/src/components/ui/menubar.tsx [72-73]

    -className={cn(
    -  'data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] overflow-hidden rounded-md border border-zinc-200 bg-white p-1 text-zinc-950 dark:border-zinc-800 dark:bg-zinc-950 dark:text-zinc-50',
    -  className
    -)}
    +className={cn(styles.menuBar, className)}
     
    Suggestion importance[1-10]: 6

    Why: Extracting complex class strings into a CSS module or styled component can significantly improve readability and maintainability. However, the impact on functionality is moderate.

    6
    Refactor complex JSX into smaller, reusable components for better maintainability

    To enhance code readability and maintainability, consider breaking down the complex JSX in
    the Menubar component into smaller, reusable sub-components. This approach helps in
    isolating functionality and makes the codebase easier to manage.

    apps/platform/src/components/ui/menubar.tsx [20-27]

    -<MenubarPrimitive.Root
    -  className={cn(
    -    'flex h-10 items-center space-x-1 rounded-md border border-zinc-200 bg-white p-1 dark:border-zinc-800 dark:bg-zinc-950',
    -    className
    -  )}
    -  ref={ref}
    -  {...props}
    -/>
    +<StyledMenubarRoot className={className} ref={ref} {...props} />
     
    Suggestion importance[1-10]: 6

    Why: Breaking down complex JSX into smaller components can improve maintainability and readability. This suggestion is relevant and beneficial, though not critical.

    6
    Abstract className logic into a separate function to improve readability

    To enhance code readability and maintainability, consider abstracting the complex
    className logic into a separate function or utility. This will make the component code
    cleaner and easier to understand.

    apps/platform/src/components/ui/context-menu.tsx [25-29]

    -className={cn(
    -    'flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-zinc-100 focus:text-zinc-900 data-[state=open]:bg-zinc-100 data-[state=open]:text-zinc-900 dark:focus:bg-zinc-800 dark:focus:text-zinc-50 dark:data-[state=open]:bg-zinc-800 dark:data-[state=open]:text-zinc-50',
    -    inset && 'pl-8',
    -    className
    -)}
    +className={generateClassName(inset, className)}
     
    Suggestion importance[1-10]: 6

    Why: Abstracting complex className logic into a separate function is a good practice for improving code readability and maintainability, making the suggestion relevant and useful.

    6
    Refactor OTP validation logic into a separate function for better maintainability

    Refactor the OTP validation logic into a separate function or module to improve code
    readability and maintainability. This will also make it easier to manage changes to the
    validation logic independently of the UI logic.

    apps/platform/src/app/auth/otp/page.tsx [42-48]

    -const alphanumeric = z
    -  .string()
    -  .length(6)
    -  .refine((value) => /^[a-z0-9]+$/i.test(value), {
    -    message: 'OTP must be alphanumeric'
    -  })
    -const otpResult = alphanumeric.safeParse(userOtp)
    +const validateOTP = (otp) => {
    +  const alphanumeric = z
    +    .string()
    +    .length(6)
    +    .refine((value) => /^[a-z0-9]+$/i.test(value), {
    +      message: 'OTP must be alphanumeric'
    +    })
    +  return alphanumeric.safeParse(otp)
    +}
    +const otpResult = validateOTP(userOtp)
     
    Suggestion importance[1-10]: 6

    Why: Refactoring the OTP validation logic into a separate function enhances code readability and maintainability, making it easier to manage and update.

    6

    apps/api/src/main.ts Show resolved Hide resolved
    package.json Outdated Show resolved Hide resolved
    Copy link

    sonarcloud bot commented May 18, 2024

    Quality Gate Passed Quality Gate passed

    Issues
    5 New issues
    16 Accepted issues

    Measures
    0 Security Hotspots
    No data about Coverage
    1.3% Duplication on New Code

    See analysis details on SonarCloud

    @rajdip-b rajdip-b merged commit feace86 into develop May 18, 2024
    8 checks passed
    @rajdip-b rajdip-b deleted the platform branch May 18, 2024 08:34
    rajdip-b pushed a commit that referenced this pull request May 24, 2024
    ## [1.4.0](v1.3.0...v1.4.0) (2024-05-24)
    
    ### 🚀 Features
    
    * add example for health and email auth ([b834d25](b834d25))
    * **api:** Add `minio-client` provider ([#237](#237)) ([cd71c5a](cd71c5a))
    * **api:** Add feature to fork projects ([#239](#239)) ([3bab653](3bab653))
    * **api:** Added feedback form module ([#210](#210)) ([ae1efd8](ae1efd8))
    * **api:** Added Project Level Access  ([#221](#221)) ([564f5ed](564f5ed))
    * **api:** Added support for changing email of users ([#233](#233)) ([5ea9a10](5ea9a10))
    * implemented auth, ui for most, and fixed cors ([#217](#217)) ([feace86](feace86))
    * **platfrom:** add delete method in api client ([#225](#225)) ([55cf09f](55cf09f))
    * **postman:** add example for get_self and update_self ([e015acf](e015acf))
    * **web:** Add and link privacy and tnc page ([#226](#226)) ([ec81eb9](ec81eb9))
    
    ### 🐛 Bug Fixes
    
    * **web:** docker next config not found ([#228](#228)) ([afe3160](afe3160))
    
    ### 📚 Documentation
    
    * Added docs regarding postman, and refactored architecture diagrams ([f1c9777](f1c9777))
    * Fix typo in organization-of-code.md ([#234](#234)) ([11244a2](11244a2))
    
    ### 🔧 Miscellaneous Chores
    
    * **api:** Get feedback forward email from process.env ([#236](#236)) ([204c9d1](204c9d1))
    * **postman:** Initialized postman ([bb76384](bb76384))
    * **release:** Update changelog config ([af91283](af91283))
    * Remove swagger docs ([#220](#220)) ([7640299](7640299))
    
    ### 🔨 Code Refactoring
    
    * **api:** Replaced OTP code from alphanumeric to numeric ([#230](#230)) ([f16162a](f16162a))
    @rajdip-b
    Copy link
    Member

    🎉 This PR is included in version 1.4.0 🎉

    The release is available on GitHub release

    Your semantic-release bot 📦🚀

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

    Successfully merging this pull request may close these issues.

    2 participants