Refactor JobHistory

This commit is contained in:
Dejvino 2023-05-25 15:33:18 +02:00
parent 2308c0394b
commit ecefefb757

View File

@ -5,7 +5,6 @@ import Col from 'react-bootstrap/Col';
import Row from 'react-bootstrap/Row'; import Row from 'react-bootstrap/Row';
import JobCard from './JobCard'; import JobCard from './JobCard';
import { usePersonContext } from './PersonContext'; import { usePersonContext } from './PersonContext';
import { Job } from '../../PersonalDataTypes';
import { partition } from '../utils'; import { partition } from '../utils';
const entriesPerRow = 2 const entriesPerRow = 2
@ -13,20 +12,13 @@ const entriesPerRow = 2
export default function JobsHistory() { export default function JobsHistory() {
const person = usePersonContext() const person = usePersonContext()
function JobEntry(job: Job, heading?: string) {
return <JobCard
heading={heading}
{...job}
/>
}
return ( return (
<Container> <Container>
<h2>Experience</h2> <h2>Experience</h2>
{person.jobs.current && ( {person.jobs.current && (
<Row> <Row>
<Col> <Col>
{JobEntry(person.jobs.current, 'Current position')} <JobCard heading={'Current position'} {...person.jobs.current} />
</Col> </Col>
</Row> </Row>
)} )}
@ -34,11 +26,11 @@ export default function JobsHistory() {
<Row key={index}> <Row key={index}>
{(jobs.map((job, subindex) => ( {(jobs.map((job, subindex) => (
<Col key={index + '_' + subindex}> <Col key={index + '_' + subindex}>
{JobEntry(job)} <JobCard {...job} />
</Col> </Col>
)))} )))}
</Row> </Row>
))} ))}
</Container> </Container>
) )
} }