import { Document, Model, Schema, model } from "mongoose";

export type AppContentSection =
  | "privacy_policy"
  | "terms"
  | "about"
  | "help"
  | "social_links";

export interface IAppContent extends Document {
  section: AppContentSection;
  title: string;
  body: string;
  metadata: Record<string, unknown>;
}

const AppContentSchema = new Schema<IAppContent>(
  {
    section: {
      type: String,
      enum: ["privacy_policy", "terms", "about", "help", "social_links"],
      required: true,
      unique: true,
    },
    title: { type: String, default: "" },
    body: { type: String, required: true },
    metadata: { type: Schema.Types.Mixed, default: {} },
  },
  { timestamps: true }
);

const AppContentModel: Model<IAppContent> = model<IAppContent>(
  "AppContent",
  AppContentSchema
);

export default AppContentModel;
