Overview
TheJobCard component displays a single job listing with all relevant information and actions. It includes an “Apply” button with state management and a link to view detailed job information.
Usage
Props
The job object containing all job information
Features
Apply Button State Management
The component manages its own “applied” state using React’suseState hook:
Data Attributes
The card uses data attributes for filtering and styling purposes:Navigation
Includes two navigation options:- Clickable job title that links to the full job details
- “Ver detalles” (View details) link button
/jobs/{job.id}.
Component Structure
Styling
The component uses CSS modules (jobCard.module.css) for scoped styling:
styles.info- Container for job informationstyles.title- Job title link stylingstyles.actions- Container for action buttonsstyles.details- “Ver detalles” link styling
job-listing-card- Main card containerbutton-apply-job- Apply button base stylingis-applied- Applied state modifier
State Management
Local State
The component maintains its ownisApplied state, which persists only during the component’s lifetime. The state is reset if:
- The component unmounts
- The page is refreshed
- The user navigates away and back
Persistent State
For production applications, you might want to persist the applied state:Source Code
Location:src/components/JobCard/JobCard.jsx:5
Related Components
JobListings
Container component that renders multiple JobCards
Loading
Skeleton loading state for JobCards
Best Practices
- Always provide a key - When rendering multiple JobCards, use the
job.idas the React key - Complete job data - Ensure all required job properties are present to avoid errors
- Consistent structure - Maintain the expected job object structure across your application
- Handle missing data - Consider adding fallbacks for optional fields
Accessibility
- Uses semantic
<article>element for each job listing - Proper heading hierarchy with
<h3>for job titles - Descriptive link text (“Ver detalles”)
- Button state changes are visually indicated
- Data attributes support custom filtering interfaces