-
Notifications
You must be signed in to change notification settings - Fork 236
chore: update dependencies and refactor authentication redirects in l… #139
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
Conversation
…ayout and risk pages; change login redirects to /auth for improved user experience
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThis pull request updates the authentication flow and code formatting across several dashboard and risk-related components. The redirect path for unauthenticated users has been changed from Changes
Sequence Diagram(s)sequenceDiagram
participant Browser
participant AppServer
Browser->>AppServer: Request Page
AppServer->>AppServer: Check session & organization ID
alt Session invalid/missing organization ID
AppServer->>Browser: Redirect to /auth
else Session valid
AppServer->>Browser: Render requested page with layout and components
end
Possibly Related PRs
Poem
Tip ⚡🧪 Multi-step agentic review comment chat (experimental)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
…y; update styling to remove unnecessary classes and ensure select-none is applied where appropriate.
There was a problem hiding this 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
🧹 Nitpick comments (3)
apps/app/src/app/[locale]/(app)/(dashboard)/policies/all/(overview)/actions/get-policies.ts (3)
47-111: Consider extracting duplicate WHERE conditionThe WHERE condition is duplicated between the
findManyandcountqueries. This could be extracted to a variable to improve maintainability.try { const skip = (page - 1) * pageSize; const [column, order] = sort?.split(":") ?? []; let orderByClause: any = { updatedAt: "desc" }; if (column) { // ...existing orderByClause logic... } + const whereCondition = { + organizationId: user.organizationId, + AND: [ + search + ? { + policy: { + OR: [ + { name: { contains: search, mode: "insensitive" } }, + { + description: { + contains: search, + mode: "insensitive", + }, + }, + ], + }, + } + : {}, + status ? { status: status as any } : {}, + ], + }; + const [policies, total] = await Promise.all([ db.organizationPolicy.findMany({ - where: { - organizationId: user.organizationId, - AND: [ - search - ? { - policy: { - OR: [ - { name: { contains: search, mode: "insensitive" } }, - { - description: { - contains: search, - mode: "insensitive", - }, - }, - ], - }, - } - : {}, - status ? { status: status as any } : {}, - ], - }, + where: whereCondition, select: { // ...existing select... }, skip, take: pageSize, orderBy: orderByClause, }), db.organizationPolicy.count({ - where: { - organizationId: user.organizationId, - AND: [ - search - ? { - policy: { - OR: [ - { name: { contains: search, mode: "insensitive" } }, - { - description: { - contains: search, - mode: "insensitive", - }, - }, - ], - }, - } - : {}, - status ? { status: status as any } : {}, - ], - }, + where: whereCondition, }), ]);
67-67: Consider using proper type for statusThe code uses
status as anywhich bypasses TypeScript's type checking. If possible, define a proper type for the status field to maintain type safety.- status ? { status: status as any } : {}, + status ? { status } : {},If the status parameter has a different type than the database field, consider properly typing and transforming it:
- status ? { status: status as any } : {}, + status ? { status: status as PolicyStatus } : {},Where
PolicyStatuswould be the appropriate enum or type.
31-31: Consider type safety improvement for orderByClause
orderByClauseis typed asanywhich bypasses TypeScript's type checking. If possible, define a proper type for better maintainability.- let orderByClause: any = { updatedAt: "desc" }; + let orderByClause: Prisma.OrganizationPolicyOrderByWithRelationInput = { updatedAt: "desc" };This would require importing the appropriate Prisma type:
import { Prisma } from "@bubba/db";
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
apps/app/src/app/[locale]/(app)/(dashboard)/(home)/components/FrameworkProgress.tsx(2 hunks)apps/app/src/app/[locale]/(app)/(dashboard)/(home)/components/FrameworksGrid.tsx(1 hunks)apps/app/src/app/[locale]/(app)/(dashboard)/(home)/components/FrameworksOverview.tsx(1 hunks)apps/app/src/app/[locale]/(app)/(dashboard)/(home)/components/RequirementStatusChart.tsx(1 hunks)apps/app/src/app/[locale]/(app)/(dashboard)/policies/all/(overview)/actions/get-policies.ts(1 hunks)packages/ui/src/components/secondary-menu.tsx(2 hunks)
✅ Files skipped from review due to trivial changes (5)
- apps/app/src/app/[locale]/(app)/(dashboard)/(home)/components/FrameworkProgress.tsx
- apps/app/src/app/[locale]/(app)/(dashboard)/(home)/components/FrameworksOverview.tsx
- apps/app/src/app/[locale]/(app)/(dashboard)/(home)/components/FrameworksGrid.tsx
- apps/app/src/app/[locale]/(app)/(dashboard)/(home)/components/RequirementStatusChart.tsx
- packages/ui/src/components/secondary-menu.tsx
🔇 Additional comments (3)
apps/app/src/app/[locale]/(app)/(dashboard)/policies/all/(overview)/actions/get-policies.ts (3)
7-16: LGTM: Improved architecture with AuthActionClientThe refactored implementation now properly leverages the
authActionClientpattern with schema validation and metadata tracking. This is a better approach than the previous caching mechanism viaunstable_cacheas it provides more consistent authentication handling.
17-25: Good authentication checkValidating the presence of
user.organizationIdearly in the function and returning a clear error message ensures proper access control and prevents unauthorized data access.
113-116: Response structure improvementThe simplified response structure with
successflag and eitherdataorerrorfield makes error handling more consistent on the client side.
…ayout and risk pages; change login redirects to /auth for improved user experience
Summary by CodeRabbit
SecondaryMenustyling to prevent text selection on specific elements.