"use client"; import { useMemo, useState } from "react"; import Link from "next/link"; import { Bookmark, BriefcaseBusiness, CheckCircle2, MapPin, Search, SlidersHorizontal } from "lucide-react"; import { jobs } from "@/lib/demo-data"; export function JobsView({ selectedId }: { selectedId?: string }) { const [query, setQuery] = useState(""); const [location, setLocation] = useState(""); const [saved, setSaved] = useState([]); const [applied, setApplied] = useState([]); const [openFilter, setOpenFilter] = useState(null); const [applicationError, setApplicationError] = useState(""); const [jobActionError, setJobActionError] = useState(""); const [applicationJobId, setApplicationJobId] = useState(null); const [coverNote, setCoverNote] = useState(""); const [resumeUrl, setResumeUrl] = useState(""); const [submittingApplication, setSubmittingApplication] = useState(false); const [savingJobId, setSavingJobId] = useState(null); const filtered = useMemo(() => jobs.filter((job) => `${job.title} ${job.company.name}`.toLowerCase().includes(query.toLowerCase()) && job.location.toLowerCase().includes(location.toLowerCase()) ), [query, location]); const selected = jobs.find((job) => job.id === selectedId) ?? filtered[0] ?? jobs[0]; const applicationJob = jobs.find((job) => job.id === applicationJobId) ?? null; function openApplication(jobId: string) { setApplicationError(""); const job = jobs.find((item) => item.id === jobId); setCoverNote(job ? `I’m interested in the ${job.title} role at ${job.company.name}.` : ""); setResumeUrl(""); setApplicationJobId(jobId); } async function submitApplication(event: React.FormEvent) { event.preventDefault(); if (!applicationJob) return; setApplicationError(""); setSubmittingApplication(true); try { const payload = { action: "apply", jobId: applicationJob.id, coverNote: coverNote.trim(), ...(resumeUrl.trim() ? { resumeUrl: resumeUrl.trim() } : {}), }; const response = await fetch("/api/jobs", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(payload) }); const result = await response.json().catch(() => ({})) as { error?: string }; if (!response.ok) throw new Error(result.error ?? "Unable to submit this application."); setApplied((items) => items.includes(applicationJob.id) ? items : [...items, applicationJob.id]); setApplicationJobId(null); } catch (caught) { setApplicationError(caught instanceof Error ? caught.message : "Unable to submit this application."); } finally { setSubmittingApplication(false); } } async function saveJob(jobId: string) { if (saved.includes(jobId) || savingJobId) return; setSavingJobId(jobId); setJobActionError(""); try { const response = await fetch("/api/jobs", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ action: "save", jobId }) }); const result = await response.json().catch(() => ({})) as { savedJob?: { jobId?: string }, error?: string }; if (!response.ok || result.savedJob?.jobId !== jobId) throw new Error(result.error ?? "Unable to save this job."); setSaved((items) => items.includes(jobId) ? items : [...items, jobId]); } catch (caught) { setJobActionError(caught instanceof Error ? caught.message : "Unable to save this job."); } finally { setSavingJobId(null); } } function saveLabel(jobId: string) { if (savingJobId === jobId) return "Saving…"; return saved.includes(jobId) ? "Saved" : "Save"; } return (
{["Date posted", "Experience level", "Company", "Remote"].map((filter) => ( {openFilter === filter && (
)}
))} {openFilter === "All filters" &&
All filters
}

Top job picks for you

{filtered.length} results based on your profile

{filtered.length ? filtered.map((job) => ( {job.company.logo}

{job.title}

{job.company.name}{job.location}{job.salary} · {job.age}{job.easyApply && Easy Apply}
)) :

No jobs match those filters

Try a broader title or remove the location.

}
{selected.company.logo}{selected.company.name}

{selected.title}

{selected.location} · {selected.age} · 38 applicants

{selected.type}{selected.salary}
{jobActionError &&
{jobActionError}
} {applicationError &&
{applicationError}
}

About the job

Join a collaborative product group building dependable tools for teams that run critical operations. You will lead end-to-end product work, partner closely with engineering and research, and raise the quality of our shared design practice.

What you’ll do

  • Frame complex customer problems and turn them into clear product direction.
  • Prototype, test, and ship polished experiences with cross-functional partners.
  • Strengthen the systems and rituals that help the team do its best work.

What we’re looking for

Strong product judgment, excellent communication, and a portfolio showing thoughtful decisions across complex workflows.

{applicationJob && (
{applicationJob.company.logo}

Apply to {applicationJob.title}

{applicationJob.company.name} · {applicationJob.location}