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.

fix(jobs): derive Applied from status and date everywhere, remove the Add Job Applied toggle, backfill applied via migration; move Add Skill beside Cover Letter in the job form; update the jobs help page

Khuram Niaz6c8d8c460a37
diff --git a/__tests__/AddJob.spec.tsx b/__tests__/AddJob.spec.tsx
index 2425483..18a6f2e 100644
--- a/__tests__/AddJob.spec.tsx
+++ b/__tests__/AddJob.spec.tsx
@@ -104,21 +104,16 @@ describe("AddJob Component", () => {
expect(dialogTitle).toBeInTheDocument();
expect(dialogTitle).toHaveTextContent("Add Job");
});
- it("should reflect on status and date applied when applied switch toggles", async () => {
- const appliedSwitch = screen.getByRole("switch");
- expect(appliedSwitch).not.toBeChecked();
- const dateApplied = screen.getByLabelText("Date Applied");
- expect(dateApplied).toBeDisabled();
- await user.click(appliedSwitch); // toggle applied switch
- expect(appliedSwitch).toBeChecked();
- expect(dateApplied).toBeEnabled(); // date applied is enabled
- expect(dateApplied).toHaveTextContent(format(new Date(), "PP")); // to have today's date
+ it("moves a Draft job to Applied when a date applied is picked", async () => {
const status = screen.getByLabelText("Status");
- expect(status).toHaveTextContent("Applied");
- await user.click(appliedSwitch);
expect(status).toHaveTextContent("Draft");
- expect(dateApplied).toBeDisabled();
- expect(dateApplied).toHaveTextContent("Pick a date");
+ await user.click(screen.getByLabelText("Date Applied"));
+ const days = screen
+ .getAllByRole("gridcell")
+ .map((cell) => cell.querySelector("button"))
+ .filter((b): b is HTMLButtonElement => !!b && !b.disabled);
+ await user.click(days[0]);
+ expect(status).toHaveTextContent("Applied");
});
it("should open the dialog when clicked on add job button with title 'Edit Job'", async () => {
// TODO: To be tested with job container and jobs table component
@@ -208,6 +203,29 @@ describe("AddJob Component", () => {
),
);
});
+ const pickStatus = async (label: string) => {
+ await user.click(screen.getByLabelText("Status"));
+ await user.click(screen.getByRole("option", { name: label }));
+ };
+ it("fills today's date on Applied and takes it back on a non-applying status", async () => {
+ const dateApplied = screen.getByLabelText("Date Applied");
+ expect(dateApplied).toBeEnabled();
+ await pickStatus("Applied");
+ expect(dateApplied).toHaveTextContent(format(new Date(), "PP"));
+ await pickStatus("Interview");
+ expect(dateApplied).toHaveTextContent(format(new Date(), "PP"));
+ await pickStatus("Draft");
+ expect(dateApplied).toHaveTextContent("Pick a date");
+ });
+ it.each(["Interview", "Offer"])(
+ "leaves the date empty when the status is set straight to %s",
+ async (label) => {
+ await pickStatus(label);
+ expect(screen.getByLabelText("Date Applied")).toHaveTextContent(
+ "Pick a date",
+ );
+ },
+ );
it("should load and show the status select list", async () => {
const statusSelect = screen.getByLabelText("Status");
await user.click(statusSelect);
@@ -276,7 +294,6 @@ describe("AddJob Component", () => {
salaryRange: "",
jobDescription: "<p>New Job Description</p>",
jobUrl: "",
- applied: false,
tags: [],
});
});
@@ -445,9 +462,6 @@ describe("AddJob Component - Edit Mode", () => {
expect(screen.getByLabelText("Salary Range")).toHaveTextContent(
"100,000 - 110,000",
);
-
- const appliedSwitch = screen.getByRole("switch");
- expect(appliedSwitch).toBeChecked();
});
it("pre-fills a free-text salary that matches no suggestion", async () => {
@@ -588,7 +602,7 @@ describe("AddJob Component - Status Order", () => {
...JOB_STATUSES,
];
- it("defaults to Draft and toggles to Applied whatever order statuses arrive in", async () => {
+ it("defaults to Draft and fills the date on Applied whatever order statuses arrive in", async () => {
render(
<AddJob
jobStatuses={freshInstallStatuses}
@@ -605,9 +619,10 @@ describe("AddJob Component - Status Order", () => {
const status = screen.getByLabelText("Status");
expect(status).toHaveTextContent("Draft");
- await user.click(screen.getByRole("switch"));
- expect(status).toHaveTextContent("Applied");
- await user.click(screen.getByRole("switch"));
- expect(status).toHaveTextContent("Draft");
+ await user.click(status);
+ await user.click(screen.getByRole("option", { name: "Applied" }));
+ expect(screen.getByLabelText("Date Applied")).toHaveTextContent(
+ format(new Date(), "PP"),
+ );
});
});
diff --git a/__tests__/CompanyDetails.spec.tsx b/__tests__/CompanyDetails.spec.tsx
index c71db22..a8f88d9 100644
--- a/__tests__/CompanyDetails.spec.tsx
+++ b/__tests__/CompanyDetails.spec.tsx
@@ -373,7 +373,14 @@ describe("CompanyDetails – Jobs tab", () => {
render(
<CompanyDetails
details={makeDetails({
- jobs: [job({ appliedDate: null, matchScore: null, JobSource: null })],
+ jobs: [
+ job({
+ applied: false,
+ appliedDate: null,
+ matchScore: null,
+ JobSource: null,
+ }),
+ ],
})}
/>,
);
diff --git a/__tests__/JobCard.spec.tsx b/__tests__/JobCard.spec.tsx
index 4e7fc2d..d71425d 100644
--- a/__tests__/JobCard.spec.tsx
+++ b/__tests__/JobCard.spec.tsx
@@ -67,10 +67,15 @@ describe("JobCard", () => {
expect(screen.getByText("Jun 1, 2024")).toBeInTheDocument();
unmount();
- renderCard(makeJob({ appliedDate: null as unknown as Date }));
+ renderCard(makeJob({ appliedDate: null as unknown as Date, applied: false }));
expect(screen.getByText("Not applied")).toBeInTheDocument();
});
+ it("shows Applied for an applied job with no date", () => {
+ renderCard(makeJob({ appliedDate: null as unknown as Date, applied: true }));
+ expect(screen.queryByText("Not applied")).not.toBeInTheDocument();
+ });
+
it("renders the match score, or a Match button when there is none", () => {
const { unmount } = renderCard(makeJob({ matchScore: 87 }));
expect(screen.getByText("87%")).toBeInTheDocument();
diff --git a/__tests__/createJobStage.spec.ts b/__tests__/createJobStage.spec.ts
index ab33582..f484a24 100644
--- a/__tests__/createJobStage.spec.ts
+++ b/__tests__/createJobStage.spec.ts
@@ -6,6 +6,7 @@ vi.mock("@/lib/db", () => ({
default: {
job: { create: vi.fn() },
jobStage: { create: vi.fn() },
+ jobStatus: { findUnique: vi.fn() },
},
}));
vi.mock("@/lib/jobs/resolve", () => ({
@@ -17,6 +18,7 @@ const db = prisma as any;
beforeEach(() => {
vi.clearAllMocks();
(resolveStageTypeForStatusId as any).mockResolvedValue("t-draft");
+ db.jobStatus.findUnique.mockResolvedValue({ value: "draft" });
db.job.create.mockResolvedValue({ id: "j1", createdAt: new Date("2026-09-19T00:00:00Z") });
});
diff --git a/__tests__/job.actions.spec.ts b/__tests__/job.actions.spec.ts
index 4328ab6..3de17ec 100644
--- a/__tests__/job.actions.spec.ts
+++ b/__tests__/job.actions.spec.ts
@@ -23,6 +23,7 @@ vi.mock("@prisma/client", () => {
const mPrismaClient = {
jobStatus: {
findMany: vi.fn(),
+ findUnique: vi.fn(),
create: vi.fn(),
update: vi.fn(),
},
@@ -55,6 +56,7 @@ vi.mock("@prisma/client", () => {
tag: { count: vi.fn() },
jobStage: {
findFirst: vi.fn(),
+ count: vi.fn(),
create: vi.fn(),
update: vi.fn(),
updateMany: vi.fn(),
@@ -127,6 +129,7 @@ describe("jobActions", () => {
(prisma as any).jobStage.create.mockResolvedValue({ id: "stage-id" });
(prisma as any).jobStage.updateMany.mockResolvedValue({ count: 1 });
(resolveStageTypeForStatusId as any).mockResolvedValue("stage-type-id");
+ (prisma as any).jobStatus.findUnique.mockResolvedValue({ value: "draft" });
});
describe("getStatusList", () => {
it("should return status list on successful query", async () => {
@@ -1177,7 +1180,6 @@ describe("jobActions", () => {
description: jobData.jobDescription,
jobType: jobData.type,
userId: mockUser.id,
- applied: jobData.applied,
resumeId: jobData.resume,
stages: {
create: {
@@ -1190,6 +1192,28 @@ describe("jobActions", () => {
});
expect(result).toEqual({ data: jobData, success: true });
});
+ it("marks the job applied when the chosen status is Applied", async () => {
+ (getCurrentUser as any).mockResolvedValue(mockUser);
+ (prisma as any).jobStatus.findUnique.mockResolvedValue({ value: "applied" });
+ (prisma.job.create as any).mockResolvedValue(jobData);
+
+ await addJob({ ...jobData, dateApplied: undefined });
+
+ const data = (prisma.job.create as any).mock.calls[0][0].data;
+ expect(data.applied).toBe(true);
+ expect(data.appliedDate).toEqual(expect.any(Date));
+ });
+ it("marks an Offer job applied without inventing a date", async () => {
+ (getCurrentUser as any).mockResolvedValue(mockUser);
+ (prisma as any).jobStatus.findUnique.mockResolvedValue({ value: "offer" });
+ (prisma.job.create as any).mockResolvedValue(jobData);
+
+ await addJob({ ...jobData, dateApplied: undefined });
+
+ const data = (prisma.job.create as any).mock.calls[0][0].data;
+ expect(data.applied).toBe(true);
+ expect(data.appliedDate).toBeUndefined();
+ });
it("should handle unexpected errors", async () => {
(getCurrentUser as any).mockResolvedValue(mockUser);
@@ -1286,6 +1310,7 @@ describe("jobActions", () => {
jobSourceId: "source-id",
resumeId: null,
coverLetterId: null,
+ statusId: "status-id",
tags: [{ id: "tag-1" }],
};
beforeEach(() => {
@@ -1361,6 +1386,71 @@ describe("jobActions", () => {
expect(result).toStrictEqual({ data: jobData, success: true });
expect(prisma.job.update).toHaveBeenCalledTimes(1);
});
+ it("keeps an Interview job applied when it has no date", async () => {
+ (getCurrentUser as any).mockResolvedValue(mockUser);
+ (prisma as any).jobStatus.findUnique.mockResolvedValue({
+ value: "interview",
+ });
+ (prisma.job.update as any).mockResolvedValue(jobData);
+
+ await updateJob({ ...jobData, dateApplied: undefined });
+
+ const data = (prisma.job.update as any).mock.calls[0][0].data;
+ expect(data.applied).toBe(true);
+ expect(data.appliedDate).toBeNull();
+ });
+ it("un-applies a job whose date is cleared and was never applied to", async () => {
+ (getCurrentUser as any).mockResolvedValue(mockUser);
+ (prisma as any).jobStage.count.mockResolvedValue(0);
+ (prisma.job.update as any).mockResolvedValue(jobData);
+
+ await updateJob({ ...jobData, dateApplied: undefined });
+
+ expect((prisma as any).jobStage.count.mock.calls[0][0].where).toMatchObject(
+ { jobId: "job-id", Job: { userId: mockUser.id } },
+ );
+ const data = (prisma.job.update as any).mock.calls[0][0].data;
+ expect(data.applied).toBe(false);
+ expect(data.appliedDate).toBeNull();
+ });
+ it("keeps a job applied when an earlier stage was an applying one", async () => {
+ (getCurrentUser as any).mockResolvedValue(mockUser);
+ (prisma as any).jobStatus.findUnique.mockResolvedValue({
+ value: "rejected",
+ });
+ (prisma as any).jobStage.count.mockResolvedValue(1);
+ (prisma.job.update as any).mockResolvedValue(jobData);
+
+ await updateJob({ ...jobData, dateApplied: undefined });
+
+ expect((prisma.job.update as any).mock.calls[0][0].data.applied).toBe(true);
+ });
+ it("does not date an Applied job on a save that keeps its status", async () => {
+ (getCurrentUser as any).mockResolvedValue(mockUser);
+ (prisma as any).jobStatus.findUnique.mockResolvedValue({
+ value: "applied",
+ });
+ (prisma.job.update as any).mockResolvedValue(jobData);
+
+ await updateJob({ ...jobData, dateApplied: undefined });
+
+ const data = (prisma.job.update as any).mock.calls[0][0].data;
+ expect(data.applied).toBe(true);
+ expect(data.appliedDate).toBeNull();
+ });
+ it("dates a job when the save moves it to Applied without a date", async () => {
+ (getCurrentUser as any).mockResolvedValue(mockUser);
+ (prisma as any).jobStatus.findUnique.mockResolvedValue({
+ value: "applied",
+ });
+ (prisma.job.update as any).mockResolvedValue(jobData);
+
+ await updateJob({ ...jobData, status: "s-new", dateApplied: undefined });
+
+ const data = (prisma.job.update as any).mock.calls[0][0].data;
+ expect(data.applied).toBe(true);
+ expect(data.appliedDate).toEqual(expect.any(Date));
+ });
it("appends a status stage when the Edit Job dialog changes the status", async () => {
(getCurrentUser as any).mockResolvedValue(mockUser);
(prisma.job.update as any).mockResolvedValue(jobData);
diff --git a/__tests__/updateJobFromNames.spec.ts b/__tests__/updateJobFromNames.spec.ts
index 807fcf8..719c573 100644
--- a/__tests__/updateJobFromNames.spec.ts
+++ b/__tests__/updateJobFromNames.spec.ts
@@ -157,6 +157,30 @@ describe("updateJobFromNames", () => {
expect(data.appliedDate).toBeInstanceOf(Date);
});
+ it("marks the job applied when only an appliedDate is sent", async () => {
+ const appliedDate = new Date("2026-09-01T00:00:00Z");
+ await updateJobFromNames({ jobId: "job-1", appliedDate }, userId);
+
+ const data = (prisma.job.update as any).mock.calls[0][0].data;
+ expect(data).toEqual({ appliedDate, applied: true });
+ });
+
+ it("marks the job applied when the status moves to Applied", async () => {
+ await updateJobFromNames({ jobId: "job-1", status: "Applied" }, userId);
+
+ const data = (prisma.job.update as any).mock.calls[0][0].data;
+ expect(data.applied).toBe(true);
+ expect(data.appliedDate).toBeInstanceOf(Date);
+ });
+
+ it("leaves applied alone for a status that doesn't imply applying", async () => {
+ await updateJobFromNames({ jobId: "job-1", status: "archived" }, userId);
+
+ expect((prisma.job.update as any).mock.calls[0][0].data).not.toHaveProperty(
+ "applied",
+ );
+ });
+
it("returns updated:false with a not-found message on P2025", async () => {
(prisma.job.update as any).mockRejectedValue({ code: "P2025" });
diff --git a/e2e/add-job.spec.ts b/e2e/add-job.spec.ts
index 3aa8d9e..99ff60c 100644
--- a/e2e/add-job.spec.ts
+++ b/e2e/add-job.spec.ts
@@ -83,7 +83,8 @@ test.describe("Add New Job", () => {
const jobText = uniqueName("developer test title applied");
await createNewJob(page, jobText, cleanup, {
beforeSave: async (page) => {
- await page.getByRole("switch").click();
+ await page.getByLabel("Select Job Status").click();
+ await page.getByRole("option", { name: "Applied", exact: true }).click();
},
});
await expect(page.getByRole("row", { name: jobText }).first()).toBeVisible();
@@ -93,7 +94,6 @@ test.describe("Add New Job", () => {
.getByRole("button", { name: "Edit Job" })
.first()
.click();
- await expect(page.getByRole("switch")).toBeChecked();
await expect(page.getByLabel("Select Job Status")).toContainText("Applied");
await expect(page.getByLabel("Date Applied")).toContainText(
format(new Date(), "PP"),
diff --git a/e2e/dashboard.spec.ts b/e2e/dashboard.spec.ts
index 8be0ee5..986bff3 100644
--- a/e2e/dashboard.spec.ts
+++ b/e2e/dashboard.spec.ts
@@ -123,7 +123,8 @@ test.describe("Dashboard page", () => {
const jobText = uniqueName("dashboard applied job");
await createNewJob(page, jobText, cleanup, {
beforeSave: async (page) => {
- await page.getByRole("switch").click();
+ await page.getByLabel("Select Job Status").click();
+ await page.getByRole("option", { name: "Applied", exact: true }).click();
},
});
await expect(page.getByRole("row", { name: jobText }).first()).toBeVisible();
diff --git a/prisma/migrations/20260926120000_backfill_job_applied/migration.sql b/prisma/migrations/20260926120000_backfill_job_applied/migration.sql
new file mode 100644
index 0000000..afe4726
--- /dev/null
+++ b/prisma/migrations/20260926120000_backfill_job_applied/migration.sql
@@ -0,0 +1,18 @@
+-- Jobs saved at an applying status through the old Add/Edit Job form kept
+-- applied = false. Derived from the status, stage history and date only;
+-- no appliedDate is invented. Idempotent.
+UPDATE "Job" SET "applied" = 1
+WHERE "applied" = 0
+ AND (
+ "appliedDate" IS NOT NULL
+ OR "statusId" IN (
+ SELECT "id" FROM "JobStatus"
+ WHERE "value" IN ('applied', 'interview', 'offer', 'offer-accepted', 'offer-declined')
+ )
+ OR "id" IN (
+ SELECT s."jobId" FROM "JobStage" s
+ JOIN "JobStageType" t ON t."id" = s."stageTypeId"
+ JOIN "JobStatus" st ON st."id" = t."statusId"
+ WHERE st."value" IN ('applied', 'interview', 'offer', 'offer-accepted', 'offer-declined')
+ )
+ );
diff --git a/src/actions/job/mutations.ts b/src/actions/job/mutations.ts
index b08b6ff..bd68598 100644
--- a/src/actions/job/mutations.ts
+++ b/src/actions/job/mutations.ts
@@ -7,7 +7,9 @@ import { revalidatePath } from "next/cache";
import { z } from "zod";
import { requireUser } from "../shared";
import { appendStatusStage } from "./shared";
+import { jobFieldsForStage } from "../jobStage/shared";
import { resolveStageTypeForStatusId } from "@/lib/jobs/resolve";
+import { APPLIED_STATUS_VALUES } from "@/lib/constants";
type JobRefs = {
jobTitleId?: string | null;
@@ -81,7 +83,6 @@ export const addJob = async (
dateApplied,
jobDescription,
jobUrl,
- applied,
resume,
coverLetter,
tags,
@@ -111,7 +112,6 @@ export const addJob = async (
workplaceType,
userId: user.id,
jobUrl,
- applied,
resumeId: resume,
coverLetterId: coverLetter,
tagIds: tags ?? [],
@@ -147,7 +147,6 @@ export const updateJob = async (
dateApplied,
jobDescription,
jobUrl,
- applied,
resume,
coverLetter,
tags,
@@ -164,6 +163,7 @@ export const updateJob = async (
jobSourceId: true,
resumeId: true,
coverLetterId: true,
+ statusId: true,
tags: { select: { id: true } },
},
});
@@ -188,6 +188,22 @@ export const updateJob = async (
// Same D4 rule: resolve before the transaction opens.
const stageTypeId = await resolveStageTypeForStatusId(status, user.id);
+ const statusRow = await prisma.jobStatus.findUnique({
+ where: { id: status },
+ select: { value: true },
+ });
+ // Clearing the date un-applies the job, unless its status or an earlier
+ // stage says it was applied to (Offer then Rejected keeps it applied).
+ const applied =
+ !!dateApplied ||
+ APPLIED_STATUS_VALUES.includes(statusRow?.value ?? "") ||
+ (await prisma.jobStage.count({
+ where: {
+ jobId: id,
+ Job: { userId: user.id },
+ StageType: { Status: { value: { in: [...APPLIED_STATUS_VALUES] } } },
+ },
+ })) > 0;
const job = await prisma.$transaction(async (tx: any) => {
// The Edit Job dialog's Status field is the fourth entry point into the
@@ -207,15 +223,23 @@ export const updateJob = async (
salaryRange: salaryRange || null,
createdAt: new Date(),
dueDate: dueDate,
- appliedDate: dateApplied,
+ appliedDate: dateApplied ?? null,
description: jobDescription,
jobType: type,
workplaceType,
jobUrl,
- applied,
resumeId: resume,
coverLetterId: coverLetter,
tags: { set: tagIds.map((id) => ({ id })) },
+ // Stamp today only on a move to Applied, never on an unrelated save.
+ ...(status !== current.statusId &&
+ jobFieldsForStage(
+ statusRow?.value ?? "",
+ status,
+ null,
+ dateApplied ?? null,
+ )),
+ applied,
},
});
});
diff --git a/src/actions/jobStage/shared.ts b/src/actions/jobStage/shared.ts
index 11909b5..7dc8fe9 100644
--- a/src/actions/jobStage/shared.ts
+++ b/src/actions/jobStage/shared.ts
@@ -1,4 +1,5 @@
import prisma from "@/lib/db";
+import { APPLIED_STATUS_VALUES } from "@/lib/constants";
export { sortStages } from "@/lib/jobs/sortStages";
@@ -33,8 +34,9 @@ export const STAGE_DETAIL_INCLUDE = {
},
};
-// The applied/appliedDate rules updateJobStatus has always used, lifted out so
-// every stage write path keeps the dashboard and CSV export in agreement.
+// The applied/appliedDate rules, shared so every status write path keeps the
+// dashboard and CSV export in agreement. Only Applied stamps a date: an
+// Interview or Offer logged later would otherwise count as applied today.
export function jobFieldsForStage(
statusValue: string,
statusId: string,
@@ -42,7 +44,7 @@ export function jobFieldsForStage(
existingAppliedDate: Date | null,
): Record<string, unknown> {
const data: Record<string, unknown> = { statusId };
- if (statusValue === "applied" || statusValue === "interview") {
+ if (APPLIED_STATUS_VALUES.includes(statusValue) || existingAppliedDate) {
data.applied = true;
}
if (statusValue === "applied" && !existingAppliedDate) {
diff --git a/src/components/admin/company-details/CompanyJobsTab.tsx b/src/components/admin/company-details/CompanyJobsTab.tsx
index 8614251..112fa87 100644
--- a/src/components/admin/company-details/CompanyJobsTab.tsx
+++ b/src/components/admin/company-details/CompanyJobsTab.tsx
@@ -68,7 +68,9 @@ export function CompanyJobsTab({ jobs }: CompanyJobsTabProps) {
<TableCell className="hidden md:table-cell">
{job.appliedDate
? format(new Date(job.appliedDate), "PP")
- : "Not applied"}
+ : job.applied
+ ? "Applied"
+ : "Not applied"}
</TableCell>
<TableCell>
{job.matchScore != null ? (
diff --git a/src/components/myjobs/AddJob.tsx b/src/components/myjobs/AddJob.tsx
index 09e568a..0e18943 100644
--- a/src/components/myjobs/AddJob.tsx
+++ b/src/components/myjobs/AddJob.tsx
@@ -12,7 +12,13 @@ import { addJob, updateJob } from "@/actions/job.actions";
import { Loader, PlusCircle } from "lucide-react";
import { Button } from "../ui/button";
import { useForm } from "react-hook-form";
-import { useCallback, useEffect, useState, useTransition } from "react";
+import {
+ useCallback,
+ useEffect,
+ useRef,
+ useState,
+ useTransition,
+} from "react";
import { AddJobFormSchema } from "@/models/addJobForm.schema";
import { zodResolver } from "@hookform/resolvers/zod";
import {
@@ -43,7 +49,6 @@ import { DatePicker } from "../DatePicker";
import { SALARY_RANGES } from "@/lib/data/salaryRangeData";
import TiptapEditor from "../TiptapEditor";
import { Input } from "../ui/input";
-import { Switch } from "../ui/switch";
import { redirect, useRouter, useSearchParams } from "next/navigation";
import { Combobox } from "../ComboBox";
import { NotesCollapsibleSection } from "./NotesCollapsibleSection";
@@ -52,7 +57,7 @@ import CreateResume from "../profile/CreateResume";
import { getResumeList } from "@/actions/profile.actions";
import { getCoverLetterList } from "@/actions/coverLetter.actions";
import { TagInput } from "./TagInput";
-import { APP_CONSTANTS } from "@/lib/constants";
+import { APP_CONSTANTS, APPLIED_STATUS_VALUES } from "@/lib/constants";
import {
getFromLocalStorage,
saveToLocalStorage,
@@ -118,6 +123,7 @@ export function AddJob({
// By value, not position: the list's order is not guaranteed.
const draftStatusId = jobStatuses.find((s) => s.value === "draft")?.id;
const appliedStatusId = jobStatuses.find((s) => s.value === "applied")?.id;
+ const newStatusId = jobStatuses.find((s) => s.value === "new")?.id;
const newJobDefaultValues = {
type: Object.keys(JOB_TYPES)[0],
workplaceType: "ONSITE",
@@ -135,9 +141,10 @@ export function AddJob({
defaultValues: newJobDefaultValues,
});
- const { setValue, reset, watch, resetField } = form;
+ const { setValue, reset } = form;
- const appliedValue = watch("applied");
+ // The date the form filled in itself, so it can take it back again.
+ const autoFilledDate = useRef<Date | null>(null);
const loadResumes = useCallback(async () => {
try {
@@ -176,7 +183,6 @@ export function AddJob({
dueDate: editJob.dueDate,
salaryRange: editJob.salaryRange ?? "",
jobDescription: editJob.description,
- applied: editJob.applied,
jobUrl: editJob.jobUrl ?? "",
dateApplied: editJob.appliedDate ?? undefined,
resume: editJob.Resume?.id ?? undefined,
@@ -191,6 +197,7 @@ export function AddJob({
return incoming.length > 0 ? [...prev, ...incoming] : prev;
});
}
+ autoFilledDate.current = null;
setDialogOpen(true);
}
}, [editJob, reset]);
@@ -236,19 +243,39 @@ export function AddJob({
const addJobForm = () => {
reset(newJobDefaultValues);
+ autoFilledDate.current = null;
resetEditJob();
setDialogOpen(true);
};
- const jobAppliedChange = (applied: boolean) => {
- if (applied) {
+ // Mirrors jobFieldsForStage: only Applied stamps today's date.
+ const jobStatusChange = (statusId: string) => {
+ const value = jobStatuses.find((s) => s.id === statusId)?.value ?? "";
+ const date = form.getValues("dateApplied");
+ if (value === "applied" && !date) {
+ autoFilledDate.current = new Date();
+ setValue("dateApplied", autoFilledDate.current);
+ } else if (
+ !APPLIED_STATUS_VALUES.includes(value) &&
+ date &&
+ // react-hook-form stores a copy, so compare by time, not identity
+ date.getTime() === autoFilledDate.current?.getTime()
+ ) {
+ autoFilledDate.current = null;
+ setValue("dateApplied", undefined);
+ }
+ };
+
+ // A date the user picks means they applied, as the old toggle did.
+ const dateAppliedChange = (date?: Date) => {
+ autoFilledDate.current = null;
+ const status = form.getValues("status");
+ if (
+ date &&
appliedStatusId &&
- form.getValues("status") === draftStatusId &&
- setValue("status", appliedStatusId);
- setValue("dateApplied", new Date());
- } else {
- resetField("dateApplied");
- draftStatusId && setValue("status", draftStatusId);
+ (status === draftStatusId || status === newStatusId)
+ ) {
+ setValue("status", appliedStatusId);
}
};
@@ -455,37 +482,6 @@ export function AddJob({
/>
</div>
- {/* Applied */}
- <div
- className="flex items-center"
- data-testid="switch-container"
- >
- <FormField
- control={form.control}
- name="applied"
- render={({ field }) => (
- <FormItem className="flex flex-row">
- <Switch
- id="applied-switch"
- checked={field.value ?? false}
- onCheckedChange={(a) => {
- field.onChange(a);
- jobAppliedChange(a);
- }}
- />
- <FormLabel
- htmlFor="applied-switch"
- className="flex items-center ml-4 mb-2"
- >
- {field.value ? "Applied" : "Not Applied"}
- </FormLabel>
-
- <FormMessage />
- </FormItem>
- )}
- />
- </div>
-
{/* Status */}
<div>
<FormField
@@ -497,7 +493,13 @@ export function AddJob({
<SelectFormCtrl
label="Job Status"
options={jobStatuses}
- field={field}
+ field={{
+ ...field,
+ onChange: (id: string) => {
+ field.onChange(id);
+ jobStatusChange(id);
+ },
+ }}
/>
<FormMessage />
</FormItem>
@@ -514,9 +516,15 @@ export function AddJob({
<FormItem className="flex flex-col">
<FormLabel>Date Applied</FormLabel>
<DatePicker
- field={field}
+ field={{
+ ...field,
+ onChange: (date?: Date) => {
+ field.onChange(date);
+ dateAppliedChange(date);
+ },
+ }}
presets={false}
- isEnabled={appliedValue}
+ isEnabled={true}
/>
<FormMessage />
</FormItem>
@@ -593,7 +601,7 @@ export function AddJob({
</div>
{/* Cover Letter */}
- <div className="flex items-end">
+ <div className="flex items-end self-start">
<FormField
control={form.control}
name="coverLetter"
@@ -612,7 +620,7 @@ export function AddJob({
</div>
{/* Add Skill Tags */}
- <div className="md:col-span-2">
+ <div>
<FormField
control={form.control}
name="tags"
diff --git a/src/components/myjobs/JobCard.tsx b/src/components/myjobs/JobCard.tsx
index 22a3066..272be64 100644
--- a/src/components/myjobs/JobCard.tsx
+++ b/src/components/myjobs/JobCard.tsx
@@ -97,7 +97,11 @@ export function JobCard({
)}
<span className="flex items-center gap-1 whitespace-nowrap">
<Calendar className="h-3.5 w-3.5 shrink-0" />
- {job.appliedDate ? format(job.appliedDate, "PP") : "Not applied"}
+ {job.appliedDate
+ ? format(job.appliedDate, "PP")
+ : job.applied
+ ? "Applied"
+ : "Not applied"}
</span>
{job.JobSource?.label && (
<span className="flex min-w-0 items-center gap-1">
diff --git a/src/components/myjobs/JobDetails.tsx b/src/components/myjobs/JobDetails.tsx
index 7d1e6db..7cb7add 100644
--- a/src/components/myjobs/JobDetails.tsx
+++ b/src/components/myjobs/JobDetails.tsx
@@ -188,6 +188,8 @@ function JobDetails({
// The status change appends a stage server-side, and the badge reads
// that stage, so this is awaited rather than fired off.
await reloadStages();
+ // applied/appliedDate may have changed too, and they come from the prop.
+ router.refresh();
toastSuccess(`Job has been updated successfully`);
} else {
toastError(message);
diff --git a/src/components/myjobs/job-details/JobSummaryCard.tsx b/src/components/myjobs/job-details/JobSummaryCard.tsx
index 36ac583..4583555 100644
--- a/src/components/myjobs/job-details/JobSummaryCard.tsx
+++ b/src/components/myjobs/job-details/JobSummaryCard.tsx
@@ -72,7 +72,9 @@ export function JobSummaryCard({
<p className="mt-1 font-medium">
{job.appliedDate
? format(new Date(job.appliedDate), "PP")
- : "Not applied"}
+ : job.applied
+ ? "Yes, no date"
+ : "Not applied"}
</p>
</div>
<div>
diff --git a/src/lib/constants.ts b/src/lib/constants.ts
index 275865e..6a569ac 100644
--- a/src/lib/constants.ts
+++ b/src/lib/constants.ts
@@ -348,6 +348,15 @@ export const STAGE_OUTCOMES = [
{ label: "Cancelled", value: "cancelled" },
] as const;
+// Statuses you can only reach by applying: setting one marks the job applied.
+export const APPLIED_STATUS_VALUES: readonly string[] = [
+ "applied",
+ "interview",
+ "offer",
+ "offer-accepted",
+ "offer-declined",
+];
+
// Zod's z.enum needs a non-empty tuple; JOB_STATUSES is the source of truth.
export const JOB_STATUS_VALUES = JOB_STATUSES.map((s) => s.value) as unknown as [
string,
diff --git a/src/lib/jobs/createJobRecord.ts b/src/lib/jobs/createJobRecord.ts
index 76f38dd..e03f54f 100644
--- a/src/lib/jobs/createJobRecord.ts
+++ b/src/lib/jobs/createJobRecord.ts
@@ -1,5 +1,6 @@
import prisma from "@/lib/db";
import { resolveStageTypeForStatusId } from "@/lib/jobs/resolve";
+import { jobFieldsForStage } from "@/actions/jobStage/shared";
type StageClient = {
jobStage: { create: (args: any) => Promise<any> };
@@ -56,9 +57,19 @@ export async function createJobRecord(fields: {
const { tagIds = [], ...rest } = fields;
const createdAt = new Date();
const stages = await firstStageCreate(fields.statusId, fields.userId, createdAt);
+ const status = await prisma.jobStatus.findUnique({
+ where: { id: fields.statusId },
+ select: { value: true },
+ });
return await prisma.job.create({
data: {
...rest,
+ ...jobFieldsForStage(
+ status?.value ?? "",
+ fields.statusId,
+ null,
+ fields.appliedDate ?? null,
+ ),
createdAt,
...(tagIds.length > 0 ? { tags: { connect: tagIds.map((id) => ({ id })) } } : {}),
stages,
diff --git a/src/lib/jobs/updateJobFromNames.ts b/src/lib/jobs/updateJobFromNames.ts
index b9af4bd..3896fda 100644
--- a/src/lib/jobs/updateJobFromNames.ts
+++ b/src/lib/jobs/updateJobFromNames.ts
@@ -17,6 +17,7 @@ import {
type ResolvedEntity,
} from "./resolve";
import { appendStatusStage } from "@/actions/job/shared";
+import { jobFieldsForStage } from "@/actions/jobStage/shared";
// Same renderer config as createJobFromNames — html:false escapes raw HTML.
const md = new MarkdownIt({ html: false, linkify: false, breaks: true });
@@ -125,7 +126,10 @@ export async function updateJobFromNames(
if (input.dueDate !== undefined) data.dueDate = input.dueDate;
if (input.jobUrl !== undefined) data.jobUrl = normalizeJobUrl(input.jobUrl);
if (input.applied !== undefined) data.applied = input.applied;
- if (input.appliedDate !== undefined) data.appliedDate = input.appliedDate;
+ if (input.appliedDate !== undefined) {
+ data.appliedDate = input.appliedDate;
+ data.applied = true;
+ }
// D5: an appliedDate already on the job is never overwritten, the same rule
// updateJobStatus and every stage write path now follow.
if (
@@ -135,6 +139,17 @@ export async function updateJobFromNames(
) {
data.appliedDate = new Date();
}
+ if (statusId && input.status !== undefined) {
+ Object.assign(
+ data,
+ jobFieldsForStage(
+ input.status.toLowerCase(),
+ statusId,
+ null,
+ (data.appliedDate as Date | undefined) ?? existing.appliedDate,
+ ),
+ );
+ }
if (resolvedTagsResult) {
data.tags = { set: resolvedTagsResult.resolved.map((t) => ({ id: t.id })) };
}
diff --git a/src/models/addJobForm.schema.ts b/src/models/addJobForm.schema.ts
index 3776805..10ba1ca 100644
--- a/src/models/addJobForm.schema.ts
+++ b/src/models/addJobForm.schema.ts
@@ -58,7 +58,6 @@ export const AddJobFormSchema = z.object({
message: "Job description must be at least 10 characters.",
}),
jobUrl: z.string().optional(),
- applied: z.boolean().default(false),
resume: z.string().optional(),
coverLetter: z.string().optional(),
tags: z
diff --git a/wiki/jobs.md b/wiki/jobs.md
index af726d4..1832274 100644
--- a/wiki/jobs.md
+++ b/wiki/jobs.md
@@ -15,7 +15,7 @@ stale_after: 2027-08-31
Open **Jobs** in the sidebar and click **Add Job** at the top-right of the Jobs card. Job Title, Company, Job Location and Job Source are the fields you must fill in — each is a combo box that either picks an existing entry or creates a new one as you type, and Location and Source come pre-selected with whatever you used on your last job.
-Job Type, Workplace Type, Status, Due Date and Job Description are required too, but the form opens with them already set — Job Type on its first option, Workplace Type on Onsite, Status on Draft, Due Date three days from today and Job Description the placeholder `N/A`. You can change any of them; you cannot clear them. Genuinely optional are Job URL, Salary Range, the Applied switch, Date Applied, a resume and cover letter to attach, and skills. Salary Range is free text: pick one of the 10,000-wide suggestions from `Under 50,000` to `300,000+`, or type your own — `$120k – $150k`, `Negotiable` — and it is saved exactly as typed and shown on the job's details page.
+Job Type, Workplace Type, Status, Due Date and Job Description are required too, but the form opens with them already set — Job Type on its first option, Workplace Type on Onsite, Status on Draft, Due Date three days from today and Job Description the placeholder `N/A`. You can change any of them; you cannot clear them. Genuinely optional are Job URL, Salary Range, Date Applied, a resume and cover letter to attach, and skills. Salary Range is free text: pick one of the 10,000-wide suggestions from `Under 50,000` to `300,000+`, or type your own — `$120k – $150k`, `Negotiable` — and it is saved exactly as typed and shown on the job's details page.
Paste the full posting text into Job Description if you have it. The AI features — resume review, job match and cover letter generation — read that field, and a job saved with only a title and a salary gives them almost nothing to work from.
@@ -31,6 +31,13 @@ A job carries exactly one status from: **New**, **Draft**, **Applied**, **Interv
A job's status now follows its [timeline](./timeline.md): it is whatever the job's current stage means, so changing the status also records a stage, and moving which stage is current also moves the status.
+A job counts as applied — on the dashboard, in the Jobs list's applied filter and in the CSV export — once its status reaches **Applied**, **Interview**, **Offer**, **Offer Accepted** or **Offer Declined**, or once it has a Date Applied, whichever way you set it: a status menu, the Add or Edit Job form, a timeline stage or the MCP tools. It stays applied if the status later moves to Rejected, Withdrawn or anything else. Choosing **Applied** fills in today's Date Applied when the job has none; Interview and the Offer statuses leave the date for you, so an application you are logging late isn't counted as sent today. Until it has a date, such a job shows as *Applied* without one and is left out of the dashboard's dated counts and charts. An existing Date Applied is never overwritten. In the form, picking a Date Applied on a Draft or New job moves its status to Applied.
+
+To take back an application logged by mistake:
+
+1. On the job's **Timeline** tab, [delete](./timeline.md#how-do-i-delete-a-stage) every Applied, Interview or Offer stage. If one of them was the current stage, the status moves back to the stage before it, such as Draft.
+2. Open **Edit**, clear Date Applied (click the selected day again), check the status is one such as Draft and save.
+
## How do I change a job's status?
There are three ways. In the Jobs list, click a row's status badge and pick the new status from the menu, or use the row's **⋮** menu and choose **Change status**. Or open the job and use the **Update Status** button at the top-right of the job details, choosing **Change status**. Every one of these menus lists every status with the current one greyed out, and the change saves immediately — there is no separate save step.