Fix: about feature

This commit is contained in:
2026-04-23 01:17:51 +07:00
parent 2094ada80f
commit 9c266f71f3
14 changed files with 504 additions and 419 deletions
+1 -18
View File
@@ -1,7 +1,5 @@
const mongoose = require("mongoose");
const { Schema } = mongoose;
// Hero
const HeroSchema = new Schema(
{
@@ -15,7 +13,6 @@ const HeroSchema = new Schema(
},
{ _id: false },
);
// Leadership
const SocialSchema = new Schema(
{
@@ -24,7 +21,6 @@ const SocialSchema = new Schema(
},
{ _id: false },
);
const LeadershipMemberSchema = new Schema(
{
name: { type: String, default: "" },
@@ -35,7 +31,6 @@ const LeadershipMemberSchema = new Schema(
},
{ _id: false },
);
const LeadershipSchema = new Schema(
{
heading: { type: String, default: "" },
@@ -44,7 +39,6 @@ const LeadershipSchema = new Schema(
},
{ _id: false },
);
// Learning Model
const LearningFeatureSchema = new Schema(
{
@@ -54,7 +48,6 @@ const LearningFeatureSchema = new Schema(
},
{ _id: false },
);
const LearningModeSchema = new Schema(
{
title: { type: String, default: "" },
@@ -63,7 +56,6 @@ const LearningModeSchema = new Schema(
},
{ _id: false },
);
const LearningModelSchema = new Schema(
{
heading: { type: String, default: "" },
@@ -73,7 +65,6 @@ const LearningModelSchema = new Schema(
},
{ _id: false },
);
// Accreditation
const AccreditationBadgeSchema = new Schema(
{
@@ -83,7 +74,6 @@ const AccreditationBadgeSchema = new Schema(
},
{ _id: false },
);
const AccreditationStatSchema = new Schema(
{
value: { type: String, default: "" },
@@ -92,7 +82,6 @@ const AccreditationStatSchema = new Schema(
},
{ _id: false },
);
const AccreditationSchema = new Schema(
{
heading: { type: String, default: "" },
@@ -102,7 +91,6 @@ const AccreditationSchema = new Schema(
},
{ _id: false },
);
// Success Stories
const StorySchema = new Schema(
{
@@ -113,7 +101,6 @@ const StorySchema = new Schema(
},
{ _id: false },
);
const SuccessStoriesSchema = new Schema(
{
heading: { type: String, default: "" },
@@ -122,7 +109,6 @@ const SuccessStoriesSchema = new Schema(
},
{ _id: false },
);
// CTA
const CtaButtonSchema = new Schema(
{
@@ -131,7 +117,6 @@ const CtaButtonSchema = new Schema(
},
{ _id: false },
);
const CtaSchema = new Schema(
{
heading: { type: String, default: "" },
@@ -141,7 +126,6 @@ const CtaSchema = new Schema(
},
{ _id: false },
);
// Root schema
const AboutSchema = new Schema(
{
@@ -157,5 +141,4 @@ const AboutSchema = new Schema(
strict: false,
},
);
module.exports = mongoose.model("About", AboutSchema);
module.exports = mongoose.model("About", AboutSchema);
-108
View File
@@ -1,108 +0,0 @@
const mongoose = require("mongoose");
const aboutUsSchema = new mongoose.Schema(
{
hero: {
title: String,
breadcrumb: [String],
backgroundImage: String,
},
intro: {
subheading: String,
heading: String,
description: String,
image: String,
},
mission: {
subheading: String,
heading: String,
description: String,
images: {
main: String,
secondary: String,
bgShape: String,
planeShape: String,
topShape: String,
globeShape: String,
},
items: [
new mongoose.Schema(
{
icon: String,
label: String,
description: String,
},
{ _id: false },
),
],
features: [String],
ctaButton: {
label: String,
href: String,
},
},
features: {
backgroundImage: String,
subheading: String,
heading: String,
description: String,
image: String,
items: [
new mongoose.Schema(
{
icon: String,
title: String,
description: String,
},
{ _id: false },
),
],
ctaButton: {
label: String,
href: String,
},
},
news: {
subheading: String,
heading: String,
ctaButton: {
label: String,
href: String,
},
selectedBlogIds: [{ type: mongoose.Schema.Types.ObjectId, ref: "Blog" }],
// Deprecated: items field kept for backward compatibility during migration
items: [
new mongoose.Schema(
{
title: String,
category: String,
date: String,
comments: Number,
author: {
name: String,
avatar: String,
},
link: String,
thumbnail: String,
},
{ _id: false },
),
],
},
},
{
timestamps: true,
collection: "aboutus",
},
);
// Static method để đảm bảo luôn chỉ có 1 bản ghi duy nhất (Singleton)
aboutUsSchema.statics.getSingle = async function () {
let doc = await this.findOne();
if (!doc) {
doc = await this.create({});
}
return doc;
};
module.exports = mongoose.model("AboutUs", aboutUsSchema);