// The existing Jobs URL vocabulary, shared by the separate Table and Board routes. // Pagination is Table-only; neither view may reinterpret the logical filters. export type JobSortKey = "dateApplied" | "company" | "jobTitle" | "status" | "daysSince" | "location"; export type ReadinessFilter = "all" | "needs-work" | "interview"; const sortKeys: JobSortKey[] = ["dateApplied", "company", "jobTitle", "status", "daysSince", "location"]; export function jobsQueryFromSearch(search: string) { const query = new URLSearchParams(search); const company = Number(query.get("companyId")); const readiness = query.get("readiness"); const sort = query.get("sortBy") as JobSortKey | null; return { q: query.get("q") ?? "", status: query.get("status") || "All", companyId: Number.isInteger(company) && company > 0 ? company : undefined, location: query.get("location") ?? "", needsFollowUp: query.get("needsFollowUp") === "1", readiness: readiness === "needs-work" || readiness === "interview" ? readiness as Exclude : undefined, includeDeleted: query.get("includeDeleted") === "1", sortBy: sort && sortKeys.includes(sort) ? sort : "dateApplied" as JobSortKey, sortDir: query.get("sortDir") === "asc" ? "asc" as const : "desc" as const, }; }