feat: standardize admin form limits and guidance

This commit is contained in:
Tống Thành Đạt
2026-04-10 15:55:15 +07:00
parent 7ce5921fe0
commit 51c6303437
34 changed files with 1692 additions and 361 deletions

View File

@@ -7,28 +7,33 @@ const activitySchema = new mongoose.Schema(
titleActivities: {
type: String,
trim: true,
default: ''
default: "",
maxlength: 80,
},
titleBooking: {
type: String,
trim: true,
default: ''
default: "",
maxlength: 80,
},
bannerImageActivities: {
type: String,
trim: true,
default: ''
default: "",
maxlength: 255,
},
bannerImageBooking: {
type: String,
trim: true,
default: ''
default: "",
maxlength: 255,
},
},
name: {
type: String,
required: true,
trim: true,
maxlength: 120,
},
price: {
type: Number,
@@ -38,6 +43,7 @@ const activitySchema = new mongoose.Schema(
priceText: {
type: String,
trim: true,
maxlength: 32,
},
season: [
{
@@ -58,25 +64,28 @@ const activitySchema = new mongoose.Schema(
{
type: String,
trim: true,
maxlength: 80,
},
],
image: {
type: String,
trim: true,
maxlength: 255,
},
link: {
type: String,
trim: true,
maxlength: 255,
},
// Global filters document (single document in Activity collection)
filters: [
{
label: { type: String, required: true, trim: true },
value: { type: String, required: true, trim: true },
label: { type: String, required: true, trim: true, maxlength: 64 },
value: { type: String, required: true, trim: true, maxlength: 64 },
items: [
{
value: { type: String, required: true },
label: { type: String, required: true },
value: { type: String, required: true, maxlength: 64 },
label: { type: String, required: true, maxlength: 64 },
},
],
order: { type: Number, default: 0 },
@@ -85,6 +94,7 @@ const activitySchema = new mongoose.Schema(
program: {
type: String,
trim: true,
maxlength: 80,
},
rating: {
type: Number,
@@ -113,7 +123,7 @@ const activitySchema = new mongoose.Schema(
// Booking sessions - các đợt booking với thông số riêng
bookingSessions: [
{
sessionId: { type: String, required: true },
sessionId: { type: String, required: true, maxlength: 80 },
startDate: { type: Date, required: true },
endDate: { type: Date, required: true },
overnightStays: { type: Number, required: true, default: 14 },
@@ -127,11 +137,11 @@ const activitySchema = new mongoose.Schema(
// Danh sách booking cho session này
bookingList: [
{
address: { type: String, required: true },
address: { type: String, required: true, maxlength: 255 },
agreeNewsletter: { type: Boolean, default: false },
agreeTerms: { type: Boolean, required: true },
city: { type: String, required: true },
country: { type: String, required: true },
city: { type: String, required: true, maxlength: 80 },
country: { type: String, required: true, maxlength: 80 },
dietaryRestrictions: {
type: String,
enum: ['none', 'vegetarian', 'vegan', 'halal', 'kosher', 'gluten-free', 'other'],
@@ -141,26 +151,27 @@ const activitySchema = new mongoose.Schema(
type: String,
required: true,
lowercase: true,
trim: true
trim: true,
maxlength: 120
},
emergencyContact: { type: String, required: true },
emergencyPhone: { type: String, required: true },
medicalConditions: { type: String, default: '' },
emergencyContact: { type: String, required: true, maxlength: 80 },
emergencyPhone: { type: String, required: true, maxlength: 40 },
medicalConditions: { type: String, default: '', maxlength: 500 },
numberOfParticipants: { type: Number, required: true, min: 1 },
parentFirstName: { type: String, required: true, trim: true },
parentLastName: { type: String, required: true, trim: true },
parentFirstName: { type: String, required: true, trim: true, maxlength: 80 },
parentLastName: { type: String, required: true, trim: true, maxlength: 80 },
participantBirthDate: { type: Date, required: true },
participantFirstName: { type: String, required: true, trim: true },
participantFirstName: { type: String, required: true, trim: true, maxlength: 80 },
participantGender: {
type: String,
enum: ['male', 'female', 'other'],
required: true
},
participantLastName: { type: String, required: true, trim: true },
phone: { type: String, required: true },
postalCode: { type: String, required: true },
sessionDate: { type: String, required: true }, // sessionId reference
specialRequests: { type: String, default: '' },
participantLastName: { type: String, required: true, trim: true, maxlength: 80 },
phone: { type: String, required: true, maxlength: 40 },
postalCode: { type: String, required: true, maxlength: 20 },
sessionDate: { type: String, required: true, maxlength: 80 }, // sessionId reference
specialRequests: { type: String, default: '', maxlength: 500 },
// Thêm các trường quản lý
bookingStatus: {
type: String,
@@ -175,8 +186,8 @@ const activitySchema = new mongoose.Schema(
totalAmount: { type: Number, default: 0 },
paidAmount: { type: Number, default: 0 },
bookingDate: { type: Date, default: Date.now },
confirmationCode: { type: String, unique: true },
adminNotes: { type: String, default: '' }
confirmationCode: { type: String, unique: true, maxlength: 32 },
adminNotes: { type: String, default: '', maxlength: 1000 }
}
]
}