"use client"; import { useState, useTransition } from "react"; import { useRouter } from "next/navigation"; import { PlusIcon } from "lucide-react"; import { toast } from "sonner"; import { Button } from "@/components/ui/button"; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, } from "@/components/ui/dialog"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { createCompanyAction } from "@/server/actions"; export function NewCompanyDialog() { const [open, setOpen] = useState(false); const [name, setName] = useState(""); const [website, setWebsite] = useState(""); const [pending, startTransition] = useTransition(); const router = useRouter(); const submit = () => { if (!name.trim()) return; startTransition(async () => { try { const { id } = await createCompanyAction({ name: name.trim(), website: website.trim() }); setOpen(false); setName(""); setWebsite(""); router.push(`/crm/companies/${id}`); } catch (error) { toast.error(error instanceof Error ? error.message : "Could not add that company."); } }); }; return ( Add a company Somewhere to keep research before there is an application. Applying to somewhere new creates its company for you, so this is for the ones you are still circling.
setName(event.target.value)} onKeyDown={(event) => event.key === "Enter" && submit()} placeholder="Stripe" />
setWebsite(event.target.value)} onKeyDown={(event) => event.key === "Enter" && submit()} placeholder="stripe.com" />

Their own site — this is where the logo comes from.

); }