diff --git a/controllers/serviceController.js b/controllers/serviceController.js new file mode 100644 index 0000000..33b36ac --- /dev/null +++ b/controllers/serviceController.js @@ -0,0 +1,360 @@ +const { getServiceData } = require("../services/service.service"); +const Service = require("../models/service"); +const { addBaseUrlToImages, getFullImageUrl } = require("../utils/imageHelper"); +const slugify = require("slugify"); + +// Admin page - Service list +exports.index = async (req, res) => { + try { + const data = await getServiceData(); + console.log(data.services.items.image); + res.render("admin/service/index", { + title: "Service Management", + data, + layout: "layouts/main", + getFullImageUrl, // Truyền helper function vào view + }); + } catch (err) { + console.error(err); + req.flash("error_msg", "Error loading service data"); + res.redirect("/admin/dashboard"); + } +}; + +// Admin page - Service edit +exports.edit = async (req, res) => { + try { + const { slug } = req.params; + const data = await getServiceData(); + + const service = data.services?.items?.find((item) => item.slug === slug); + if (!service) { + req.flash("error_msg", "Service not found"); + return res.redirect("/admin/service"); + } + + res.render("admin/service/edit", { + title: `Edit Service - ${service.name}`, + service, + layout: "layouts/main", + getFullImageUrl, + }); + } catch (err) { + console.error(err); + req.flash("error_msg", "Error loading service for editing"); + res.redirect("/admin/service"); + } +}; + +// Update single service +exports.updateService = async (req, res) => { + try { + const { slug } = req.params; + const currentData = await getServiceData(); + + const serviceIndex = currentData.services?.items?.findIndex( + (item) => item.slug === slug, + ); + if (serviceIndex === -1) { + req.flash("error_msg", "Service not found"); + return res.redirect("/admin/service"); + } + + // Update service data + const updatedData = { ...currentData.toObject?.() }; + updatedData.services.items[serviceIndex] = { + ...updatedData.services.items[serviceIndex], + name: req.body.name, + slug: req.body.slug, + description: req.body.description, + image: req.body.image, + layout: req.body.layout, + }; + + if (currentData._id) { + await Service.findByIdAndUpdate(currentData._id, updatedData); + } else { + await Service.create(updatedData); + } + + req.flash("success_msg", "Service updated successfully"); + res.redirect("/admin/service"); + } catch (err) { + console.error(err); + req.flash("error_msg", err.message); + res.redirect("/admin/service"); + } +}; + +// Admin page - Service details +exports.details = async (req, res) => { + try { + const { slug } = req.params; + const data = await getServiceData(); + + const service = data.services?.items?.find((item) => item.slug === slug); + if (!service) { + req.flash("error_msg", "Service not found"); + return res.redirect("/admin/service"); + } + + res.render("admin/service/details", { + title: `Service Details - ${service.name}`, + service, + layout: "layouts/main", + getFullImageUrl, // Truyền helper function vào view + }); + } catch (err) { + console.error(err); + req.flash("error_msg", "Error loading service details"); + res.redirect("/admin/service"); + } +}; + +// Update service list +exports.update = async (req, res) => { + try { + const currentData = await getServiceData(); + const sections = [ + "pageTitle", + "services", + "destinations", + "visas", + "reviews", + ]; + + let updatedData = { ...currentData.toObject?.() }; + let hasChanges = false; + + sections.forEach((section) => { + if (!req.body[section]) return; + + const newData = JSON.parse(req.body[section]); + if (JSON.stringify(newData) !== JSON.stringify(currentData[section])) { + updatedData[section] = newData; + hasChanges = true; + } + }); + + if (!hasChanges) { + req.flash("info_msg", "No changes were made"); + return res.redirect("/admin/service"); + } + + if (currentData._id) { + await Service.findByIdAndUpdate(currentData._id, updatedData); + } else { + await Service.create(updatedData); + } + + req.flash("success_msg", "Service updated successfully"); + res.redirect("/admin/service"); + } catch (err) { + console.error(err); + req.flash("error_msg", err.message); + res.redirect("/admin/service"); + } +}; + +// Update service details +exports.updateDetails = async (req, res) => { + try { + const { slug } = req.params; + const currentData = await getServiceData(); + + const serviceIndex = currentData.services?.items?.findIndex( + (item) => item.slug === slug, + ); + if (serviceIndex === -1) { + req.flash("error_msg", "Service not found"); + return res.redirect("/admin/service"); + } + + // Parse features and FAQ from JSON strings + const features = req.body.features ? JSON.parse(req.body.features) : []; + const faq = req.body.faq ? JSON.parse(req.body.faq) : []; + + // Update service details + const updatedData = { ...currentData.toObject?.() }; + updatedData.services.items[serviceIndex].details = { + title: req.body.title, + description: req.body.description, + mainImage: req.body.mainImage, + overviewTitle: req.body.overviewTitle, + overviewDescription: req.body.overviewDescription, + additionalDescription: req.body.additionalDescription, + keyFeaturesTitle: req.body.keyFeaturesTitle, + keyFeaturesImage: req.body.keyFeaturesImage, + features: features, + faqTitle: req.body.faqTitle, + faqImage: req.body.faqImage, + faq: faq, + }; + + if (currentData._id) { + await Service.findByIdAndUpdate(currentData._id, updatedData); + } else { + await Service.create(updatedData); + } + + req.flash("success_msg", "Service details updated successfully"); + res.redirect(`/admin/service/${slug}/details`); + } catch (err) { + console.error(err); + req.flash("error_msg", err.message); + res.redirect("/admin/service"); + } +}; + +// API endpoint +exports.api = async (req, res) => { + try { + const serviceData = await getServiceData(); + const baseUrl = + process.env.BACKEND_URL || `${req.protocol}://${req.get("host")}`; + + const processedData = addBaseUrlToImages(serviceData, baseUrl); + res.json(processedData); + } catch (err) { + res.status(500).json({ error: "Error loading service data" }); + } +}; + +/** + * Get service details by slug - API endpoint + */ +exports.getServiceBySlug = async (req, res) => { + try { + const { slug } = req.params; + + const serviceDoc = await Service.findOne().lean(); + + if (!serviceDoc) { + return res.status(404).json({ + success: false, + message: "Service data not found", + }); + } + + // Find service by slug + const service = serviceDoc.services?.items?.find( + (item) => item.slug === slug, + ); + + if (!service) { + return res.status(404).json({ + success: false, + message: `Service with slug '${slug}' not found`, + }); + } + + const baseUrl = + process.env.BACKEND_URL || `${req.protocol}://${req.get("host")}`; + + // Return service details in the expected format + const responseData = { + pageTitle: serviceDoc.pageTitle, + breadcrumb: { + ...serviceDoc.breadcrumb, + title: "Service Details", + items: [ + { label: "Home", href: "/" }, + { label: "Services", href: "/services" }, + { label: service.name, href: `/services/${slug}` }, + ], + }, + serviceDetails: { + content: service.details, + keyFeatures: { + title: service.details.keyFeaturesTitle || "Key Features", + sideImage: service.details.keyFeaturesImage || "img/default.jpg", + items: service.details.features || [], + }, + faq: { + title: service.details.faqTitle || "Frequently Asked Questions", + sideImage: service.details.faqImage || "img/default.jpg", + items: service.details.faq || [], + }, + }, + }; + + const processedData = addBaseUrlToImages(responseData, baseUrl); + res.json(processedData); + } catch (error) { + console.error("Error fetching service by slug:", error); + res.status(500).json({ + success: false, + message: "Internal server error", + error: error.message, + }); + } +}; + +/** + * Generate slug from text - API endpoint + */ +exports.generateSlug = async (req, res) => { + try { + const { text } = req.body; + + if (!text || typeof text !== "string") { + return res.status(400).json({ + success: false, + message: "Text is required", + }); + } + + // Generate slug using slugify library with Vietnamese support + const slug = slugify(text, { + lower: true, + strict: true, + locale: "vi", + }); + + res.json({ + success: true, + slug: slug, + }); + } catch (error) { + console.error("Error generating slug:", error); + res.status(500).json({ + success: false, + message: "Internal server error", + error: error.message, + }); + } +}; + +/** + * Get all service slugs - API endpoint + */ +exports.getServiceSlugs = async (req, res) => { + try { + const serviceDoc = await Service.findOne().lean(); + + if (!serviceDoc?.services?.items) { + return res.json({ + success: true, + slugs: [], + }); + } + + const slugs = serviceDoc.services.items.map((item) => ({ + slug: item.slug, + name: item.name, + id: item.id, + })); + + res.json({ + success: true, + slugs, + }); + } catch (error) { + console.error("Error fetching service slugs:", error); + res.status(500).json({ + success: false, + message: "Internal server error", + error: error.message, + }); + } +}; diff --git a/data/service.json b/data/service.json new file mode 100644 index 0000000..0b524c7 --- /dev/null +++ b/data/service.json @@ -0,0 +1,363 @@ +{ + "pageTitle": "Visaway – Immigration & Visa Consulting HTML Template", + + "services": { + "title": { + "subTitle": "What We Offer", + "mainTitle": "Our Immigration Services" + }, + "items": [ + { + "slug": "immigration-appeal", + "name": "Immigration Appeal & Legal Support", + "description": "Our experts provide professional guidance for immigration appeals and legal matters, helping clients overcome visa rejections with personalized strategies and strong case representation.", + "image": "img/home-3/service/01.jpg", + "layout": "left", + "details": { + "title": "Immigration Appeal & Legal Support", + "description": "Our experts provide professional guidance for immigration appeals and legal matters, helping clients overcome visa rejections with personalized strategies and strong case representation. We analyze your case thoroughly and develop custom strategies to maximize your chances of success.", + "mainImage": "img/inner-page/service-details/details-1.jpg", + "overviewTitle": "Service Overview", + "overviewDescription": "Our Immigration Appeal & Legal Support service is designed to help clients navigate complex immigration challenges. We provide expert legal guidance, case analysis, and strategic representation to maximize your chances of success. With our expert consultants, personalized approach, and global network, we ensure a smooth transition for every client.", + "additionalDescription": "From start to finish, we are committed to turning your immigration challenges into success stories through professional legal representation and strategic planning.", + "keyFeaturesTitle": "Key Features", + "keyFeaturesImage": "img/inner-page/service-details/details-2.jpg", + "features": [ + { + "title": "Personalized Guidance", + "description": "Tailored support for each client's specific legal situation and requirements." + }, + { + "title": "Expert Legal Team", + "description": "Experienced immigration lawyers with proven track records in appeals." + }, + { + "title": "Case Analysis & Strategy", + "description": "Thorough case review and development of winning appeal strategies." + }, + { + "title": "Document Preparation", + "description": "Professional preparation of all legal documents and supporting evidence." + }, + { + "title": "Court Representation", + "description": "Expert representation in immigration courts and tribunals." + }, + { + "title": "Success Monitoring", + "description": "Regular updates and monitoring throughout the appeal process." + } + ], + "faqTitle": "Frequently Asked Question", + "faqImage": "img/inner-page/service-details/details-3.jpg", + "faq": [ + { + "id": "faq-appeal-1", + "question": "01. What are the chances of a successful appeal?", + "answer": "Success rates vary by case type and circumstances, but our experienced legal team significantly improves your chances through thorough case analysis and strategic representation tailored to your specific situation.", + "isExpanded": false + }, + { + "id": "faq-appeal-2", + "question": "02. How long does the appeal process take?", + "answer": "Appeal timelines vary by jurisdiction and case complexity, typically ranging from 6-18 months. We keep you informed throughout the process and work to expedite where possible.", + "isExpanded": false + }, + { + "id": "faq-appeal-3", + "question": "03. What documents do I need for an appeal?", + "answer": "Required documents vary by case but typically include the original decision, supporting evidence, and legal submissions. We provide a comprehensive checklist and assist with document preparation.", + "isExpanded": false + }, + { + "id": "faq-appeal-4", + "question": "04. Do you handle all types of immigration appeals?", + "answer": "Yes, we handle various types of immigration appeals including visa refusals, deportation orders, and residency rejections. Our team has expertise across all immigration categories.", + "isExpanded": false + } + ] + } + }, + { + "slug": "scholarship-guidance", + "name": "Scholarship & Study Grant Guidance", + "description": "We help students unlock opportunities to study abroad with the right financial support. Our expert advisors guide you in finding scholarships, grants, and funding options that match your academic background, chosen destination, and career goals.", + "image": "img/home-3/service/02.jpg", + "layout": "right", + "details": { + "title": "Scholarship & Study Grant Guidance", + "description": "We help students unlock opportunities to study abroad with the right financial support. Our expert advisors guide you in finding scholarships, grants, and funding options that match your academic background, chosen destination, and career goals. From preparing strong applications to meeting eligibility criteria, we ensure you maximize your chances of securing financial aid.", + "mainImage": "img/inner-page/service-details/details-1.jpg", + "overviewTitle": "Service Overview", + "overviewDescription": "Our Education Visa Consultancy is dedicated to guiding students in achieving their study abroad dreams. We provide complete support including university selection, application assistance, scholarship guidance, visa documentation, and interview preparation. With our expert consultants, personalized approach, and global network, we ensure a smooth transition for every student.", + "additionalDescription": "From start to finish, we are committed to turning your education journey into a successful international experience.", + "keyFeaturesTitle": "Key Features", + "keyFeaturesImage": "img/inner-page/service-details/details-2.jpg", + "features": [ + { + "title": "Personalized Guidance", + "description": "Tailored support for each student's goals and requirements." + }, + { + "title": "Target Audience & Persona Development", + "description": "Experienced team with global education and visa knowledge." + }, + { + "title": "Scholarship & Grant Assistance", + "description": "Helping students secure financial aid opportunities." + }, + { + "title": "Visa Application Support", + "description": "Step-by-step guidance for smooth visa processing." + }, + { + "title": "Interview Preparation", + "description": "Coaching for successful student visa interviews." + }, + { + "title": "Documentation Assistance", + "description": "Accurate and complete paperwork for faster approvals." + } + ], + "faqTitle": "Frequently Asked Question", + "faqImage": "img/inner-page/service-details/details-3.jpg", + "faq": [ + { + "id": "faq-scholarship-1", + "question": "01. Do you assist with university selection?", + "answer": "Absolutely! We identify suitable scholarships, guide application processes, and maximize your chances of receiving financial aid.", + "isExpanded": false + }, + { + "id": "faq-scholarship-2", + "question": "02. Can you help with scholarship applications?", + "answer": "Absolutely! We identify suitable scholarships, guide application processes, and maximize your chances of receiving financial aid.", + "isExpanded": true + }, + { + "id": "faq-scholarship-3", + "question": "03. How long does the visa process take?", + "answer": "Absolutely! We identify suitable scholarships, guide application processes, and maximize your chances of receiving financial aid.", + "isExpanded": false + }, + { + "id": "faq-scholarship-4", + "question": "04. Is post-arrival support available?", + "answer": "Absolutely! We identify suitable scholarships, guide application processes, and maximize your chances of receiving financial aid.", + "isExpanded": false + } + ] + } + }, + { + "slug": "permanent-residency", + "name": "Permanent Residency (PR) Services", + "description": "Our PR services guide clients through every step of the residency process, including documentation, eligibility assessment, and application support, ensuring a smooth and successful approval.", + "image": "img/home-3/service/03.jpg", + "layout": "left", + "details": { + "title": "Permanent Residency (PR) Services", + "description": "Our PR services guide clients through every step of the residency process, including documentation, eligibility assessment, and application support, ensuring a smooth and successful approval.", + "mainImage": "img/inner-page/service-details/details-1.jpg", + "overviewTitle": "Service Overview", + "overviewDescription": "Our Permanent Residency services provide comprehensive support for individuals seeking to establish permanent residence in their chosen country. We handle all aspects of the PR application process with expertise and care.", + "additionalDescription": "Our experienced team ensures that your PR application is handled professionally and efficiently, maximizing your chances of approval.", + "keyFeaturesTitle": "Key Features", + "keyFeaturesImage": "img/inner-page/service-details/details-2.jpg", + "features": [ + { + "title": "Eligibility Assessment", + "description": "Comprehensive evaluation of your PR eligibility and options." + }, + { + "title": "Points Calculation", + "description": "Accurate calculation and optimization of your points score." + }, + { + "title": "Document Verification", + "description": "Thorough verification and preparation of all required documents." + }, + { + "title": "Application Tracking", + "description": "Regular updates and tracking of your PR application status." + }, + { + "title": "Interview Preparation", + "description": "Coaching and preparation for PR interviews if required." + }, + { + "title": "Post-Approval Support", + "description": "Guidance on next steps after PR approval and settlement." + } + ], + "faqTitle": "Frequently Asked Question", + "faqImage": "img/inner-page/service-details/details-3.jpg", + "faq": [ + { + "id": "faq-pr-1", + "question": "01. How long does the PR process take?", + "answer": "Processing times vary by country and program, typically ranging from 12-24 months. We provide realistic timelines based on current processing standards.", + "isExpanded": false + }, + { + "id": "faq-pr-2", + "question": "02. What documents are required for PR application?", + "answer": "Document requirements vary by country but typically include educational credentials, work experience, language test results, and medical examinations. We provide a complete checklist.", + "isExpanded": true + }, + { + "id": "faq-pr-3", + "question": "03. Can I include my family in the PR application?", + "answer": "Yes, most PR programs allow you to include your spouse and dependent children. We help you understand family inclusion requirements and processes.", + "isExpanded": false + }, + { + "id": "faq-pr-4", + "question": "04. What happens if my PR application is rejected?", + "answer": "If rejected, we analyze the reasons and explore options including appeals, reapplication, or alternative immigration pathways to achieve your goals.", + "isExpanded": false + } + ] + } + }, + { + "slug": "citizenship-naturalization", + "name": "Citizenship & Naturalization Guidance", + "description": "We provide expert guidance for citizenship and naturalization processes, assisting clients with documentation, eligibility, and legal procedures to achieve a smooth and successful application.", + "image": "img/home-3/service/04.jpg", + "layout": "right", + "details": { + "title": "Citizenship & Naturalization Guidance", + "description": "We provide expert guidance for citizenship and naturalization processes, assisting clients with documentation, eligibility, and legal procedures to achieve a smooth and successful application.", + "mainImage": "img/inner-page/service-details/details-1.jpg", + "overviewTitle": "Service Overview", + "overviewDescription": "Our Citizenship & Naturalization service helps individuals navigate the complex process of becoming a citizen. We provide step-by-step guidance, documentation support, and legal expertise throughout the entire process.", + "additionalDescription": "With our comprehensive approach, we make the path to citizenship clear, manageable, and successful for every client.", + "keyFeaturesTitle": "Key Features", + "keyFeaturesImage": "img/inner-page/service-details/details-2.jpg", + "features": [ + { + "title": "Citizenship Test Preparation", + "description": "Comprehensive preparation for citizenship knowledge tests." + }, + { + "title": "Language Requirements", + "description": "Guidance on meeting language proficiency requirements." + }, + { + "title": "Residency Verification", + "description": "Assistance with proving residency and physical presence requirements." + }, + { + "title": "Application Processing", + "description": "Complete support throughout the citizenship application process." + }, + { + "title": "Interview Coaching", + "description": "Preparation and coaching for citizenship interviews." + }, + { + "title": "Ceremony Preparation", + "description": "Support and guidance for the citizenship ceremony process." + } + ], + "faqTitle": "Frequently Asked Question", + "faqImage": "img/inner-page/service-details/details-3.jpg", + "faq": [ + { + "id": "faq-citizenship-1", + "question": "What are the basic requirements for citizenship?", + "answer": "Requirements typically include permanent residency, physical presence, language proficiency, and knowledge of the country's history and government. Specific requirements vary by country.", + "isExpanded": false + }, + { + "id": "faq-citizenship-2", + "question": "How do I prepare for the citizenship test?", + "answer": "We provide comprehensive study materials, practice tests, and coaching sessions to help you prepare for both the knowledge test and language requirements.", + "isExpanded": false + }, + { + "id": "faq-citizenship-3", + "question": "How long does the citizenship process take?", + "answer": "Processing times vary by country but typically range from 12-24 months from application to ceremony. We help you understand specific timelines for your situation.", + "isExpanded": false + }, + { + "id": "faq-citizenship-4", + "question": "Can I maintain dual citizenship?", + "answer": "Dual citizenship policies vary by country. We help you understand the implications and requirements for maintaining multiple citizenships if applicable.", + "isExpanded": false + } + ] + } + } + ] + }, + + "destinations": { + "backgroundImage": "img/home-3/choose-us/bg.png", + "title": { + "subTitle": "Countries we offer", + "mainTitle": "Choose Your Immigration Destination" + } + }, + + "visas": { + "items": [ + { + "id": "family-visa", + "number": "01", + "name": "Family Visa", + "description": "Our Family Visa services help reunite loved ones by providing expert guidance.", + "buttonText": "service _ 02", + "buttonLink": "service-details.html" + }, + { + "id": "student-visa", + "number": "02", + "name": "Student Visa", + "description": "We provide expert guidance for student visa applications.", + "buttonText": "service _ 02", + "buttonLink": "service-details.html" + }, + { + "id": "work-visa", + "number": "03", + "name": "Work Visa", + "description": "Collaboratively disintermediate one to one functionalities and long term.", + "buttonText": "service _ 02", + "buttonLink": "service-details.html" + } + ] + }, + + "reviews": { + "title": { + "subTitle": "What Our Clients Say", + "mainTitle": "Immigration Success Stories" + }, + "thumb": "img/home-3/test-thumb.jpg", + "items": [ + { + "id": "client-review-1", + "rating": 5, + "content": "The team provided exceptional guidance throughout my immigration process.", + "author": { + "name": "Mohammed Ali,", + "type": "Family Visa" + }, + "icon": "fa-solid fa-quote-right" + }, + { + "id": "client-review-2", + "rating": 5, + "content": "Their expertise and personalized support ensured a smooth visa approval.", + "author": { + "name": "Sarah Johnson,", + "type": "Student Visa" + }, + "icon": "fa-solid fa-quote-right" + } + ] + } +} diff --git a/models/service.js b/models/service.js new file mode 100644 index 0000000..a1d0f2e --- /dev/null +++ b/models/service.js @@ -0,0 +1,118 @@ +const mongoose = require("mongoose"); + +// Define sub-schemas first +const authorSchema = new mongoose.Schema( + { + name: String, + type: String, + }, + { _id: false }, +); + +const clientReviewSchema = new mongoose.Schema( + { + id: String, + rating: Number, + content: String, + author: authorSchema, + icon: String, + }, + { _id: false }, +); + +const featureSchema = new mongoose.Schema( + { + title: String, + description: String, + }, + { _id: false }, +); + +const faqSchema = new mongoose.Schema( + { + id: String, + question: String, + answer: String, + isExpanded: { type: Boolean, default: false }, + }, + { _id: false }, +); + +const serviceDetailsSchema = new mongoose.Schema( + { + title: String, + description: String, + mainImage: String, + overviewTitle: String, + overviewDescription: String, + additionalDescription: String, + keyFeaturesTitle: String, + keyFeaturesImage: String, + features: [featureSchema], + faqTitle: String, + faqImage: String, + faq: [faqSchema], + }, + { _id: false }, +); + +// Main service page schema +const serviceSchema = new mongoose.Schema( + { + pageTitle: String, + + // Main services section + services: { + title: { + subTitle: String, + mainTitle: String, + }, + items: [ + { + slug: String, + name: String, + description: String, + image: String, + layout: String, + details: serviceDetailsSchema, + }, + ], + }, + + // Destination countries section + destinations: { + backgroundImage: String, + title: { + subTitle: String, + mainTitle: String, + }, + }, + + // Visa types section + visas: { + items: [ + { + id: String, + number: String, + name: String, + description: String, + buttonText: String, + buttonLink: String, + }, + ], + }, + + // Client reviews section + reviews: { + title: { + subTitle: String, + mainTitle: String, + }, + thumb: String, + items: [clientReviewSchema], + }, + }, + { timestamps: true }, +); + +module.exports = mongoose.model("Service", serviceSchema); diff --git a/public/img/default.jpg b/public/img/default.jpg new file mode 100644 index 0000000..b0e2512 Binary files /dev/null and b/public/img/default.jpg differ diff --git a/public/uploads/service/03.jpg b/public/uploads/service/03.jpg new file mode 100644 index 0000000..1b47583 Binary files /dev/null and b/public/uploads/service/03.jpg differ diff --git a/public/uploads/service/404.png b/public/uploads/service/404.png new file mode 100644 index 0000000..f7c61d3 Binary files /dev/null and b/public/uploads/service/404.png differ diff --git a/public/uploads/service/Dell_Inspiron15.webp b/public/uploads/service/Dell_Inspiron15.webp new file mode 100644 index 0000000..00b169d Binary files /dev/null and b/public/uploads/service/Dell_Inspiron15.webp differ diff --git a/public/uploads/service/intro.jpg b/public/uploads/service/intro.jpg new file mode 100644 index 0000000..2540cd4 Binary files /dev/null and b/public/uploads/service/intro.jpg differ diff --git a/public/uploads/service/iphone15.webp b/public/uploads/service/iphone15.webp new file mode 100644 index 0000000..d158840 Binary files /dev/null and b/public/uploads/service/iphone15.webp differ diff --git a/public/uploads/service/smart_samsung_55inch.jpg b/public/uploads/service/smart_samsung_55inch.jpg new file mode 100644 index 0000000..07ede78 Binary files /dev/null and b/public/uploads/service/smart_samsung_55inch.jpg differ diff --git a/routes/admin.js b/routes/admin.js index d41e56d..548ff68 100644 --- a/routes/admin.js +++ b/routes/admin.js @@ -23,6 +23,7 @@ const insuranceController = require("../controllers/insuranceController"); const activityController = require("../controllers/activityController"); const bookingSubmissionController = require("../controllers/bookingSubmissionController"); +const serviceController = require("../controllers/serviceController"); // Dashboard router.get("/dashboard", ensureAuthenticated, dashboardController.getDashboard); @@ -46,28 +47,28 @@ router.get("/about-us", ensureAuthenticated, aboutUsController.index); router.get( "/about-us/create", ensureAuthenticated, - aboutUsController.createForm + aboutUsController.createForm, ); router.post("/about-us/create", ensureAuthenticated, aboutUsController.create); router.get( "/about-us/:id/edit", ensureAuthenticated, - aboutUsController.editForm + aboutUsController.editForm, ); router.post( "/about-us/:id/update", ensureAuthenticated, - aboutUsController.update + aboutUsController.update, ); router.post( "/about-us/:id/delete", ensureAuthenticated, - aboutUsController.delete + aboutUsController.delete, ); router.get( "/about-us/:id/preview", ensureAuthenticated, - aboutUsController.preview + aboutUsController.preview, ); // Booking admin CRUD removed @@ -77,7 +78,7 @@ router.get("/form", ensureAuthenticated, formController.index); router.post( "/form/update", ensureAuthenticated, - formController.updateDefaultForm + formController.updateDefaultForm, ); // Upload routes @@ -93,23 +94,23 @@ router.post( ensureAuthenticated, upload.single("image"), // convertToWebp, // Disabled to keep original image format (JPG/PNG) - uploadController.uploadImage + uploadController.uploadImage, ); router.post( "/upload/video", ensureAuthenticated, uploadVideo.single("video"), - uploadController.uploadVideo + uploadController.uploadVideo, ); router.post( "/upload/update-path", ensureAuthenticated, - uploadController.updateImagePath + uploadController.updateImagePath, ); router.post( "/upload/delete", ensureAuthenticated, - uploadController.deleteImage + uploadController.deleteImage, ); // Header routes @@ -118,22 +119,22 @@ router.post("/header/update", ensureAuthenticated, headerController.update); router.post( "/header/update-menu", ensureAuthenticated, - headerController.updateMenu + headerController.updateMenu, ); router.get( "/header/menu-tree", ensureAuthenticated, - headerController.getMenuTree + headerController.getMenuTree, ); router.get( "/header/programmes/:menuId", ensureAuthenticated, - headerController.getProgrammesByMenuId + headerController.getProgrammesByMenuId, ); router.get( "/header/menu-item/:menuId", ensureAuthenticated, - headerController.getMenuItem + headerController.getMenuItem, ); router.get("/header/data", ensureAuthenticated, headerController.getHeaderData); @@ -148,7 +149,7 @@ router.post("/contact/update", ensureAuthenticated, contactController.update); router.get( "/contact/data", ensureAuthenticated, - contactController.getContactData + contactController.getContactData, ); // Activity CRUD routes @@ -156,81 +157,81 @@ router.get("/activity", ensureAuthenticated, activityController.index); router.get( "/activity/create", ensureAuthenticated, - activityController.createForm + 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 + activityController.updateFilters, ); // Update hero (global hero section for activities) router.post( "/activity/hero/update", ensureAuthenticated, - activityController.updateHero + activityController.updateHero, ); router.get( "/activity/:id/edit", ensureAuthenticated, - activityController.editForm + activityController.editForm, ); router.post( "/activity/:id/update", ensureAuthenticated, - activityController.update + activityController.update, ); router.post( "/activity/:id/delete", ensureAuthenticated, - activityController.delete + activityController.delete, ); router.post( "/activity/:id/toggle-status", ensureAuthenticated, - activityController.toggleStatus + activityController.toggleStatus, ); // Update display order router.post( "/activity/update-order", ensureAuthenticated, - activityController.updateOrder + activityController.updateOrder, ); // Booking submissions routes router.get( "/activity/:id/bookings/count", ensureAuthenticated, - activityController.getBookingCount + activityController.getBookingCount, ); router.get( "/activity/:id/bookings", ensureAuthenticated, - activityController.getBookingSubmissions + activityController.getBookingSubmissions, ); router.get( "/activity/:id/bookings/export", ensureAuthenticated, - activityController.exportBookingData + activityController.exportBookingData, ); // Export all bookings (across all activities) router.get( "/bookings/export-all", ensureAuthenticated, - activityController.exportAllBookingsData + activityController.exportAllBookingsData, ); // Update booking submission router.put( "/bookings/:bookingId", ensureAuthenticated, - bookingSubmissionController.updateBookingSubmission + bookingSubmissionController.updateBookingSubmission, ); // Delete booking submission router.delete( "/bookings/:bookingId", ensureAuthenticated, - bookingSubmissionController.deleteBookingSubmission + bookingSubmissionController.deleteBookingSubmission, ); // Update filters @@ -239,7 +240,7 @@ router.delete( router.get( "/activity/:id/preview", ensureAuthenticated, - activityController.preview + activityController.preview, ); // FAQ routes - Thêm vào đây @@ -250,8 +251,16 @@ router.get("/faq/api", faqController.api); // API routes cho quản lý FAQ items (AJAX calls) router.post("/faq/api/add-faq", ensureAuthenticated, faqController.addFAQ); -router.put("/faq/api/update-faq-item/:sectionId/:faqId", ensureAuthenticated, faqController.updateFAQItem); -router.delete("/faq/api/delete-faq-item/:sectionId/:faqId", ensureAuthenticated, faqController.deleteFAQItem); +router.put( + "/faq/api/update-faq-item/:sectionId/:faqId", + ensureAuthenticated, + faqController.updateFAQItem, +); +router.delete( + "/faq/api/delete-faq-item/:sectionId/:faqId", + ensureAuthenticated, + faqController.deleteFAQItem, +); router.get("/terms-conditions", ensureAuthenticated, termsController.index); router.post("/terms/update", ensureAuthenticated, termsController.update); router.get("/terms/data", ensureAuthenticated, termsController.getTermsData); @@ -267,80 +276,138 @@ router.get("/travel/api", travelController.api); router.get("/travel/seed", ensureAuthenticated, travelController.seed); // API routes cho quản lý FAQ sections (AJAX calls) -router.post("/faq/api/add-section", ensureAuthenticated, faqController.addFAQSection); -router.put("/faq/api/update-section/:sectionId", ensureAuthenticated, faqController.updateFAQSection); -router.delete("/faq/api/delete-section/:sectionId", ensureAuthenticated, faqController.deleteFAQSection); -router.post("/faq/api/reorder-sections", ensureAuthenticated, faqController.reorderFAQSection); +router.post( + "/faq/api/add-section", + ensureAuthenticated, + faqController.addFAQSection, +); +router.put( + "/faq/api/update-section/:sectionId", + ensureAuthenticated, + faqController.updateFAQSection, +); +router.delete( + "/faq/api/delete-section/:sectionId", + ensureAuthenticated, + faqController.deleteFAQSection, +); +router.post( + "/faq/api/reorder-sections", + ensureAuthenticated, + faqController.reorderFAQSection, +); // API routes cho sidebar navigation (AJAX calls) -router.put("/faq/api/update-sidebar", ensureAuthenticated, faqController.updateSidebarNav); +router.put( + "/faq/api/update-sidebar", + ensureAuthenticated, + faqController.updateSidebarNav, +); // Safety routes router.get("/safety", ensureAuthenticated, safetyController.index); router.post("/safety/update", ensureAuthenticated, safetyController.update); // Camp Location routes router.get("/camp-location", ensureAuthenticated, campLocationController.index); -router.post("/camp-location/update", ensureAuthenticated, campLocationController.update); +router.post( + "/camp-location/update", + ensureAuthenticated, + campLocationController.update, +); //Insurance routes router.get("/insurance", ensureAuthenticated, insuranceController.index); -router.post("/insurance/update", ensureAuthenticated, insuranceController.update); +router.post( + "/insurance/update", + ensureAuthenticated, + insuranceController.update, +); + +// Service routes +router.get("/service", ensureAuthenticated, serviceController.index); +router.post("/service/update", ensureAuthenticated, serviceController.update); +router.post( + "/service/generate-slug", + ensureAuthenticated, + serviceController.generateSlug, +); +router.get("/service/:slug/edit", ensureAuthenticated, serviceController.edit); +router.post( + "/service/:slug/edit", + ensureAuthenticated, + serviceController.updateService, +); +router.get( + "/service/:slug/details", + ensureAuthenticated, + serviceController.details, +); +router.post( + "/service/:slug/details/update", + ensureAuthenticated, + 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'); - + 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 => { + campLocationData.camps.forEach((camp) => { if (camp.image) { imagePaths.push({ - type: 'Camp', + type: "Camp", name: camp.title, path: camp.image, - exists: fs.existsSync(path.join(__dirname, '../public', camp.image)) + exists: fs.existsSync(path.join(__dirname, "../public", camp.image)), }); } }); } - + // Locations images if (campLocationData.locations) { - campLocationData.locations.forEach(location => { + campLocationData.locations.forEach((location) => { if (location.imageSrc) { imagePaths.push({ - type: 'Location', + type: "Location", name: location.title, path: location.imageSrc, - exists: fs.existsSync(path.join(__dirname, '../public', location.imageSrc)) + exists: fs.existsSync( + path.join(__dirname, "../public", location.imageSrc), + ), }); } - + // Program images if (location.programOptions) { - location.programOptions.forEach(program => { + location.programOptions.forEach((program) => { if (program.imageSrc) { imagePaths.push({ - type: 'Program', + type: "Program", name: program.title, path: program.imageSrc, - exists: fs.existsSync(path.join(__dirname, '../public', program.imageSrc)) + exists: fs.existsSync( + path.join(__dirname, "../public", program.imageSrc), + ), }); } }); } }); } - - res.render('admin/test-images', { - layout: 'layouts/admin', - title: 'Test Image Paths', + + res.render("admin/test-images", { + layout: "layouts/admin", + title: "Test Image Paths", images: imagePaths, - user: req.session.user + user: req.session.user, }); }); diff --git a/routes/index.js b/routes/index.js index beecd84..a22ea19 100644 --- a/routes/index.js +++ b/routes/index.js @@ -13,12 +13,14 @@ const safetyController = require("../controllers/safetyController"); const campLocationController = require("../controllers/campLocationController"); // Booking flow removed -const insuranceController= require("../controllers/insuranceController"); +const insuranceController = require("../controllers/insuranceController"); const termsController = require("../controllers/termsController"); // <-- IMPORT ĐÃ CÓ const activityController = require("../controllers/activityController"); const travelController = require("../controllers/travelController"); const bookingSubmissionController = require("../controllers/bookingSubmissionController"); +const serviceController = require("../controllers/serviceController"); + // Trang chủ router.get("/", (req, res) => { res.render("index", { @@ -61,8 +63,7 @@ router.get("/api/activities/:id", activityController.apiDetail); router.get("/api/camp-location", campLocationController.api); // Booking routes removed // Insurance APi route -router.get("/api/insurance", insuranceController.api) - +router.get("/api/insurance", insuranceController.api); router.get("/api/terms", termsController.api); @@ -71,14 +72,14 @@ router.get("/travel", async (req, res) => { try { const Travel = require("../models/travel"); const travel = await Travel.findOne(); - + if (!travel) { return res.status(404).render("errors/404", { title: "Page Not Found", message: "Travel information not found", }); } - + res.render("page/travel", { title: travel.page.title, data: travel.toObject(), @@ -95,33 +96,58 @@ router.get("/api/travel", travelController.api); // Booking submission APIs (public endpoints) router.post("/api/booking/submit", bookingSubmissionController.submitBooking); -router.get("/api/activity/:activityId/sessions", bookingSubmissionController.getAvailableSessions); -router.get("/api/activity/:activityId/session/:sessionId/availability", bookingSubmissionController.getSessionAvailability); +router.get( + "/api/activity/:activityId/sessions", + bookingSubmissionController.getAvailableSessions, +); +router.get( + "/api/activity/:activityId/session/:sessionId/availability", + bookingSubmissionController.getSessionAvailability, +); // New API for creating bookings directly into camp sessions (by program) router.post( "/api/camps/:program/sessions/:sessionId/bookings", - activityController.createSessionBookingByProgram + activityController.createSessionBookingByProgram, ); router.get( "/api/camps/:program/sessions/:sessionId/bookings", - activityController.getSessionBookingsByProgram + activityController.getSessionBookingsByProgram, ); // Keep admin-style update/delete by activityId (protected) if needed -router.put("/api/camps/:activityId/sessions/:sessionId/bookings/:bookingId", activityController.updateSessionBooking); -router.delete("/api/camps/:activityId/sessions/:sessionId/bookings/:bookingId", activityController.deleteSessionBooking); +router.put( + "/api/camps/:activityId/sessions/:sessionId/bookings/:bookingId", + activityController.updateSessionBooking, +); +router.delete( + "/api/camps/:activityId/sessions/:sessionId/bookings/:bookingId", + activityController.deleteSessionBooking, +); // Demo booking form router.get("/demo/booking-form", (req, res) => { - res.sendFile(path.join(__dirname, '../views/demo/booking-form.html')); + res.sendFile(path.join(__dirname, "../views/demo/booking-form.html")); }); // Demo session booking API router.get("/demo/session-booking-api", (req, res) => { - res.sendFile(path.join(__dirname, '../views/demo/session-booking-api.html')); + res.sendFile(path.join(__dirname, "../views/demo/session-booking-api.html")); }); // // API route cho blog detail // router.get('/api/blog-detail', blogDetailController.api); +/* CMS - Hailearning + */ +// service +router.get("/service", serviceController.index); +router.post("/service", serviceController.update); +router.get("/api/service", serviceController.api); + +// Service details by slug +router.get("/api/service/:slug", serviceController.getServiceBySlug); + +// Service slugs list +router.get("/api/service-slugs", serviceController.getServiceSlugs); + module.exports = router; diff --git a/scripts/2026_02_02_131615_service.js b/scripts/2026_02_02_131615_service.js new file mode 100644 index 0000000..af24f29 --- /dev/null +++ b/scripts/2026_02_02_131615_service.js @@ -0,0 +1,186 @@ +require("dotenv").config(); +const fs = require("fs").promises; +const path = require("path"); +const mongoose = require("mongoose"); + +const connectDB = require("../config/database"); +const Service = require("../models/service"); + +/** + * Transform service.json data to match Service schema + */ +function transformServiceData(sourceData) { + return { + pageTitle: sourceData.pageTitle || "", + + // Breadcrumb navigation section + breadcrumb: { + title: sourceData?.breadcrumb?.title || "", + backgroundImage: sourceData?.breadcrumb?.backgroundImage || "", + shape: sourceData?.breadcrumb?.shape || "", + items: Array.isArray(sourceData?.breadcrumb?.items) + ? sourceData.breadcrumb.items.map((item) => ({ + label: item.label || "", + href: item.href || "", + })) + : [], + }, + + // Main services section + services: { + title: { + subTitle: sourceData?.services?.title?.subTitle || "", + mainTitle: sourceData?.services?.title?.mainTitle || "", + }, + items: Array.isArray(sourceData?.services?.items) + ? sourceData.services.items.map((service) => ({ + slug: service.slug || "", + name: service.name || "", + description: service.description || "", + image: service.image || "", + layout: service.layout || "", + details: { + title: service.details?.title || "", + description: service.details?.description || "", + mainImage: service.details?.mainImage || "", + overviewTitle: service.details?.overviewTitle || "", + overviewDescription: service.details?.overviewDescription || "", + additionalDescription: + service.details?.additionalDescription || "", + keyFeaturesTitle: service.details?.keyFeaturesTitle || "", + keyFeaturesImage: service.details?.keyFeaturesImage || "", + features: Array.isArray(service.details?.features) + ? service.details.features.map((feature) => ({ + icon: feature.icon || "", + title: feature.title || "", + description: feature.description || "", + })) + : [], + faqTitle: service.details?.faqTitle || "", + faqImage: service.details?.faqImage || "", + faq: Array.isArray(service.details?.faq) + ? service.details.faq.map((faqItem) => ({ + id: faqItem.id || "", + question: faqItem.question || "", + answer: faqItem.answer || "", + isExpanded: faqItem.isExpanded || false, + })) + : [], + }, + })) + : [], + }, + + // Destination countries section + destinations: { + backgroundImage: sourceData?.destinations?.backgroundImage || "", + title: { + subTitle: sourceData?.destinations?.title?.subTitle || "", + mainTitle: sourceData?.destinations?.title?.mainTitle || "", + }, + items: Array.isArray(sourceData?.destinations?.items) + ? sourceData.destinations.items.map((country) => ({ + id: country.id || "", + name: country.name || "", + description: country.description || "", + image: country.image || "", + icon: country.icon || "", + link: country.link || "", + })) + : [], + }, + + // Visa types section + visas: { + items: Array.isArray(sourceData?.visas?.items) + ? sourceData.visas.items.map((visa) => ({ + id: visa.id || "", + number: visa.number || "", + name: visa.name || "", + description: visa.description || "", + buttonText: visa.buttonText || "", + buttonLink: visa.buttonLink || "", + })) + : [], + }, + + // Client reviews section + reviews: { + title: { + subTitle: sourceData?.reviews?.title?.subTitle || "", + mainTitle: sourceData?.reviews?.title?.mainTitle || "", + }, + viewAllButton: { + text: sourceData?.reviews?.viewAllButton?.text || "", + icon: sourceData?.reviews?.viewAllButton?.icon || "", + link: sourceData?.reviews?.viewAllButton?.link || "", + }, + thumb: sourceData?.reviews?.thumb || "", + items: Array.isArray(sourceData?.reviews?.items) + ? sourceData.reviews.items.map((review) => ({ + id: review.id || "", + rating: review.rating || 5, + content: review.content || "", + author: { + name: review.author?.name || "", + type: review.author?.type || "", + }, + icon: review.icon || "", + })) + : [], + navigation: { + prevButton: sourceData?.reviews?.navigation?.prevButton || "", + nextButton: sourceData?.reviews?.navigation?.nextButton || "", + prevIcon: sourceData?.reviews?.navigation?.prevIcon || "", + nextIcon: sourceData?.reviews?.navigation?.nextIcon || "", + }, + }, + + updatedAt: new Date(), + }; +} + +/** + * Migration function for service page data + */ +async function migrateServiceData() { + try { + await connectDB(); + console.log("🚀 Starting service page migration..."); + + // Clear existing service documents + await Service.deleteMany({}); + console.log("🗑️ Cleared existing service documents"); + + // Read service.json file + const serviceJsonPath = path.join(__dirname, "..", "data", "service.json"); + const rawJsonData = await fs.readFile(serviceJsonPath, "utf8"); + const sourceServiceData = JSON.parse(rawJsonData); + + // Transform data to match schema + const transformedServiceData = transformServiceData(sourceServiceData); + + // Create new service document + const newService = new Service(transformedServiceData); + const savedService = await newService.save(); + + console.log("✅ Service page migration completed successfully!"); + console.log(`📄 Service document ID: ${savedService._id}`); + + await mongoose.disconnect(); + process.exit(0); + } catch (error) { + console.error("❌ Service migration error:", error); + process.exit(1); + } +} + +// Run migration if called directly +if (require.main === module) { + migrateServiceData(); +} + +module.exports = { + migrate: migrateServiceData, + transformServiceData, +}; diff --git a/server.js b/server.js index 24d4a0c..8b1dda4 100644 --- a/server.js +++ b/server.js @@ -42,7 +42,21 @@ app.use( }, express.static(path.join(__dirname, "assets")), ); +app.use("/img", express.static(path.join(process.cwd(), "public/img"))); +// Serve static files from public directory (uploads, etc.) +app.use( + "/uploads", + (req, res, next) => { + // Cho phép mọi domain truy cập tài nguyên tĩnh + res.header("Access-Control-Allow-Origin", "*"); + res.header("Access-Control-Allow-Methods", "GET"); + next(); + }, + express.static(path.join(__dirname, "public", "uploads")), +); +// Serve other public files +app.use(express.static(path.join(__dirname, "public"))); // Session configuration app.use( session({ diff --git a/services/service.service.js b/services/service.service.js new file mode 100644 index 0000000..64483a6 --- /dev/null +++ b/services/service.service.js @@ -0,0 +1,43 @@ +const Service = require("../models/service"); + +const getServiceData = async () => { + const service = await Service.findOne().sort({ updatedAt: -1 }); + console.log("check layout", service.services.items.layout); + + if (!service) { + return { + pageTitle: "", + services: { + title: { + subTitle: "", + mainTitle: "", + }, + items: [], + }, + destinations: { + backgroundImage: "", + title: { + subTitle: "", + mainTitle: "", + }, + }, + visas: { + items: [], + }, + reviews: { + title: { + subTitle: "", + mainTitle: "", + }, + thumb: "", + items: [], + }, + }; + } + + return service; +}; + +module.exports = { + getServiceData, +}; diff --git a/utils/imageHelper.js b/utils/imageHelper.js index b772b1d..bce7697 100644 --- a/utils/imageHelper.js +++ b/utils/imageHelper.js @@ -1,37 +1,68 @@ /** * Thêm BACKEND_URL vào đường dẫn hình ảnh - * @param {Object} data - Dữ liệu cần xử lý + * @param {Object} data - Dữ liệu cần xử lý * @returns {Object} - Dữ liệu đã được xử lý với đường dẫn hình ảnh đầy đủ */ function addBaseUrlToImages(data, baseUrl) { // baseUrl can be passed explicitly (e.g., from req), otherwise fall back to env - const BACKEND_URL = baseUrl || process.env.BACKEND_URL || ''; - + const BACKEND_URL = baseUrl || process.env.BACKEND_URL || ""; + // Tạo bản sao sâu để tránh thay đổi dữ liệu gốc const processedData = JSON.parse(JSON.stringify(data)); - + // Hàm đệ quy để xử lý tất cả các URL hình ảnh trong đối tượng const processObject = (obj) => { - if (!obj || typeof obj !== 'object') return; - - Object.keys(obj).forEach(key => { + if (!obj || typeof obj !== "object") return; + + Object.keys(obj).forEach((key) => { // Kiểm tra nếu thuộc tính chứa đường dẫn hình ảnh bắt đầu bằng /uploads/ - if (typeof obj[key] === 'string' && obj[key].startsWith('/uploads/')) { + if (typeof obj[key] === "string" && obj[key].startsWith("/uploads/")) { // Thêm BACKEND_URL nếu đường dẫn chưa có http - if (!obj[key].startsWith('http')) { + if (!obj[key].startsWith("http")) { obj[key] = `${BACKEND_URL}${obj[key]}`; } - } else if (typeof obj[key] === 'object') { + } else if (typeof obj[key] === "object") { // Đệ quy xử lý các đối tượng và mảng lồng nhau processObject(obj[key]); } }); }; - + processObject(processedData); return processedData; } +/** + * Tạo full URL cho ảnh từ đường dẫn tương đối - dùng cho EJS templates + * @param {string} imagePath - Đường dẫn ảnh + * @param {string} backendUrl - Backend URL (optional, sẽ lấy từ env nếu không có) + * @returns {string} - Full URL của ảnh + */ +function getFullImageUrl(imagePath, backendUrl = null) { + if (!imagePath) return ""; + + // Nếu đã là full URL thì return luôn + if (imagePath.startsWith("http")) { + return imagePath; + } + + // Lấy backend URL + const baseUrl = ( + backendUrl || + process.env.BACKEND_URL || + "http://localhost:3001" + ).replace(/\/$/, ""); + + // Xử lý đường dẫn + let imgSrc = imagePath; + if (!imgSrc.startsWith("/")) { + imgSrc = "/" + imgSrc; + } + + return baseUrl + imgSrc; +} + module.exports = { - addBaseUrlToImages -}; \ No newline at end of file + addBaseUrlToImages, + getFullImageUrl, +}; diff --git a/views/admin/dashboard.ejs b/views/admin/dashboard.ejs index 77d6d63..9fb5879 100644 --- a/views/admin/dashboard.ejs +++ b/views/admin/dashboard.ejs @@ -4,16 +4,25 @@
-
Quick Management
+
Quick Management
-
- +
+
Home
@@ -29,9 +38,18 @@
-
- +
+
Header & Menu
@@ -47,9 +65,18 @@
-
- +
+
Footer
@@ -62,14 +89,21 @@
- -
-
- +
+
About Us
@@ -85,9 +119,18 @@
-
- +
+
Contact
@@ -103,9 +146,18 @@
-
- +
+
FAQ
@@ -121,16 +173,28 @@
-
- +
+
Terms & Conditions

Manage terms

- + Edit
@@ -139,9 +203,18 @@
-
- +
+
Travel
@@ -157,9 +230,18 @@
-
- +
+
Safety
@@ -175,16 +257,28 @@
-
- +
+
Camp Location

Manage camp location

- + Edit
@@ -193,9 +287,18 @@
-
- +
+
Activities
@@ -207,7 +310,32 @@
- +
+
+
+
+ +
+
+
Services
+

Manage services

+
+
+ + Edit + +
+
@@ -234,18 +362,37 @@
-
- +
+
Menu Header API
/api/header - GET + + GET + API to get menu header data - + View @@ -253,18 +400,37 @@
-
- +
+
Home API
/api/home - GET + + GET + API to get homepage data - + View @@ -272,18 +438,37 @@
-
- +
+
About API
/api/about - GET + + GET + API to get about page data - + View @@ -291,18 +476,37 @@
-
- +
+
About Us API
/api/about-us - GET + + GET + API to get about us data - + View @@ -310,18 +514,37 @@
-
- +
+
FAQ API
/api/faq - GET + + GET + API to get FAQ data - + View @@ -329,18 +552,37 @@
-
- +
+
Terms & Conditions API
/api/terms - GET + + GET + API to get terms & conditions data - + View @@ -348,18 +590,37 @@
-
- +
+
Travel API
/api/travel - GET + + GET + API to get travel data - + View @@ -367,18 +628,37 @@
-
- +
+
Safety API
/api/safety - GET + + GET + API to get safety data - + View @@ -386,38 +666,76 @@
-
- +
+
Camp Location API
/api/camp-location - GET + + GET + API to get camp location data - + View - +
-
- +
+
Menu Tree API
/api/menu-tree - GET + + GET + API to get menu tree data - + View @@ -425,18 +743,37 @@
-
- +
+
Contact API
/api/contact - GET + + GET + API to get contact data - + View @@ -444,18 +781,75 @@
-
- +
+ +
+ Service API +
+ + /api/service + + GET + + API to get service data + + + View + + + + + +
+
+
Camp Location API
/api/camp-location - GET + + GET + API to get camp location data - + View @@ -468,46 +862,83 @@
-
+
System Information
-
+
-
- +
+
Version
-
CMS-SIMS v1.0.0
+
+ CMS-SIMS v1.0.0 +
- +
-
- +
+
Logged in as
-
<%= user.username %>
+
+ <%= user.username %> +
- -