import { CollectionConfig } from "payload";

export const Schedules: CollectionConfig = {
  slug: 'schedules',
  admin: {
    group: 'User Data',
  },
  fields: [
    {
      name: 'user',
      type: 'relationship',
      relationTo: 'users',
      hasMany: false,
    },
    {
      name: 'scheduledItems',
      type: 'array',
      fields: [
        {
          name: 'item',
          type: 'relationship',
          relationTo: ['workouts', 'meals', 'habbits'],
          hasMany: false,
        },
        {
          name: 'dateTime',
          type: 'date',
          admin: {
            date: {
              pickerAppearance: 'dayAndTime'
            }
          }
        },
      ],
    },
  ],
}
