
import mongoose, { Schema, Document } from 'mongoose';

export interface IHSEIncidentDocument extends Document {
    date: Date;
    type: string;
    description: string;
    severity: 'Low' | 'Medium' | 'High' | 'Critical';
    status: 'Open' | 'Closed' | 'In Progress';
    mitigationAction: string;
    projectId: mongoose.Types.ObjectId;
}

const hseIncidentSchema = new Schema<IHSEIncidentDocument>(
    {
        date: { type: Date, required: true },
        type: { type: String, required: true },
        description: { type: String, required: true },
        severity: { type: String, enum: ['Low', 'Medium', 'High', 'Critical'], required: true },
        status: { type: String, enum: ['Open', 'Closed', 'In Progress'], default: 'Open' },
        mitigationAction: String,
        projectId: { type: Schema.Types.Mixed, ref: 'Project', required: true },
    },
    { timestamps: true }
);

export const HSEIncident = mongoose.model<IHSEIncidentDocument>('HSEIncident', hseIncidentSchema);

// ---

export interface IRiskAssessmentDocument extends Document {
    riskCategory: string;
    description: string;
    riskLevel: 'Low' | 'Medium' | 'High' | 'Extreme';
    mitigationStrategy: string;
}

const riskAssessmentSchema = new Schema<IRiskAssessmentDocument>(
    {
        riskCategory: { type: String, required: true },
        description: { type: String, required: true },
        riskLevel: { type: String, enum: ['Low', 'Medium', 'High', 'Extreme'], required: true },
        mitigationStrategy: { type: String, required: true },
    },
    { timestamps: true }
);

export const RiskAssessment = mongoose.model<IRiskAssessmentDocument>('RiskAssessment', riskAssessmentSchema);
