Skip to content

Job application tracker and AI-powered job search assistant. Helps job seekers manage their search journey with AI resume review, job matching, task logging, and application analytics, all while keeping your data private.

feat(contacts): add job-contact link actions and the job-details Contacts tab

Khuram Niazec08ae074d8f
diff --git a/__tests__/JobContactsTab.spec.tsx b/__tests__/JobContactsTab.spec.tsx
new file mode 100644
index 0000000..cf45c81
--- /dev/null
+++ b/__tests__/JobContactsTab.spec.tsx
@@ -0,0 +1,112 @@
+import { JobContactsTab } from "@/components/myjobs/job-details/JobContactsTab";
+import { render, screen, waitFor } from "@testing-library/react";
+import userEvent from "@testing-library/user-event";
+import {
+ getAllContacts,
+ getJobContacts,
+ removeJobContact,
+} from "@/actions/contact.actions";
+import { getAllContactRoles } from "@/actions/contactRole.actions";
+
+vi.mock("@/actions/contact.actions", () => ({
+ getAllContacts: vi.fn(),
+ getJobContacts: vi.fn(),
+ addJobContact: vi.fn(),
+ removeJobContact: vi.fn(),
+ createContact: vi.fn(),
+ updateContact: vi.fn(),
+}));
+
+vi.mock("@/actions/contactRole.actions", () => ({
+ getAllContactRoles: vi.fn(),
+ createContactRole: vi.fn(),
+}));
+
+vi.mock("@/actions/company.actions", () => ({
+ getAllCompanies: vi.fn().mockResolvedValue([]),
+ addCompany: vi.fn(),
+}));
+vi.mock("@/actions/jobLocation.actions", () => ({
+ getAllJobLocations: vi.fn().mockResolvedValue([]),
+}));
+
+vi.mock("@/lib/toast", () => ({
+ toastSuccess: vi.fn(),
+ toastError: vi.fn(),
+ toastActionResult: vi.fn((res, opts) => res?.success && opts?.onSuccess?.()),
+}));
+
+const link = {
+ id: "jc1",
+ jobId: "j1",
+ contactId: "c1",
+ roleId: "r1",
+ createdAt: new Date(),
+ Role: { id: "r1", label: "Recruiter", value: "recruiter", createdBy: "u1" },
+ Contact: {
+ id: "c1",
+ name: "Sarah Cole",
+ title: "Talent Partner",
+ email: "[email protected]",
+ phone: null,
+ linkedinUrl: null,
+ Company: { id: "co1", label: "Vercel" },
+ },
+};
+
+describe("JobContactsTab", () => {
+ const user = userEvent.setup({ skipHover: true });
+
+ beforeEach(() => {
+ vi.clearAllMocks();
+ (getAllContacts as any).mockResolvedValue([
+ { id: "c2", label: "Priya Nair", value: "priya nair" },
+ ]);
+ (getAllContactRoles as any).mockResolvedValue([
+ { id: "r1", label: "Recruiter", value: "recruiter", createdBy: "u1" },
+ ]);
+ (getJobContacts as any).mockResolvedValue([link]);
+ });
+
+ it("lists the linked contacts with their role", () => {
+ render(<JobContactsTab jobId="j1" links={[link] as any} />);
+ expect(screen.getByText("Sarah Cole")).toBeInTheDocument();
+ expect(screen.getByText("Recruiter")).toBeInTheDocument();
+ });
+
+ it("shows an empty state with no links", () => {
+ render(<JobContactsTab jobId="j1" links={[]} />);
+ expect(screen.getByText(/no contacts on this job/i)).toBeInTheDocument();
+ });
+
+ it("does not fetch the picker lists until the add form is opened", () => {
+ render(<JobContactsTab jobId="j1" links={[link] as any} />);
+ expect(getAllContacts).not.toHaveBeenCalled();
+ expect(getAllContactRoles).not.toHaveBeenCalled();
+ });
+
+ it("fetches contacts and roles on first open of the add form", async () => {
+ render(<JobContactsTab jobId="j1" links={[link] as any} />);
+ await user.click(screen.getByRole("button", { name: /add contact/i }));
+
+ await waitFor(() => expect(getAllContacts).toHaveBeenCalledTimes(1));
+ expect(getAllContactRoles).toHaveBeenCalledTimes(1);
+
+ await user.click(screen.getByRole("button", { name: /cancel/i }));
+ await user.click(screen.getByRole("button", { name: /add contact/i }));
+
+ expect(getAllContacts).toHaveBeenCalledTimes(1);
+ });
+
+ it("unlinks a contact and refreshes the list", async () => {
+ (removeJobContact as any).mockResolvedValue({ success: true });
+ (getJobContacts as any).mockResolvedValue([]);
+
+ render(<JobContactsTab jobId="j1" links={[link] as any} />);
+ await user.click(screen.getByRole("button", { name: /remove sarah cole/i }));
+ await user.click(await screen.findByRole("button", { name: "Delete" }));
+
+ await waitFor(() => expect(removeJobContact).toHaveBeenCalledWith("jc1"));
+ await waitFor(() => expect(getJobContacts).toHaveBeenCalledWith("j1"));
+ });
+});
diff --git a/__tests__/JobDetails.spec.tsx b/__tests__/JobDetails.spec.tsx
index 67aa3a1..b58087e 100644
--- a/__tests__/JobDetails.spec.tsx
+++ b/__tests__/JobDetails.spec.tsx
@@ -45,6 +45,20 @@ vi.mock("@/components/profile/DownloadFileButton", () => ({
DownloadFileButton: () => null,
}));
+vi.mock("@/actions/contact.actions", () => ({
+ getAllContacts: vi.fn().mockResolvedValue([]),
+ getJobContacts: vi.fn().mockResolvedValue([]),
+ addJobContact: vi.fn(),
+ removeJobContact: vi.fn(),
+ createContact: vi.fn(),
+ updateContact: vi.fn(),
+}));
+
+vi.mock("@/actions/contactRole.actions", () => ({
+ getAllContactRoles: vi.fn().mockResolvedValue([]),
+ createContactRole: vi.fn(),
+}));
+
vi.mock("@/components/CircularScore", () => ({
CircularScore: ({ score }: { score: number }) => (
<div data-testid="circular-score">{score}%</div>
@@ -233,14 +247,15 @@ describe("JobDetails – tabs", () => {
searchParams = new URLSearchParams();
});
- // The bar must not shift between jobs, so all four are always present.
- it("renders all four tabs regardless of what the job has", () => {
+ // The bar must not shift between jobs, so all five are always present.
+ it("renders all five tabs regardless of what the job has", () => {
render(<JobDetails {...baseProps} job={makeJob()} />);
expect(screen.getByRole("tab", { name: /description/i })).toBeInTheDocument();
expect(screen.getByRole("tab", { name: /ai match/i })).toBeInTheDocument();
expect(screen.getByRole("tab", { name: /cover letter/i })).toBeInTheDocument();
expect(screen.getByRole("tab", { name: /notes/i })).toBeInTheDocument();
+ expect(screen.getByRole("tab", { name: "Contacts" })).toBeInTheDocument();
});
it("opens on the Description tab", () => {
diff --git a/__tests__/jobContact.actions.spec.ts b/__tests__/jobContact.actions.spec.ts
new file mode 100644
index 0000000..3313491
--- /dev/null
+++ b/__tests__/jobContact.actions.spec.ts
@@ -0,0 +1,116 @@
+import {
+ getJobContacts,
+ addJobContact,
+ removeJobContact,
+} from "@/actions/contact.actions";
+import { getCurrentUser } from "@/utils/user.utils";
+import prisma from "@/lib/db";
+
+vi.mock("@/lib/db", () => ({
+ default: {
+ jobContact: {
+ findMany: vi.fn(),
+ create: vi.fn(),
+ deleteMany: vi.fn(),
+ },
+ job: { count: vi.fn() },
+ contact: { count: vi.fn() },
+ contactRole: { count: vi.fn() },
+ },
+}));
+
+vi.mock("@/utils/user.utils", () => ({ getCurrentUser: vi.fn() }));
+
+const db = prisma as any;
+const user = { id: "user-1" };
+
+describe("job contact links", () => {
+ beforeEach(() => {
+ vi.clearAllMocks();
+ (getCurrentUser as any).mockResolvedValue(user);
+ db.job.count.mockResolvedValue(1);
+ db.contact.count.mockResolvedValue(1);
+ db.contactRole.count.mockResolvedValue(1);
+ });
+
+ it("reads links through the job's ownership chain", async () => {
+ db.jobContact.findMany.mockResolvedValue([]);
+
+ await getJobContacts("j1");
+
+ expect(db.jobContact.findMany.mock.calls[0][0].where).toEqual({
+ jobId: "j1",
+ Job: { userId: user.id },
+ });
+ });
+
+ it("refuses to link a contact the caller does not own", async () => {
+ db.contact.count.mockResolvedValue(0);
+
+ const res = await addJobContact("j1", "someone-elses-contact", "r1");
+
+ expect(res.success).toBe(false);
+ expect(db.jobContact.create).not.toHaveBeenCalled();
+ });
+
+ it("refuses to link to a job the caller does not own", async () => {
+ db.job.count.mockResolvedValue(0);
+
+ const res = await addJobContact("someone-elses-job", "c1", "r1");
+
+ expect(res.success).toBe(false);
+ expect(db.jobContact.create).not.toHaveBeenCalled();
+ });
+
+ it("refuses a role the caller does not own", async () => {
+ db.contactRole.count.mockResolvedValue(0);
+
+ const res = await addJobContact("j1", "c1", "someone-elses-role");
+
+ expect(res.success).toBe(false);
+ expect(db.jobContact.create).not.toHaveBeenCalled();
+ });
+
+ it("creates the link when all three belong to the caller", async () => {
+ db.jobContact.create.mockResolvedValue({ id: "jc1" });
+
+ const res = await addJobContact("j1", "c1", "r1");
+
+ expect(res.success).toBe(true);
+ expect(db.jobContact.create).toHaveBeenCalledWith(
+ expect.objectContaining({
+ data: { jobId: "j1", contactId: "c1", roleId: "r1" },
+ }),
+ );
+ });
+
+ it("reports a duplicate link as a message, not a crash", async () => {
+ db.jobContact.create.mockRejectedValue({ code: "P2002" });
+
+ const res = await addJobContact("j1", "c1", "r1");
+
+ expect(res.success).toBe(false);
+ expect(res.message).toMatch(/already/i);
+ });
+
+ it("removes a link only through both ownership chains", async () => {
+ db.jobContact.deleteMany.mockResolvedValue({ count: 1 });
+
+ const res = await removeJobContact("jc1");
+
+ expect(db.jobContact.deleteMany).toHaveBeenCalledWith({
+ where: {
+ id: "jc1",
+ Job: { userId: user.id },
+ Contact: { createdBy: user.id },
+ },
+ });
+ expect(res.success).toBe(true);
+ });
+
+ it("reports a removal that matched nothing", async () => {
+ db.jobContact.deleteMany.mockResolvedValue({ count: 0 });
+ const res = await removeJobContact("jc1");
+ expect(res.success).toBe(false);
+ });
+});
diff --git a/src/actions/contact.actions.ts b/src/actions/contact.actions.ts
index f8441d0..ceca057 100644
--- a/src/actions/contact.actions.ts
+++ b/src/actions/contact.actions.ts
@@ -9,3 +9,9 @@ export {
updateContact,
deleteContactById,
} from "./contact/mutations";
+
+export {
+ getJobContacts,
+ addJobContact,
+ removeJobContact,
+} from "./contact/jobLinks";
diff --git a/src/actions/contact/jobLinks.ts b/src/actions/contact/jobLinks.ts
new file mode 100644
index 0000000..dd34c7e
--- /dev/null
+++ b/src/actions/contact/jobLinks.ts
@@ -0,0 +1,88 @@
+"use server";
+import prisma from "@/lib/db";
+import { handleError } from "@/lib/utils";
+import { requireUser } from "../shared";
+
+const JOB_CONTACT_INCLUDE = {
+ Role: true,
+ Contact: {
+ select: {
+ id: true,
+ name: true,
+ title: true,
+ email: true,
+ phone: true,
+ linkedinUrl: true,
+ Company: { select: { id: true, label: true } },
+ },
+ },
+};
+
+export const getJobContacts = async (
+ jobId: string,
+): Promise<any | undefined> => {
+ try {
+ const user = await requireUser();
+ return await prisma.jobContact.findMany({
+ where: { jobId, Job: { userId: user.id } },
+ include: JOB_CONTACT_INCLUDE,
+ orderBy: { createdAt: "asc" },
+ });
+ } catch (error) {
+ return handleError(error, "Failed to fetch job contacts. ");
+ }
+};
+
+export const addJobContact = async (
+ jobId: string,
+ contactId: string,
+ roleId: string,
+): Promise<any | undefined> => {
+ try {
+ const user = await requireUser();
+
+ // JobContact has no userId. All three sides are checked, not just the job:
+ // linking someone else's contact to your own job must fail.
+ const [job, contact, role] = await Promise.all([
+ prisma.job.count({ where: { id: jobId, userId: user.id } }),
+ prisma.contact.count({ where: { id: contactId, createdBy: user.id } }),
+ prisma.contactRole.count({ where: { id: roleId, createdBy: user.id } }),
+ ]);
+ if (job === 0) throw new Error("Job not found");
+ if (contact === 0) throw new Error("Contact not found");
+ if (role === 0) throw new Error("Role not found");
+
+ const data = await prisma.jobContact.create({
+ data: { jobId, contactId, roleId },
+ include: JOB_CONTACT_INCLUDE,
+ });
+ return { success: true, data };
+ } catch (error: any) {
+ if (error?.code === "P2002") {
+ return {
+ success: false,
+ message: "That contact already holds this role on this job.",
+ };
+ }
+ return handleError(error, "Failed to link contact to job.");
+ }
+};
+
+export const removeJobContact = async (
+ linkId: string,
+): Promise<any | undefined> => {
+ try {
+ const user = await requireUser();
+ const res = await prisma.jobContact.deleteMany({
+ where: {
+ id: linkId,
+ Job: { userId: user.id },
+ Contact: { createdBy: user.id },
+ },
+ });
+ if (res.count === 0) throw new Error("Link not found");
+ return { success: true };
+ } catch (error) {
+ return handleError(error, "Failed to unlink contact.");
+ }
+};
diff --git a/src/actions/job/queries.ts b/src/actions/job/queries.ts
index 8a50801..bd11dd7 100644
--- a/src/actions/job/queries.ts
+++ b/src/actions/job/queries.ts
@@ -52,6 +52,23 @@ const JOB_DETAILS_INCLUDE = {
},
CoverLetter: true,
tags: true,
+ contactLinks: {
+ include: {
+ Role: true,
+ Contact: {
+ select: {
+ id: true,
+ name: true,
+ title: true,
+ email: true,
+ phone: true,
+ linkedinUrl: true,
+ Company: { select: { id: true, label: true } },
+ },
+ },
+ },
+ orderBy: { createdAt: "asc" as const },
+ },
};
type JobsListFilters = {
diff --git a/src/components/myjobs/JobDetails.tsx b/src/components/myjobs/JobDetails.tsx
index bf75167..75c89b6 100644
--- a/src/components/myjobs/JobDetails.tsx
+++ b/src/components/myjobs/JobDetails.tsx
@@ -39,8 +39,15 @@ import { JobSummaryCard } from "./job-details/JobSummaryCard";
import { JobTabEmptyState } from "./job-details/JobTabEmptyState";
import { CoverLetterTab } from "./job-details/CoverLetterTab";
import { useAutoMatch } from "./job-details/useAutoMatch";
+import { JobContactsTab } from "./job-details/JobContactsTab";
-const JOB_DETAIL_TABS = ["description", "match", "letter", "notes"] as const;
+const JOB_DETAIL_TABS = [
+ "description",
+ "match",
+ "letter",
+ "notes",
+ "contacts",
+] as const;
type JobDetailsProps = {
job: JobResponse;
@@ -204,6 +211,14 @@ function JobDetails({
</Badge>
)}
</TabsTrigger>
+ <TabsTrigger value="contacts">
+ Contacts
+ {(job.contactLinks?.length ?? 0) > 0 && (
+ <Badge variant="secondary" className="ml-2">
+ {job.contactLinks!.length}
+ </Badge>
+ )}
+ </TabsTrigger>
</TabsList>
<TabsContent value="description" className="mt-4">
<Card className="p-6">
@@ -250,6 +265,16 @@ function JobDetails({
/>
</Card>
</TabsContent>
+ <TabsContent value="contacts" className="mt-4">
+ <Card className="p-6">
+ <JobContactsTab
+ jobId={job.id}
+ links={job.contactLinks ?? []}
+ companies={companies}
+ locations={locations}
+ />
+ </Card>
+ </TabsContent>
</Tabs>
</div>
<AddJob
diff --git a/src/components/myjobs/job-details/AddJobContactForm.tsx b/src/components/myjobs/job-details/AddJobContactForm.tsx
new file mode 100644
index 0000000..1f34c01
--- /dev/null
+++ b/src/components/myjobs/job-details/AddJobContactForm.tsx
@@ -0,0 +1,147 @@
+"use client";
+import { useState, useTransition } from "react";
+import { useForm } from "react-hook-form";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { z } from "zod";
+import { Button } from "@/components/ui/button";
+import {
+ Form,
+ FormField,
+ FormItem,
+ FormLabel,
+ FormMessage,
+} from "@/components/ui/form";
+import { Combobox } from "@/components/ComboBox";
+import AddContact from "@/components/AddContact";
+import { toastActionResult } from "@/lib/toast";
+import { addJobContact } from "@/actions/contact.actions";
+import type { ContactRef, ContactRole } from "@/models/contact.model";
+import type { Company, JobLocation } from "@/models/job.model";
+
+const LinkContactSchema = z.object({
+ contact: z.string().min(1, "Pick a contact."),
+ contactRole: z.string().min(1, "Pick a role."),
+});
+
+type LinkContactValues = z.infer<typeof LinkContactSchema>;
+
+type AddJobContactFormProps = {
+ jobId: string;
+ contacts: ContactRef[];
+ roles: ContactRole[];
+ companies: Company[];
+ locations: JobLocation[];
+ onCancel: () => void;
+ onLinked: () => void;
+ onContactCreated: (contact: ContactRef) => void;
+};
+
+export function AddJobContactForm({
+ jobId,
+ contacts,
+ roles,
+ companies,
+ locations,
+ onCancel,
+ onLinked,
+ onContactCreated,
+}: AddJobContactFormProps) {
+ const [isPending, startTransition] = useTransition();
+ const [newContactOpen, setNewContactOpen] = useState(false);
+ // What the contact picker's search box holds, so "New contact" can carry it
+ const [typedName, setTypedName] = useState("");
+
+ const form = useForm<LinkContactValues>({
+ resolver: zodResolver(LinkContactSchema),
+ defaultValues: { contact: "", contactRole: "" },
+ });
+
+ const onSubmit = (values: LinkContactValues) => {
+ startTransition(async () => {
+ const res = await addJobContact(jobId, values.contact, values.contactRole);
+ toastActionResult(res, {
+ success: "Contact has been linked to this job",
+ onSuccess: () => {
+ form.reset();
+ onLinked();
+ },
+ });
+ });
+ };
+
+ return (
+ <Form {...form}>
+ <form
+ onSubmit={form.handleSubmit(onSubmit)}
+ className="flex flex-wrap items-end gap-3"
+ >
+ <FormField
+ control={form.control}
+ name="contact"
+ render={({ field }) => (
+ <FormItem className="flex flex-col">
+ <FormLabel>Contact</FormLabel>
+ <Combobox
+ options={contacts}
+ field={field}
+ label="contact"
+ onSearchChange={setTypedName}
+ />
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+
+ <FormField
+ control={form.control}
+ name="contactRole"
+ render={({ field }) => (
+ <FormItem className="flex flex-col">
+ <FormLabel>Role</FormLabel>
+ <Combobox options={roles} field={field} creatable label="role" />
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+
+ <Button type="submit" className="cursor-pointer" disabled={isPending}>
+ Save
+ </Button>
+ <Button
+ type="button"
+ variant="outline"
+ className="cursor-pointer"
+ onClick={onCancel}
+ >
+ Cancel
+ </Button>
+ <Button
+ type="button"
+ variant="link"
+ className="cursor-pointer"
+ onClick={() => setNewContactOpen(true)}
+ >
+ New contact
+ </Button>
+ </form>
+
+ {/* A contact has a dozen fields, so the picker has no creatable path:
+ the typed name carries into the full dialog instead. */}
+ <AddContact
+ hideTrigger
+ prefillName={typedName}
+ dialogOpen={newContactOpen}
+ setDialogOpen={setNewContactOpen}
+ companies={companies}
+ locations={locations}
+ roles={roles}
+ reloadContacts={() => {}}
+ resetEditContact={() => {}}
+ onSaved={(contact) => {
+ onContactCreated(contact);
+ form.setValue("contact", contact.id);
+ }}
+ />
+ </Form>
+ );
+}
diff --git a/src/components/myjobs/job-details/JobContactsTab.tsx b/src/components/myjobs/job-details/JobContactsTab.tsx
new file mode 100644
index 0000000..a69a5c6
--- /dev/null
+++ b/src/components/myjobs/job-details/JobContactsTab.tsx
@@ -0,0 +1,182 @@
+"use client";
+import { useRef, useState } from "react";
+import { PlusCircle, Trash, Users } from "lucide-react";
+import { Badge } from "@/components/ui/badge";
+import { Button } from "@/components/ui/button";
+import { DeleteAlertDialog } from "@/components/DeleteAlertDialog";
+import { toastActionResult } from "@/lib/toast";
+import {
+ getAllContacts,
+ getJobContacts,
+ removeJobContact,
+} from "@/actions/contact.actions";
+import { getAllContactRoles } from "@/actions/contactRole.actions";
+import type {
+ ContactRef,
+ ContactRole,
+ JobContactLink,
+} from "@/models/contact.model";
+import type { Company, JobLocation } from "@/models/job.model";
+import { JobTabEmptyState } from "./JobTabEmptyState";
+import { AddJobContactForm } from "./AddJobContactForm";
+
+type JobContactsTabProps = {
+ jobId: string;
+ links: JobContactLink[];
+ companies?: Company[];
+ locations?: JobLocation[];
+};
+
+export function JobContactsTab({
+ jobId,
+ links,
+ companies = [],
+ locations = [],
+}: JobContactsTabProps) {
+ const [rows, setRows] = useState<JobContactLink[]>(links);
+ const [showForm, setShowForm] = useState(false);
+ const [contacts, setContacts] = useState<ContactRef[]>([]);
+ const [roles, setRoles] = useState<ContactRole[]>([]);
+ const [removeTarget, setRemoveTarget] = useState<JobContactLink | null>(null);
+ const loadedRef = useRef(false);
+
+ // The job page already runs seven parallel queries and most visits never
+ // leave Description, so the pickers wait for the first open of the form.
+ const openForm = async () => {
+ setShowForm(true);
+ if (loadedRef.current) return;
+ loadedRef.current = true;
+ const [contactList, roleList] = await Promise.all([
+ getAllContacts(),
+ getAllContactRoles(),
+ ]);
+ if (Array.isArray(contactList)) setContacts(contactList);
+ if (Array.isArray(roleList)) setRoles(roleList);
+ };
+
+ const reload = async () => {
+ const fresh = await getJobContacts(jobId);
+ if (Array.isArray(fresh)) setRows(fresh);
+ };
+
+ const onRemove = async () => {
+ if (!removeTarget) return;
+ const res = await removeJobContact(removeTarget.id);
+ setRemoveTarget(null);
+ toastActionResult(res, {
+ success: "Contact has been unlinked from this job",
+ onSuccess: reload,
+ });
+ };
+
+ return (
+ <div className="space-y-4">
+ {rows.length > 0 && !showForm && (
+ <div className="flex justify-end">
+ <Button
+ variant="outline"
+ size="sm"
+ className="h-7 gap-1"
+ onClick={openForm}
+ >
+ <PlusCircle className="h-3.5 w-3.5" />
+ Add Contact
+ </Button>
+ </div>
+ )}
+
+ {showForm && (
+ <AddJobContactForm
+ jobId={jobId}
+ contacts={contacts}
+ roles={roles}
+ companies={companies}
+ locations={locations}
+ onCancel={() => setShowForm(false)}
+ onLinked={() => {
+ setShowForm(false);
+ reload();
+ }}
+ onContactCreated={(contact) => setContacts([contact, ...contacts])}
+ />
+ )}
+
+ {rows.length === 0 && !showForm && (
+ <JobTabEmptyState
+ icon={Users}
+ title="No contacts on this job"
+ description="Link the recruiter, the panel, or a reference you named for this application."
+ actionLabel="Add Contact"
+ onAction={openForm}
+ />
+ )}
+
+ {rows.length > 0 && (
+ <ul className="space-y-2">
+ {rows.map((row) => (
+ <li
+ key={row.id}
+ className="flex flex-wrap items-center gap-x-3 gap-y-1 rounded-md border p-3 text-sm"
+ >
+ <span className="font-medium">{row.Contact?.name}</span>
+ {row.Contact?.title && (
+ <span className="text-muted-foreground">
+ {row.Contact.title}
+ </span>
+ )}
+ {row.Contact?.Company && (
+ <span className="text-muted-foreground">
+ {row.Contact.Company.label}
+ </span>
+ )}
+ <Badge variant="secondary">{row.Role.label}</Badge>
+ {row.Contact?.email && (
+ <a
+ href={`mailto:${row.Contact.email}`}
+ className="text-primary underline-offset-4 hover:underline"
+ >
+ {row.Contact.email}
+ </a>
+ )}
+ {row.Contact?.phone && (
+ <a
+ href={`tel:${row.Contact.phone}`}
+ className="text-primary underline-offset-4 hover:underline"
+ >
+ {row.Contact.phone}
+ </a>
+ )}
+ {row.Contact?.linkedinUrl && (
+ <a
+ href={row.Contact.linkedinUrl}
+ target="_blank"
+ rel="noopener noreferrer"
+ className="text-primary underline-offset-4 hover:underline"
+ >
+ LinkedIn
+ </a>
+ )}
+ <Button
+ variant="ghost"
+ size="icon"
+ className="ml-auto cursor-pointer"
+ aria-label={`Remove ${row.Contact?.name}`}
+ onClick={() => setRemoveTarget(row)}
+ >
+ <Trash className="h-4 w-4 text-red-600" />
+ </Button>
+ </li>
+ ))}
+ </ul>
+ )}
+
+ <DeleteAlertDialog
+ pageTitle="contact link"
+ open={!!removeTarget}
+ onOpenChange={(open) => !open && setRemoveTarget(null)}
+ onDelete={onRemove}
+ alertDescription="Removing this only unlinks the contact from this job. The contact itself is kept."
+ />
+ </div>
+ );
+}
diff --git a/src/models/job.model.ts b/src/models/job.model.ts
index c98e49d..70c2c16 100644
--- a/src/models/job.model.ts
+++ b/src/models/job.model.ts
@@ -1,5 +1,6 @@
import type { JobBoard, LeverHost } from "@/models/automation.model";
import { CoverLetter, Resume } from "./profile.model";
+import type { JobContactLink } from "./contact.model";
export interface JobForm {
id?: string;
@@ -55,6 +56,7 @@ export interface JobResponse {
matchScore?: number | null;
matchData?: string | null;
tags?: Tag[];
+ contactLinks?: JobContactLink[];
createdVia?: string | null;
discoveryStatus?: string | null;
descriptionCompleteness?: DescriptionCompleteness | null;