Download tasks/linkedin/solution/site/implementation/clone/components/Jobs.tsx from TIGER-Lab/WebsiteBench: direct link, hf CLI and curl.
- Browser
- Download file 10.3 kB
-
https://huggingface.co/datasets/TIGER-Lab/WebsiteBench/resolve/main/tasks/linkedin/solution/site/implementation/clone/components/Jobs.tsx
- Command line
-
hf download hf://datasets/TIGER-Lab/WebsiteBench/tasks/linkedin/solution/site/implementation/clone/components/Jobs.tsx
-
curl -L -o Jobs.tsx https://huggingface.co/datasets/TIGER-Lab/WebsiteBench/resolve/main/tasks/linkedin/solution/site/implementation/clone/components/Jobs.tsx
10.3 kB
| "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<string[]>([]); | |
| const [applied, setApplied] = useState<string[]>([]); | |
| const [openFilter, setOpenFilter] = useState<string | null>(null); | |
| const [applicationError, setApplicationError] = useState(""); | |
| const [jobActionError, setJobActionError] = useState(""); | |
| const [applicationJobId, setApplicationJobId] = useState<string | null>(null); | |
| const [coverNote, setCoverNote] = useState(""); | |
| const [resumeUrl, setResumeUrl] = useState(""); | |
| const [submittingApplication, setSubmittingApplication] = useState(false); | |
| const [savingJobId, setSavingJobId] = useState<string | null>(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<HTMLFormElement>) { | |
| 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 ( | |
| <div className="jobs-page"> | |
| <section className="job-search-bar"> | |
| <label><Search size={19} /><input value={query} onChange={(event) => setQuery(event.target.value)} placeholder="Title, skill, or company" /></label> | |
| <label><MapPin size={19} /><input value={location} onChange={(event) => setLocation(event.target.value)} placeholder="City, state, or remote" /></label> | |
| <button className="button button-primary">Search</button> | |
| </section> | |
| <div className="filter-row"> | |
| <button className="button button-outline" onClick={() => setOpenFilter(openFilter === "All filters" ? null : "All filters")}><SlidersHorizontal size={17} /> All filters</button> | |
| {["Date posted", "Experience level", "Company", "Remote"].map((filter) => ( | |
| <span className="job-filter-wrap" key={filter}> | |
| <button className={`filter-pill ${openFilter === filter ? "active" : ""}`} onClick={() => setOpenFilter(openFilter === filter ? null : filter)}>{filter}</button> | |
| {openFilter === filter && ( | |
| <div className="job-filter-menu"> | |
| <button>Past 24 hours</button><button>Past week</button><button>Entry level</button><button>Mid-Senior level</button><button>Northstar Systems</button> | |
| </div> | |
| )} | |
| </span> | |
| ))} | |
| {openFilter === "All filters" && <div className="job-filter-menu all"><b>All filters</b><button>Easy Apply</button><button>Remote</button><button>Under 10 applicants</button><button>In your network</button></div>} | |
| </div> | |
| <div className="jobs-layout"> | |
| <section className="surface job-results"> | |
| <header><div><h1>Top job picks for you</h1><p>{filtered.length} results based on your profile</p></div></header> | |
| {filtered.length ? filtered.map((job) => ( | |
| <Link prefetch={false} className={`job-listing ${selected.id === job.id ? "selected" : ""}`} href={`/jobs/${job.id}`} key={job.id}> | |
| <span className="company-logo">{job.company.logo}</span> | |
| <div><h2>{job.title}</h2><b>{job.company.name}</b><span>{job.location}</span><small>{job.salary} · {job.age}</small>{job.easyApply && <em>Easy Apply</em>}</div> | |
| <button className="icon-button" aria-label={`${saveLabel(job.id)} job`} disabled={savingJobId === job.id || saved.includes(job.id)} onClick={(event) => { event.preventDefault(); void saveJob(job.id); }}><Bookmark size={19} fill={saved.includes(job.id) ? "currentColor" : "none"} /></button> | |
| </Link> | |
| )) : <div className="empty-state"><Search size={34} /><h3>No jobs match those filters</h3><p>Try a broader title or remove the location.</p></div>} | |
| </section> | |
| <article className="surface job-detail"> | |
| <div className="job-detail-company"><span className="company-logo company-logo-lg">{selected.company.logo}</span><Link prefetch={false} href={`/companies/${selected.company.slug}`}>{selected.company.name}</Link></div> | |
| <h1>{selected.title}</h1> | |
| <p>{selected.location} · {selected.age} · 38 applicants</p> | |
| <div className="job-tags"><span><BriefcaseBusiness size={17} /> {selected.type}</span><span>{selected.salary}</span></div> | |
| <div className="job-cta"> | |
| <button className="button button-primary" disabled={applied.includes(selected.id)} onClick={() => openApplication(selected.id)}> | |
| {applied.includes(selected.id) ? <><CheckCircle2 size={18} /> Applied</> : "Easy Apply"} | |
| </button> | |
| <button className="button button-outline" disabled={savingJobId === selected.id || saved.includes(selected.id)} onClick={() => { void saveJob(selected.id); }}><Bookmark size={18} fill={saved.includes(selected.id) ? "currentColor" : "none"} /> {saveLabel(selected.id)}</button> | |
| </div> | |
| {jobActionError && <div className="form-error" role="alert">{jobActionError}</div>} | |
| {applicationError && <div className="form-error" role="alert">{applicationError}</div>} | |
| <hr /> | |
| <h2>About the job</h2> | |
| <p>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.</p> | |
| <h3>What you’ll do</h3> | |
| <ul><li>Frame complex customer problems and turn them into clear product direction.</li><li>Prototype, test, and ship polished experiences with cross-functional partners.</li><li>Strengthen the systems and rituals that help the team do its best work.</li></ul> | |
| <h3>What we’re looking for</h3> | |
| <p>Strong product judgment, excellent communication, and a portfolio showing thoughtful decisions across complex workflows.</p> | |
| </article> | |
| </div> | |
| {applicationJob && ( | |
| <div className="application-modal-backdrop" role="presentation"> | |
| <section className="application-modal" role="dialog" aria-labelledby="application-title" aria-modal="true"> | |
| <header> | |
| <span className="company-logo">{applicationJob.company.logo}</span> | |
| <div> | |
| <h2 id="application-title">Apply to {applicationJob.title}</h2> | |
| <p>{applicationJob.company.name} · {applicationJob.location}</p> | |
| </div> | |
| </header> | |
| <form onSubmit={submitApplication}> | |
| <label> | |
| Cover note | |
| <textarea value={coverNote} onChange={(event) => setCoverNote(event.target.value)} maxLength={2000} required /> | |
| </label> | |
| <label> | |
| Resume URL <span>Optional</span> | |
| <input value={resumeUrl} onChange={(event) => setResumeUrl(event.target.value)} placeholder="https://example.com/resume.pdf" type="url" /> | |
| </label> | |
| {applicationError && <div className="form-error" role="alert">{applicationError}</div>} | |
| <div className="application-modal-actions"> | |
| <button className="button button-quiet" type="button" onClick={() => setApplicationJobId(null)}>Cancel</button> | |
| <button className="button button-primary" disabled={submittingApplication} type="submit"> | |
| {submittingApplication ? "Submitting…" : "Submit application"} | |
| </button> | |
| </div> | |
| </form> | |
| </section> | |
| </div> | |
| )} | |
| </div> | |
| ); | |
| } | |