import type { Block } from 'payload';
import { lexicalEditor, InlineToolbarFeature, FixedToolbarFeature } from '@payloadcms/richtext-lexical';

const PricingBlock: Block = {
  slug: 'pricing',
  imageURL: '/admin/blocks/pricing.png',
  labels: {
    singular: 'Pricing Block',
    plural: 'Pricing Blocks',
  },
  fields: [
    {
      name: 'title',
      type: 'text',
      required: true,
    },
    {
      name: 'description',
      type: 'textarea',
    },
    {
      name: 'plans',
      type: 'array',
      fields: [
        {
          name: 'title',
          type: 'text',
          required: true,
        },
        {
          name: 'description',
          type: 'richText',
          editor: lexicalEditor({
            features: ({ defaultFeatures }) => [
              ...defaultFeatures,
              InlineToolbarFeature(),
            ],
          }),
        },
        {
          name: 'prices',
          type: 'array',
          fields: [
            {
              name: 'price',
              type: 'richText',
              editor: lexicalEditor({
                features: ({ defaultFeatures }) => [
                  ...defaultFeatures,
                  InlineToolbarFeature(),
                ],
              }),
            },
          ]
        },
        {
          name: 'properties',
          type: 'array',
          fields: [
            {
              name: 'title',
              type: 'text',
              required: true,
            },
            {
              name: 'description',
              type: 'richText',
              editor: lexicalEditor({
                features: ({ defaultFeatures }) => [
                  ...defaultFeatures,
                  InlineToolbarFeature(),
                ],
              }),
            },
          ]
        },


      ],
    },
    {
              name: 'tag',
              type: 'text',
            },
               {
              name: 'tag2',
              type: 'text',
            },
        {
          name: 'label',
          type: 'text',
          required: true,
        },
        {
          name: 'url',
          type: 'text',
          required: true,
        },
  ],
};

export default PricingBlock;