forked from UKSOURCE/cms.hailearning.edu.vn
84 lines
2.0 KiB
JavaScript
84 lines
2.0 KiB
JavaScript
const mongoose = require("mongoose");
|
|
|
|
/**
|
|
* Schema for Appointment Submissions
|
|
* Stores appointment requests from users
|
|
*/
|
|
const appointmentSubmissionSchema = new mongoose.Schema(
|
|
{
|
|
name: {
|
|
type: String,
|
|
required: [true, "Name is required"],
|
|
trim: true,
|
|
maxlength: [100, "Name cannot exceed 100 characters"],
|
|
},
|
|
email: {
|
|
type: String,
|
|
required: [true, "Email is required"],
|
|
trim: true,
|
|
lowercase: true,
|
|
match: [/^\S+@\S+\.\S+$/, "Please enter a valid email"],
|
|
},
|
|
phone: {
|
|
type: String,
|
|
trim: true,
|
|
default: "",
|
|
},
|
|
address: {
|
|
type: String,
|
|
trim: true,
|
|
default: "",
|
|
},
|
|
appointmentDate: {
|
|
type: String,
|
|
trim: true,
|
|
default: "",
|
|
},
|
|
message: {
|
|
type: String,
|
|
trim: true,
|
|
default: "",
|
|
},
|
|
visaTypes: {
|
|
type: [String],
|
|
default: [],
|
|
},
|
|
status: {
|
|
type: String,
|
|
enum: ["pending", "confirmed", "completed", "cancelled"],
|
|
default: "pending",
|
|
},
|
|
notes: {
|
|
type: String,
|
|
trim: true,
|
|
default: "",
|
|
},
|
|
confirmedAt: {
|
|
type: Date,
|
|
default: null,
|
|
},
|
|
completedAt: {
|
|
type: Date,
|
|
default: null,
|
|
},
|
|
ipAddress: {
|
|
type: String,
|
|
default: "",
|
|
},
|
|
userAgent: {
|
|
type: String,
|
|
default: "",
|
|
},
|
|
},
|
|
{
|
|
timestamps: true,
|
|
}
|
|
);
|
|
|
|
// Index for faster queries
|
|
appointmentSubmissionSchema.index({ status: 1, createdAt: -1 });
|
|
appointmentSubmissionSchema.index({ email: 1 });
|
|
appointmentSubmissionSchema.index({ appointmentDate: 1 });
|
|
|
|
module.exports = mongoose.model("AppointmentSubmission", appointmentSubmissionSchema);
|