import projectFullTwig from './node.project.full.twig';
import projectFullData from './node.project.full.yml';
import './node.project.full.js';
import './node.project.full--case-study.js';
import './node.project.full--portfolio.js';

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

import { statistic } from '@ui-paragraph/statistic/component/paragraph.statistic.stories.js';

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

/**
 * Storybook Definition.
 */
export default {
  title: 'Content Types/Project/Full',
};

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

  data.node = setPublishedStatus(data.node_is_published);

  return projectFullTwig({
    ...data,
    node_field_project_link: linkTwig({ link_text: 'Visit the site'}),
    node_field_ert_client: 'client',
    node_field_tldr: formatParagraphCKEditor(data.node_field_tldr),
    node_field_erm_page_image: imgTwig({ image_src: data.node_field_erm_page_image }),
    node_field_erp_statistic: statistic(),
    node_field_project_type: 'case-study',
  });
}
caseStudy.args = projectFullData;

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

  data.node = setPublishedStatus(data.node_is_published);

  return projectFullTwig({
    ...data,
    node_field_project_link: linkTwig({ link_text: 'Visit the site'}),
    node_field_ert_client: 'client',
    node_field_tldr: formatParagraphCKEditor(data.node_field_tldr),
    node_field_erm_page_image: imgTwig({ image_src: data.node_field_erm_page_image }),
    node_field_erp_statistic: statistic(),
    node_field_project_type: 'portfolio',
  });
}
portfolio.args = projectFullData;
