import { ComponentConfig } from '@puckeditor/core';
import ImagePicker from '../fields/image-picker';
import ReviewSection, { ReviewProps } from '../sections/review-section';

export const ReviewBlock: ComponentConfig<{
  props: ReviewProps;
  fields: {
    userField: {
      type: 'userField';
      option: boolean;
    };
  };
}> = {
  label: 'Reviews',
  fields: {
    cards: {
      type: 'array',
      label: 'Review Cards',
      min: 1,
      getItemSummary: (item) => item.name || 'Review',
      arrayFields: {
        name: { type: 'text', label: 'Name' },
        title: { type: 'text', label: 'Title' },
        quote: { type: 'textarea', label: 'Quote' },
        image: {
          type: 'custom',
          label: 'Image',
          render: (props) => <ImagePicker {...props} />,
        },
      },
      defaultItemProps: {
        name: 'Amelia Joseph',
        title: 'Chief Manager',
        quote:
          'My vision came alive effortlessly. Their blend of casual and professional approach made the process a breeze. Creativity flowed, and the results were beyond my expectations.',
        image: '',
      },
    },
  },
  defaultProps: {
    cards: [
      {
        name: 'Amelia Joseph',
        title: 'Chief Manager',
        quote:
          'My vision came alive effortlessly. Their blend of casual and professional approach made the process a breeze. Creativity flowed, and the results were beyond my expectations.',
        image: '',
      },
      {
        name: 'Amelia Joseph',
        title: 'Chief Manager',
        quote:
          'My vision came alive effortlessly. Their blend of casual and professional approach made the process a breeze. Creativity flowed, and the results were beyond my expectations.',
        image: '',
      },
      {
        name: 'Amelia Joseph',
        title: 'Chief Manager',
        quote:
          'My vision came alive effortlessly. Their blend of casual and professional approach made the process a breeze. Creativity flowed, and the results were beyond my expectations.',
        image: '',
      },
      {
        name: 'Amelia Joseph',
        title: 'Chief Manager',
        quote:
          'My vision came alive effortlessly. Their blend of casual and professional approach made the process a breeze. Creativity flowed, and the results were beyond my expectations.',
        image: '',
      },
    ],
  },
  render: ReviewSection,
};
