---
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 { TestimonialsSection } from '@/types/testimonials-section';
import removeLast from '@/utils/remove-last';

import Testimonial from './testimonial.astro';

export interface Props extends TestimonialsSection {}

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

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

<SectionCard section={section} title={title}>
  <DividedList>
    {removeLast(testimonials.flatMap((testimonial) => [<Testimonial testimonial={testimonial} />, <Divider />]))}
  </DividedList>
</SectionCard>
