import testimonialTwig from './paragraph.testimonial.twig';
import testimonialData from './paragraph.testimonial.yml';
import './paragraph.testimonial.js';

import linkTwig from '@ui-base/link/_link.twig';
import imgTwig from '@ui-base/img/_img.twig';

import { setPublishedStatus, formatParagraphCKEditor } from '.storybook/utils';

/**
 * Storybook Definition.
 */
export default {
  title: 'Layout Components/Testimonial',
};

export const testimonial = (args) => {
  // Create deep copy of data and merge args.
  let data = JSON.parse(JSON.stringify(testimonialData ?? {}));
  data = Object.assign(data, args);

  data.paragraph = setPublishedStatus(data.paragraph_is_published);

  return testimonialTwig({
    ...data,
    paragraph_field_body: formatParagraphCKEditor(data.paragraph_field_body),
    paragraph_field_link: linkTwig({ link_text: data.paragraph_field_link }),
    paragraph_field_erm_image: imgTwig({ image_src: data.paragraph_field_erm_image })
  });
}
testimonial.args = testimonialData;
