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

type DescriptionItem = {
  description: string;
  price: string;
  remark: string;
};

@Schema({ timestamps: true })
export class Estimate {
  @Prop({
    type: [
      {
        description: String,
        price: String,
        remark: String,
      },
    ],
    default: [],
  })
  description: DescriptionItem[];

  @Prop({ type: [String], default: [] })
  notes: string[];

  @Prop({ type: [String], default: [] })
  remarks: string[];

  @Prop({ type: mongoose.Schema.Types.ObjectId, ref: 'quotations', unique:true })
  quotation_id: mongoose.Types.ObjectId;
}

export type EstimateDocument = Estimate & Document;

export const EstimateSchema = SchemaFactory.createForClass(Estimate);
