Skip to content

Commit 8c5c175

Browse files
authored
Merge pull request #470 from trycompai/main
Release
2 parents 9b938bf + e6d505f commit 8c5c175

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+773
-650
lines changed

apps/app/src/actions/organization/invite-employee.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export const inviteEmployee = authActionClient
4545
});
4646

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

5151
return {

apps/app/src/actions/organization/remove-employee.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export const removeEmployeeRoleOrMember = authActionClient
108108
]);
109109

110110
// Revalidate
111-
revalidatePath(`/${organizationId}/employees/all`);
111+
revalidatePath(`/${organizationId}/people/all`);
112112
revalidateTag(`user_${currentUserId}`);
113113

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

126126
// Revalidate
127-
revalidatePath(`/${organizationId}/employees/all`);
127+
revalidatePath(`/${organizationId}/people/all`);
128128
revalidateTag(`user_${currentUserId}`);
129129

130130
return {

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

Lines changed: 0 additions & 12 deletions
This file was deleted.

apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/employees/all/components/EmployeeRow.tsx

Lines changed: 0 additions & 61 deletions
This file was deleted.

apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/employees/all/components/EmployeesList.tsx

Lines changed: 0 additions & 57 deletions
This file was deleted.

apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/employees/all/components/EmployeesListClient.tsx

Lines changed: 0 additions & 88 deletions
This file was deleted.

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

Lines changed: 0 additions & 11 deletions
This file was deleted.

apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/employees/all/page.tsx

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
"use server";
2+
3+
import { db } from "@comp/db";
4+
import { generateChecklistItems } from "./checklist-items";
5+
import type { ChecklistItemProps, OnboardingStep } from "./types";
6+
import { onboardingSteps } from "./types"; // Keep for type checking
7+
import { revalidatePath } from "next/cache";
8+
import { appErrors } from "@/lib/errors";
9+
10+
export interface OnboardingStatus {
11+
checklistItems: ChecklistItemProps[];
12+
completedItems: number;
13+
totalItems: number;
14+
}
15+
16+
export async function getOnboardingStatus(
17+
orgId: string,
18+
): Promise<OnboardingStatus | { error: string }> {
19+
const onboarding = await db.onboarding.findUnique({
20+
where: {
21+
organizationId: orgId,
22+
},
23+
});
24+
25+
if (!onboarding) {
26+
// If onboarding record doesn't exist, create one
27+
// This might happen for newly created orgs or if something went wrong
28+
try {
29+
const newOnboarding = await db.onboarding.create({
30+
data: {
31+
organizationId: orgId,
32+
// Initialize all steps to false
33+
policies: false,
34+
employees: false,
35+
vendors: false,
36+
risk: false,
37+
tasks: false,
38+
},
39+
});
40+
// Continue with the newly created record
41+
const checklistItems = generateChecklistItems(newOnboarding, orgId);
42+
const completedItems = 0;
43+
const totalItems = checklistItems.length;
44+
return { checklistItems, completedItems, totalItems };
45+
} catch (error) {
46+
console.error("Failed to create onboarding record:", error);
47+
return { error: "Failed to initialize onboarding status." };
48+
}
49+
}
50+
51+
const checklistItems = generateChecklistItems(onboarding, orgId);
52+
const completedItems = checklistItems.filter((item) => item.completed).length;
53+
const totalItems = checklistItems.length;
54+
55+
return { checklistItems, completedItems, totalItems };
56+
}
57+
58+
// Regular Server Action to mark a step complete/incomplete
59+
export async function markOnboardingStep({
60+
orgId,
61+
step,
62+
completed,
63+
}: {
64+
orgId: string;
65+
step: OnboardingStep; // Use the specific type
66+
completed: boolean;
67+
}): Promise<{ success: boolean; error?: string }> {
68+
// Basic validation (can add more checks if needed)
69+
if (!orgId || !onboardingSteps.includes(step)) {
70+
return { success: false, error: "Invalid input provided." };
71+
}
72+
73+
try {
74+
const updatedOnboarding = await db.onboarding.update({
75+
where: {
76+
organizationId: orgId,
77+
},
78+
data: {
79+
[step]: completed,
80+
},
81+
});
82+
83+
if (!updatedOnboarding) {
84+
// Return the error key directly
85+
return { success: false, error: appErrors.NOT_FOUND };
86+
}
87+
88+
// Revalidate paths
89+
revalidatePath(`/${orgId}/implementation`);
90+
revalidatePath(`/${orgId}/layout`);
91+
92+
return { success: true };
93+
} catch (error) {
94+
console.error("Failed to update onboarding step:", error);
95+
// Return the error key directly
96+
return { success: false, error: appErrors.UNEXPECTED_ERROR };
97+
}
98+
}

0 commit comments

Comments
 (0)