---
import DividedList from '@/components/divided-list.astro';
import Divider from '@/components/divider.astro';
import SectionCard from '@/components/section-card.astro';
import type { SectionKey } from '@/types/data';
import type { ExperienceSection, Job } from '@/types/experience-section';
import type { I18n } from '@/types/i18n';
import removeLast from '@/utils/remove-last';

import WorkTimelineItem from './work-timeline-item.astro';

export interface Props extends ExperienceSection {
  jobs: Job[];
  i18n: I18n;
}

const {
  config: { title },
  i18n,
  jobs,
} = Astro.props;

const section: SectionKey = 'experience';
---

<SectionCard section={section} title={title}>
  <DividedList>
    {removeLast(jobs.flatMap((job) => [<WorkTimelineItem job={job} i18n={i18n} />, <Divider />]))}
  </DividedList>
</SectionCard>
