-
Notifications
You must be signed in to change notification settings - Fork 275
Claudio/comp 106 add implementation widget #467
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
Changes from all commits
Commits
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
32 changes: 32 additions & 0 deletions
32
apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/implementation/actions.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,32 @@ | ||
| "use server"; | ||
|
|
||
| import { db } from "@comp/db"; | ||
| import { generateChecklistItems } from "./checklist-items"; | ||
| import type { ChecklistItemProps } from "./types"; | ||
|
|
||
| export interface OnboardingStatus { | ||
| checklistItems: ChecklistItemProps[]; | ||
| completedItems: number; | ||
| totalItems: number; | ||
| } | ||
|
|
||
| export async function getOnboardingStatus( | ||
| orgId: string, | ||
| ): Promise<OnboardingStatus | { error: string }> { | ||
| const onboarding = await db.onboarding.findUnique({ | ||
| where: { | ||
| organizationId: orgId, | ||
| }, | ||
| }); | ||
|
|
||
| if (!onboarding) { | ||
| return { error: "Organization onboarding not found" }; | ||
| } | ||
|
|
||
| const checklistItems = generateChecklistItems(onboarding, orgId); | ||
|
|
||
| const completedItems = checklistItems.filter((item) => item.completed).length; | ||
| const totalItems = checklistItems.length; | ||
|
|
||
| return { checklistItems, completedItems, totalItems }; | ||
| } |
67 changes: 67 additions & 0 deletions
67
apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/implementation/checklist-items.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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| import type { Onboarding } from "@comp/db/types"; | ||
| import { Icons } from "@comp/ui/icons"; | ||
| import { ListCheck, NotebookText, Store, Users } from "lucide-react"; | ||
| import type { ChecklistItemProps } from "./types"; | ||
|
|
||
| export function generateChecklistItems( | ||
| onboarding: Onboarding, | ||
| orgId: string, | ||
| ): ChecklistItemProps[] { | ||
| return [ | ||
| { | ||
| title: "Check & Publish Policies", | ||
| description: | ||
| "We've given you all of the policies you need to get started. Go through them, make sure they're relevant to your organization and then publish them for your employees to sign.", | ||
| href: `/${orgId}/policies`, | ||
| dbColumn: "policies", | ||
| completed: onboarding.policies, | ||
| docs: "https://trycomp.ai/docs/policies", | ||
| buttonLabel: "Publish Policies", | ||
| icon: <NotebookText className="h-5 w-5" />, | ||
| }, | ||
| { | ||
| title: "Add Employees", | ||
| description: | ||
| "You should add all of your employees to Comp AI, either through an integration or by manually adding them and then ask them to sign the policies you published in the employee portal.", | ||
| href: `/${orgId}/people`, | ||
| dbColumn: "employees", | ||
| completed: onboarding.employees, | ||
| docs: "https://trycomp.ai/docs/people", | ||
| buttonLabel: "Add an Employee", | ||
| icon: <Users className="h-5 w-5" />, | ||
| }, | ||
| { | ||
| title: "Add Vendors", | ||
| description: | ||
| "For frameworks like SOC 2, you must assess and report on your vendors. You can add your vendors to Comp AI, and assign risk levels to them. Auditors can review the vendors and their risk levels.", | ||
| href: `/${orgId}/vendors`, | ||
| dbColumn: "vendors", | ||
| completed: onboarding.vendors, | ||
| docs: "https://trycomp.ai/docs/vendors", | ||
| buttonLabel: "Add a Vendor", | ||
| icon: <Store className="h-5 w-5" />, | ||
| }, | ||
| { | ||
| title: "Manage Risks", | ||
| description: | ||
| "You can manage your risks in Comp AI by adding them to your organization and then assigning them to employees or vendors. Auditors can review the risks and their status.", | ||
| href: `/${orgId}/risk`, | ||
| dbColumn: "risk", | ||
| completed: onboarding.risk, | ||
| docs: "https://trycomp.ai/docs/risks", | ||
| buttonLabel: "Create a Risk", | ||
| icon: <Icons.Risk className="h-5 w-5" />, | ||
| }, | ||
| { | ||
| title: "Complete Tasks", | ||
| description: | ||
| "Tasks in Comp AI are automatically generated for you, based on the frameworks you selected. Tasks are linked to controls, which are determined by your policies. By completing tasks, you can show auditors that you are following your own policies.", | ||
| href: `/${orgId}/tasks`, | ||
| dbColumn: "tasks", | ||
| completed: onboarding.tasks, | ||
| docs: "https://trycomp.ai/docs/tasks", | ||
| buttonLabel: "Create a Task", | ||
| icon: <ListCheck className="h-5 w-5" />, | ||
| }, | ||
| ]; | ||
| } |
6 changes: 3 additions & 3 deletions
6
apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/implementation/components/Checklist.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
102 changes: 3 additions & 99 deletions
102
apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/implementation/page.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
12 changes: 4 additions & 8 deletions
12
...lementation/types/ChecklistProps.types.ts → ...ashboard)/[orgId]/implementation/types.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 |
|---|---|---|
| @@ -1,16 +1,12 @@ | ||
| import { Onboarding } from "@comp/db/types"; | ||
|
|
||
| export interface ChecklistProps { | ||
| items: ChecklistItemProps[]; | ||
| } | ||
| import type { Onboarding } from "@comp/db/types"; | ||
|
|
||
| export interface ChecklistItemProps { | ||
| title: string; | ||
| description?: string; | ||
| description: string; | ||
| href: string; | ||
| docs: string; | ||
| dbColumn: Exclude<keyof Onboarding, "organizationId">; | ||
| completed: boolean; | ||
| docs: string; | ||
| buttonLabel: string; | ||
| icon: React.ReactNode; | ||
| } | ||
| } |
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
77 changes: 77 additions & 0 deletions
77
apps/app/src/components/onboarding/FloatingOnboardingChecklist.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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| 'use client'; | ||
|
|
||
| import { Progress } from "@comp/ui/progress"; | ||
| import { cn } from "@comp/ui/cn"; | ||
| import Link from "next/link"; | ||
| import { Button } from "@comp/ui/button"; | ||
| import type { ChecklistItemProps } from "@/app/[locale]/(app)/(dashboard)/[orgId]/implementation/types"; | ||
| import { Circle } from "lucide-react"; | ||
| import { usePathname } from "next/navigation"; | ||
|
|
||
| interface FloatingOnboardingChecklistProps { | ||
| orgId: string; | ||
| completedItems: number; | ||
| totalItems: number; | ||
| checklistItems: ChecklistItemProps[]; | ||
| className?: string; | ||
| } | ||
|
|
||
| export function FloatingOnboardingChecklist({ | ||
| orgId, | ||
| completedItems, | ||
| totalItems, | ||
| checklistItems, | ||
| className, | ||
| }: FloatingOnboardingChecklistProps) { | ||
| const progressPercentage = (completedItems / totalItems) * 100; | ||
| const remainingItems = totalItems - completedItems; | ||
| const incompleteItems = checklistItems.filter((item) => !item.completed); | ||
| const pathname = usePathname(); | ||
|
|
||
| const implementationPathRegex = /\/[^/]+\/implementation$/; | ||
|
|
||
| if (remainingItems === 0 || implementationPathRegex.test(pathname)) { | ||
| return null; | ||
| } | ||
|
|
||
| return ( | ||
| <div | ||
| className={cn( | ||
| "fixed bottom-4 right-4 z-50 w-80 rounded-sm border bg-card p-4 text-card-foreground shadow-lg", | ||
| className, | ||
| )} | ||
| > | ||
| <div className="mb-3"> | ||
| <h4 className="mb-1 font-medium leading-none">Implementation Progress</h4> | ||
| <div className="flex justify-between text-xs text-muted-foreground mb-2"> | ||
| <span>{completedItems} Completed</span> | ||
| <span>{remainingItems} Remaining</span> | ||
| </div> | ||
| <Progress value={progressPercentage} className="h-1.5" /> | ||
| </div> | ||
|
|
||
| <div className="mb-3 grid gap-3 max-h-40 overflow-y-auto"> | ||
| {incompleteItems.map((item) => ( | ||
| <Link | ||
| href={item.href} | ||
| key={item.dbColumn} | ||
| className="group flex items-center gap-2 text-sm hover:text-primary" | ||
| > | ||
| <Circle className="h-4 w-4 text-muted-foreground group-hover:text-primary" /> | ||
| <span className="font-medium">{item.title}</span> | ||
| </Link> | ||
| ))} | ||
| </div> | ||
|
|
||
| <Link href={`/${orgId}/implementation`} passHref> | ||
| <Button | ||
| variant="secondary" | ||
| size="sm" | ||
| className="w-full" | ||
| > | ||
| View All Steps | ||
| </Button> | ||
| </Link> | ||
| </div> | ||
| ); | ||
| } |
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.
[nitpick] While console.error is useful for debugging during development, integrating a structured error tracking or user feedback mechanism may improve error handling in production.