import { CollectionConfig } from "payload";

export const ExerciseTypes: CollectionConfig = {
  slug: 'exerciseTypes',
  admin: {
    useAsTitle: 'name',
    group: 'Exercise',
  },
  fields: [
    {
      name: 'name',
      type: 'text',
      unique: true,
      admin: {
        description: 'Strength, Cardio, etc...',
      },
    },
    {
      name: 'description',
      type: 'textarea',
    },
  ],
}

export const MuscleGroups: CollectionConfig = {
  slug: 'muscleGroups',
  admin: {
    useAsTitle: 'name',
    group: 'Exercise',
  },
  fields: [
    {
      name: 'name',
      type: 'text',
      unique: true,
      admin: {
        description: 'Legs, Chest, or more specific...',
      },
    },
    {
      name: 'description',
      type: 'text',
    },
  ],
}

export const Equipments: CollectionConfig = {
  slug: 'equipments',
  admin: {
    useAsTitle: 'name',
    group: 'Exercise',
  },
  fields: [
    {
      name: 'name',
      type: 'text',
      unique: true,
    },
    {
      name: 'description',
      type: 'textarea',
    },
    {
      name: 'warning',
      type: 'textarea',
    },
  ],
}

export const Exercises: CollectionConfig = {
  slug: 'exercises',
  admin: {
    useAsTitle: 'name',
    group: 'Exercise',
  },
  fields: [
    {
      name: 'name',
      type: 'text',
      unique: true,
    },
    {
      name: 'type',
      type: 'relationship',
      relationTo: 'exerciseTypes',
      hasMany: true,
    },
    {
      name: 'muscleGroup',
      type: 'relationship',
      relationTo: 'muscleGroups',
      hasMany: true,
    },
    {
      name: 'equipmentNeeded',
      type: 'relationship',
      relationTo: 'equipments',
      hasMany: true,
    },
    {
      name: 'difficulty',
      type: 'number',
      max: 10,
    },
    {
      name: 'instructions',
      type: 'richText',
    },
    {
      name: 'displayImage',
      type: 'relationship',
      relationTo: 'media'
    },
  ],
}
