const mongoose = require("mongoose");
const Schema = mongoose.Schema;

const requestFormSchema = new Schema({
    userId: {
        type: Schema.Types.ObjectId,
        ref: "User",
        required: true
    },
    technicianId: {
        type: Schema.Types.ObjectId,
        ref: "User",
        required: true
    },
    serviceId:{
        type: Schema.Types.ObjectId,
        ref: "Service",
        required: true
    },
    propertyType: {
        type: String,
        enum: ["Residential", "Commercial", "Industrial"],
        required: true
    },
    residentailType:{
         type: String,
        enum: ["Single Family", "Multi Units"],
        required: false 
    },
    severity: {
        type: String,
        enum: ["High", "Low", "Medium"],
        required: true
    },
    date: {
        type: String,
        required: true
    },
    time: {
        type: String,
        required: true
    },
    address: {
        type: String,
        required: true
    },
    notes:{
        type: String
    },
    location: {
        type: {
            type: String,
            enum: ["Point"]
        },
        coordinates: {
            type: [Number]
        },
        locationName: {
            type: String
        }
    },
    longitude: {
        type: Number
    },
    latitude: {
        type: Number
    },
    locationName: {
        type: String
    },
    status: {
        type: String,
        enum: ["Pending", "Accepted", "On The Way", "Arrived", "Discussing", "Confirm", "Rejected" , "Paid"],
        default: "Pending"
    }
}, { timestamps: true });

const requestFormModel = mongoose.model("RequestForm", requestFormSchema);
module.exports = requestFormModel;