Skip to content

Lewis/pol#164

Merged
carhartlewis merged 2 commits into
mainfrom
lewis/pol
Mar 20, 2025
Merged

Lewis/pol#164
carhartlewis merged 2 commits into
mainfrom
lewis/pol

Conversation

@carhartlewis

@carhartlewis carhartlewis commented Mar 20, 2025

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features
    • Enhanced login experience: Signed-in users are now automatically redirected to the home page.
  • Refactor
    • Streamlined retrieval of user API keys through improved session handling.
    • Removed redundant code and adjusted component structuring for clarity.
  • Style
    • Unified code formatting and indentation across configurations and tasks to boost maintainability.

- Cleaned up layout component for better readability and structure.
- Improved authentication handling in the API keys page by removing redundant session checks.
- Updated the `getApiKeys` function to directly use the session for organization ID retrieval.
- Added session check in the auth page to redirect logged-in users away from the login screen.
…ndling

- Reformatted the `createOrganizationTask` function for better code structure and clarity.
- Enhanced error handling and logging throughout the organization creation process.
- Updated the `createOrganizationPolicy`, `createOrganizationCategories`, `createOrganizationControlRequirements`, and `createOrganizationEvidence` functions to include userId in their parameters for better tracking.
- Ensured consistent use of async/await patterns for database operations.
@vercel

vercel Bot commented Mar 20, 2025

Copy link
Copy Markdown

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

Name Status Preview Comments Updated (UTC)
app ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 20, 2025 7:12pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
comp-portal ⬜️ Skipped (Inspect) Mar 20, 2025 7:12pm

@coderabbitai

coderabbitai Bot commented Mar 20, 2025

Copy link
Copy Markdown

Walkthrough

The pull request updates several application modules with primarily formatting improvements and minor logic refinements. The configuration and task files now use tab-based indentation instead of spaces. In addition, some files have undergone cleanup by removing unused imports and reformatting function signatures. The API keys page has been refactored to centralize session handling and simplify its parameter list, while the authentication page now checks for a valid session and redirects authenticated users. There are no changes to the exported interfaces.

Changes

File(s) Change Summary
apps/app/next.config.ts
apps/app/src/jobs/tasks/organization/.../create-organization.ts
Reformatting changes: Indentation changed from spaces to tabs; configuration and task logic remain unaffected.
apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/layout.tsx Formatting and cleanup: Code restructured for readability and unused imports removed.
apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/settings/api-keys/page.tsx
apps/app/src/app/[locale]/(public)/auth/page.tsx
Logic updates: API keys page now handles session retrieval internally (removed redundant organizationId parameter), and auth page adds a session check with redirection for authenticated users.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant AuthPage
    participant AuthService

    User->>AuthPage: Request Auth Page
    AuthPage->>AuthService: Invoke auth()
    AuthService-->>AuthPage: Return session data
    alt User is authenticated
        AuthPage->>User: Redirect to Home Page
    else
        AuthPage->>User: Render Login Page
    end
Loading
sequenceDiagram
    participant User
    participant ApiKeysPage
    participant AuthService
    participant Database

    User->>ApiKeysPage: Request API Keys Page
    ApiKeysPage->>AuthService: Invoke auth() internally
    AuthService-->>ApiKeysPage: Return session (with orgId)
    alt Organization ID exists
        ApiKeysPage->>Database: Query API keys using orgId
        Database-->>ApiKeysPage: Return API keys
        ApiKeysPage->>User: Render API keys list
    else
        ApiKeysPage->>User: Render empty list
    end
Loading

Poem

I'm a rabbit with a joyful code hop,
Tabs now lead spaces to the top.
Unused imports scamper away,
Clean code brightens up my day.
With each line trimmed and logic clear,
My bunny heart cheers—code magic is here!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e9a3600 and 2e7485b.

📒 Files selected for processing (5)
  • apps/app/next.config.ts (1 hunks)
  • apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/layout.tsx (1 hunks)
  • apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/settings/api-keys/page.tsx (2 hunks)
  • apps/app/src/app/[locale]/(public)/auth/page.tsx (2 hunks)
  • apps/app/src/jobs/tasks/organization/create-organization.ts (1 hunks)
🔇 Additional comments (9)
apps/app/next.config.ts (1)

4-36: Consistent indentation style applied.

The configuration has been reformatted to use tabs instead of spaces for indentation without changing any of the functionality or configuration values. This formatting change appears to be consistent with other files in this PR.

apps/app/src/jobs/tasks/organization/create-organization.ts (1)

8-388: Consistent indentation style applied to the entire file.

The entire file has been reformatted to use tabs instead of spaces for indentation, which aligns with the formatting changes in other files. No functional changes have been made to the business logic, task definitions, or database operations.

apps/app/src/app/[locale]/(public)/auth/page.tsx (2)

13-14: Required imports added for authentication flow.

Added imports for the auth function and the redirect utility, which are used to implement the authentication check and redirect logic.


26-30: Improved authentication flow with redirect.

Added a session check that redirects authenticated users away from the login page to the home page. This is a good security practice that prevents unnecessary display of the login page to already authenticated users.

apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/layout.tsx (2)

8-11: Consistent indentation style applied.

Dynamic import for HotKeys component has been reformatted to use tabs instead of spaces for indentation, maintaining consistency with other files in this PR.


15-43: Consistent indentation style throughout the component.

The Layout component's parameter list and function body have been reformatted to use tabs for indentation, while maintaining the same functionality. Unused imports have been removed (not visible in the diff), improving code cleanliness.

apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/settings/api-keys/page.tsx (3)

19-19: Good simplification of the API keys retrieval

The code now directly calls getApiKeys() without parameters, which makes the component cleaner and follows good separation of concerns by moving session handling logic inside the data fetching function.


42-47: Good refactoring to centralize session handling

This is a solid improvement that:

  1. Centralizes session handling within the data fetching function
  2. Properly handles the case when no valid session exists
  3. Makes the component code cleaner by encapsulating authentication logic

The empty array return provides graceful degradation when no organization ID is available.


51-51: Consistent update to use session data directly

Using session.user.organizationId directly in the query is consistent with the refactoring approach and ensures the correct organization's API keys are retrieved.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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 generate docstrings to generate docstrings for this 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.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant