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: Add workplaceType field and related functionality across job management features

Khuram Niaz7cf4eb5c37b1
diff --git a/__tests__/AddJob.spec.tsx b/__tests__/AddJob.spec.tsx
index 9a427be..6cdbd98 100644
--- a/__tests__/AddJob.spec.tsx
+++ b/__tests__/AddJob.spec.tsx
@@ -254,6 +254,7 @@ describe("AddJob Component", () => {
company: "2zz",
location: "1yy",
type: "FT",
+ workplaceType: "ONSITE",
source: "1359dac4-a397-4461-b747-382706dcbe79",
status: "d7ba200a-6dc1-4ea8-acff-29ebb0d4676a",
dueDate: expect.any(Date),
@@ -333,6 +334,26 @@ describe("AddJob Component - Edit Mode", () => {
expect(appliedSwitch).toBeChecked();
});
+ it("leaves workplace type unselected when editing a job with no workplaceType", async () => {
+ await renderEditMode();
+
+ await waitFor(() => {
+ expect(screen.getByTestId("add-job-dialog-title")).toHaveTextContent(
+ "Edit Job",
+ );
+ });
+
+ const workplaceRadios = screen
+ .getAllByRole("radio")
+ .filter((radio) =>
+ ["REMOTE", "HYBRID", "ONSITE"].includes(
+ radio.getAttribute("value") || "",
+ ),
+ );
+ expect(workplaceRadios).toHaveLength(3);
+ workplaceRadios.forEach((radio) => expect(radio).not.toBeChecked());
+ });
+
it("calls updateJob (not addJob) with the job id when saving an edited job", async () => {
await renderEditMode();
diff --git a/__tests__/createJobFromNames.spec.ts b/__tests__/createJobFromNames.spec.ts
index f705c6a..1f4a0aa 100644
--- a/__tests__/createJobFromNames.spec.ts
+++ b/__tests__/createJobFromNames.spec.ts
@@ -6,6 +6,7 @@ import {
resolveLocation,
resolveJobSource,
resolveJobType,
+ resolveWorkplaceType,
resolveJobStatus,
resolveTags,
} from "@/lib/jobs/resolve";
@@ -30,6 +31,7 @@ vi.mock("@/lib/jobs/resolve", () => ({
resolveLocation: vi.fn(),
resolveJobSource: vi.fn(),
resolveJobType: vi.fn(),
+ resolveWorkplaceType: vi.fn(),
resolveJobStatus: vi.fn(),
resolveTags: vi.fn(),
}));
@@ -50,6 +52,7 @@ describe("createJobFromNames", () => {
(resolveLocation as any).mockResolvedValue(null);
(resolveJobSource as any).mockResolvedValue(null);
(resolveJobType as any).mockReturnValue("Full-time");
+ (resolveWorkplaceType as any).mockReturnValue(null);
(resolveJobStatus as any).mockResolvedValue("status-1");
(resolveTags as any).mockResolvedValue({ resolved: [], dropped: [] });
(prisma.job.findFirst as any).mockResolvedValue(null);
diff --git a/__tests__/resolveWorkplaceType.spec.ts b/__tests__/resolveWorkplaceType.spec.ts
new file mode 100644
index 0000000..e4055a6
--- /dev/null
+++ b/__tests__/resolveWorkplaceType.spec.ts
@@ -0,0 +1,26 @@
+import { resolveWorkplaceType } from "@/lib/jobs/resolve";
+
+describe("resolveWorkplaceType", () => {
+ it("resolves a valid key", () => {
+ expect(resolveWorkplaceType("REMOTE")).toBe("REMOTE");
+ });
+
+ it("resolves a valid label", () => {
+ expect(resolveWorkplaceType("Hybrid")).toBe("HYBRID");
+ });
+
+ it("resolves case-insensitively", () => {
+ expect(resolveWorkplaceType("onsite")).toBe("ONSITE");
+ });
+
+ it("returns null for empty input", () => {
+ expect(resolveWorkplaceType(undefined)).toBeNull();
+ expect(resolveWorkplaceType("")).toBeNull();
+ });
+
+ it("throws a helpful message for an invalid value", () => {
+ expect(() => resolveWorkplaceType("Moon Base")).toThrow(
+ /Invalid workplaceType "Moon Base"\. Valid values: Remote, Hybrid, Onsite/,
+ );
+ });
+});
diff --git a/__tests__/scraper-mapper.spec.ts b/__tests__/scraper-mapper.spec.ts
index f9a9240..e5c96b1 100644
--- a/__tests__/scraper-mapper.spec.ts
+++ b/__tests__/scraper-mapper.spec.ts
@@ -1,4 +1,4 @@
-import { mapScrapedJobToJobRecord } from "@/lib/scraper/mapper";
+import { mapScrapedJobToJobRecord, normalizeWorkplaceType } from "@/lib/scraper/mapper";
import db from "@/lib/db";
import type { ScrapedJobData } from "@/models/automation.model";
@@ -59,6 +59,20 @@ beforeEach(() => {
mockedDb.jobStatus.findFirst.mockResolvedValue({ id: "status-1" } as never);
});
+describe("normalizeWorkplaceType", () => {
+ it("maps true to REMOTE", () => {
+ expect(normalizeWorkplaceType(true)).toBe("REMOTE");
+ });
+
+ it("maps false to null", () => {
+ expect(normalizeWorkplaceType(false)).toBeNull();
+ });
+
+ it("maps undefined to null", () => {
+ expect(normalizeWorkplaceType(undefined)).toBeNull();
+ });
+});
+
describe("mapScrapedJobToJobRecord - job title matching", () => {
it("does not reuse a title that only shares one unrelated keyword", async () => {
mockedDb.jobTitle.findFirst.mockResolvedValue(null);
diff --git a/e2e/add-job.spec.ts b/e2e/add-job.spec.ts
index 855920c..22bd1f6 100644
--- a/e2e/add-job.spec.ts
+++ b/e2e/add-job.spec.ts
@@ -276,6 +276,28 @@ test.describe("Add New Job", () => {
);
});
+ test("should persist selected workplace type after saving", async ({
+ page,
+ }, testInfo) => {
+ const jobText = `developer test title workplace ${testInfo.project.name}`;
+ jobIdToCleanup = await createNewJob(page, jobText, {
+ beforeSave: async (page) => {
+ await page.getByRole("radio", { name: "Remote" }).click();
+ },
+ });
+ await expect(
+ page.getByRole("row", { name: jobText }).first(),
+ ).toBeVisible();
+
+ await page
+ .getByRole("row", { name: jobText })
+ .getByTestId("job-actions-menu-btn")
+ .first()
+ .click();
+ await page.getByRole("menuitem", { name: "Edit Job" }).click();
+ await expect(page.getByRole("radio", { name: "Remote" })).toBeChecked();
+ });
+
test("should persist selected due date after saving", async ({
page,
}, testInfo) => {
diff --git a/prisma/migrations/20260707151433_add_workplace_type_to_job/migration.sql b/prisma/migrations/20260707151433_add_workplace_type_to_job/migration.sql
new file mode 100644
index 0000000..e0c343b
--- /dev/null
+++ b/prisma/migrations/20260707151433_add_workplace_type_to_job/migration.sql
@@ -0,0 +1,2 @@
+-- AlterTable
+ALTER TABLE "Job" ADD COLUMN "workplaceType" TEXT;
diff --git a/prisma/schema.prisma b/prisma/schema.prisma
index 892fb51..3758aa8 100644
--- a/prisma/schema.prisma
+++ b/prisma/schema.prisma
@@ -288,6 +288,7 @@ model Job {
jobUrl String?
description String
jobType String
+ workplaceType String?
createdAt DateTime
applied Boolean @default(false)
appliedDate DateTime?
diff --git a/src/actions/job.actions.ts b/src/actions/job.actions.ts
index 2e15380..f5c89e7 100644
--- a/src/actions/job.actions.ts
+++ b/src/actions/job.actions.ts
@@ -133,6 +133,7 @@ export const getJobsList = async (
JobSource: true,
JobTitle: true,
jobType: true,
+ workplaceType: true,
Company: true,
Status: true,
Location: true,
@@ -188,6 +189,7 @@ export async function* getJobsIterator(filter?: string, pageSize = 200) {
JobSource: true,
JobTitle: true,
jobType: true,
+ workplaceType: true,
Company: true,
Status: true,
Location: true,
@@ -335,6 +337,7 @@ export const addJob = async (
company,
location,
type,
+ workplaceType,
status,
source,
salaryRange,
@@ -359,6 +362,7 @@ export const addJob = async (
appliedDate: dateApplied,
description: jobDescription,
jobType: type,
+ workplaceType,
userId: user.id,
jobUrl,
applied,
@@ -393,6 +397,7 @@ export const updateJob = async (
company,
location,
type,
+ workplaceType,
status,
source,
salaryRange,
@@ -425,6 +430,7 @@ export const updateJob = async (
appliedDate: dateApplied,
description: jobDescription,
jobType: type,
+ workplaceType,
jobUrl,
applied,
resumeId: resume,
diff --git a/src/actions/mock.actions.ts b/src/actions/mock.actions.ts
index 96501b8..b5900d5 100644
--- a/src/actions/mock.actions.ts
+++ b/src/actions/mock.actions.ts
@@ -529,6 +529,7 @@ export const generateMockJobsAction = async (): Promise<any> => {
const statusMap = new Map(statuses.map((s) => [s.value, s.id]));
const totalJobs = getRandomInt(30, 40);
const now = new Date();
+ const mockWorkplaceTypes = ["REMOTE", "HYBRID", "ONSITE", null];
const jobsData = Array.from({ length: totalJobs }, () => {
const company = companies[getRandomInt(0, companies.length - 1)];
@@ -555,6 +556,8 @@ export const generateMockJobsAction = async (): Promise<any> => {
SALARY_RANGES[getRandomInt(0, SALARY_RANGES.length - 1)].id;
const dueDate = subDays(now, daysAgo - getRandomInt(7, 21));
const jobType = mockJobTypes[getRandomInt(0, mockJobTypes.length - 1)];
+ const workplaceType =
+ mockWorkplaceTypes[getRandomInt(0, mockWorkplaceTypes.length - 1)];
// ~80% of jobs link to a resume
const resume =
@@ -573,6 +576,7 @@ export const generateMockJobsAction = async (): Promise<any> => {
appliedDate,
description: `${description} ${MOCK_DATA_IDENTIFIER}`,
jobType,
+ workplaceType,
salaryRange,
dueDate,
jobSourceId: jobSource.id,
diff --git a/src/app/api/jobs/export/route.ts b/src/app/api/jobs/export/route.ts
index 1f0da79..a691b60 100644
--- a/src/app/api/jobs/export/route.ts
+++ b/src/app/api/jobs/export/route.ts
@@ -4,6 +4,7 @@ import { PassThrough } from "node:stream";
import { getJobsIterator } from "@/actions/job.actions";
import { format } from "date-fns";
import { auth } from "@/auth";
+import { getWorkplaceTypeLabel } from "@/models/job.model";
const FIELDS: string[] = [
"index",
@@ -13,6 +14,7 @@ const FIELDS: string[] = [
"Company",
"JobTitle",
"jobType",
+ "workplaceType",
"Location",
"JobSource",
"Status",
@@ -51,6 +53,7 @@ const transformJobData = (
Company: extractLabel(job.Company),
JobTitle: extractLabel(job.JobTitle),
jobType: mapJobType(job.jobType),
+ workplaceType: getWorkplaceTypeLabel(job.workplaceType),
Location: extractLabel(job.Location),
JobSource: extractLabel(job.JobSource),
Status: extractLabel(job.Status),
diff --git a/src/components/automations/DiscoveredJobDetail.tsx b/src/components/automations/DiscoveredJobDetail.tsx
index cf07246..ee72ddd 100644
--- a/src/components/automations/DiscoveredJobDetail.tsx
+++ b/src/components/automations/DiscoveredJobDetail.tsx
@@ -24,6 +24,7 @@ import {
} from "lucide-react";
import type { DiscoveredJob } from "@/models/automation.model";
import type { JobMatchData } from "@/models/ai.schemas";
+import { getWorkplaceTypeLabel } from "@/models/job.model";
import {
acceptDiscoveredJob,
dismissDiscoveredJob,
@@ -148,6 +149,11 @@ export function DiscoveredJobDetail({
<MapPin className="h-4 w-4" />
{job.Location?.label || "N/A"}
</span>
+ {job.workplaceType && (
+ <Badge variant="outline">
+ {getWorkplaceTypeLabel(job.workplaceType, job.workplaceType)}
+ </Badge>
+ )}
</DialogDescription>
</DialogHeader>
diff --git a/src/components/automations/DiscoveredJobsList.tsx b/src/components/automations/DiscoveredJobsList.tsx
index df26d6d..a537a97 100644
--- a/src/components/automations/DiscoveredJobsList.tsx
+++ b/src/components/automations/DiscoveredJobsList.tsx
@@ -5,6 +5,7 @@ import { format } from "date-fns";
import { APP_CONSTANTS, DISCOVERY_STATUSES } from "@/lib/constants";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { Button } from "@/components/ui/button";
+import { Badge } from "@/components/ui/badge";
import { StatusBadge } from "@/components/StatusBadge";
import { CircularScore } from "@/components/CircularScore";
import { getDiscoveryStatusBadgeColor } from "@/lib/badge-colors";
@@ -49,6 +50,7 @@ import {
Trash2,
} from "lucide-react";
import type { DiscoveredJob, DiscoveryStatus } from "@/models/automation.model";
+import { getWorkplaceTypeLabel } from "@/models/job.model";
import {
acceptDiscoveredJob,
dismissDiscoveredJob,
@@ -408,6 +410,11 @@ export function DiscoveredJobsList({
<div className="flex items-center gap-2">
<MapPin className="h-4 w-4 text-muted-foreground" />
{job.Location?.label || "N/A"}
+ {job.workplaceType && (
+ <Badge variant="outline" className="text-xs">
+ {getWorkplaceTypeLabel(job.workplaceType, job.workplaceType)}
+ </Badge>
+ )}
</div>
</TableCell>
<TableCell className="text-center">
diff --git a/src/components/myjobs/AddJob.tsx b/src/components/myjobs/AddJob.tsx
index fc07f56..eea139a 100644
--- a/src/components/myjobs/AddJob.tsx
+++ b/src/components/myjobs/AddJob.tsx
@@ -23,6 +23,7 @@ import {
JobStatus,
JobTitle,
Tag,
+ WORKPLACE_TYPES,
} from "@/models/job.model";
import { addDays } from "date-fns";
import { z } from "zod";
@@ -96,14 +97,17 @@ export function AddJob({
router.replace(newPath);
}
}, [dialogOpen, router, searchParams]);
+ const newJobDefaultValues = {
+ type: Object.keys(JOB_TYPES)[0],
+ workplaceType: "ONSITE",
+ dueDate: addDays(new Date(), 3),
+ status: jobStatuses[0]?.id,
+ salaryRange: "1",
+ };
+
const form = useForm<z.infer<typeof AddJobFormSchema>>({
resolver: zodResolver(AddJobFormSchema) as any,
- defaultValues: {
- type: Object.keys(JOB_TYPES)[0],
- dueDate: addDays(new Date(), 3),
- status: jobStatuses[0]?.id,
- salaryRange: "1",
- },
+ defaultValues: newJobDefaultValues,
});
const { setValue, reset, watch, resetField } = form;
@@ -134,28 +138,26 @@ export function AddJob({
useEffect(() => {
if (editJob) {
- reset(
- {
- id: editJob.id,
- userId: editJob.userId,
- title: editJob.JobTitle.id,
- company: editJob.Company.id,
- location: editJob.Location.id,
- type: editJob.jobType,
- source: editJob.JobSource.id,
- status: editJob.Status.id,
- dueDate: editJob.dueDate,
- salaryRange: editJob.salaryRange,
- jobDescription: editJob.description,
- applied: editJob.applied,
- jobUrl: editJob.jobUrl ?? undefined,
- dateApplied: editJob.appliedDate ?? undefined,
- resume: editJob.Resume?.id ?? undefined,
- coverLetter: editJob.CoverLetter?.id ?? undefined,
- tags: editJob.tags?.map((t) => t.id) ?? [],
- },
- { keepDefaultValues: true },
- );
+ reset({
+ id: editJob.id,
+ userId: editJob.userId,
+ title: editJob.JobTitle.id,
+ company: editJob.Company.id,
+ location: editJob.Location.id,
+ type: editJob.jobType,
+ workplaceType: editJob.workplaceType ?? undefined,
+ source: editJob.JobSource.id,
+ status: editJob.Status.id,
+ dueDate: editJob.dueDate,
+ salaryRange: editJob.salaryRange,
+ jobDescription: editJob.description,
+ applied: editJob.applied,
+ jobUrl: editJob.jobUrl ?? undefined,
+ dateApplied: editJob.appliedDate ?? undefined,
+ resume: editJob.Resume?.id ?? undefined,
+ coverLetter: editJob.CoverLetter?.id ?? undefined,
+ tags: editJob.tags?.map((t) => t.id) ?? [],
+ });
// Merge any tags from editJob into the local pool so they're selectable
if (editJob.tags && editJob.tags.length > 0) {
setAvailableTags((prev) => {
@@ -207,7 +209,7 @@ export function AddJob({
const pageTitle = editJob ? "Edit Job" : "Add Job";
const addJobForm = () => {
- reset();
+ reset(newJobDefaultValues);
resetEditJob();
setDialogOpen(true);
};
@@ -258,18 +260,19 @@ export function AddJob({
onSubmit={form.handleSubmit(onSubmit)}
className="grid grid-cols-1 md:grid-cols-2 gap-4 p-4"
>
- {/* Job URL */}
- <div className="md:col-span-2">
+ {/* Job Title */}
+ <div>
<FormField
control={form.control}
- name="jobUrl"
+ name="title"
render={({ field }) => (
<FormItem className="flex flex-col">
- <FormLabel>Job URL</FormLabel>
+ <FormLabel>Job Title</FormLabel>
<FormControl>
- <Input
- placeholder="Copy and paste job link here"
- {...field}
+ <Combobox
+ options={jobTitles}
+ field={field}
+ creatable
/>
</FormControl>
<FormMessage />
@@ -278,19 +281,18 @@ export function AddJob({
/>
</div>
- {/* Job Title */}
+ {/* Job URL */}
<div>
<FormField
control={form.control}
- name="title"
+ name="jobUrl"
render={({ field }) => (
<FormItem className="flex flex-col">
- <FormLabel>Job Title</FormLabel>
+ <FormLabel>Job URL</FormLabel>
<FormControl>
- <Combobox
- options={jobTitles}
- field={field}
- creatable
+ <Input
+ placeholder="Copy and paste job link here"
+ {...field}
/>
</FormControl>
<FormMessage />
@@ -371,6 +373,41 @@ export function AddJob({
)}
/>
</div>
+ {/* Workplace Type */}
+ <div>
+ <FormField
+ control={form.control}
+ name="workplaceType"
+ render={({ field }) => (
+ <FormItem className="flex flex-col">
+ <FormLabel className="mb-2">Workplace Type</FormLabel>
+ <RadioGroup
+ name="workplaceType"
+ onValueChange={field.onChange}
+ defaultValue={field.value}
+ className="flex space-y-1"
+ >
+ {Object.entries(WORKPLACE_TYPES).map(
+ ([key, value]) => (
+ <FormItem
+ key={key}
+ className="flex items-center space-x-3 space-y-0"
+ >
+ <FormControl>
+ <RadioGroupItem value={key} />
+ </FormControl>
+ <FormLabel className="font-normal">
+ {value}
+ </FormLabel>
+ </FormItem>
+ ),
+ )}
+ </RadioGroup>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+ </div>
{/* Job Source */}
<div>
<FormField
diff --git a/src/components/myjobs/JobDetails.tsx b/src/components/myjobs/JobDetails.tsx
index 87b103e..bd35446 100644
--- a/src/components/myjobs/JobDetails.tsx
+++ b/src/components/myjobs/JobDetails.tsx
@@ -12,6 +12,7 @@ import {
JobStatus,
JobTitle,
Tag,
+ getWorkplaceTypeLabel,
} from "@/models/job.model";
import { TipTapContentViewer } from "../TipTapContentViewer";
import {
@@ -164,6 +165,7 @@ function JobDetails({
return "Unknown";
}
};
+
return (
<>
<div className="flex justify-between">
@@ -248,6 +250,7 @@ function JobDetails({
<CardTitle>{job?.JobTitle?.label}</CardTitle>
<CardDescription>
{job?.Location?.label} - {getJobType(job?.jobType)}
+ {job?.workplaceType && ` · ${getWorkplaceTypeLabel(job.workplaceType)}`}
</CardDescription>
</div>
<div className="flex flex-col items-end gap-2">
diff --git a/src/lib/ai/tools/preprocessing-job.ts b/src/lib/ai/tools/preprocessing-job.ts
index 43680a0..13ba308 100644
--- a/src/lib/ai/tools/preprocessing-job.ts
+++ b/src/lib/ai/tools/preprocessing-job.ts
@@ -4,7 +4,7 @@
* Normalizes, validates, and extracts metadata from job descriptions
*/
-import { JobResponse } from "@/models/job.model";
+import { JobResponse, WORKPLACE_TYPES } from "@/models/job.model";
import {
removeHtmlTags,
normalizeWhitespace,
@@ -46,13 +46,19 @@ export const convertJobToText = (job: JobResponse): Promise<string> => {
JobTitle: { label: jobTitle },
Company: { label: companyName },
Location: { label: location },
+ workplaceType,
} = job;
+ const workplaceTypeLine =
+ workplaceType && workplaceType in WORKPLACE_TYPES
+ ? `Workplace Type: ${WORKPLACE_TYPES[workplaceType as keyof typeof WORKPLACE_TYPES]}\n`
+ : "";
+
const jobText = `
Job Title: ${jobTitle}
Company: ${companyName}
Location: ${location}
-Description: ${removeHtmlTags(description)}
+${workplaceTypeLine}Description: ${removeHtmlTags(description)}
`;
return resolve(jobText);
diff --git a/src/lib/jobs/createJobFromNames.ts b/src/lib/jobs/createJobFromNames.ts
index 752c032..fc33447 100644
--- a/src/lib/jobs/createJobFromNames.ts
+++ b/src/lib/jobs/createJobFromNames.ts
@@ -8,6 +8,7 @@ import {
resolveLocation,
resolveJobSource,
resolveJobType,
+ resolveWorkplaceType,
resolveJobStatus,
resolveTags,
type ResolvedEntity,
@@ -20,6 +21,7 @@ export interface CreateJobFromNamesInput {
location?: string;
source?: string;
jobType?: string;
+ workplaceType?: string;
status?: string;
dueDate?: Date | null;
applied?: boolean;
@@ -50,6 +52,7 @@ export async function createJobFromNames(
location,
source,
jobType,
+ workplaceType,
status,
dueDate = null,
applied = false,
@@ -61,6 +64,11 @@ export async function createJobFromNames(
createdVia,
} = input;
+ // Validate synchronously before starting any async resolution work, so an
+ // invalid jobType/workplaceType can't orphan already-started promises.
+ const jobTypeValue = resolveJobType(jobType);
+ const workplaceTypeValue = resolveWorkplaceType(workplaceType);
+
// Resolve Bucket A and B in parallel where possible
const [
resolvedCompany,
@@ -68,7 +76,6 @@ export async function createJobFromNames(
resolvedLocation,
resolvedSource,
resolvedTagsResult,
- jobTypeValue,
statusId,
] = await Promise.all([
resolveCompany(company, userId),
@@ -76,7 +83,6 @@ export async function createJobFromNames(
location ? resolveLocation(location, userId) : Promise.resolve(null),
source ? resolveJobSource(source, userId) : Promise.resolve(null),
resolveTags(tags, userId, APP_CONSTANTS.MAX_JOB_TAGS),
- Promise.resolve(resolveJobType(jobType)),
resolveJobStatus(status),
]);
@@ -120,6 +126,7 @@ export async function createJobFromNames(
appliedDate: resolvedAppliedDate,
description: jobDescription,
jobType: jobTypeValue,
+ workplaceType: workplaceTypeValue,
userId,
jobUrl: jobUrl ? normalizeJobUrl(jobUrl) : null,
applied,
diff --git a/src/lib/jobs/createJobRecord.ts b/src/lib/jobs/createJobRecord.ts
index b4ae93c..7096572 100644
--- a/src/lib/jobs/createJobRecord.ts
+++ b/src/lib/jobs/createJobRecord.ts
@@ -11,6 +11,7 @@ export async function createJobRecord(fields: {
appliedDate?: Date | null;
description: string;
jobType: string;
+ workplaceType?: string | null;
userId: string;
jobUrl?: string | null;
applied?: boolean;
diff --git a/src/lib/jobs/resolve.ts b/src/lib/jobs/resolve.ts
index cc2cdd3..6f40c0d 100644
--- a/src/lib/jobs/resolve.ts
+++ b/src/lib/jobs/resolve.ts
@@ -1,5 +1,5 @@
import prisma from "@/lib/db";
-import { JOB_TYPES } from "@/models/job.model";
+import { JOB_TYPES, WORKPLACE_TYPES } from "@/models/job.model";
export interface ResolvedEntity {
id: string;
@@ -134,6 +134,19 @@ export function resolveJobType(input?: string): string {
throw new Error(`Invalid jobType "${input}". Valid values: ${valid.join(", ")}`);
}
+export function resolveWorkplaceType(input?: string): string | null {
+ if (!input) return null;
+ const entries = Object.entries(WORKPLACE_TYPES) as [string, string][];
+ const match = entries.find(
+ ([key, value]) =>
+ key.toLowerCase() === input.toLowerCase() ||
+ value.toLowerCase() === input.toLowerCase(),
+ );
+ if (match) return match[0];
+ const valid = entries.map(([, value]) => value);
+ throw new Error(`Invalid workplaceType "${input}". Valid values: ${valid.join(", ")}`);
+}
+
export async function resolveJobStatus(value?: string): Promise<string> {
const target = (value ?? "draft").toLowerCase();
const status = await prisma.jobStatus.findUnique({ where: { value: target } });
diff --git a/src/lib/scraper/jsearch/index.ts b/src/lib/scraper/jsearch/index.ts
index 2e7cab8..ec3de23 100644
--- a/src/lib/scraper/jsearch/index.ts
+++ b/src/lib/scraper/jsearch/index.ts
@@ -191,6 +191,7 @@ export async function searchJSearchJobs(
postedDate: job.job_posted_at_datetime_utc,
salary: formatSalary(job),
employmentType: job.job_employment_type,
+ isRemote: job.job_is_remote,
}));
return { success: true, data: jobs };
diff --git a/src/lib/scraper/mapper.ts b/src/lib/scraper/mapper.ts
index 81782f6..583720e 100644
--- a/src/lib/scraper/mapper.ts
+++ b/src/lib/scraper/mapper.ts
@@ -21,6 +21,10 @@ function normalizeJobType(employmentType?: string): string {
return JOB_TYPE_ALIASES[key] ?? "FT";
}
+export function normalizeWorkplaceType(isRemote?: boolean): string | null {
+ return isRemote ? "REMOTE" : null;
+}
+
interface MapperInput {
scrapedJob: ScrapedJobData;
userId: string;
@@ -35,6 +39,7 @@ interface MapperOutput {
jobUrl: string;
description: string;
jobType: string;
+ workplaceType: string | null;
createdAt: Date;
applied: boolean;
statusId: string;
@@ -65,6 +70,7 @@ export async function mapScrapedJobToJobRecord(
jobUrl: scrapedJob.sourceUrl,
description: scrapedJob.description,
jobType: normalizeJobType(scrapedJob.employmentType),
+ workplaceType: normalizeWorkplaceType(scrapedJob.isRemote),
createdAt: new Date(),
applied: false,
statusId,
diff --git a/src/lib/scraper/runner.ts b/src/lib/scraper/runner.ts
index c1d409b..781ab2c 100644
--- a/src/lib/scraper/runner.ts
+++ b/src/lib/scraper/runner.ts
@@ -487,6 +487,7 @@ export async function runAutomation(
sourceUrl: normalizeJobUrl(job.url),
sourceBoard: automation.jobBoard as JobBoard,
employmentType: job.employmentType,
+ isRemote: job.isRemote,
};
const jobRecord = await mapScrapedJobToJobRecord({
@@ -705,6 +706,7 @@ async function persistDiscoveredJob(
sourceUrl: normalizeJobUrl(job.url),
sourceBoard: automation.jobBoard,
employmentType: job.employmentType,
+ isRemote: job.isRemote,
};
const jobRecord = await mapScrapedJobToJobRecord({
diff --git a/src/lib/scraper/types.ts b/src/lib/scraper/types.ts
index 81a07f1..4b9f2fe 100644
--- a/src/lib/scraper/types.ts
+++ b/src/lib/scraper/types.ts
@@ -15,6 +15,7 @@ export interface JobDetails {
postedDate?: string;
salary?: string;
employmentType?: string;
+ isRemote?: boolean;
}
export type ScraperError =
diff --git a/src/models/addJobForm.schema.ts b/src/models/addJobForm.schema.ts
index adaa7bc..89535fb 100644
--- a/src/models/addJobForm.schema.ts
+++ b/src/models/addJobForm.schema.ts
@@ -26,6 +26,7 @@ export const AddJobFormSchema = z.object({
message: "Location name must be at least 2 characters.",
}),
type: z.string().min(1),
+ workplaceType: z.string().optional(),
source: z
.string({
error: "Source is required.",
diff --git a/src/models/automation.model.ts b/src/models/automation.model.ts
index 3dd0359..472f6c9 100644
--- a/src/models/automation.model.ts
+++ b/src/models/automation.model.ts
@@ -90,6 +90,7 @@ export interface DiscoveredJob {
jobUrl: string | null;
description: string;
jobType: string;
+ workplaceType?: string | null;
createdAt: Date;
jobTitleId: string;
companyId: string;
@@ -111,4 +112,5 @@ export interface ScrapedJobData {
sourceUrl: string;
sourceBoard: JobBoard;
employmentType?: string;
+ isRemote?: boolean;
}
diff --git a/src/models/job.model.ts b/src/models/job.model.ts
index 6260d8e..279f0b3 100644
--- a/src/models/job.model.ts
+++ b/src/models/job.model.ts
@@ -15,6 +15,7 @@ export interface JobForm {
jobDescription: string;
jobUrl?: string;
applied: boolean;
+ workplaceType?: string | null;
}
export interface Tag {
@@ -38,6 +39,7 @@ export interface JobResponse {
Location: JobLocation;
JobSource: JobSource;
jobType: string;
+ workplaceType?: string | null;
createdAt: Date;
appliedDate: Date;
dueDate: Date;
@@ -118,3 +120,17 @@ export enum JOB_TYPES {
PT = "Part-time",
C = "Contract",
}
+
+export enum WORKPLACE_TYPES {
+ REMOTE = "Remote",
+ HYBRID = "Hybrid",
+ ONSITE = "Onsite",
+}
+
+export function getWorkplaceTypeLabel(
+ code?: string | null,
+ fallback: string = "Not specified",
+): string {
+ if (!code) return fallback;
+ return (WORKPLACE_TYPES as Record<string, string>)[code] ?? fallback;
+}
diff --git a/src/models/mcp.schema.ts b/src/models/mcp.schema.ts
index 0aef51b..b61952d 100644
--- a/src/models/mcp.schema.ts
+++ b/src/models/mcp.schema.ts
@@ -9,6 +9,7 @@ export const McpAddJobInputShape = {
location: z.string().optional().describe("City, province/state, country, or 'Remote'"),
source: z.string().optional().describe("Job board or site the listing came from, e.g. 'LinkedIn', 'Indeed', 'company website'"),
jobType: z.string().optional().describe("Employment type: 'Full-time', 'Part-time', or 'Contract'"),
+ workplaceType: z.string().optional().describe("Work arrangement: 'Remote', 'Hybrid', or 'Onsite'"),
status: z.string().optional().describe("Application status: draft, applied, interview, offer, rejected, expired, or archived. Defaults to 'draft'"),
dueDate: z.string().datetime({ offset: true }).optional().describe("Application deadline as an ISO-8601 datetime string"),
applied: z.boolean().optional().describe("Set true if you have already submitted the application"),