Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import { toast } from "sonner";
import { motion, AnimatePresence } from "framer-motion";
import { LogoSpinner } from "@/components/logo-spinner";
import { SelectPills } from "@comp/ui/select-pills";
import { Textarea } from "@comp/ui/textarea";

type OnboardingFormFields = Partial<CompanyDetails> & {
[K in keyof CompanyDetails as `${K}Other`]?: string;
Expand Down Expand Up @@ -122,6 +123,7 @@ export function OnboardingForm() {
onboardOrganizationAction.execute({
legalName: answers.legalName || "",
website: answers.website || "",
describe: answers.describe || "",
industry: answers.industry || "",
teamSize: answers.teamSize || "",
devices: answers.devices || "",
Expand Down Expand Up @@ -188,6 +190,18 @@ export function OnboardingForm() {
const isLastStep = stepIndex === steps.length - 1;

function renderStepInput() {
if (step.key === "describe") {
return (
<Textarea
{...form.register(step.key)}
placeholder={`${savedAnswers.legalName || ""} is a company that...`}
rows={2}
maxLength={300}
className="resize-none"
/>
);
}

if (step.options) {
if (step.key === "industry" || step.key === "teamSize") {
return (
Expand Down Expand Up @@ -230,6 +244,7 @@ export function OnboardingForm() {
/>
);
}

return (
<Input
{...form.register(step.key)}
Expand Down
13 changes: 13 additions & 0 deletions apps/app/src/app/[locale]/(app)/setup/onboarding/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ export const STORAGE_KEY = "onboarding_answers";
export const companyDetailsSchema = z.object({
legalName: z.string().min(2, "Company name must be at least 2 characters"),
website: z.string().url("Please enter a valid URL"),
describe: z
.string()
.min(
1,
"Please provide a brief overview and description of what your company does",
)
.max(300, "Description must be less than 300 characters"),
industry: z.string().min(1, "Please select your industry"),
teamSize: z.string().min(1, "Please select your team size"),
software: z.string().min(1, "Please select software you use"),
Expand All @@ -27,6 +34,12 @@ export const steps: Step[] = [
question: "What's your company website?",
placeholder: "e.g., https://www.acme.com",
},
{
key: "describe",
question: "Describe your company in a few sentences",
placeholder:
"e.g., We are a software company that builds tools for businesses to manage their employees.",
},
{
key: "industry",
question: "What industry is your company in?",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export type CompanyDetails = {
legalName: string;
website: string;
describe: string;
industry: string;
teamSize: string;
devices: string;
Expand Down
22 changes: 22 additions & 0 deletions apps/app/src/jobs/tasks/scrape/research.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,28 @@ export const researchVendor = schemaTask({
}),
maxDuration: 1000 * 60 * 10, // 10 minutes total task duration
run: async (payload, { ctx }) => {
// Check if vendor already exists
const existingVendor = await db.globalVendors.findFirst({
where: {
OR: [
{ website: payload.website },
{
company_name: {
equals: payload.website,
mode: "insensitive",
},
},
],
},
});

if (existingVendor) {
return {
message: "Vendor already exists in database",
existingVendor,
};
}

return researchJobCore({
website: payload.website,
prompt: "You're a cyber security researcher, researching a vendor.",
Expand Down
Loading