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

export type NotificationDocument = Notification & Document;

@Schema({ collection: "notifications", timestamps: false })
export class Notification {
  @Prop({ required: true })
  declare userId: string;

  @Prop({ required: true })
  declare type: string; // "approval_request" | "approved" | "rejected"

  @Prop({ required: true })
  declare message: string;

  @Prop({ type: String, default: null })
  declare documentId: string | null;

  @Prop({ default: false })
  declare read: boolean;

  @Prop({ required: true })
  declare createdAt: string;
}

export const NotificationSchema = SchemaFactory.createForClass(Notification);
