-
Notifications
You must be signed in to change notification settings - Fork 324
Overview fully SSR #175
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
Merged
Merged
Overview fully SSR #175
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
76 changes: 0 additions & 76 deletions
76
...src/app/[locale]/(app)/(dashboard)/[orgId]/(home)/actions/getFrameworkCategoriesAction.ts
This file was deleted.
Oops, something went wrong.
31 changes: 16 additions & 15 deletions
31
...hboard)/[orgId]/(home)/overview/frameworks/[frameworkId]/components/FrameworkControls.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...]/(app)/(dashboard)/[orgId]/(home)/overview/frameworks/[frameworkId]/data/getFramework.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import { db } from "@bubba/db"; | ||
|
|
||
| export const getFramework = async ( | ||
| frameworkId: string, | ||
| organizationId: string | ||
| ) => { | ||
| const framework = await db.organizationFramework.findUnique({ | ||
| where: { | ||
| organizationId_frameworkId: { | ||
| organizationId, | ||
| frameworkId, | ||
| }, | ||
| }, | ||
| include: { | ||
| framework: true, | ||
| organizationControl: true, | ||
| }, | ||
| }); | ||
|
|
||
| return framework; | ||
| }; |
49 changes: 49 additions & 0 deletions
49
...ashboard)/[orgId]/(home)/overview/frameworks/[frameworkId]/data/getFrameworkCategories.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| import { db } from "@bubba/db"; | ||
| import type { | ||
| OrganizationControl, | ||
| OrganizationControlRequirement, | ||
| Control, | ||
| OrganizationCategory, | ||
| OrganizationPolicy, | ||
| OrganizationEvidence, | ||
| } from "@bubba/db/types"; | ||
|
|
||
| export type FrameworkCategories = (OrganizationCategory & { | ||
| name: string; | ||
| organizationControl: (OrganizationControl & { | ||
| id: string; | ||
| status: any; // ComplianceStatus enum | ||
| control: Control; | ||
| OrganizationControlRequirement: (OrganizationControlRequirement & { | ||
| organizationPolicy: OrganizationPolicy | null; | ||
| organizationEvidence: OrganizationEvidence | null; | ||
| })[]; | ||
| })[]; | ||
| })[]; | ||
|
|
||
| export const getFrameworkCategories = async ( | ||
| frameworkId: string, | ||
| organizationId: string | ||
| ) => { | ||
| const organizationCategories = await db.organizationCategory.findMany({ | ||
| where: { | ||
| organizationId, | ||
| frameworkId, | ||
| }, | ||
| include: { | ||
| organizationControl: { | ||
| include: { | ||
| control: true, | ||
| OrganizationControlRequirement: { | ||
| include: { | ||
| organizationPolicy: true, | ||
| organizationEvidence: true, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| return organizationCategories; | ||
| }; | ||
26 changes: 26 additions & 0 deletions
26
.../[locale]/(app)/(dashboard)/[orgId]/(home)/overview/frameworks/[frameworkId]/lib/utils.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import type { OrganizationControlType } from "../components/table/FrameworkControlsTableColumns"; | ||
| import type { StatusType } from "@/components/frameworks/framework-status"; | ||
|
|
||
| export function getControlStatus( | ||
| requirements: OrganizationControlType["requirements"] | ||
| ): StatusType { | ||
| if (!requirements || requirements.length === 0) return "not_started"; | ||
|
|
||
| const totalRequirements = requirements.length; | ||
| const completedRequirements = requirements.filter((req) => { | ||
| switch (req.type) { | ||
| case "policy": | ||
| return req.organizationPolicy?.status === "published"; | ||
| case "file": | ||
| return !!req.fileUrl; | ||
| case "evidence": | ||
| return req.organizationEvidence?.published === true; | ||
| default: | ||
| return req.published; | ||
| } | ||
| }).length; | ||
|
|
||
| if (completedRequirements === 0) return "not_started"; | ||
| if (completedRequirements === totalRequirements) return "completed"; | ||
| return "in_progress"; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🛠️ Refactor suggestion
Add error handling for database query
The database query lacks error handling. If the query fails, the error will propagate up the call stack without any context about what operation failed.
export const getFrameworkCategories = async ( frameworkId: string, organizationId: string ) => { + try { const organizationCategories = await db.organizationCategory.findMany({ where: { organizationId, frameworkId, }, include: { organizationControl: { include: { control: true, OrganizationControlRequirement: { include: { organizationPolicy: true, organizationEvidence: true, }, }, }, }, }, }); return organizationCategories; + } catch (error) { + console.error(`Failed to fetch framework categories: ${error}`); + throw new Error(`Failed to fetch framework categories for framework ${frameworkId} and organization ${organizationId}`); + } };📝 Committable suggestion