import mongoose, { Document, Schema } from 'mongoose';
import { SubscriptionPeriod } from './SubscriptionPeriod';

export interface IPlan extends Document {
    title: string;
    price: number;
    period: SubscriptionPeriod; // Normalized to lowercase for consistency
    features?: string[];
    createdAt: Date;
    updatedAt: Date;
}

const planSchema = new Schema<IPlan>({
    title: { type: String, required: true },
    price: { type: Number, required: true },
    period: { type: String, enum: Object.values(SubscriptionPeriod), required: true },
    features: [{ type: String }]
}, { timestamps: true });

export default mongoose.model<IPlan>('Plan', planSchema);
