import { ObjectType, Field, ID, registerEnumType, Int, Float, GraphQLISODateTime } from '@nestjs/graphql';
import { ChildType } from './child.type';
import { UserType } from './user.type';
import GraphQLJSON from 'graphql-type-json';

export enum ActivityType {
  FEEDING = 'feeding',
  SLEEP = 'sleep',
  DIAPER = 'diaper',
  GROWTH = 'growth',
  MEDICATION = 'medication',
  MEDICINE = 'medicine',
  TEMPERATURE = 'temperature',
  MILESTONE = 'milestone',
  ACTIVITY = 'activity',
}

export enum FeedingMethod {
  BREAST = 'breast',
  BOTTLE = 'bottle',
  SOLIDS = 'solids',
}

export enum DiaperType {
  WET = 'wet',
  DIRTY = 'dirty',
  BOTH = 'both',
}

registerEnumType(ActivityType, { name: 'ActivityType' });
registerEnumType(FeedingMethod, { name: 'FeedingMethod' });
registerEnumType(DiaperType, { name: 'DiaperType' });

@ObjectType('Activity')
export class ActivityGQLType {
  @Field(() => ID)
  id: string;

  @Field()
  childId: string;

  @Field(() => ActivityType)
  type: ActivityType;

  @Field()
  startedAt: Date;

  @Field({ nullable: true })
  endedAt?: Date;

  @Field()
  loggedBy: string;

  @Field({ nullable: true })
  notes?: string;

  // Metadata as JSON object
  @Field(() => GraphQLJSON, { nullable: true })
  metadata?: any;

  // Relations
  @Field(() => ChildType, { nullable: true })
  child?: ChildType;

  @Field(() => UserType, { nullable: true })
  logger?: UserType;

  @Field()
  createdAt: Date;

  @Field()
  updatedAt: Date;
}
