From ae468e7f26e2e4c6d316a42ef425bfeb479e28b5 Mon Sep 17 00:00:00 2001 From: r2xrzh9q2z-lab Date: Thu, 5 Feb 2026 12:49:59 +0700 Subject: [PATCH 1/3] fea Visa-VisaDetail --- controllers/visaController.js | 76 +- routes/admin.js | 359 +++++- views/admin/dashboard.ejs | 19 + views/admin/visa/index.ejs | 2128 +++++++++++++++------------------ views/layouts/admin.ejs | 3 + views/layouts/main.ejs | 4 + 6 files changed, 1319 insertions(+), 1270 deletions(-) diff --git a/controllers/visaController.js b/controllers/visaController.js index 47137bc..7a2ae6a 100644 --- a/controllers/visaController.js +++ b/controllers/visaController.js @@ -47,9 +47,9 @@ const Visa = require("../models/visa"); const slugify = require("slugify"); const createSlug = (text) => { return slugify(text, { - lower: true, // Chuyển về chữ thường - strict: true, // Loại bỏ ký tự đặc biệt - locale: "vi", // Xử lý tiếng Việt chuẩn + lower: true, + strict: true, + locale: "en", trim: true, }); }; @@ -57,7 +57,7 @@ const createSlug = (text) => { // Get visa data from MongoDB const getVisaData = async () => { - const visa = await Visa.findOne().sort({ updatedAt: -1 }).lean(); + const visa = await Visa.findOne().sort({ updatedAt: -1 }); return visa || {}; }; @@ -324,11 +324,11 @@ exports.updateCountry = async (req, res) => { const { id } = req.params; let visaData = await getVisaData(); - // if (!visaData || !visaData.hero || !visaData.hero.summaryList) { - // return res - // .status(400) - // .json({ error: "Cấu trúc dữ liệu Visa không hợp lệ" }); - // } + if (!visaData || !visaData.hero || !visaData.hero.summaryList) { + return res + .status(400) + .json({ error: "Cấu trúc dữ liệu Visa không hợp lệ" }); + } // 2. Tìm index theo ID (Chuyển về Number để so sánh chính xác) const countryIndex = visaData.hero.summaryList.findIndex( @@ -413,43 +413,51 @@ exports.updateCountry = async (req, res) => { // Delete country exports.deleteCountry = async (req, res) => { try { - const { slug } = req.params; + // 1. Lấy id từ params + const { id } = req.params; let visaData = await getVisaData(); - if (!visaData.hero || !visaData.hero.summaryList) { - return res.status(400).json({ error: "Invalid visa data structure" }); + if (!visaData || !visaData.hero || !visaData.hero.summaryList) { + return res + .status(400) + .json({ success: false, error: "Cấu trúc dữ liệu Visa không hợp lệ" }); } + // 2. Tìm index theo ID (Chuyển về Number để so sánh chính xác) const countryIndex = visaData.hero.summaryList.findIndex( - (c) => c.slug === slug, + (c) => c.id === parseInt(id), ); if (countryIndex === -1) { - return res.status(404).json({ error: `Country "${slug}" not found` }); + return res.status(404).json({ + success: false, + error: `Không tìm thấy quốc gia có ID: ${id}`, + }); } + // 3. Xóa phần tử khỏi mảng const deletedCountry = visaData.hero.summaryList[countryIndex]; visaData.hero.summaryList.splice(countryIndex, 1); - // Update database - const updatedData = { - ...(visaData.toObject ? visaData.toObject() : visaData), - }; - - if (visaData._id) { - await Visa.findByIdAndUpdate(visaData._id, updatedData, { new: true }); - } else { - await Visa.create(updatedData); + // 4. Cập nhật vào Database + if (visaData.markModified) { + visaData.markModified("hero.summaryList"); } - console.log(`✅ Country "${deletedCountry.name}" deleted successfully`); - res.json({ + if (visaData._id) { + await visaData.save(); + } else { + await Visa.create(visaData); + } + + console.log(`✅ Deleted Successfully: "${deletedCountry.name}"`); + return res.json({ success: true, - message: `Country "${deletedCountry.name}" deleted successfully`, + message: `Country "${deletedCountry.name}" Deleted Successfully`, }); } catch (err) { - console.error("Delete country error:", err); - res.status(500).json({ error: err.message }); + console.error("❌ Error Delete:", err); + return res.status(500).json({ success: false, error: err.message }); } }; @@ -469,9 +477,7 @@ exports.api = async (req, res) => { const heroData = visaData?.hero; // 2. Lấy riêng phần hero (Dùng biến mới, không gán đè vào const) - const baseUrl = - process.env.BACKEND_URL || `${req.protocol}://${req.get("host")}`; - const processedData = addBaseUrlToImages(heroData, baseUrl); + const processedData = heroData; return res.json({ success: true, @@ -552,20 +558,16 @@ exports.apiCountry = async (req, res) => { data: null, }); } - - const baseUrl = - process.env.BACKEND_URL || `${req.protocol}://${req.get("host")}`; - // 3. Chỉ lấy phần chi tiết (detailed view) // Lưu ý: Chúng ta copy ra object mới để tránh tham chiếu dữ liệu gốc const detailedData = JSON.parse(JSON.stringify(country.viewDetail)); // 4. Gắn baseUrl vào các ảnh nằm trong phần chi tiết này - const processedData = addBaseUrlToImages(detailedData, baseUrl); + const processedData = detailedData; return res.json({ success: true, - data: processedData, // Trả về nội dung của detailedView + data: processedData, }); } catch (err) { console.error("Visa country API error:", err); diff --git a/routes/admin.js b/routes/admin.js index 829abaf..d292f3f 100644 --- a/routes/admin.js +++ b/routes/admin.js @@ -40,8 +40,8 @@ router.post("/home/update", ensureAuthenticated, homeController.update); // Middleware chuẩn hóa code router.param("code", (req, res, next, code) => { - req.params.code = code.toUpperCase(); - next(); + req.params.code = code.toUpperCase(); + next(); }); // About @@ -50,51 +50,125 @@ router.post("/about/update", ensureAuthenticated, aboutController.update); // AboutUs admin CRUD router.get("/about-us", ensureAuthenticated, aboutUsController.index); -router.get("/about-us/create", ensureAuthenticated, aboutUsController.createForm); +router.get( + "/about-us/create", + ensureAuthenticated, + aboutUsController.createForm, +); router.post("/about-us/create", ensureAuthenticated, aboutUsController.create); -router.get("/about-us/:id/edit", ensureAuthenticated, aboutUsController.editForm); -router.post("/about-us/:id/update", ensureAuthenticated, aboutUsController.update); -router.post("/about-us/:id/delete", ensureAuthenticated, aboutUsController.delete); -router.get("/about-us/:id/preview", ensureAuthenticated, aboutUsController.preview); +router.get( + "/about-us/:id/edit", + ensureAuthenticated, + aboutUsController.editForm, +); +router.post( + "/about-us/:id/update", + ensureAuthenticated, + aboutUsController.update, +); +router.post( + "/about-us/:id/delete", + ensureAuthenticated, + aboutUsController.delete, +); +router.get( + "/about-us/:id/preview", + ensureAuthenticated, + aboutUsController.preview, +); // Booking admin CRUD removed // Form Management router.get("/form", ensureAuthenticated, formController.index); -router.post("/form/update", ensureAuthenticated, formController.updateDefaultForm); +router.post( + "/form/update", + ensureAuthenticated, + formController.updateDefaultForm, +); // Upload routes router.get("/upload", ensureAuthenticated, (req, res) => { - res.render("admin/upload/index", { - layout: "layouts/admin", - title: "Quản lý Upload Ảnh", - user: req.session.user, - }); + res.render("admin/upload/index", { + layout: "layouts/admin", + title: "Quản lý Upload Ảnh", + user: req.session.user, + }); }); -router.post("/upload/image", ensureAuthenticated, upload.single("image"), uploadController.uploadImage); -router.post("/upload/video", ensureAuthenticated, uploadVideo.single("video"), uploadController.uploadVideo); -router.post("/upload/update-path", ensureAuthenticated, uploadController.updateImagePath); -router.post("/upload/delete", ensureAuthenticated, uploadController.deleteImage); +router.post( + "/upload/image", + ensureAuthenticated, + upload.single("image"), + uploadController.uploadImage, +); +router.post( + "/upload/video", + ensureAuthenticated, + uploadVideo.single("video"), + uploadController.uploadVideo, +); +router.post( + "/upload/update-path", + ensureAuthenticated, + uploadController.updateImagePath, +); +router.post( + "/upload/delete", + ensureAuthenticated, + uploadController.deleteImage, +); // Header routes router.get("/header", ensureAuthenticated, headerController.index); router.post("/header/update", ensureAuthenticated, headerController.update); router.get("/header/data", ensureAuthenticated, headerController.api); // Normalized from getHeaderData -router.patch("/header/:id/status", ensureAuthenticated, headerController.updateStatus); +router.patch( + "/header/:id/status", + ensureAuthenticated, + headerController.updateStatus, +); router.delete("/header/:id", ensureAuthenticated, headerController.destroy); // Header Menu INTEGRATED routes -router.post("/header/menu/create", ensureAuthenticated, headerMenuController.store); -router.post("/header/menu/update/:id", ensureAuthenticated, headerMenuController.update); -router.post("/header/menu/delete", ensureAuthenticated, headerMenuController.destroy); -router.post("/header/menu/reorder", ensureAuthenticated, headerMenuController.reorder); +router.post( + "/header/menu/create", + ensureAuthenticated, + headerMenuController.store, +); +router.post( + "/header/menu/update/:id", + ensureAuthenticated, + headerMenuController.update, +); +router.post( + "/header/menu/delete", + ensureAuthenticated, + headerMenuController.destroy, +); +router.post( + "/header/menu/reorder", + ensureAuthenticated, + headerMenuController.reorder, +); // Social Links routes router.get("/social-links", ensureAuthenticated, socialLinkController.index); router.post("/social-links", ensureAuthenticated, socialLinkController.store); -router.put("/social-links/:platform", ensureAuthenticated, socialLinkController.update); -router.delete("/social-links/:platform", ensureAuthenticated, socialLinkController.destroy); -router.post("/social-links/reorder", ensureAuthenticated, socialLinkController.reorder); +router.put( + "/social-links/:platform", + ensureAuthenticated, + socialLinkController.update, +); +router.delete( + "/social-links/:platform", + ensureAuthenticated, + socialLinkController.destroy, +); +router.post( + "/social-links/reorder", + ensureAuthenticated, + socialLinkController.reorder, +); // Footer routes router.get("/footer", ensureAuthenticated, footerController.index); @@ -104,60 +178,160 @@ router.get("/footer/data", ensureAuthenticated, footerController.getFooterData); // Contact routes router.get("/contact", ensureAuthenticated, contactController.index); router.post("/contact/update", ensureAuthenticated, contactController.update); -router.get("/contact/data", ensureAuthenticated, contactController.getContactData); +router.get( + "/contact/data", + ensureAuthenticated, + contactController.getContactData, +); // Contact submissions management -router.get("/contact/submissions", ensureAuthenticated, contactController.getSubmissions); -router.put("/contact/submissions/:id", ensureAuthenticated, contactController.updateSubmissionStatus); +router.get( + "/contact/submissions", + ensureAuthenticated, + contactController.getSubmissions, +); +router.put( + "/contact/submissions/:id", + ensureAuthenticated, + contactController.updateSubmissionStatus, +); // Appointment management const appointmentController = require("../controllers/appointmentController"); -router.get("/appointments", ensureAuthenticated, appointmentController.getAppointments); -router.get("/appointments/:id", ensureAuthenticated, appointmentController.getAppointmentById); -router.put("/appointments/:id", ensureAuthenticated, appointmentController.updateAppointmentStatus); -router.delete("/appointments/:id", ensureAuthenticated, appointmentController.deleteAppointment); +router.get( + "/appointments", + ensureAuthenticated, + appointmentController.getAppointments, +); +router.get( + "/appointments/:id", + ensureAuthenticated, + appointmentController.getAppointmentById, +); +router.put( + "/appointments/:id", + ensureAuthenticated, + appointmentController.updateAppointmentStatus, +); +router.delete( + "/appointments/:id", + ensureAuthenticated, + appointmentController.deleteAppointment, +); // Appointment CMS page management router.get("/appointment", ensureAuthenticated, appointmentController.index); -router.post("/appointment/update", ensureAuthenticated, appointmentController.update); -router.get("/appointment/data", ensureAuthenticated, appointmentController.getAppointmentData); +router.post( + "/appointment/update", + ensureAuthenticated, + appointmentController.update, +); +router.get( + "/appointment/data", + ensureAuthenticated, + appointmentController.getAppointmentData, +); // Pricing CMS page management const pricingController = require("../controllers/pricingController"); router.get("/pricing", ensureAuthenticated, pricingController.index); router.post("/pricing/update", ensureAuthenticated, pricingController.update); -router.get("/pricing/data", ensureAuthenticated, pricingController.getPricingData); +router.get( + "/pricing/data", + ensureAuthenticated, + pricingController.getPricingData, +); // Activity CRUD routes router.get("/activity", ensureAuthenticated, activityController.index); -router.get("/activity/create", ensureAuthenticated, activityController.createForm); +router.get( + "/activity/create", + ensureAuthenticated, + activityController.createForm, +); router.post("/activity/create", ensureAuthenticated, activityController.create); // Update filters (place before any parameterized /activity/:id routes to avoid route collision) -router.post("/activity/filters/update", ensureAuthenticated, activityController.updateFilters); +router.post( + "/activity/filters/update", + ensureAuthenticated, + activityController.updateFilters, +); // Update hero (global hero section for activities) -router.post("/activity/hero/update", ensureAuthenticated, activityController.updateHero); -router.get("/activity/:id/edit", ensureAuthenticated, activityController.editForm); -router.post("/activity/:id/update", ensureAuthenticated, activityController.update); -router.post("/activity/:id/delete", ensureAuthenticated, activityController.delete); -router.post("/activity/:id/toggle-status", ensureAuthenticated, activityController.toggleStatus); +router.post( + "/activity/hero/update", + ensureAuthenticated, + activityController.updateHero, +); +router.get( + "/activity/:id/edit", + ensureAuthenticated, + activityController.editForm, +); +router.post( + "/activity/:id/update", + ensureAuthenticated, + activityController.update, +); +router.post( + "/activity/:id/delete", + ensureAuthenticated, + activityController.delete, +); +router.post( + "/activity/:id/toggle-status", + ensureAuthenticated, + activityController.toggleStatus, +); // Update display order -router.post("/activity/update-order", ensureAuthenticated, activityController.updateOrder); +router.post( + "/activity/update-order", + ensureAuthenticated, + activityController.updateOrder, +); // Booking submissions routes -router.get("/activity/:id/bookings/count", ensureAuthenticated, activityController.getBookingCount); -router.get("/activity/:id/bookings", ensureAuthenticated, activityController.getBookingSubmissions); -router.get("/activity/:id/bookings/export", ensureAuthenticated, activityController.exportBookingData); +router.get( + "/activity/:id/bookings/count", + ensureAuthenticated, + activityController.getBookingCount, +); +router.get( + "/activity/:id/bookings", + ensureAuthenticated, + activityController.getBookingSubmissions, +); +router.get( + "/activity/:id/bookings/export", + ensureAuthenticated, + activityController.exportBookingData, +); // Export all bookings (across all activities) -router.get("/bookings/export-all", ensureAuthenticated, activityController.exportAllBookingsData); +router.get( + "/bookings/export-all", + ensureAuthenticated, + activityController.exportAllBookingsData, +); // Update booking submission -router.put("/bookings/:bookingId", ensureAuthenticated, bookingSubmissionController.updateBookingSubmission); +router.put( + "/bookings/:bookingId", + ensureAuthenticated, + bookingSubmissionController.updateBookingSubmission, +); // Delete booking submission -router.delete("/bookings/:bookingId", ensureAuthenticated, bookingSubmissionController.deleteBookingSubmission); +router.delete( + "/bookings/:bookingId", + ensureAuthenticated, + bookingSubmissionController.deleteBookingSubmission, +); // Update filters // Preview activity -router.get("/activity/:id/preview", ensureAuthenticated, activityController.preview); +router.get( + "/activity/:id/preview", + ensureAuthenticated, + activityController.preview, +); // FAQ routes - Thêm vào đây router.get("/faq", ensureAuthenticated, faqController.index); @@ -257,6 +431,69 @@ router.post( serviceController.updateDetails, ); +// Test Image Paths route +router.get("/test-images", ensureAuthenticated, (req, res) => { + const fs = require("fs"); + const path = require("path"); + const campLocationData = require("../data/camp-location.json"); + + // Collect all image paths + const imagePaths = []; + + // Camps images + if (campLocationData.camps) { + campLocationData.camps.forEach((camp) => { + if (camp.image) { + imagePaths.push({ + type: "Camp", + name: camp.title, + path: camp.image, + exists: fs.existsSync(path.join(__dirname, "../public", camp.image)), + }); + } + }); + } + + // Locations images + if (campLocationData.locations) { + campLocationData.locations.forEach((location) => { + if (location.imageSrc) { + imagePaths.push({ + type: "Location", + name: location.title, + path: location.imageSrc, + exists: fs.existsSync( + path.join(__dirname, "../public", location.imageSrc), + ), + }); + } + + // Program images + if (location.programOptions) { + location.programOptions.forEach((program) => { + if (program.imageSrc) { + imagePaths.push({ + type: "Program", + name: program.title, + path: program.imageSrc, + exists: fs.existsSync( + path.join(__dirname, "../public", program.imageSrc), + ), + }); + } + }); + } + }); + } + + res.render("admin/test-images", { + layout: "layouts/admin", + title: "Test Image Paths", + images: imagePaths, + user: req.session.user, + }); +}); + // Display visa management page router.get("/visa", ensureAuthenticated, visaController.index); @@ -264,7 +501,7 @@ router.get("/visa", ensureAuthenticated, visaController.index); router.get("/visa/edit/:id", ensureAuthenticated, visaController.getCountry); // Update hero title -router.post("/visa/update", ensureAuthenticated, visaController.update); +router.post("/visa/update", ensureAuthenticated, visaController.updateCountry); // Add new country router.post("/visa/add", ensureAuthenticated, visaController.addCountry); @@ -278,7 +515,7 @@ router.put( // Delete country router.delete( - "/delete/:slug", + "/visa/delete/:id", ensureAuthenticated, visaController.deleteCountry, ); @@ -292,9 +529,21 @@ router.post("/blog/:id/edit", ensureAuthenticated, blogController.update); router.post("/blog/:id/delete", ensureAuthenticated, blogController.destroy); // Comment management routes -router.post("/blog/:blogId/comments/:commentId/approve", ensureAuthenticated, blogController.approveComment); -router.post("/blog/:blogId/comments/:commentId/reject", ensureAuthenticated, blogController.rejectComment); -router.post("/blog/:blogId/comments/:commentId/delete", ensureAuthenticated, blogController.deleteComment); +router.post( + "/blog/:blogId/comments/:commentId/approve", + ensureAuthenticated, + blogController.approveComment, +); +router.post( + "/blog/:blogId/comments/:commentId/reject", + ensureAuthenticated, + blogController.rejectComment, +); +router.post( + "/blog/:blogId/comments/:commentId/delete", + ensureAuthenticated, + blogController.deleteComment, +); // Blog Categories Management router.get( diff --git a/views/admin/dashboard.ejs b/views/admin/dashboard.ejs index c04eaa0..3aec7e3 100644 --- a/views/admin/dashboard.ejs +++ b/views/admin/dashboard.ejs @@ -273,6 +273,25 @@ + + +
+
+
+
+ +
+
+
Visa
+

Manage visa countries

+
+
+ + Edit + +
+
diff --git a/views/admin/visa/index.ejs b/views/admin/visa/index.ejs index 488d279..8ebd107 100644 --- a/views/admin/visa/index.ejs +++ b/views/admin/visa/index.ejs @@ -1,1231 +1,1003 @@ - - -
-
-
-
- - Visa Management -
- -
- - -
- - - - - - - - - - - - <% if (data && data.hero && data.hero.summaryList) { %> - <% data.hero.summaryList.forEach(function(country) { %> - - - - - - - - <% }); %> - <% } %> - -
IDFlagCountry NameServicesActions
- #<%= String(country.id).padStart(3, "0" ) %> - -
- <%= country.name %> -
-
- <%= country.name %> - -
- <% country.services.forEach(function(service) { %> - - <%= service %> - - <% }); %> -
-
-
- - - -
-
-
- - - - - - +
+
+
+

+ Visa Management +

+

Manage visa information for different countries

-
- \ No newline at end of file diff --git a/views/layouts/admin.ejs b/views/layouts/admin.ejs index e740d1b..b132781 100644 --- a/views/layouts/admin.ejs +++ b/views/layouts/admin.ejs @@ -84,6 +84,9 @@ + diff --git a/views/layouts/main.ejs b/views/layouts/main.ejs index a85e09a..1345671 100644 --- a/views/layouts/main.ejs +++ b/views/layouts/main.ejs @@ -772,6 +772,10 @@ Blog +
- + View Homepage
@@ -19,75 +15,51 @@
-
+ - - - + + + + + - - - +
@@ -140,2093 +87,16 @@
- -
-
- -
-
-
-
- Basic - Information -
-
-
-
-
- - -
-
- -
- - -
- <% if (data.hero?.backgroundImage) { %> -
- Background preview -
- <% } %> -
-
- - -
-
-
-
-
- - -
-
-
-
- Button - Configuration -
-
-
-
-
- - -
-
- - -
-
-
-
-
- - -
-
-
-
- Contact Box -
-
-
-
-
- - -
-
- - - Will auto-generate tel: link -
-
- - - Will auto-generate mailto: link -
-
- - -
-
-
-
-
-
-
- - -
-
- -
-
-
-
- Basic - Information -
-
-
-
-
- - -
-
- - -
-
- - -
-
- - -
-
-
-
-
- - -
-
-
-
- Main Images -
-
-
-
-
- -
- - -
- <% if (data.about?.images?.mainImage1) { %> -
- Main Image 1 -
- <% } %> -
-
- -
- - -
- <% if (data.about?.images?.mainImage2) { %> -
- Main Image 2 -
- <% } %> -
-
-
-
-
- - -
-
-
-
- Team Avatars -
-
-
- <% (data.about?.images?.avatars || []).forEach((avatar, - index) => { %> -
-
- -
- - -
-
-
- <% if (avatar) { %> - Avatar <%= index + 1 %> - <% } %> -
-
- <% }); %> -
-
-
- - -
-
-
-
- Features -
-
-
- <% (data.about?.features || - []).forEach(function(feature, index) { %> -
- - -
- <% }); %> -
-
-
- - -
-
-
-
- Button & Statistics -
-
-
-
-
- - -
-
- - -
-
- - -
-
- - -
-
-
-
-
-
-
- - -
-
- -
-
-
-
- General - Information -
-
-
-
-
- - -
-
- - -
-
- -
- - -
- <% if (data.missionVision?.backgroundImage) { %> -
- Mission Vision Background -
- <% } %> -
-
-
-
-
- - -
-
-
-
- Mission & Vision - Cards -
-
-
- <% (data.missionVision?.cards || - []).forEach(function(card, index) { %> -
-
-
-
- Card <%= index + 1 %> -
-
-
-
- - -
-
- - -
-
-
-
- <% }); %> <% if (!data.missionVision?.cards || - data.missionVision.cards.length === 0) { %> -
- No cards available. To add cards, please update the - database or run migration. -
- <% } %> -
-
-
-
-
- - -
-
- -
-
-
-
- General - Information -
-
-
-
-
- - -
-
- - -
-
- - -
-
-
-
-
- - -
-
-
-
- Main Button -
-
-
-
-
- - -
-
- - -
-
-
-
-
- - -
-
-
-
- Features -
-
-
- <% (data.whyChooseUs?.features || - []).forEach(function(feature, index) { %> -
-
-
- Feature <%= index + 1 %> -
-
-
- - -
-
- - -
-
-
-
- <% }); %> <% if (!data.whyChooseUs?.features || - data.whyChooseUs.features.length === 0) { %> -
- No features available. Add via database or migration. -
- <% } %> -
-
-
- - -
-
-
-
- Tags -
-
-
-
- - -
- Enter each tag on a new line. -
-
-
-
-
- - -
-
-
-
- Call to Action - (CTA) -
-
-
-
-
- - -
-
- - -
-
- - -
-
-
-
-
-
-
- - -
-
-
-
-
-
- Activity Cards -
-
-
- <% (data.activities?.cards || []).forEach(function(card, - index) { %> -
-
-
- Activity <%= index + 1 %> -
-
-
- - -
-
- -
- - -
- <% if (card.image) { %> -
- Activity Image -
- <% } %> -
-
- - -
-
-
-
- <% }); %> <% if (!data.activities?.cards || - data.activities.cards.length === 0) { %> -
- No activities found. Add them via database or - migration. -
- <% } %> -
-
-
-
-
- - -
-
- -
-
-
-
- General - Information -
-
-
-
-
- - -
-
- - -
-
- - -
-
- -
- - -
- <% if (data.faq?.image) { %> -
- FAQ Image -
- <% } %> -
-
-
-
-
- - -
-
-
-
- Sidebar Contact -
-
-
-
-
- - -
-
- - -
-
-
-
-
- - -
-
-
-
- Questions & - Answers -
-
-
- <% (data.faq?.questions || []).forEach(function(item, - index) { %> -
-
-
- Q&A <%= index + 1 %> -
-
-
- - -
-
- - -
-
-
-
- <% }); %> <% if (!data.faq?.questions || - data.faq.questions.length === 0) { %> -
- No questions available. Add via database or migration. -
- <% } %> -
-
-
-
-
- - -
-
- -
-
-
-
- General - Information -
-
-
-
-
- - -
-
- - -
-
- -
- - -
- <% if (data.partners?.backgroundImage) { %> -
- Partners Background -
- <% } %> -
-
-
-
-
- - -
-
-
-
- Partner Logos -
-
-
- <% (data.partners?.logos || []).forEach(function(logo, - index) { %> -
-
- -
- - -
- <% if (logo) { %> -
- Logo <%= index + 1 %> -
- <% } %> -
-
- <% }); %> <% if (!data.partners?.logos || - data.partners.logos.length === 0) { %> -
- No logos available. Add via database or migration. -
- <% } %> -
-
-
- - -
-
-
-
- CTA Section -
-
-
-
-
- - -
-
- - -
-
- - -
-
- - -
-
-
-
-
-
-
- - -
-
- -
-
-
-
- General - Information -
-
-
-
-
- - -
-
- - -
-
- - -
-
- - -
-
-
-
-
- - -
-
-
-
- Card Display - Settings -
-
-
-
-
- - -
-
- - -
-
- - -
-
- - -
-
-
-
-
- - -
-
-
-
- Program Items - <%= (data.programs?.items || []).length %> - items -
-
-
- <% (data.programs?.items || []).forEach(function(item, - index) { %> -
-
-
-
- Program <%= index + 1 %>: <%= item.title || - 'Untitled' %> -
- <%= item.id || 'No ID' %> -
-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
- Enter seasons separated by commas -
-
-
- -
- - -
- <% if (item.image) { %> -
- Program Image -
- <% } %> -
-
-
-
- <% }); %> <% if (!data.programs?.items || - data.programs.items.length === 0) { %> -
- - No program items available. Add them via database or - migration. -
- <% } %> -
-
-
-
-
- - -
-
-
-
-
-
- Newsletter - Configuration -
-
-
-
-
- - -
-
- - -
-
- - -
- - -
- -
- - -
- <% if (data.newsletter?.image) { %> -
- Newsletter Image -
- <% } %> -
-
- -
- - -
- <% if (data.newsletter?.decorativeImage) { %> -
- Decorative Image -
- <% } %> -
- - -
- - -
-
- - -
-
- - -
-
-
-
-
-
-
- - -
-
- -
-
-
-
- General Settings -
-
-
-
-
- - -
-
- - -
-
- - -
-
- - -
-
-
-
-
- - -
-
-
-
- Featured Card - (Sidebar) -
-
-
-
-
- -
- - -
- <% if (data.latestPosts?.featuredCard?.image) { %> -
- Featured -
- <% } %> -
-
- - -
-
- - -
-
-
-
-
- - -
-
-
-
- Main Blog Posts -
-
-
- <% (data.latestPosts?.blogPosts || - []).forEach(function(post, index) { %> -
-
-
- Post <%= index + 1 %> -
-
-
- - -
-
- - -
-
- - -
-
- -
- - -
-
-
- - -
-
-
-
- <% }); %> <% if (!data.latestPosts?.blogPosts || - data.latestPosts.blogPosts.length === 0) { %> -
- No blog posts found. -
- <% } %> -
-
-
- - -
-
-
-
- Sidebar Posts -
-
-
- <% (data.latestPosts?.sidebarPosts || - []).forEach(function(post, index) { %> -
-
-
- Sidebar Post <%= index + 1 %> -
-
-
- - -
-
- -
- - -
-
-
- - -
-
-
-
- <% }); %> <% if (!data.latestPosts?.sidebarPosts || - data.latestPosts.sidebarPosts.length === 0) { %> -
- No sidebar posts found. -
- <% } %> -
-
-
-
-
+ <%- include('sections/hero') %> + <%- include('sections/whyChooseUs') %> + <%- include('sections/visaSolutions') %> + <%- include('sections/visaCountries') %> + <%- include('sections/testimonials') %> + <%- include('sections/videoGallery') %> + <%- include('sections/faq') %> + <%- include('sections/achievements') %> + <%- include('sections/partners') %> + <%- include('sections/blogPreview') %>
@@ -2253,43 +123,64 @@ + \ No newline at end of file diff --git a/views/admin/home/sections/achievements.ejs b/views/admin/home/sections/achievements.ejs new file mode 100644 index 0000000..28f4bd5 --- /dev/null +++ b/views/admin/home/sections/achievements.ejs @@ -0,0 +1,122 @@ + +
+
+ +
+
+
+
+ General Information +
+
+
+
+
+ + +
+
+ + +
+
+
+
+
+ + +
+
+
+
+ Achievement Items (Fixed 4 Items) +
+
+
+ <% for(let i=0; i<4; i++) { + const item = (data.achievements?.items && data.achievements.items[i]) || {}; + %> +
+
+
+
Achievement #<%= i + 1 %>
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ <% } %> +
+
+
+
+
+ + diff --git a/views/admin/home/sections/blogPreview.ejs b/views/admin/home/sections/blogPreview.ejs new file mode 100644 index 0000000..342fef7 --- /dev/null +++ b/views/admin/home/sections/blogPreview.ejs @@ -0,0 +1,175 @@ + +
+
+ +
+
+
+
+ Basic Information & Blog Selection +
+ CMS will automatically fetch the 3 latest posts if no specific blog is + selected. +
+
+
+
+ + +
+
+ + +
+ +
+ +

Select blog posts to prioritize on the home page. If none are selected, + the system will use the 3 latest posts.

+
+ <% if (allBlogs && allBlogs.length> 0) { %> + <% allBlogs.forEach(blog=> { + const isSelected = data.blogPreview?.selectedBlogIds && data.blogPreview.selectedBlogIds.some(id => + id.toString() === blog._id.toString()); + %> +
+
+
+
+ onclick="event.stopPropagation(); + handleCheckboxChange(this)"> +
+
+ +
+
+ <%= blog.title %> +
+

+ <%= blog.publishedAt ? new Date(blog.publishedAt).toLocaleDateString('vi-VN') : '' %> +

+
+
+
+ <% }) %> + <% } else { %> +
+

No published blogs found. Please create some blogs first.

+ Create Blog +
+ <% } %> +
+
+
+
+
+
+ + +
+
+
+
+ CTA Button +
+
+
+
+
+ + +
+
+ + +
+
+
+
+
+
+
+ + + + \ No newline at end of file diff --git a/views/admin/home/sections/faq.ejs b/views/admin/home/sections/faq.ejs new file mode 100644 index 0000000..021c06a --- /dev/null +++ b/views/admin/home/sections/faq.ejs @@ -0,0 +1,124 @@ + +
+
+ +
+
+
+
+ Basic Information +
+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+
+
+
+ + +
+
+
+
+ FAQ Items +
+
+
+ <% (data.faq?.items || []).forEach(function(item, index) { %> +
+
+
FAQ <%= index + 1 %>
+
+
+ + +
+
+ + +
+
+
+
+ <% }); %> +
+
+
+ + +
+
+
+
+ CTA Button +
+
+
+
+
+ + +
+
+ + +
+
+
+
+
+
+
diff --git a/views/admin/home/sections/hero.ejs b/views/admin/home/sections/hero.ejs new file mode 100644 index 0000000..c1f333f --- /dev/null +++ b/views/admin/home/sections/hero.ejs @@ -0,0 +1,157 @@ + +
+
+ +
+
+
+
+ Basic Information +
+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ +
+ + +
+ <% if (data.hero?.backgroundImage) { %> +
+ Background preview +
+ <% } %> +
+
+ + +
+
+
+
+
+ + +
+
+
+
+ Primary Button +
+
+
+
+
+ + +
+
+ + +
+
+
+
+
+ + +
+
+
+
+ Secondary Button +
+
+
+
+
+ + +
+
+ + +
+
+
+
+
+
+
diff --git a/views/admin/home/sections/partners.ejs b/views/admin/home/sections/partners.ejs new file mode 100644 index 0000000..1536ade --- /dev/null +++ b/views/admin/home/sections/partners.ejs @@ -0,0 +1,150 @@ + +
+
+ +
+
+
+
+ Awards & Certifications (Fixed 4 Items) +
+
+
+
+ <% for(let i=0; i<4; i++) { + const item = (data.partners?.visaConsultancy?.items && data.partners.visaConsultancy.items[i]) || {}; + %> +
+
+
+
Award #<%= i + 1 %>
+
+
+
+ + +
+
+ + +
+
+ +
+ + +
+
+ +
+
+
+
+
+ <% } %> +
+
+
+
+ + +
+
+
+
+ Brand Partner Logos (Slider) +
+ +
+
+
+ <% (data.partners?.brands?.items || []).forEach(function(item, index) { %> +
+
+
+
+ Brand Logo + +
+
+ + +
+
+ +
+
+
+
+ <% }); %> +
+
+
+
+
+
+ + \ No newline at end of file diff --git a/views/admin/home/sections/testimonials.ejs b/views/admin/home/sections/testimonials.ejs new file mode 100644 index 0000000..55f91ac --- /dev/null +++ b/views/admin/home/sections/testimonials.ejs @@ -0,0 +1,159 @@ + +
+
+ +
+
+
+
+ Basic Information +
+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ +
+ + +
+
+
+
+
+
+ + +
+
+
+
+ Testimonials +
+
+
+ <% (data.testimonials?.items || []).forEach(function(item, index) { %> +
+
+
Testimonial <%= index + 1 %>
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+ + +
+
+
+
+
+ <% }); %> +
+
+
+
+
diff --git a/views/admin/home/sections/videoGallery.ejs b/views/admin/home/sections/videoGallery.ejs new file mode 100644 index 0000000..4398814 --- /dev/null +++ b/views/admin/home/sections/videoGallery.ejs @@ -0,0 +1,67 @@ + +
+
+
+
+
+
+ Video Gallery +
+
+
+
+
+ + +
+
+ + +
+
+ +
+ + +
+ <% if (data.videoGallery?.thumbnail) { %> +
+ Thumbnail preview +
+ <% } %> +
+
+
+
+
+
+
diff --git a/views/admin/home/sections/visaCountries.ejs b/views/admin/home/sections/visaCountries.ejs new file mode 100644 index 0000000..73472f8 --- /dev/null +++ b/views/admin/home/sections/visaCountries.ejs @@ -0,0 +1,163 @@ + +
+
+ +
+
+
+
+ Basic Information +
+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+
+
+
+ + +
+
+
+
+ Countries +
+
+
+ <% (data.visaCountries?.countries || []).forEach(function(country, index) { %> +
+
+
Country <%= index + 1 %>
+
+
+ + +
+
+ + +
+
+ +
+ + +
+
+
+ + +
+
+ + +
+
+
+
+ <% }); %> +
+
+
+ + +
+
+
+
+ CTA Button +
+
+
+
+
+ + +
+
+ + +
+
+
+
+
+
+
diff --git a/views/admin/home/sections/visaSolutions.ejs b/views/admin/home/sections/visaSolutions.ejs new file mode 100644 index 0000000..bfad6f1 --- /dev/null +++ b/views/admin/home/sections/visaSolutions.ejs @@ -0,0 +1,100 @@ + +
+
+ +
+
+
+
+ Basic Information +
+
+
+
+
+ + +
+
+ + +
+
+
+
+
+ + +
+
+
+
+ Visa Solutions Items +
+
+
+ <% (data.visaSolutions?.items || []).forEach(function(item, index) { %> +
+
+
Service <%= index + 1 %>
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ <% }); %> +
+
+
+
+
diff --git a/views/admin/home/sections/whyChooseUs.ejs b/views/admin/home/sections/whyChooseUs.ejs new file mode 100644 index 0000000..2a1a24b --- /dev/null +++ b/views/admin/home/sections/whyChooseUs.ejs @@ -0,0 +1,169 @@ + +
+
+ +
+
+
+
+ Basic Information +
+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+
+
+
+ + +
+
+
+
+ Why Choose Us Items +
+
+
+ <% (data.whyChooseUs?.items || []).forEach(function(item, index) { %> +
+
+
Item <%= index + 1 %>
+
+
+ +
+ + +
+
+
+ + +
+
+ + +
+
+
+
+ <% }); %> +
+
+
+ + +
+
+
+
+ Features +
+
+
+ <% (data.whyChooseUs?.features || []).forEach(function(feature, index) { %> +
+ + +
+ <% }); %> +
+
+
+ + +
+
+
+
+ CTA Button +
+
+
+
+
+ + +
+
+ + +
+
+
+
+
+
+
diff --git a/views/auth/login.ejs b/views/auth/login.ejs index 8469dec..bc14e19 100644 --- a/views/auth/login.ejs +++ b/views/auth/login.ejs @@ -178,8 +178,8 @@
-

CMS Management System

-

Welcome to Content Management System

+

CMS Management System

+

Welcome to Content Management System