Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
b505af6
feat: enhance organization management and UI components
claudfuen Apr 29, 2025
01a16e1
refactor: update OrganizationInitialsAvatar with color pairs and impr…
claudfuen Apr 29, 2025
2e64bd9
Merge pull request #462 from trycompai/claudio/misc-fixes-apr-29
claudfuen Apr 29, 2025
74f1d10
refactor: rename employee routes and update related components
claudfuen Apr 29, 2025
c03e86c
Merge branch 'main' of https://github.com/trycompai/comp into claudio…
claudfuen Apr 29, 2025
0adaca9
refactor: simplify middleware by removing session handling and unused…
carhartlewis Apr 29, 2025
f98f0a7
Merge pull request #464 from trycompai/lewis/remove-middleware
carhartlewis Apr 29, 2025
bfe1650
feat: implement onboarding checklist and status management
claudfuen Apr 29, 2025
6436aa5
Merge pull request #466 from trycompai/claudio/comp-105-simplify-peop…
claudfuen Apr 29, 2025
d48c283
Merge branch 'main' into claudio/comp-106-add-implementation-widget
claudfuen Apr 29, 2025
78a5081
Merge pull request #467 from trycompai/claudio/comp-106-add-implement…
claudfuen Apr 29, 2025
f78fe0e
feat: enhance onboarding actions and checklist component
claudfuen Apr 29, 2025
9db5613
Merge pull request #468 from trycompai/claudio/comp-106-add-implement…
claudfuen Apr 29, 2025
aff7161
refactor: streamline ChecklistItem component and update imports
claudfuen Apr 29, 2025
e97a976
Merge branch 'main' into claudio/comp-106-add-implementation-widget-3
claudfuen Apr 29, 2025
e6d505f
Merge pull request #469 from trycompai/claudio/comp-106-add-implement…
claudfuen Apr 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/app/src/actions/organization/invite-employee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const inviteEmployee = authActionClient
});

// Revalidate the employees list page
revalidatePath(`/${organizationId}/employees/all`);
revalidatePath(`/${organizationId}/people/all`);
revalidateTag(`user_${ctx.user.id}`); // Keep user tag revalidation

return {
Expand Down
4 changes: 2 additions & 2 deletions apps/app/src/actions/organization/remove-employee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export const removeEmployeeRoleOrMember = authActionClient
]);

// Revalidate
revalidatePath(`/${organizationId}/employees/all`);
revalidatePath(`/${organizationId}/people/all`);
revalidateTag(`user_${currentUserId}`);

return { success: true, data: { removed: true } };
Expand All @@ -124,7 +124,7 @@ export const removeEmployeeRoleOrMember = authActionClient
});

// Revalidate
revalidatePath(`/${organizationId}/employees/all`);
revalidatePath(`/${organizationId}/people/all`);
revalidateTag(`user_${currentUserId}`);

return {
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
"use server";

import { db } from "@comp/db";
import { generateChecklistItems } from "./checklist-items";
import type { ChecklistItemProps, OnboardingStep } from "./types";
import { onboardingSteps } from "./types"; // Keep for type checking
import { revalidatePath } from "next/cache";
import { appErrors } from "@/lib/errors";

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) {
// If onboarding record doesn't exist, create one
// This might happen for newly created orgs or if something went wrong
try {
const newOnboarding = await db.onboarding.create({
data: {
organizationId: orgId,
// Initialize all steps to false
policies: false,
employees: false,
vendors: false,
risk: false,
tasks: false,
},
});
// Continue with the newly created record
const checklistItems = generateChecklistItems(newOnboarding, orgId);
const completedItems = 0;
const totalItems = checklistItems.length;
return { checklistItems, completedItems, totalItems };
} catch (error) {
console.error("Failed to create onboarding record:", error);
return { error: "Failed to initialize onboarding status." };
}
}

const checklistItems = generateChecklistItems(onboarding, orgId);
const completedItems = checklistItems.filter((item) => item.completed).length;
const totalItems = checklistItems.length;

return { checklistItems, completedItems, totalItems };
}

// Regular Server Action to mark a step complete/incomplete
export async function markOnboardingStep({
orgId,
step,
completed,
}: {
orgId: string;
step: OnboardingStep; // Use the specific type
completed: boolean;
}): Promise<{ success: boolean; error?: string }> {
// Basic validation (can add more checks if needed)
if (!orgId || !onboardingSteps.includes(step)) {
return { success: false, error: "Invalid input provided." };
}

try {
const updatedOnboarding = await db.onboarding.update({
where: {
organizationId: orgId,
},
data: {
[step]: completed,
},
});

if (!updatedOnboarding) {
// Return the error key directly
return { success: false, error: appErrors.NOT_FOUND };
}

// Revalidate paths
revalidatePath(`/${orgId}/implementation`);
revalidatePath(`/${orgId}/layout`);

return { success: true };
} catch (error) {
console.error("Failed to update onboarding step:", error);
// Return the error key directly
return { success: false, error: appErrors.UNEXPECTED_ERROR };
}
}
Loading
Loading