// Connections
import mongoConnection from "$connections/mongo/mongo.connection.js";

import mongoose from "mongoose";
const mongooseSchema = mongoose.Schema;

export const schemaModel = {
  user: {
    type: mongooseSchema.Types.ObjectId,
    ref: "User",
    unique: true,
    sparse: true,
  },
  firstName: {
    type: String,
    default: "",
  },
  lastName: {
    type: String,
    default: "",
  },
  fatherName: {
    type: String,
    default: "",
  },
  gender: {
    type: String,
    default: "",
  },
  birthDate: {
    type: Date,
    default: null,
  },
  placeOfBirth: {
    type: String,
    default: "",
  },
  placeOfIssue: {
    type: String,
    default: "",
  },
  seriShChar: {
    type: String,
    default: "",
  },
  seriSh: {
    type: String,
    default: "",
  },
  serial: {
    type: String,
    default: "",
  },
  shNumber: {
    type: String,
    default: "",
  },
  mobile: {
    type: String,
    default: "",
  },
  tradingCodes: {
    type: Array,
    default: [],
  },
  address: {
    province: {
      type: String,
      default: "",
    },
    city: {
      type: String,
      default: "",
    },
    postalCode: {
      type: String,
      default: "",
    },
    fullAddress: {
      type: String,
      default: "",
    },
    remnantAddress: {
      type: String,
      default: "",
    },
    alley: {
      type: String,
      default: "",
    },
    plaque: {
      type: String,
      default: "",
    },
  },
  bankAccount: {
    sheba: {
      type: String,
      default: "",
    },
    accountNumber: {
      type: String,
      default: "",
    },
    bankName: {
      type: String,
      default: "",
    },
    bankId: {
      type: Number,
      default: null,
    },
    isDefault: {
      type: Boolean,
      default: false,
    },
    lastModified: {
      type: Date,
      default: null,
    },
  },
};

export const schema = new mongooseSchema(schemaModel, { timestamps: true });

export default mongoConnection.model("userInfo", schema);
