Skip to content

Commit 8b20395

Browse files
authored
Merge pull request #990 from trycompai/main
[comp] Production Deploy
2 parents 8491131 + 14ad77c commit 8b20395

File tree

21 files changed

+937
-315
lines changed

21 files changed

+937
-315
lines changed

apps/app/src/app/(app)/setup/actions/create-organization-minimal.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
import { createStripeCustomer } from '@/actions/organization/lib/create-stripe-customer';
44
import { initializeOrganization } from '@/actions/organization/lib/initialize-organization';
55
import { authActionClientWithoutOrg } from '@/actions/safe-action';
6+
import { createFleetLabelForOrg } from '@/jobs/tasks/device/create-fleet-label-for-org';
67
import { auth } from '@/utils/auth';
78
import { db } from '@comp/db';
9+
import { tasks } from '@trigger.dev/sdk/v3';
810
import { revalidatePath } from 'next/cache';
911
import { headers } from 'next/headers';
1012
import { z } from 'zod';
@@ -110,6 +112,11 @@ export const createOrganizationMinimal = authActionClientWithoutOrg
110112
revalidatePath(`/${orgId}`);
111113
revalidatePath('/setup');
112114

115+
// Create Fleet Label.
116+
await tasks.trigger<typeof createFleetLabelForOrg>('create-fleet-label-for-org', {
117+
organizationId: orgId,
118+
});
119+
113120
return {
114121
success: true,
115122
organizationId: orgId,

apps/app/src/app/(app)/setup/actions/create-organization.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { createStripeCustomer } from '@/actions/organization/lib/create-stripe-customer';
44
import { initializeOrganization } from '@/actions/organization/lib/initialize-organization';
55
import { authActionClientWithoutOrg } from '@/actions/safe-action';
6+
import { createFleetLabelForOrg } from '@/jobs/tasks/device/create-fleet-label-for-org';
67
import { onboardOrganization as onboardOrganizationTask } from '@/jobs/tasks/onboarding/onboard-organization';
78
import { auth } from '@/utils/auth';
89
import { db } from '@comp/db';
@@ -142,6 +143,11 @@ export const createOrganization = authActionClientWithoutOrg
142143

143144
(await cookies()).set('publicAccessToken', handle.publicAccessToken);
144145

146+
// Create Fleet Label.
147+
await tasks.trigger<typeof createFleetLabelForOrg>('create-fleet-label-for-org', {
148+
organizationId: orgId,
149+
});
150+
145151
return {
146152
success: true,
147153
handle: handle.id,
55.7 KB
Loading
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
'use server';
2+
3+
import { db } from '@comp/db';
4+
5+
export async function acceptPolicy(policyId: string, memberId: string) {
6+
try {
7+
// Add the member ID to the signedBy array if not already present
8+
const policy = await db.policy.findUnique({
9+
where: { id: policyId },
10+
});
11+
12+
if (!policy) {
13+
throw new Error('Policy not found');
14+
}
15+
16+
if (!policy.signedBy.includes(memberId)) {
17+
await db.policy.update({
18+
where: { id: policyId },
19+
data: {
20+
signedBy: {
21+
push: memberId,
22+
},
23+
},
24+
});
25+
}
26+
27+
return { success: true };
28+
} catch (error) {
29+
console.error('Error accepting policy:', error);
30+
return { success: false, error: 'Failed to accept policy' };
31+
}
32+
}
33+
34+
export async function acceptAllPolicies(policyIds: string[], memberId: string) {
35+
try {
36+
// Update all policies to include the member ID in signedBy array
37+
const updatePromises = policyIds.map(async (policyId) => {
38+
const policy = await db.policy.findUnique({
39+
where: { id: policyId },
40+
});
41+
42+
if (policy && !policy.signedBy.includes(memberId)) {
43+
return db.policy.update({
44+
where: { id: policyId },
45+
data: {
46+
signedBy: {
47+
push: memberId,
48+
},
49+
},
50+
});
51+
}
52+
return null;
53+
});
54+
55+
await Promise.all(updatePromises);
56+
57+
return { success: true };
58+
} catch (error) {
59+
console.error('Error accepting all policies:', error);
60+
return { success: false, error: 'Failed to accept all policies' };
61+
}
62+
}

apps/portal/src/app/(app)/(home)/[orgId]/components/EmployeeTaskList.tsx

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

0 commit comments

Comments
 (0)