import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose";
import { Document, Types } from "mongoose";

export type TrainingCalloutDocument = TrainingCallout & Document;

@Schema({ timestamps: true })
export class TrainingCallout {
  @Prop({ type: Types.ObjectId, ref: "User" })
  created_by: Types.ObjectId | undefined;

  @Prop({ required: true, trim: true })
  title: string | undefined;

  @Prop({ default: "" })
  description: string | undefined;

  @Prop({ required: true, type: Date })
  training_date: Date | undefined;

  @Prop({ type: Types.ObjectId, ref: "TrainingHomeGym", required: true })
  gym_id: Types.ObjectId | undefined;

  @Prop({ default: 1 })
  max_participants!: number;

  @Prop({ default: "community", enum: ["community", "buddies"] })
  visible_to: string | undefined;

  @Prop({ type: [{ type: Types.ObjectId, ref: "User" }], default: [] })
  joined_users: Types.ObjectId[] | undefined;

  @Prop({ default: true })
  is_active: boolean | undefined;


  @Prop({})
  deleted_at: Date | null | undefined;
}

export const TrainingCalloutSchema =
  SchemaFactory.createForClass(TrainingCallout);
