import mongoose, { Model } from 'mongoose';

import { MODEL_NAMES } from './_models';

export interface IUserMobileAccess {
  _id?: mongoose.Types.ObjectId;
  userId?: string;
  hasAccess: boolean;
  canSignDocument: boolean;
}

type UserMobileAccessModel = Model<IUserMobileAccess, {}, {}>;

export const UserMobileAccessSchema = new mongoose.Schema<IUserMobileAccess, UserMobileAccessModel>(
  {
    userId: {
      type: String,
      trim: true,
      required: true,
    },
    hasAccess: {
      type: Boolean,
      default: false,
    },
    canSignDocument: {
      type: Boolean,
      default: false,
    },
  },
  {
    timestamps: { createdAt: true, updatedAt: false },
  },
);

export const UserMobileAccess = mongoose.model<IUserMobileAccess, UserMobileAccessModel>(MODEL_NAMES.userMobileAccess, UserMobileAccessSchema);
