import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { ObjectType, Field, ID, Float } from '@nestjs/graphql';
import { Base } from '@/models/base.model';
import { Document, Types } from 'mongoose';

@ObjectType()
@Schema({ timestamps: true })
export class BuildArea extends Base {

    @Field(() => ID)
    readonly _id: string;

    @Field(() => Float)
    @Prop({ required: true })
    areaName: string;

    @Field(() => Float)
    @Prop({ required: true })
    areaCode: string;

    @Field()
    @Prop({ required: true })
    areaType: string;

    @Field()
    @Prop({ required: true })
    areaDirection: string;

    @Field()
    @Prop({ required: true })
    areaGrossSize: number;

    @Field()
    @Prop({ required: true })
    areaNetSize: number;

    @Field()
    @Prop({ required: true })
    width: number;

    @Field()
    @Prop({ required: true })
    size: number;

    @Field(() => ID, { nullable: true })
    @Prop({ type: Types.ObjectId, ref: 'Build', required: false })
    buildId?: Types.ObjectId;

    @Field(() => ID, { nullable: true })
    @Prop({ type: Types.ObjectId, ref: 'BuildType', required: false })
    partTypeId?: Types.ObjectId;

}

export type BuildAreaDocument = BuildArea & Document;
export const BuildAreaSchema = SchemaFactory.createForClass(BuildArea);
