import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { HydratedDocument, Types } from 'mongoose';

export enum CallingStatus {
    ACCEPT = 'ACCEPT', // when call pic by the user
    DECLINE = 'DECLINE', // when call not pic by the user
    NOT_ANSWERE = 'NOT_ANSWERE',  // when call cut at mid by the user
    END = 'END',  // when call cut at mid by the user
    PENDING = 'PENDING',  // when call cut at mid by the user
}

@Schema({
    timestamps: {
        createdAt: 'created_at',
        updatedAt: 'updated_at',
    },
})
export class CallJoinedMember {
    @Prop({ type: Types.ObjectId, default: null, ref: 'calls' })
    call_id: Types.ObjectId;

    @Prop({ type: Types.ObjectId, default: null, ref: 'users' })
    joined_by: Types.ObjectId;

    @Prop({ type: String, enum: CallingStatus, default: CallingStatus.PENDING })
    status: CallingStatus;

    @Prop({ type: Number, default: 0 })
    accepted_at: number; // or group_id

    @Prop({ type: Number, default: 0 })
    ended_at: number; // or group_id

    @Prop({ type: Number, default: 0 })
    declined_at: number; // or group_id

}

export type CallJoinedMemberDocument = HydratedDocument<CallJoinedMember>;
export const CallJoinedMemberSchema = SchemaFactory.createForClass(CallJoinedMember);
