import type { Block } from 'payload';

import {
  defaultLandingCtaContent,
  defaultLandingFaqContent,
  defaultLandingFeaturesContent,
  defaultLandingHeroContent,
  defaultLandingLogoCloudContent,
  defaultLandingPricingContent,
  defaultLandingStatsContent,
  defaultLandingTechStackContent,
  defaultLandingTestimonialsContent,
} from '../../components/landing/content';

export const landingPageBlocks: Block[] = [
  {
    slug: 'hero',
    labels: {
      singular: 'Hero Section',
      plural: 'Hero Sections',
    },
    fields: [
      {
        name: 'badgeEmoji',
        type: 'text',
        defaultValue: defaultLandingHeroContent.badgeEmoji,
      },
      {
        name: 'badgeText',
        type: 'text',
        defaultValue: defaultLandingHeroContent.badgeText,
      },
      {
        name: 'headingPrefix',
        type: 'text',
        defaultValue: defaultLandingHeroContent.headingPrefix,
      },
      {
        name: 'headingHighlight',
        type: 'text',
        defaultValue: defaultLandingHeroContent.headingHighlight,
      },
      {
        name: 'description',
        type: 'textarea',
        defaultValue: defaultLandingHeroContent.description,
      },
      {
        name: 'primaryCta',
        label: 'Primary CTA',
        type: 'group',
        fields: [
          {
            name: 'label',
            type: 'text',
            defaultValue: defaultLandingHeroContent.primaryCta.label,
          },
          {
            name: 'url',
            type: 'text',
            defaultValue: defaultLandingHeroContent.primaryCta.url,
          },
        ],
      },
      {
        name: 'highlights',
        type: 'array',
        defaultValue: defaultLandingHeroContent.highlights.map((label) => ({
          label,
        })),
        fields: [
          {
            name: 'label',
            type: 'text',
          },
        ],
      },
    ],
  },
  {
    slug: 'logoCloud',
    labels: {
      singular: 'Logo Cloud',
      plural: 'Logo Clouds',
    },
    fields: [
      {
        name: 'heading',
        type: 'text',
        defaultValue: defaultLandingLogoCloudContent.heading,
      },
      {
        name: 'items',
        type: 'array',
        defaultValue: defaultLandingLogoCloudContent.items,
        fields: [
          {
            name: 'name',
            type: 'text',
          },
          {
            name: 'accent',
            type: 'text',
          },
        ],
      },
    ],
  },
  {
    slug: 'features',
    labels: {
      singular: 'Features Section',
      plural: 'Features Sections',
    },
    fields: [
      {
        name: 'heading',
        type: 'text',
        defaultValue: defaultLandingFeaturesContent.heading,
      },
      {
        name: 'description',
        type: 'textarea',
        defaultValue: defaultLandingFeaturesContent.description,
      },
      {
        name: 'items',
        type: 'array',
        defaultValue: defaultLandingFeaturesContent.items,
        fields: [
          {
            name: 'icon',
            type: 'text',
          },
          {
            name: 'title',
            type: 'text',
          },
          {
            name: 'description',
            type: 'textarea',
          },
        ],
      },
    ],
  },
  {
    slug: 'stats',
    labels: {
      singular: 'Stats Section',
      plural: 'Stats Sections',
    },
    fields: [
      {
        name: 'heading',
        type: 'text',
        defaultValue: defaultLandingStatsContent.heading,
      },
      {
        name: 'description',
        type: 'textarea',
        defaultValue: defaultLandingStatsContent.description,
      },
      {
        name: 'items',
        type: 'array',
        defaultValue: defaultLandingStatsContent.items,
        fields: [
          {
            name: 'value',
            type: 'text',
          },
          {
            name: 'label',
            type: 'text',
          },
          {
            name: 'description',
            type: 'textarea',
          },
        ],
      },
    ],
  },
  {
    slug: 'techStack',
    labels: {
      singular: 'Tech Stack Section',
      plural: 'Tech Stack Sections',
    },
    fields: [
      {
        name: 'heading',
        type: 'text',
        defaultValue: defaultLandingTechStackContent.heading,
      },
      {
        name: 'description',
        type: 'textarea',
        defaultValue: defaultLandingTechStackContent.description,
      },
      {
        name: 'categories',
        type: 'array',
        defaultValue: defaultLandingTechStackContent.categories,
        fields: [
          {
            name: 'category',
            type: 'text',
          },
          {
            name: 'technologies',
            type: 'array',
            fields: [
              {
                name: 'name',
                type: 'text',
              },
              {
                name: 'description',
                type: 'text',
              },
            ],
          },
        ],
      },
    ],
  },
  {
    slug: 'testimonials',
    labels: {
      singular: 'Testimonials Section',
      plural: 'Testimonials Sections',
    },
    fields: [
      {
        name: 'heading',
        type: 'text',
        defaultValue: defaultLandingTestimonialsContent.heading,
      },
      {
        name: 'description',
        type: 'textarea',
        defaultValue: defaultLandingTestimonialsContent.description,
      },
      {
        name: 'items',
        type: 'array',
        defaultValue: defaultLandingTestimonialsContent.items,
        fields: [
          {
            name: 'quote',
            type: 'textarea',
          },
          {
            name: 'name',
            type: 'text',
          },
          {
            name: 'role',
            type: 'text',
          },
          {
            name: 'company',
            type: 'text',
          },
          {
            name: 'avatarEmoji',
            type: 'text',
          },
        ],
      },
    ],
  },
  {
    slug: 'pricing',
    labels: {
      singular: 'Pricing Section',
      plural: 'Pricing Sections',
    },
    fields: [
      {
        name: 'heading',
        type: 'text',
        defaultValue: defaultLandingPricingContent.heading,
      },
      {
        name: 'description',
        type: 'textarea',
        defaultValue: defaultLandingPricingContent.description,
      },
      {
        name: 'plans',
        type: 'array',
        defaultValue: defaultLandingPricingContent.plans.map((plan) => ({
          ...plan,
          features: plan.features.map((label) => ({ label })),
        })),
        fields: [
          {
            name: 'name',
            type: 'text',
          },
          {
            name: 'price',
            type: 'text',
          },
          {
            name: 'billingPeriod',
            type: 'text',
          },
          {
            name: 'description',
            type: 'textarea',
          },
          {
            name: 'badge',
            type: 'text',
          },
          {
            name: 'isHighlighted',
            type: 'checkbox',
          },
          {
            name: 'ctaLabel',
            type: 'text',
          },
          {
            name: 'ctaUrl',
            type: 'text',
          },
          {
            name: 'features',
            type: 'array',
            fields: [
              {
                name: 'label',
                type: 'text',
              },
            ],
          },
        ],
      },
    ],
  },
  {
    slug: 'faq',
    labels: {
      singular: 'FAQ Section',
      plural: 'FAQ Sections',
    },
    fields: [
      {
        name: 'heading',
        type: 'text',
        defaultValue: defaultLandingFaqContent.heading,
      },
      {
        name: 'description',
        type: 'textarea',
        defaultValue: defaultLandingFaqContent.description,
      },
      {
        name: 'items',
        type: 'array',
        defaultValue: defaultLandingFaqContent.items,
        fields: [
          {
            name: 'question',
            type: 'text',
          },
          {
            name: 'answer',
            type: 'textarea',
          },
        ],
      },
    ],
  },
  {
    slug: 'cta',
    labels: {
      singular: 'CTA Section',
      plural: 'CTA Sections',
    },
    fields: [
      {
        name: 'heading',
        type: 'text',
        defaultValue: defaultLandingCtaContent.heading,
      },
      {
        name: 'description',
        type: 'textarea',
        defaultValue: defaultLandingCtaContent.description,
      },
      {
        name: 'commandLabel',
        type: 'text',
        defaultValue: defaultLandingCtaContent.commandLabel,
      },
      {
        name: 'command',
        type: 'textarea',
        defaultValue: defaultLandingCtaContent.command,
      },
    ],
  },
];
