Skip to content

Commit d445d82

Browse files
committed
Merge branch 'main' of github.com:trycompai/comp into mariano/questionaire
2 parents 1bbd0ff + e6d505f commit d445d82

105 files changed

Lines changed: 1453 additions & 988 deletions

File tree

Some content is hidden

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

.cursor/rules/react-code.mdc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ When writing React code follow these standards:
88
- Always export a named component
99
- Always name components in PascalCase i.e (MyComponent)
1010
- Always name files that export components in PascalCase
11+
- Always round corners to rounded-sm
1112
- Always try to keep components small and modular
1213
- Always use sonner instead of toast.

apps/app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,4 @@
124124
"exports": {
125125
"./src/lib/encryption": "./src/lib/encryption.ts"
126126
}
127-
}
127+
}

apps/app/src/actions/files/upload-file.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,18 @@ export const uploadFile = async (
5555
// 1. Decode Base64 Data
5656
const fileBuffer = Buffer.from(fileData, "base64");
5757

58+
// --- Add file size check ---
59+
const MAX_FILE_SIZE_MB = 5;
60+
const MAX_FILE_SIZE_BYTES = MAX_FILE_SIZE_MB * 1024 * 1024;
61+
if (fileBuffer.length > MAX_FILE_SIZE_BYTES) {
62+
return {
63+
success: false,
64+
error: `File exceeds the ${MAX_FILE_SIZE_MB}MB limit.`,
65+
data: null,
66+
};
67+
}
68+
// --- End file size check ---
69+
5870
// 2. Prepare S3 Key
5971
const timestamp = Date.now();
6072
const sanitizedFileName = fileName.replace(/[^a-zA-Z0-9.-]/g, "_");

apps/app/src/actions/organization/create-organization-action.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import {
1616
createOrganizationTasks,
1717
getRelevantControls,
1818
} from "./lib/utils";
19+
import { env } from "@/env.mjs";
20+
import ky from "ky";
1921

2022
export const createOrganizationAction = authActionClient
2123
.schema(organizationSchema)
@@ -27,7 +29,7 @@ export const createOrganizationAction = authActionClient
2729
},
2830
})
2931
.action(async ({ parsedInput, ctx }) => {
30-
const { name, frameworks } = parsedInput;
32+
const { name, frameworks, website } = parsedInput;
3133
const { id: userId } = ctx.user;
3234

3335
if (!name) {
@@ -55,6 +57,19 @@ export const createOrganizationAction = authActionClient
5557
headers: await headers(),
5658
});
5759

60+
if (env.ZAPIER_HUBSPOT_WEBHOOK_URL) {
61+
await ky.post(env.ZAPIER_HUBSPOT_WEBHOOK_URL, {
62+
json: {
63+
email: session?.user.email,
64+
website: website,
65+
organization: name,
66+
frameworks: frameworks,
67+
first_name: session?.user.name?.split(" ")[0] || "",
68+
last_name: session?.user.name?.split(" ")[1] || "",
69+
},
70+
});
71+
}
72+
5873
timings.getAuthSession = (performance.now() - start) / 1000;
5974

6075
if (!session?.session.activeOrganizationId) {
@@ -97,7 +112,7 @@ export const createOrganizationAction = authActionClient
97112
start = performance.now();
98113
await db.organization.update({
99114
where: { id: organizationId },
100-
data: { stripeCustomerId },
115+
data: { stripeCustomerId, website },
101116
});
102117
timings.updateOrganizationWithStripeId =
103118
(performance.now() - start) / 1000;

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 {
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// update-organization-name-action.ts
2+
3+
"use server";
4+
5+
import { db } from "@comp/db";
6+
import { revalidatePath, revalidateTag } from "next/cache";
7+
import { authActionClient } from "../safe-action";
8+
import { organizationWebsiteSchema } from "../schema";
9+
10+
export const updateOrganizationWebsiteAction = authActionClient
11+
.schema(organizationWebsiteSchema)
12+
.metadata({
13+
name: "update-organization-website",
14+
track: {
15+
event: "update-organization-website",
16+
channel: "server",
17+
},
18+
})
19+
.action(async ({ parsedInput, ctx }) => {
20+
const { website } = parsedInput;
21+
const { activeOrganizationId } = ctx.session;
22+
23+
if (!website) {
24+
throw new Error("Invalid user input");
25+
}
26+
27+
if (!activeOrganizationId) {
28+
throw new Error("No active organization");
29+
}
30+
31+
try {
32+
await db.$transaction(async () => {
33+
await db.organization.update({
34+
where: { id: activeOrganizationId ?? "" },
35+
data: { website },
36+
});
37+
});
38+
39+
revalidatePath("/settings");
40+
revalidateTag(`organization_${activeOrganizationId}`);
41+
42+
return {
43+
success: true,
44+
};
45+
} catch (error) {
46+
console.error(error);
47+
throw new Error("Failed to update organization website");
48+
}
49+
});

apps/app/src/actions/schema.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ export const organizationSchema = z.object({
1717
frameworks: z
1818
.array(z.nativeEnum(FrameworkId))
1919
.min(1, "Please select at least one framework to get started with"),
20+
website: z
21+
.string()
22+
.url({
23+
message: "Please enter a valid website that starts with https://",
24+
})
25+
.max(255, "Website cannot exceed 255 characters"),
2026
});
2127

2228
export type OrganizationSchema = z.infer<typeof organizationSchema>;
@@ -61,7 +67,12 @@ export const updaterMenuSchema = z.array(
6167
);
6268

6369
export const organizationWebsiteSchema = z.object({
64-
website: z.string().url().max(255),
70+
website: z
71+
.string()
72+
.url({
73+
message: "Please enter a valid website that starts with https://",
74+
})
75+
.max(255, "Website cannot exceed 255 characters"),
6576
});
6677

6778
// Risks

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

Lines changed: 0 additions & 37 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.

0 commit comments

Comments
 (0)